Return list of available datacenters from catalog.

    :param consul_url: The Consul server URL.
    :return: The list of available datacenters.

    CLI Example:

    .. code-block:: bash

        salt '*' consul.catalog_datacenters
763290
def catalog_datacenters(consul_url=None, token=None):
    '''
    

    '''
    ret = {}
    if not consul_url:
        consul_url = _get_config()
        if not consul_url:
            log.error('No Consul URL found.')
            ret['message'] = 'No Consul URL found.'
            ret['res'] = False
            return ret

    function = 'catalog/datacenters'
    ret = _query(consul_url=consul_url,
                 function=function,
                 token=token)
    return ret
632187
def get_resources(self, ids, cache=True):
        
        client = local_session(self.manager.session_factory).client('dax')
        return client.describe_clusters(ClusterNames=ids).get('Clusters')
261237
def get_kafka_brokers():
    
    # NOTE: The Kafka environment variables need to be present. If using
    # Apache Kafka on Heroku, they will be available in your app configuration.
    if not os.environ.get('KAFKA_URL'):
        raise RuntimeError('The KAFKA_URL config variable is not set.')

    return ['{}:{}'.format(parsedUrl.hostname, parsedUrl.port) for parsedUrl in
            [urlparse(url) for url in os.environ.get('KAFKA_URL').split(',')]]
299472
def list_datastores(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_datastores function must be called with -f or --function.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    datastore_pool = server.one.datastorepool.info(auth)[1]

    datastores = {}
    for datastore in _get_xml(datastore_pool):
        datastores[datastore.find('NAME').text] = _xml_to_dict(datastore)

    return datastores
230219
def get_unavailable_brokers(zk, partition_metadata):
    
    topic_data = zk.get_topics(partition_metadata.topic)
    topic = partition_metadata.topic
    partition = partition_metadata.partition
    expected_replicas = set(topic_data[topic]['partitions'][str(partition)]['replicas'])
    available_replicas = set(partition_metadata.replicas)
    return expected_replicas - available_replicas
1166252
def get_catalogs(self):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bins_template
        catalogs = self._get_provider_session('catalog_lookup_session').get_catalogs()
        cat_list = []
        for cat in catalogs:
            cat_list.append(Catalog(self._provider_manager, cat, self._runtime, self._proxy))
        return CatalogList(cat_list)
819798
def get_all_distribution_names(url=None):
    
    if url is None:
        url = DEFAULT_INDEX
    client = ServerProxy(url, timeout=3.0)
    return client.list_packages()
817026
def avail_locations(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_locations function must be called with '
            '-f or --function, or with the --list-locations option'
        )

    ret = {}
    for key in JOYENT_LOCATIONS:
        ret[key] = {
            'name': key,
            'region': JOYENT_LOCATIONS[key]
        }

    # this can be enabled when the bug in the joyent get data centers call is
    # corrected, currently only the European dc (new api) returns the correct
    # values
    # ret = {}
    # rcode, datacenters = query(
    #     command='my/datacenters', location=DEFAULT_LOCATION, method='GET'
    # )
    # if rcode in VALID_RESPONSE_CODES and isinstance(datacenters, dict):
    #     for key in datacenters:
    #     ret[key] = {
    #         'name': key,
    #         'url': datacenters[key]
    #     }
    return ret
652659
def available_services(index = nil)
      loop do
        begin
          resp, nindex = _service.get_all(index: index)
          return [resp.keys - ['consul'], nindex] if nindex != index
        rescue Diplomat::Timeout
          # Continue waiting
        end
      end
    end
1008574
def get_conns(cred, providers):
    """"""
    cld_svc_map = {"aws": conn_aws,
                   "azure": conn_az,
                   "gcp": conn_gcp,
                   "alicloud": conn_ali}
    sys.stdout.write("\rEstablishing Connections:  ")
    sys.stdout.flush()
    busy_obj = busy_disp_on()
    conn_fn = [[cld_svc_map[x.rstrip('1234567890')], cred[x], x]
               for x in providers]
    cgroup = Group()
    conn_res = []
    conn_res = cgroup.map(get_conn, conn_fn)
    cgroup.join()
    conn_objs = {}
    for item in conn_res:
        conn_objs.update(item)
    busy_disp_off(dobj=busy_obj)
    sys.stdout.write("\r                                                 \r")
    sys.stdout.write("\033[?25h")  # cursor back on
    sys.stdout.flush()
    return conn_objs
954485
def list_datastore_clusters(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_datastore_clusters function must be called with '
            '-f or --function.'
        )

    return {'Datastore Clusters': salt.utils.vmware.list_datastore_clusters(_get_si())}
1169526
def PrimaryDatacenter(self):
        

        return(clc.v2.Datacenter(alias=self.alias,location=self.data['primaryDataCenter'], session=self.session))
63723
def get_datacenter(service_instance, datacenter_name):
    '''
    
    '''
    items = get_datacenters(service_instance,
                            datacenter_names=[datacenter_name])
    if not items:
        raise salt.exceptions.VMwareObjectRetrievalError(
            'Datacenter \'{0}\' was not found'.format(datacenter_name))
    return items[0]
798918
def server_list(endpoint_id):
    
    # raises usage error on shares for us
    endpoint, server_list = get_endpoint_w_server_list(endpoint_id)

    if server_list == "S3":  # not GCS -- this is an S3 endpoint
        server_list = {"s3_url": endpoint["s3_url"]}
        fields = [("S3 URL", "s3_url")]
        text_format = FORMAT_TEXT_RECORD
    else:  # regular GCS host endpoint
        fields = (
            ("ID", "id"),
            ("URI", lambda s: (s["uri"] or "none (Globus Connect Personal)")),
        )
        text_format = FORMAT_TEXT_TABLE
    formatted_print(server_list, text_format=text_format, fields=fields)
182913
def get_router_table(routers):
    
    table = formatting.Table(['Datacenter', 'Hostname', 'Backend Router Id'], "Available Routers")
    for router in routers:
        datacenter = router['topLevelLocation']['longName']
        table.add_row([datacenter, router['hostname'], router['id']])
    return table
551976
def list_datacenters(conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_datacenters function must be called with '
            '-f or --function.'
        )

    datacenters = []

    if not conn:
        conn = get_conn()

    for item in conn.list_datacenters()['items']:
        datacenter = {'id': item['id']}
        datacenter.update(item['properties'])
        datacenters.append({item['properties']['name']: datacenter})

    return {'Datacenters': datacenters}
946331
def GetAllServers(alias=None,name_groups=False):
		
		if alias is None:  alias = clc.v1.Account.GetAlias()
		servers = []
		clc.v1.Account.GetLocations()
		for location in clc.LOCATIONS:
			try:
				r = clc.v1.API.Call('post','Server/GetAllServers', {'AccountAlias': alias, 'Location': location }, hide_errors=[5,] )
				if name_groups:  r['Servers'] = clc.v1.Group.NameGroups(r['Servers'],'HardwareGroupUUID')
				if int(r['StatusCode']) == 0:  servers += r['Servers']
			except:
				pass
		return(servers)