List all cluster.
180891
def get(self, name=None, provider='AwsEKS', print_output=True):
        
        # Create cluster object
        Cluster = getattr(providers, provider)
        cluster = Cluster(name)

        self.kubeconf.open()
        if name is None:
            clusters = self.kubeconf.get_clusters()
            print("Running Clusters:")
            for cluster in clusters:
                print(f"  - {cluster['name']}")
        else:
            # Check that cluster exists.
            if self.check_cluster_exists(name) is False:
                raise JhubctlError("Cluster name not found in availabe clusters.")

            cluster = self.kubeconf.get_cluster(name=cluster.cluster_name)
            pprint.pprint(cluster, depth=4)
402645
def cluster_list(verbose=False):
    '''
    
    '''
    cmd = [salt.utils.path.which('pg_lsclusters'), '--no-header']
    ret = __salt__['cmd.run_all'](' '.join([pipes.quote(c) for c in cmd]))
    if ret.get('retcode', 0) != 0:
        log.error('Error listing clusters')
    cluster_dict = _parse_pg_lscluster(ret['stdout'])
    if verbose:
        return cluster_dict
    return cluster_dict.keys()
1046406
def list(self):
        
        self.discover()
        print_docs = []

        # mongos
        for node in sorted(self.get_tagged(['mongos'])):
            doc = OrderedDict([('process', 'mongos'), ('port', node),
                              ('status', 'running'
                               if self.cluster_running[node] else 'down')])
            print_docs.append(doc)

        if len(self.get_tagged(['mongos'])) > 0:
            print_docs.append(None)

        # configs
        for node in sorted(self.get_tagged(['config'])):
            doc = OrderedDict([('process', 'config server'),
                              ('port', node),
                              ('status', 'running'
                               if self.cluster_running[node] else 'down')])
            print_docs.append(doc)

        if len(self.get_tagged(['config'])) > 0:
            print_docs.append(None)

        # mongod
        for shard in self._get_shard_names(self.loaded_args):
            tags = []
            replicaset = ('replicaset' in self.loaded_args and
                          self.loaded_args['replicaset'])
            padding = ''

            if shard:
                print_docs.append(shard)
                tags.append(shard)
                padding = '    '

            if replicaset:
                # primary
                primary = self.get_tagged(tags + ['primary', 'running'])
                if len(primary) > 0:
                    node = list(primary)[0]
                    print_docs.append(OrderedDict
                                      ([('process', padding + 'primary'),
                                        ('port', node),
                                        ('status', 'running'
                                         if self.cluster_running[node]
                                         else 'down')]))

                # secondaries
                secondaries = self.get_tagged(tags + ['secondary', 'running'])
                for node in sorted(secondaries):
                    print_docs.append(OrderedDict
                                      ([('process', padding + 'secondary'),
                                        ('port', node),
                                        ('status', 'running'
                                         if self.cluster_running[node]
                                         else 'down')]))

                # data-bearing nodes that are down or not in the
                # replica set yet
                mongods = self.get_tagged(tags + ['mongod'])
                arbiters = self.get_tagged(tags + ['arbiter'])

                nodes = sorted(mongods - primary - secondaries - arbiters)
                for node in nodes:
                    print_docs.append(OrderedDict
                                      ([('process', padding + 'mongod'),
                                        ('port', node),
                                        ('status', 'running'
                                         if self.cluster_running[node]
                                         else 'down')]))

                # arbiters
                for node in arbiters:
                    print_docs.append(OrderedDict
                                      ([('process', padding + 'arbiter'),
                                        ('port', node),
                                        ('status', 'running'
                                         if self.cluster_running[node]
                                         else 'down')]))

            else:
                nodes = self.get_tagged(tags + ['mongod'])
                if len(nodes) > 0:
                    node = nodes.pop()
                    print_docs.append(OrderedDict
                                      ([('process', padding + 'single'),
                                        ('port', node),
                                        ('status', 'running'
                                         if self.cluster_running[node]
                                         else 'down')]))
            if shard:
                print_docs.append(None)

        processes = self._get_processes()
        startup = self.startup_info

        # print tags as well
        for doc in [x for x in print_docs if type(x) == OrderedDict]:
            try:
                doc['pid'] = processes[doc['port']].pid
            except KeyError:
                doc['pid'] = '-'

            if self.args['verbose'] or self.args['tags']:
                tags = self.get_tags_of_port(doc['port'])
                doc['tags'] = ', '.join(tags)

            if self.args['startup']:
                try:
                    # first try running process (startup may be modified
                    # via start command)
                    doc['startup command'] = ' '.join(processes[doc['port']]
                                                      .cmdline())
                except KeyError:
                    # if not running, use stored startup_info
                    doc['startup command'] = startup[str(doc['port'])]

        print_docs.append(None)
        print()
        print_table(print_docs)
        if self.loaded_args.get('auth'):
            print('\tauth: "%s:%s"' % (self.loaded_args.get('username'),
                                       self.loaded_args.get('password')))
