List opened datacenters for given type.
4135
def is_opened(cls, dc_code, type_):
        """"""
        options = {'dc_code': dc_code, '%s_opened' % type_: True}
        datacenters = cls.safe_call('hosting.datacenter.list', options)
        if not datacenters:
            # try with ISO code
            options = {'iso': dc_code, '%s_opened' % type_: True}
            datacenters = cls.safe_call('hosting.datacenter.list', options)
            if not datacenters:
                raise DatacenterClosed(r'/!\ Datacenter %s is closed, please '
                                       'choose another datacenter.' % dc_code)

        datacenter = datacenters[0]
        if datacenter.get('%s_closed_for' % type_) == 'NEW':
            dc_close_date = datacenter.get('deactivate_at', '')
            if dc_close_date:
                dc_close_date = dc_close_date.strftime('%d/%m/%Y')
            raise DatacenterLimited(dc_close_date)
952570
def list_nodes(conn=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    ret = {}
    nodes = conn.list_servers()

    for node in nodes:
        public_ips = []
        private_ips = []
        ret = {}

        size = node.get('hardware').get('fixed_instance_size_id', 'Custom size')

        if node.get('private_networks'):
            for private_ip in node['private_networks']:
                private_ips.append(private_ip)

        if node.get('ips'):
            for public_ip in node['ips']:
                public_ips.append(public_ip['ip'])

        server = {
            'id': node['id'],
            'image': node['image']['id'],
            'size': size,
            'state': node['status']['state'],
            'private_ips': private_ips,
            'public_ips': public_ips
        }
        ret[node['name']] = server

    return ret
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
1203109
def list_nodes_full(conn=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes_full function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    ret = {}
    services = list_hosted_services(conn=conn, call=call)
    for service in services:
        for deployment in services[service]['deployments']:
            deploy_dict = services[service]['deployments'][deployment]
            deploy_dict_no_role_info = copy.deepcopy(deploy_dict)
            del deploy_dict_no_role_info['role_list']
            del deploy_dict_no_role_info['role_instance_list']
            roles = deploy_dict['role_list']
            for role in roles:
                role_instances = deploy_dict['role_instance_list']
                ret[role] = roles[role]
                ret[role].update(role_instances[role])
                ret[role]['id'] = role
                ret[role]['hosted_service'] = service
                if role_instances[role]['power_state'] == 'Started':
                    ret[role]['state'] = 'running'
                elif role_instances[role]['power_state'] == 'Stopped':
                    ret[role]['state'] = 'stopped'
                else:
                    ret[role]['state'] = 'pending'
                ret[role]['private_ips'] = []
                ret[role]['public_ips'] = []
                ret[role]['deployment'] = deploy_dict_no_role_info
                ret[role]['url'] = deploy_dict['url']
                ip_address = role_instances[role]['ip_address']
                if ip_address:
                    if salt.utils.cloud.is_public_ip(ip_address):
                        ret[role]['public_ips'].append(ip_address)
                    else:
                        ret[role]['private_ips'].append(ip_address)
                ret[role]['size'] = role_instances[role]['instance_size']
                ret[role]['image'] = roles[role]['role_info']['os_virtual_hard_disk']['source_image_name']
    return ret
49736
def list_nodes_full(conn=None, call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes_full function must be called with -f or --function.'
        )
    if conn is None:
        conn = get_conn()
    ret = {}
    for node in conn.list_servers(detailed=True):
        ret[node.name] = dict(node)
        ret[node.name]['id'] = node.id
        ret[node.name]['name'] = node.name
        ret[node.name]['size'] = node.flavor.name
        ret[node.name]['state'] = node.status
        ret[node.name]['private_ips'] = _get_ips(node, 'private')
        ret[node.name]['public_ips'] = _get_ips(node, 'public')
        ret[node.name]['floating_ips'] = _get_ips(node, 'floating')
        ret[node.name]['fixed_ips'] = _get_ips(node, 'fixed')
        ret[node.name]['image'] = node.image.name
    return ret
244514
def type_list(self, index_name):
        '''
        
        '''
        request = self.session
        url = 'http://%s:%s/%s/_mapping' % (self.host, self.port, index_name)
        response = request.get(url)
        if request.status_code == 200:
            return response[index_name].keys()
        else:
            return response
823500
def list_nodes(conn=None, call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )
    ret = {}
    for node, info in list_nodes_full(conn=conn).items():
        for key in ('id', 'name', 'size', 'state', 'private_ips', 'public_ips', 'floating_ips', 'fixed_ips', 'image'):
            ret.setdefault(node, {}).setdefault(key, info.get(key))

    return ret
87205
def get_queues(self):
        """"""
        res = self.celery.control.inspect().active_queues() or dict()
        return [result.get('name') for host in res.values() for result in host]
362705
def list_migration_choice(cls, datacenter):
        """"""
        datacenter_id = cls.usable_id(datacenter)
        dc_list = cls.list()
        available_dcs = [dc for dc in dc_list
                         if dc['id'] == datacenter_id][0]['can_migrate_to']
        choices = [dc for dc in dc_list
                   if dc['id'] in available_dcs]
        return choices
114428
def list(cls, datacenter=None, flavor=None, match='', exact_match=False):
        
        if not datacenter:
            dc_ids = [dc['id'] for dc in Datacenter.filtered_list()]
            kmap = {}
            for dc_id in dc_ids:
                vals = cls.safe_call('hosting.disk.list_kernels', dc_id)
                for key in vals:
                    kmap.setdefault(key, []).extend(vals.get(key, []))
            # remove duplicates
            for key in kmap:
                kmap[key] = list(set(kmap[key]))
        else:
            dc_id = Datacenter.usable_id(datacenter)
            kmap = cls.safe_call('hosting.disk.list_kernels', dc_id)

        if match:
            for flav in kmap:
                if exact_match:
                    kmap[flav] = [x for x in kmap[flav] if match == x]
                else:
                    kmap[flav] = [x for x in kmap[flav] if match in x]
        if flavor:
            if flavor not in kmap:
                cls.error('flavor %s not supported here' % flavor)
            return dict([(flavor, kmap[flavor])])

        return kmap
898051
def list_domains():
    '''
    
    '''
    data = __salt__['vmadm.list'](keyed=True)
    vms = ["UUID                                  TYPE  RAM      STATE             ALIAS"]
    for vm in data:
        vms.append("{vmuuid}{vmtype}{vmram}{vmstate}{vmalias}".format(
            vmuuid=vm.ljust(38),
            vmtype=data[vm]['type'].ljust(6),
            vmram=data[vm]['ram'].ljust(9),
            vmstate=data[vm]['state'].ljust(18),
            vmalias=data[vm]['alias'],
        ))
    return vms
348307
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 instanceId in nodes:
        node = nodes[instanceId]
        ret[node['name']] = {
            'id': node['id'],
            'name': node['name'],
            'public_ips': node['public_ips'],
            'private_ips': node['private_ips'],
            'size': node['size'],
            'state': six.text_type(node['state']),
        }
    return ret
443130
def list_servers(backend, socket=DEFAULT_SOCKET_URL, objectify=False):
    '''
    
    '''
    ha_conn = _get_conn(socket)
    ha_cmd = haproxy.cmds.listServers(backend=backend)
    return ha_conn.sendCmd(ha_cmd, objectify=objectify)
972015
def list(gandi, state, id, vhosts, type, limit):
    """"""
    options = {
        'items_per_page': limit,
    }
    if state:
        options['state'] = state

    output_keys = ['name', 'state']
    if id:
        output_keys.append('id')
    if vhosts:
        output_keys.append('vhost')
    if type:
        output_keys.append('type')

    paas_hosts = {}
    result = gandi.paas.list(options)
    for num, paas in enumerate(result):
        paas_hosts[paas['id']] = []
        if vhosts:
            list_vhost = gandi.vhost.list({'paas_id': paas['id']})
            for host in list_vhost:
                paas_hosts[paas['id']].append(host['name'])

        if num:
            gandi.separator_line()
        output_paas(gandi, paas, [], paas_hosts[paas['id']],
                    output_keys)

    return result
353303
def list_datacenters(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_datacenters function must be called with '
            '-f or --function.'
        )

    return {'Datacenters': salt.utils.vmware.list_datacenters(_get_si())}
1125265
def list(host=None, quiet=False, hyper=None):  # pylint: disable=redefined-builtin
    '''
    
    '''
    if quiet:
        log.warning("'quiet' is deprecated. Please migrate to --quiet")
    ret = {}
    client = salt.client.get_local_client(__opts__['conf_file'])
    for info in client.cmd_iter('virtual:physical',
                                'virt.vm_info', tgt_type='grain'):
        if not info:
            continue
        if not isinstance(info, dict):
            continue
        chunk = {}
        id_ = next(six.iterkeys(info))
        if host:
            if host != id_:
                continue
        if not isinstance(info[id_], dict):
            continue
        if 'ret' not in info[id_]:
            continue
        if not isinstance(info[id_]['ret'], dict):
            continue
        data = {}
        for key, val in six.iteritems(info[id_]['ret']):
            if val['state'] in data:
                data[val['state']].append(key)
            else:
                data[val['state']] = [key]
        chunk[id_] = data
        ret.update(chunk)
        if not quiet:
            __jid_event__.fire_event({'data': chunk, 'outputter': 'nested'}, 'progress')

    return ret
665369
def cli(env, sortby, columns, datacenter, username, storage_type):
    """"""
    file_manager = SoftLayer.FileStorageManager(env.client)
    file_volumes = file_manager.list_file_volumes(datacenter=datacenter,
                                                  username=username,
                                                  storage_type=storage_type,
                                                  mask=columns.mask())

    table = formatting.Table(columns.columns)
    table.sortby = sortby

    for file_volume in file_volumes:
        table.add_row([value or formatting.blank()
                       for value in columns.row(file_volume)])

    env.fout(table)