Helper function for list_nodes. Returns public and private ip lists based on a
    given network dictionary.
969683
def _get_ips(networks):
    '''
    
    '''
    v4s = networks.get('v4')
    v6s = networks.get('v6')
    public_ips = []
    private_ips = []

    if v4s:
        for item in v4s:
            ip_type = item.get('type')
            ip_address = item.get('ip_address')
            if ip_type == 'public':
                public_ips.append(ip_address)
            if ip_type == 'private':
                private_ips.append(ip_address)

    if v6s:
        for item in v6s:
            ip_type = item.get('type')
            ip_address = item.get('ip_address')
            if ip_type == 'public':
                public_ips.append(ip_address)
            if ip_type == 'private':
                private_ips.append(ip_address)

    return public_ips, private_ips
1054444
def _parse_networks(service_list: dict) -> list:
        
        # Initialising empty list
        networks = []

        for n_values in service_list['networks'].values():
            for n_key, n_value in n_values.items():
                if 'name' in n_key:
                    networks.append(n_value)
        return networks
617154
def get_ip_address_list(list_name):
    '''
    

    '''
    payload = {"jsonrpc": "2.0",
               "id": "ID0",
               "method": "get_policy_ip_addresses",
               "params": [list_name, 0, 256]}

    response = __proxy__['bluecoat_sslv.call'](payload, False)

    return _convert_to_list(response, 'item_name')
1185806
def get_public_network_ip(ips, public_subnet):
    
    for ip in ips:
        if net.ip_in_subnet(ip, public_subnet):
            return ip
    msg = "IPs (%s) are not valid for any of subnet specified %s" % (str(ips), str(public_subnet))
    raise RuntimeError(msg)
464616
def list_nodes(call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called '
            'with -f or --function.'
        )

    providers = __opts__.get('providers', {})

    ret = {}
    providers_to_check = [_f for _f in [cfg.get('libvirt') for cfg in six.itervalues(providers)] if _f]
    for provider in providers_to_check:
        conn = __get_conn(provider['url'])
        domains = conn.listAllDomains()
        for domain in domains:
            data = {
                'id': domain.UUIDString(),
                'image': '',
                'size': '',
                'state': VIRT_STATE_NAME_MAP[domain.state()[0]],
                'private_ips': [],
                'public_ips': get_domain_ips(domain, libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)}
            # TODO: Annoyingly name is not guaranteed to be unique, but the id will not work in other places
            ret[domain.name()] = data

    return ret
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
523491
def format_private_ip_address(result):
    '''
    
    '''
    from collections import OrderedDict
    # Only display parameters that have content
    order_dict = OrderedDict()
    if result.ip_address is not None:
        order_dict['ipAddress'] = result.ip_address
    if result.subnet_resource_id is not None:
        order_dict['subnetResourceId'] = result.subnet_resource_id

    return order_dict
880280
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 = {}
    datacenter_id = get_datacenter_id()

    try:
        nodes = conn.list_servers(datacenter_id=datacenter_id)
    except PBNotFoundError:
        log.error('Failed to get nodes list '
                  'from datacenter: %s', datacenter_id)
        raise

    for item in nodes['items']:
        node = {'id': item['id']}
        node.update(item['properties'])
        node['state'] = node.pop('vmState')
        ret[node['name']] = node

    return ret
843648
def _list_interface_private_addrs(eni_desc):
    '''
    
    '''
    primary = eni_desc.get('privateIpAddress')
    if not primary:
        return None

    addresses = [primary]

    lst = eni_desc.get('privateIpAddressesSet', {}).get('item', [])
    if not isinstance(lst, list):
        return addresses

    for entry in lst:
        if entry.get('primary') == 'true':
            continue
        if entry.get('privateIpAddress'):
            addresses.append(entry.get('privateIpAddress'))

    return addresses
341385
def list():
    ""
    for node in env.nodes:
        print "%s (%s, %s)" % (node.tags["Name"], node.ip_address,
            node.private_ip_address)
262858
def _process_reservations(self, reservations):
        

        reservations = reservations['Reservations']

        private_ip_addresses = []
        private_hostnames = []
        public_ips = []
        public_hostnames = []
        for reservation in reservations:
            for instance in reservation['Instances']:
                private_ip_addresses.append(instance['PrivateIpAddress'])
                private_hostnames.append(instance['PrivateDnsName'])

                if 'PublicIpAddress' in instance:
                    public_ips.append(instance['PublicIpAddress'])
                elif not self.remove_nones:
                    public_ips.append(None)

                if ('PublicDnsName' in instance) & (not self.remove_nones):
                    public_hostnames.append(instance['PublicDnsName'])
                elif not self.remove_nones:
                    public_hostnames.append(None)

        return {
            'private': {
                'ips': private_ip_addresses,
                'hostnames': private_hostnames
            },
            'public': {
                'ips': public_ips,
                'hostnames': public_hostnames
            },
            'reservations': reservations
        }
741107
def list_nodes(call=None):
    ''' 
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    items = query(method='servers')

    ret = {}
    for node in items['servers']:
        public_ips = []
        private_ips = []
        image_id = ''

        if node.get('public_ip'):
            public_ips = [node['public_ip']['address']]

        if node.get('private_ip'):
            private_ips = [node['private_ip']]

        if node.get('image'):
            image_id = node['image']['id']

        ret[node['name']] = {
            'id': node['id'],
            'image_id': image_id,
            'public_ips': public_ips,
            'private_ips': private_ips,
            'size': node['volumes']['0']['size'],
            'state': node['state'],
        }
    return ret
1199304
def list_nodes(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    ret = {}
    items = query(action='ve')

    for item in items:
        name = item.attrib['name']
        node = show_instance(name, call='action')

        ret[name] = {
            'id': node['id'],
            'image': node['platform']['template-info']['name'],
            'state': node['state'],
        }
        if 'private-ip' in node['network']:
            ret[name]['private_ips'] = [node['network']['private-ip']]
        if 'public-ip' in node['network']:
            ret[name]['public_ips'] = [node['network']['public-ip']]

    return ret
485530
def list_network_ip_availabilities(self, retrieve_all=True, **_params):
        """"""
        return self.list('network_ip_availabilities',
                         self.network_ip_availabilities_path,
                         retrieve_all, **_params)
695568
async def _check_ip(self, addr):
        

        tasks = []
        for provider in self.providers:
            tasks.append(self.dnsbl_request(addr, provider))
        results = await asyncio.gather(*tasks)
        return DNSBLResult(addr=addr, results=results)
857696
def _get_aggregated_node_list(self, data):
        
        node_list = []
        for node in data:
            local_addresses = [node['primary']]
            if 'secondary' in node:
                local_addresses += node['secondary']
            node_list.append(local_addresses)
        return node_list
1088561
def public_ip_addresses_list_all(**kwargs):
    '''
    

    '''
    result = {}
    netconn = __utils__['azurearm.get_client']('network', **kwargs)
    try:
        pub_ips = __utils__['azurearm.paged_object_to_list'](netconn.public_ip_addresses.list_all())

        for ip in pub_ips:
            result[ip['name']] = ip
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('network', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result