

def _nodes_command(self, func, shell=False):
    provider = os.environ['KUBERNETES_PROVIDER']
    if isinstance(func, str):
        func_str = func

        def _func(node, zone):
            split = node.split()
            if (len(split) > 0):
                node_name = split[0]
                if (node_name != 'kubernetes-master'):
                    info_log(self.TAG, 'Running {0} on {1}...'.format(func, node_name))
                    cmd = ['gcloud', 'compute', 'ssh', node_name, '--zone', zone, '--command', '{}'.format(func_str)]
                    return subprocess.Popen(cmd, shell=shell)
            return None
        func = _func
    if (provider == 'gce'):
        zone = os.environ.get('KUBE_GCE_ZONE')
        if (not zone):
            zone_re = re.compile('ZONE\\=\\$\\{KUBE_GCE_ZONE:\\-(?P<zone>.*)\\}')
            with open(os.path.join(self.kubernetes_home, 'cluster/gce/config-default.sh'), 'r') as f:
                m = zone_re.search(f.read())
                if m:
                    zone = m.group('zone')
                else:
                    error_log(self.TAG, 'zone could not be determined')
        if (not node):
            return False
        nodes_cmd = ['kubectl.sh', 'get', 'nodes']
        output = subprocess.check_output(nodes_cmd)
        nodes = output.split('\n')[1:]
        return [func(node, zone) for node in nodes]
    elif (provider == 'aws'):
        return []
    else:
        warning_log(self.TAG, 'Only aws and gce providers are currently supported')
        return []

dataset/ETHPy150Open binder-project/binder/binder/cluster.py KubernetesManager._nodes_command/VarMisuse@257/386 `zone`->`node`