Returns public and private IP addresses.

    linode_id
        Limits the IP addresses returned to the specified Linode ID.
480934
def get_ips(linode_id=None):
    '''
    
    '''
    if linode_id:
        ips = _query('linode', 'ip.list', args={'LinodeID': linode_id})
    else:
        ips = _query('linode', 'ip.list')

    ips = ips['DATA']
    ret = {}

    for item in ips:
        node_id = six.text_type(item['LINODEID'])
        if item['ISPUBLIC'] == 1:
            key = 'public_ips'
        else:
            key = 'private_ips'

        if ret.get(node_id) is None:
            ret.update({node_id: {'public_ips': [], 'private_ips': []}})
        ret[node_id][key].append(item['IPADDRESS'])

    # If linode_id was specified, only return the ips, and not the
    # dictionary based on the linode ID as a key.
    if linode_id:
        _all_ips = {'public_ips': [], 'private_ips': []}
        matching_id = ret.get(six.text_type(linode_id))
        if matching_id:
            _all_ips['private_ips'] = matching_id['private_ips']
            _all_ips['public_ips'] = matching_id['public_ips']

        ret = _all_ips

    return ret
521106
def list(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/list_ipv4', params, 'GET')
1208240
def get_instance_private_ip_from_route(instance, route):
    
    ipaddr = None
    for eni in instance.interfaces:
        if eni.id == route.interface_id:
            ipaddr = eni.private_ip_address
            break
    return ipaddr, eni if ipaddr else None
1043454
def get_public_ip_address(ip_address)
      params = {
          'command' => 'listPublicIpAddresses',
          'ipaddress' => ip_address
      }
      json = send_request(params)
      return nil unless json['publicipaddress']
      json['publicipaddress'].first
    end
939803
function getMyIPs() {
	var ips = [];
	var ifs = os.networkInterfaces();
	for (var i in ifs) {
		for (var j in ifs[i]) {
			ips.push(ifs[i][j].address);
		}
	}
	return ips;
}
796630
def public_key_to_connection_id(self, public_key):
        
        with self._connections_lock:
            for connection_id, connection_info in self._connections.items():
                if connection_info.public_key == public_key:
                    return connection_id

            return None
1356613
def addresses(self):
        
        import ns1.rest.ipam
        return ns1.rest.ipam.Addresses(self.config)
1169158
def GetIPAddresses(self):
    """"""
    result = []
    filtered_ips = ["127.0.0.1", "::1", "fe80::1"]

    for interface in self.interfaces:
      for address in interface.addresses:
        if address.human_readable_address not in filtered_ips:
          result.append(Text(address.human_readable_address))
    return sorted(result)
1190958
def list_cidr_ips(cidr):
    '''
    
    '''
    ips = netaddr.IPNetwork(cidr)
    return [six.text_type(ip) for ip in list(ips)]
1265062
public static Set<String> getLocalAddresses() {
        try {
            List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());

            Set<String> result = new HashSet<>();

            for (NetworkInterface networkInterface : interfaces) {
                if (networkInterface.isLoopback() || !networkInterface.isUp())
                    continue;

                for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
                    String addr = address.getAddress().getHostAddress();

                    if (addr == null || addr.isEmpty() || addr.contains(":"))
                        continue;

                    result.add(addr);
                }
            }

            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
77057
def get_instance_route53_names(self, instance):
        '''  '''

        instance_attributes = [ 'public_dns_name', 'private_dns_name',
                                'ip_address', 'private_ip_address' ]

        name_list = set()

        for attrib in instance_attributes:
            try:
                value = getattr(instance, attrib)
            except AttributeError:
                continue

            if value in self.route53_records:
                name_list.update(self.route53_records[value])

        return list(name_list)
221318
def is_private(ip):
    
    if matches_prefix(ip, '10.0.0.0/8'):
        return True
    if matches_prefix(ip, '172.16.0.0/12'):
        return True
    if matches_prefix(ip, '192.168.0.0/16'):
        return True
    return False
444085
def get_public_ip(self, addr_family=None, *args, **kwargs):
        """"""
        return self.get_ip('public', addr_family, *args, **kwargs)
328566
def is_private(self):
        
        return (self in IPv4Network('0.0.0.0/8') or
                self in IPv4Network('10.0.0.0/8') or
                self in IPv4Network('127.0.0.0/8') or
                self in IPv4Network('169.254.0.0/16') or
                self in IPv4Network('172.16.0.0/12') or
                self in IPv4Network('192.0.0.0/29') or
                self in IPv4Network('192.0.0.170/31') or
                self in IPv4Network('192.0.2.0/24') or
                self in IPv4Network('192.168.0.0/16') or
                self in IPv4Network('198.18.0.0/15') or
                self in IPv4Network('198.51.100.0/24') or
                self in IPv4Network('203.0.113.0/24') or
                self in IPv4Network('240.0.0.0/4') or
                self in IPv4Network('255.255.255.255/32'))
991284
def get_ips(self, instance_id):
        
        if not instance_id:
          raise InstanceError("could not retrieve the ip address for node: "
                              "no associated instance id")
        gce = self._connect()
        instances = gce.instances()
        try:
            request = instances.get(instance=instance_id,
                                    project=self._project_id, zone=self._zone)
            response = self._execute_request(request)
            ip_public = None

            # If the instance is in status TERMINATED, then there will be
            # no IP addresses.
            if response and response['status'] in ('STOPPING', 'TERMINATED'):
              log.info("node '%s' state is '%s'; no IP address(es)" %
                       (instance_id, response['status']))
              return [None]

            if response and "networkInterfaces" in response:
                interfaces = response['networkInterfaces']
                if interfaces:
                    if "accessConfigs" in interfaces[0]:
                        ip_public = interfaces[0]['accessConfigs'][0]['natIP']

            if ip_public:
                return [ip_public]
            else:
                raise InstanceError("could not retrieve the ip address for "
                                    "node `%s`, please check the node "
                                    "through the cloud provider interface"
                                    % instance_id)

        except (HttpError, CloudProviderError) as e:
            raise InstanceError('could not retrieve the ip address of `%s`: '
                                '`%s`' % (instance_id, e))
234423
def _get_ids_from_name_private(self, name):
        """"""
        results = self.list_private_images(name=name)
        return [result['id'] for result in results]
284688
def ipv4_private(self, network=False, address_class=None):
        
        # compute private networks from given class
        supernet = _IPv4Constants._network_classes[
            address_class or self.ipv4_network_class()
        ]

        private_networks = [
            subnet for subnet in _IPv4Constants._private_networks
            if subnet.overlaps(supernet)
        ]

        # exclude special networks
        private_networks = self._exclude_ipv4_networks(
            private_networks,
            _IPv4Constants._excluded_networks,
        )

        # choose random private network from the list
        private_network = self.generator.random.choice(private_networks)

        return self._random_ipv4_address_from_subnet(private_network, network)