Return a dict of all available VM locations on the cloud provider with
    relevant data
326176
def list_keypairs(call=None):
    '''
    
    '''
    if call != 'function':
        log.error(
            'The list_keypairs function must be called with -f or --function.'
        )
        return False

    fetch = True
    page = 1
    ret = {}

    while fetch:
        items = query(method='account/keys', command='?page=' + six.text_type(page) +
                      '&per_page=100')

        for key_pair in items['ssh_keys']:
            name = key_pair['name']
            if name in ret:
                raise SaltCloudSystemExit(
                    'A duplicate key pair name, \'{0}\', was found in DigitalOcean\'s '
                    'key pair list. Please change the key name stored by DigitalOcean. '
                    'Be sure to adjust the value of \'ssh_key_file\' in your cloud '
                    'profile or provider configuration, if necessary.'.format(
                        name
                    )
                )
            ret[name] = {}
            for item in six.iterkeys(key_pair):
                ret[name][item] = six.text_type(key_pair[item])

        page += 1
        try:
            fetch = 'next' in items['links']['pages']
        except KeyError:
            fetch = False

    return ret
708812
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 = {}

    params = {'Action': 'DescribeRegions'}
    result = aws.query(params,
                       location=get_location(),
                       provider=get_provider(),
                       opts=__opts__,
                       sigver='4')

    for region in result:
        ret[region['regionName']] = {
            'name': region['regionName'],
            'endpoint': region['regionEndpoint'],
        }

    return ret