807113
def clusters(self):
        """"""
        if self._resources is None:
            self.__init()
        if "clusters" in self._resources:
            url = self._url + "/clusters"
            return _clusters.Cluster(url=url,
                                     securityHandler=self._securityHandler,
                                     proxy_url=self._proxy_url,
                                     proxy_port=self._proxy_port,
                                     initialize=True)
        else:
            return None
968695
def list_ext(self, collection, path, retrieve_all, **_params):
        """"""
        return self.list(collection, path, retrieve_all, **_params)
1219647
def cluster(resolve, **kwargs):
    
    # Actually we have IPs and we need not do anything to resolve them to IPs. So the default
    # behavior fits better to this option name.

    ctx = Context(**kwargs)
    ctx.execute_action('cluster', **{
        'locator': ctx.locator,
        'resolve': resolve,
    })
1168424
def get_broker_list(cluster_config):
    
    with ZK(cluster_config) as zk:
        brokers = sorted(list(zk.get_brokers().items()), key=itemgetter(0))
        return [(id, data['host']) for id, data in brokers]
1317073
public void setClusterInfoList(java.util.Collection<ClusterInfo> clusterInfoList) {
        if (clusterInfoList == null) {
            this.clusterInfoList = null;
            return;
        }

        this.clusterInfoList = new java.util.ArrayList<ClusterInfo>(clusterInfoList);
    }
317377
async def cluster_reset_all_nodes(self, soft=True):
        
        option = 'SOFT' if soft else 'HARD'
        res = list()
        for node in await self.cluster_nodes():
            res.append(
                await self.execute_command(
                    'CLUSTER RESET', option, node_id=node['id']
                ))
        return res
1224137
def get_cluster_port_names(self, cluster_name):
        
        port_names = list()
        for host_name in self.get_hosts_by_clusters()[cluster_name]:
            port_names.extend(self.get_hosts_by_name(host_name))
        return port_names
1026719
def list(cls, state=None, page=None, per_page=None):
        
        conn = Qubole.agent()
        params = {}
        if page:
            params['page'] = page
        if per_page:
            params['per_page'] = per_page
        if (params.get('page') or params.get('per_page')) and Qubole.version == 'v1.2':
            log.warn("Pagination is not supported with API v1.2. Fetching all clusters.")
        params = None if not params else params
        cluster_list = conn.get(cls.rest_entity_path, params=params)
        if state is None:
            return cluster_list
        elif state is not None:
            result = []
            if Qubole.version == 'v1.2':
                for cluster in cluster_list:
                    if state.lower() == cluster['cluster']['state'].lower():
                        result.append(cluster)
            elif Qubole.version == 'v1.3':
                cluster_list = cluster_list['clusters']
                for cluster in cluster_list:
                    if state.lower() == cluster['state'].lower():
                        result.append(cluster)
            return result
1085866
def list_nodes(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    nodes = list_nodes_full()

    ret = {}
    for instance_id, full_node in nodes.items():
        ret[instance_id] = {
            'id': full_node['id'],
            'image': full_node['image'],
            'size': full_node['size'],
            'state': full_node['state'],
            'public_ips': full_node['public_ips'],
            'private_ips': full_node['private_ips'],
        }

    return ret
1140107
def _group_cluster(self, clusters, adj_list, counts):
        ''' '''

        groups = []
        for cluster in clusters:
            groups.append(sorted(cluster, key=lambda x: counts[x],
                                 reverse=True))

        return groups
704552
def _list_nodes(call=None):
    '''
    
    '''
    local = salt.client.LocalClient()
    ret = local.cmd('salt-cloud:driver:vagrant', 'grains.items', '', tgt_type='grain')
    return ret
715663
def list_clusters(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_clusters function must be called with '
            '-f or --function.'
        )

    return {'Clusters': salt.utils.vmware.list_clusters(_get_si())}
1026003
def list_all(zone=None, permanent=True):
    '''
    
    '''
    _zone = {}
    id_ = ''

    if zone:
        cmd = '--zone={0} --list-all'.format(zone)
    else:
        cmd = '--list-all'

    if permanent:
        cmd += ' --permanent'

    for i in __firewall_cmd(cmd).splitlines():
        if re.match('^[a-z0-9]', i, re.I):
            zone_name = i.rstrip()
        else:
            if i.startswith('\t'):
                _zone[zone_name][id_].append(i.strip())
                continue

            (id_, val) = i.split(':', 1)

            id_ = id_.strip()

            if _zone.get(zone_name, None):
                _zone[zone_name].update({id_: [val.strip()]})
            else:
                _zone[zone_name] = {id_: [val.strip()]}

    return _zone
927073
def get_all(self):
        

        clusters = []
        cluster_files = glob.glob("%s/*.%s" % (self.storage_path, self.file_ending))
        for fname in cluster_files:
            try:
                name = fname[:-len(self.file_ending)-1]
                clusters.append(self.get(name))
            except (ImportError, AttributeError) as ex:
                log.error("Unable to load cluster %s: `%s`", fname, ex)
                log.error("If cluster %s was created with a previous version of elasticluster, you may need to run `elasticluster migrate %s %s` to update it.", cluster_file, self.storage_path, fname)
        return clusters