Lists all licenses on a vCenter.

    service_instance
        Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
        Default is None.

    .. code-block:: bash

        salt '*' vsphere.list_licenses
355578
def list_licenses(service_instance=None):
    '''
    
    '''
    log.trace('Retrieving all licenses')
    licenses = salt.utils.vmware.get_licenses(service_instance)
    ret_dict = [{'key': l.licenseKey,
                 'name': l.name,
                 'description': l.labels[0].value if l.labels else None,
                 # VMware handles unlimited capacity as 0
                 'capacity': l.total if l.total > 0 else sys.maxsize,
                 'used': l.used if l.used else 0}
                 for l in licenses]
    return ret_dict
364462
def cmd_list(options):
    
    (i_info, param_str) = gather_data(options)
    if i_info:
        awsc.get_all_aminames(i_info)
        param_str = "Instance List - " + param_str + "\n"
        list_instances(i_info, param_str)
    else:
        print("No instances found with parameters: {}".format(param_str))
828575
def _credential_allows_container_list(self):
        # type: (StorageAccount) -> bool
        
        if self.is_sas:
            sasparts = self.key.split('&')
            caccess = self.can_create_containers
            # search for container signed resource for service level sas
            if not caccess:
                for part in sasparts:
                    tmp = part.split('=')
                    if tmp[0] == 'sr':
                        caccess = 'c' in tmp[1] or 's' in tmp[1]
                        break
                    elif tmp[0] == 'si':
                        # assume sas policies allow container list
                        return True
            # search for list permission
            if caccess:
                for part in sasparts:
                    tmp = part.split('=')
                    if tmp[0] == 'sp':
                        return 'l' in tmp[1]
            # sas doesn't allow container level list
            return False
        else:
            # storage account key always allows container list
            return True
435484
def get_service_info(service_instance):
    '''
    
    '''
    try:
        return service_instance.content.about
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(
            'Not enough permissions. Required privilege: '
            '{0}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareRuntimeError(exc.msg)
666151
def get_host_vsan_system(service_instance, host_ref, hostname=None):
    '''
    
    '''
    if not hostname:
        hostname = salt.utils.vmware.get_managed_object_name(host_ref)
    traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
        path='configManager.vsanSystem',
        type=vim.HostSystem,
        skip=False)
    objs = salt.utils.vmware.get_mors_with_properties(
        service_instance, vim.HostVsanSystem, property_list=['config.enabled'],
        container_ref=host_ref, traversal_spec=traversal_spec)
    if not objs:
        raise VMwareObjectRetrievalError('Host\'s \'{0}\' VSAN system was '
                                         'not retrieved'.format(hostname))
    log.trace('[%s] Retrieved VSAN system', hostname)
    return objs[0]['object']
805619
def list_vmss_sub(access_token, subscription_id):
    '''
    '''
    endpoint = ''.join([get_rm_endpoint(),
                        '/subscriptions/', subscription_id,
                        '/providers/Microsoft.Compute/virtualMachineScaleSets',
                        '?api-version=', COMP_API])
    return do_get_next(endpoint, access_token)
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
1210722
def get_vsan_cluster_config_system(service_instance):
    '''
    
    '''

    #TODO Replace when better connection mechanism is available

    #For python 2.7.9 and later, the defaul SSL conext has more strict
    #connection handshaking rule. We may need turn of the hostname checking
    #and client side cert verification
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    stub = service_instance._stub
    vc_mos = vsanapiutils.GetVsanVcMos(stub, context=context)
    return vc_mos['vsan-cluster-config-system']
553263
def list_licenses():
    '''
    
    '''
    KEY_PATTERN = re.compile('Key (.*)')

    keys = []
    out = __salt__['cmd.run']('/sbin/emcpreg -list')
    for line in out.splitlines():
        match = KEY_PATTERN.match(line)

        if not match:
            continue

        keys.append({'key': match.group(1)})

    return keys
1117522
def list_by_instance(self, instance_id):
        
        ports = port_list(self.request, device_id=instance_id)
        sg_ids = []
        for p in ports:
            sg_ids += p.security_groups
        return self._list(id=set(sg_ids)) if sg_ids else []
31432
def list_vcls(self, service_id, version_number):
		""""""
		content = self._fetch("/service/%s/version/%d/vcl" % (service_id, version_number))
		return map(lambda x: FastlyVCL(self, x), content)
1129024
def valid_envs(self, service_name):
    
    service_record = self.service_record(service_name)
    if service_record is None:
      raise RuntimeError("service registry doesn't have service: {}".format(service_name))

    # Return empty list if service has no "environments" section
    if not (service_record.has_key("environments")):
      return []
    # Otherwise gather up the envs
    service_record_envs = service_record["environments"]
    result = []
    for service_env in service_record_envs:
      if service_env not in EFConfig.PROTECTED_ENVS and service_env in EFConfig.EPHEMERAL_ENVS:
        result.extend((lambda env=service_env: [env + str(x) for x in range(EFConfig.EPHEMERAL_ENVS[env])])())
      else:
        result.append(service_env)
    return result
598251
def list_asgs_all(access_token, subscription_id):
    '''
    '''
    endpoint = ''.join([get_rm_endpoint(),
                        '/subscriptions/', subscription_id,
                        '/providers/Microsoft.Network/virtualNetworks/',
                        '?api-version=', NETWORK_API])
    return do_get(endpoint, access_token)
939145
def list_storage_services(conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            ('The list_storage_services function must be called '
             'with -f or --function.')
        )

    if not conn:
        conn = get_conn()

    ret = {}
    accounts = conn.list_storage_accounts()
    for service in accounts.storage_services:
        ret[service.service_name] = {
            'capabilities': service.capabilities,
            'service_name': service.service_name,
            'storage_service_properties': service.storage_service_properties,
            'extended_properties': service.extended_properties,
            'storage_service_keys': service.storage_service_keys,
            'url': service.url,
        }
    return ret
1017960
def get_ips(self, instance_id):
        
        self._init_os_api()
        instance = self._load_instance(instance_id)
        try:
            ip_addrs = set([self.floating_ip])
        except AttributeError:
            ip_addrs = set([])
        for ip_addr in sum(instance.networks.values(), []):
            ip_addrs.add(ip_addr)
        log.debug("VM `%s` has IP addresses %r", instance_id, ip_addrs)
        return list(ip_addrs)
1324595
def service_list(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.list_services(**kwargs)
1071259
def _get_service_keys(self, service_name):
        
        guid = self.get_instance_guid(service_name)
        uri = "/v2/service_instances/%s/service_keys" % (guid)
        return self.api.get(uri)