Wraps :meth:`bang.providers.openstack.Nova.find_servers` to apply
        hpcloud specialization, namely pulling IP addresses from the hpcloud's
        non-standard return values.
189655
def find_servers(self, *args, **kwargs):
        
        servers = super(HPNova, self).find_servers(*args, **kwargs)
        return map(fix_hp_addrs, servers)
1114996
def list_locations(self, provider=None):
        '''
        
        '''
        mapper = salt.cloud.Map(self._opts_defaults())
        return salt.utils.data.simple_types_filter(
            mapper.location_list(provider)
        )
989520
def get_ip(self, access='public', addr_family=None, strict=None):
        
        if addr_family not in ['IPv4', 'IPv6', None]:
            raise Exception("`addr_family` must be 'IPv4', 'IPv6' or None")

        if access not in ['private', 'public']:
            raise Exception("`access` must be 'public' or 'private'")

        if not hasattr(self, 'ip_addresses'):
            self.populate()

        # server can have several public or private IPs
        ip_addrs = [
            ip_addr for ip_addr in self.ip_addresses
            if ip_addr.access == access
        ]

        # prefer addr_family (or IPv4 if none given)
        preferred_family = addr_family if addr_family else 'IPv4'
        for ip_addr in ip_addrs:
            if ip_addr.family == preferred_family:
                return ip_addr.address

        # any IP (of the right access) will do if available and addr_family is None
        return ip_addrs[0].address if ip_addrs and not addr_family else None
1144520
def _find_server(account, servername=None):
    
    servers = servers = [s for s in account.resources() if 'server' in s.provides]
    # If servername specified find and return it
    if servername is not None:
        for server in servers:
            if server.name == servername:
                return server.connect()
        raise SystemExit('Unknown server name: %s' % servername)
    # If servername not specified; allow user to choose
    return utils.choose('Choose a Server', servers, 'name').connect()
1285067
@Override
    public List<Server> getEligibleServers(List<Server> servers, Object loadBalancerKey) {
        List<Server> result = super.getEligibleServers(servers, loadBalancerKey);
        Iterator<AbstractServerPredicate> i = fallbacks.iterator();
        while (!(result.size() >= minimalFilteredServers && result.size() > (int) (servers.size() * minimalFilteredPercentage))
                && i.hasNext()) {
            AbstractServerPredicate predicate = i.next();
            result = predicate.getEligibleServers(servers, loadBalancerKey);
        }
        return result;
    }
914712
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 = {}
    ret['locations'] = []

    try:
        resconn = get_conn(client_type='resource')
        provider_query = resconn.providers.get(
            resource_provider_namespace='Microsoft.Compute'
        )
        locations = []
        for resource in provider_query.resource_types:
            if six.text_type(resource.resource_type) == 'virtualMachines':
                resource_dict = resource.as_dict()
                locations = resource_dict['locations']
        for location in locations:
            lowercase = location.lower().replace(' ', '')
            ret['locations'].append(lowercase)
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', exc.message)
        ret = {'Error': exc.message}

    return ret
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
763204
public List<Server> getEligibleServers(List<Server> servers, Object loadBalancerKey) {
        if (loadBalancerKey == null) {
            return ImmutableList.copyOf(Iterables.filter(servers, this.getServerOnlyPredicate()));            
        } else {
            List<Server> results = Lists.newArrayList();
            for (Server server: servers) {
                if (this.apply(new PredicateKey(loadBalancerKey, server))) {
                    results.add(server);
                }
            }
            return results;            
        }
    }
1272144
def server_show(self, server_id):
        '''
        
        '''
        ret = {}
        try:
            servers = self.server_list_detailed()
        except AttributeError:
            raise SaltCloudSystemExit('Corrupt server in server_list_detailed. Remove corrupt servers.')
        for server_name, server in six.iteritems(servers):
            if six.text_type(server['id']) == server_id:
                ret[server_name] = server
        return ret
1306257
def Servers(self):
		

		return(clc.v2.Servers(
			alias=self.alias,
			servers_lst=[obj['id'] for obj in self.data['links'] if obj['rel']=='server'],
			session=self.session))
614450
def _find_address_range(addresses):
    
    it = iter(addresses)
    first = last = next(it)
    for ip in it:
        if ip._ip != last._ip + 1:
            yield first, last
            first = ip
        last = ip
    yield first, last
141953
def _get_ids_from_ip(self, ip):  # pylint: disable=inconsistent-return-statements
        """"""
        try:
            # Does it look like an ip address?
            socket.inet_aton(ip)
        except socket.error:
            return []

        # Find the server via ip address. First try public ip, then private
        results = self.list_hardware(public_ip=ip, mask="id")
        if results:
            return [result['id'] for result in results]

        results = self.list_hardware(private_ip=ip, mask="id")
        if results:
            return [result['id'] for result in results]
1137752
def collect_hypervisors_metrics(
        self,
        servers,
        custom_tags=None,
        use_shortname=False,
        collect_hypervisor_metrics=True,
        collect_hypervisor_load=False,
    ):
        
        # Create a dictionary with hypervisor hostname as key and the list of project names as value
        hyp_project_names = defaultdict(set)
        for server in itervalues(servers):
            hypervisor_hostname = server.get('hypervisor_hostname')
            if not hypervisor_hostname:
                self.log.debug(
                    "hypervisor_hostname is None for server %s. Check that your user is an administrative users.",
                    server['server_id'],
                )
            else:
                hyp_project_names[hypervisor_hostname].add(server['project_name'])

        hypervisors = self.get_os_hypervisors_detail()
        for hyp in hypervisors:
            self.get_stats_for_single_hypervisor(
                hyp,
                hyp_project_names,
                custom_tags=custom_tags,
                use_shortname=use_shortname,
                collect_hypervisor_metrics=collect_hypervisor_metrics,
                collect_hypervisor_load=collect_hypervisor_load,
            )
        if not hypervisors:
            self.warning("Unable to collect any hypervisors from Nova 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
1028858
def lookup!(nameserver=nil)
      resolver = Resolv.resolver(nameserver)
      ips = begin
              resolver.getaddresses(self.address)
            rescue
              []
            end

      ips.map! do |addr|
        IPAddress.first_or_create(
          :address => addr,
          :host_names => [self]
        )
      end

      return ips
    end
496406
def lookup_profiles(self, provider, lookup):
        '''
        
        '''
        if provider is None:
            provider = 'all'
        if lookup is None:
            lookup = 'all'

        if lookup == 'all':
            profiles = set()
            provider_profiles = set()
            for alias, info in six.iteritems(self.opts['profiles']):
                providers = info.get('provider')

                if providers:
                    given_prov_name = providers.split(':')[0]
                    salt_prov_name = providers.split(':')[1]
                    if given_prov_name == provider:
                        provider_profiles.add((alias, given_prov_name))
                    elif salt_prov_name == provider:
                        provider_profiles.add((alias, salt_prov_name))
                    profiles.add((alias, given_prov_name))

            if not profiles:
                raise SaltCloudSystemExit(
                    'There are no cloud profiles configured.'
                )

            if provider != 'all':
                return provider_profiles

            return profiles
531979
def get_device(self):
        
        addr = self.address
        servers = [server for server in pyrax.cloudservers.list()
                if addr in server.networks.get("private", "")]
        try:
            return servers[0]
        except IndexError:
            return None