1010690
def virtual_machines_list_all(**kwargs):
    '''
    

    '''
    result = {}
    compconn = __utils__['azurearm.get_client']('compute', **kwargs)
    try:
        vms = __utils__['azurearm.paged_object_to_list'](
            compconn.virtual_machines.list_all()
        )
        for vm in vms:  # pylint: disable=invalid-name
            result[vm['name']] = vm
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('compute', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result
1259785
def vmstats():
    '''
    
    '''
    # Setup the SPI Structure
    spi = SYSTEM_PERFORMANCE_INFORMATION()
    retlen = ctypes.c_ulong()

    # 2 means to query System Performance Information and return it in a
    # SYSTEM_PERFORMANCE_INFORMATION Structure
    ctypes.windll.ntdll.NtQuerySystemInformation(
        2, ctypes.byref(spi), ctypes.sizeof(spi), ctypes.byref(retlen))

    # Return each defined field in a dict
    ret = {}
    for field in spi._fields_:
        ret.update({field[0]: getattr(spi, field[0])})

    return ret
968506
async def get(self):
        
        shepherd = self.request.app.vmshepherd
        data = {'presets': {}, 'config': shepherd.config}
        presets = await shepherd.preset_manager.list_presets()
        runtime = shepherd.runtime_manager
        for name in presets:
            preset = shepherd.preset_manager.get_preset(name)
            data['presets'][name] = {
                'preset': preset,
                'vms': preset.vms,
                'runtime': await runtime.get_preset_data(name),
                'vmshepherd_id': shepherd.instance_id,
                'now': time.time()
            }
        return data
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}
543716
def list_nodes(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    ret = {}
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
        log.debug('VM_Name: %s', vm_name)
        log.debug('vm_details: %s', vm_details)

        # Limit resultset on what Salt-cloud demands:
        ret[vm_name] = {}
        ret[vm_name]['id'] = six.text_type(vm_details['vmid'])
        ret[vm_name]['image'] = six.text_type(vm_details['vmid'])
        ret[vm_name]['size'] = six.text_type(vm_details['disk'])
        ret[vm_name]['state'] = six.text_type(vm_details['status'])

        # Figure out which is which to put it in the right column
        private_ips = []
        public_ips = []

        if 'ip_address' in vm_details['config'] and vm_details['config']['ip_address'] != '-':
            ips = vm_details['config']['ip_address'].split(' ')
            for ip_ in ips:
                if IP(ip_).iptype() == 'PRIVATE':
                    private_ips.append(six.text_type(ip_))
                else:
                    public_ips.append(six.text_type(ip_))

        ret[vm_name]['private_ips'] = private_ips
        ret[vm_name]['public_ips'] = public_ips

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

    return {'vApps': salt.utils.vmware.list_vapps(_get_si())}
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
161473
def avail_locations(conn=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_locations function must be called with '
            '-f or --function, or with the --list-locations option'
        )

    if conn is None:
        conn = get_conn()

    endpoints = nova.get_entry(conn.get_catalog(), 'type', 'compute')['endpoints']
    ret = {}
    for endpoint in endpoints:
        ret[endpoint['region']] = endpoint

    return ret
559259
def __gather_avail(self):
        '''
        
        '''
        avail = {}
        for saltenv in self._get_envs():
            avail[saltenv] = self.client.list_states(saltenv)
        return avail
1031709
def avail_locations(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudException(
            'The avail_locations function must be called with -f or --function.'
        )

    vm_ = get_configured_provider()
    manager = packet.Manager(auth_token=vm_['token'])

    ret = {}

    for facility in manager.list_facilities():
        ret[facility.name] = facility.__dict__

    return ret
893198
def available_metrics(self):
        
        req = self.request(self.mist_client.uri+"/clouds/"+self.cloud.id+"/machines/"+self.id+"/metrics")
        metrics = req.get().json()
        return metrics
377634
def __get_metadata(vm_):
    '''
    
    '''
    md = config.get_cloud_config_value(
        'metadata', vm_, __opts__,
        default='{}', search_global=False)
    # Consider warning the user that the metadata in the cloud profile
    # could not be interpreted, bad formatting?
    try:
        metadata = literal_eval(md)
    except Exception:  # pylint: disable=W0703
        metadata = None
    if not metadata or not isinstance(metadata, dict):
        metadata = {'items': [{
            'key': 'salt-cloud-profile',
            'value': vm_['profile']
        }]}
    else:
        metadata['salt-cloud-profile'] = vm_['profile']
        items = []
        for k, v in six.iteritems(metadata):
            items.append({'key': k, 'value': v})
        metadata = {'items': items}
    return metadata
288479
def __get_location(conn, vm_):
    '''
    
    '''
    location = config.get_cloud_config_value(
        'location', vm_, __opts__)
    return conn.ex_get_zone(location)
828399
def _list_nodes_full(location=None):
    '''
    
    '''
    provider = __active_provider_name__ or 'ec2'
    if ':' in provider:
        comps = provider.split(':')
        provider = comps[0]

    params = {'Action': 'DescribeInstances'}
    instances = aws.query(params,
                          location=location,
                          provider=provider,
                          opts=__opts__,
                          sigver='4')
    if 'error' in instances:
        raise SaltCloudSystemExit(
            'An error occurred while listing nodes: {0}'.format(
                instances['error']['Errors']['Error']['Message']
            )
        )

    ret = _extract_instance_info(instances)

    __utils__['cloud.cache_node_list'](ret, provider, __opts__)
    return ret
539587
def get_data(conn_objs, providers):
    """"""
    cld_svc_map = {"aws": nodes_aws,
                   "azure": nodes_az,
                   "gcp": nodes_gcp,
                   "alicloud": nodes_ali}
    sys.stdout.write("\rCollecting Info:  ")
    sys.stdout.flush()
    busy_obj = busy_disp_on()
    collec_fn = [[cld_svc_map[x.rstrip('1234567890')], conn_objs[x]]
                 for x in providers]
    ngroup = Group()
    node_list = []
    node_list = ngroup.map(get_nodes, collec_fn)
    ngroup.join()
    busy_disp_off(dobj=busy_obj)
    sys.stdout.write("\r                                                 \r")
    sys.stdout.write("\033[?25h")  # cursor back on
    sys.stdout.flush()
    return node_list