Can take a host name or an ip address. Resolves the host name
 and returns the ip address if get_ip is passed in as true.
772965
def wait_until_host_is_available(host, get_ip=false)
      resolved_host = Resolv.getaddresses(host).first
      if resolved_host.nil?
        print("Waiting for #{host} to resolve")
        wait_until('ready!') { resolved_host = Resolv.getaddresses(host).first }
      end
      host = resolved_host if get_ip
      unless remote_is_available?(host)
        print("Waiting for #{host} to accept connections")
        wait_until('ready!') { remote_is_available?(host) }
      end
      return host
    end
479841
def get_host(self):
        
        host = self.get_as_nullable_string("host")
        host = host if host != None else self.get_as_nullable_string("ip")
        return host
701414
private String getHostNameForIp(String ipAddr) {
    try {
      // this handles the case where the hostlist contains names
      // and the datanodes are using IPs
      InetAddress addr = InetAddress.getByName(ipAddr);
      return addr.getHostName();
    } catch (Exception e) { 
      // this can be safely ignored
    }
    return null;
  }
1155908
def get_ip_address(domain):
    
    if "://" not in domain:
        domain = "http://" + domain

    hostname = urlparse(domain).netloc

    if not hostname:
        raise ValueError("Can't parse hostname!")

    return socket.gethostbyname(hostname)
102219
def _check_ip(ip: str) -> bool:
    
    address = ipaddress.IPv4Address(ip)
    return address in allowed_ips
1013514
def RetrieveIP4Info(self, ip):
    """"""
    if ip.is_private:
      return (IPInfo.INTERNAL, "Internal IP address.")
    try:
      # It's an external IP, let's try to do a reverse lookup.
      res = socket.getnameinfo((str(ip), 0), socket.NI_NAMEREQD)
      return (IPInfo.EXTERNAL, res[0])
    except (socket.error, socket.herror, socket.gaierror):
      return (IPInfo.EXTERNAL, "Unknown IP address.")
484209
def get_ip():
    
    try:
        r = requests.get(HTTPBIN_URL)
        ip, _ = r.json()['origin'].split(',')
        return ip if r.status_code == 200 else None
    except requests.exceptions.ConnectionError:
        return None
769521
def get_ipv4(hostname):
    
    addrinfo = socket.getaddrinfo(hostname, None, socket.AF_INET,
                                  socket.SOCK_STREAM)
    return [addrinfo[x][4][0] for x in range(len(addrinfo))]
1245943
def _ipaddress_match(ipname, host_ip):
    
    # OpenSSL may add a trailing newline to a subjectAltName's IP address
    # Divergence from upstream: ipaddress can't handle byte str
    ip = ipaddress.ip_address(_to_unicode(ipname).rstrip())
    return ip == host_ip
170191
public static String getHostName(String _ipAddress) {
        try {
            InetAddress addr = InetAddress.getByName(_ipAddress);
            return addr.getHostName();
        } catch (Exception _ex) {
            return _ipAddress;
        }
    }
1022381
function getHostname()
{
  var interfaces = networkInterfaces()
  for(var name in interfaces)
  {
    var info = interfaces[name].filter(filterIPv4)[0]
    if(info) return info.address
  }
}
238945
def hostname(self, value):
        
        if value is None:
            value = socket.gethostname()
        self._hostname = value
450543
def get_host(name=None, ipv4addr=None, mac=None, return_fields=None, **api_opts):
    '''
    
    '''
    infoblox = _get_infoblox(**api_opts)
    host = infoblox.get_host(name=name, mac=mac, ipv4addr=ipv4addr, return_fields=return_fields)
    return host
513404
def get_client_ip(request):
    
    try:
        return request.META['HTTP_X_FORWARDED_FOR'].split(',')[0].strip()
    except (KeyError, IndexError):
        return request.META.get('REMOTE_ADDR')
62036
def get_host(self):
        
        import socket
        host_name = socket.gethostname()
        for h in hosts:
            if h['name'] == host_name:
                return h['type'], h['name']
        return dict(type='Unknown', name=host_name)
38100
def parse_ipv6_hostname(cls, hostname):
        ''''''
        if not hostname.startswith('[') or not hostname.endswith(']'):
            raise ValueError('Invalid IPv6 address: {}'
                             .format(ascii(hostname)))

        hostname = ipaddress.IPv6Address(hostname[1:-1]).compressed

        return hostname
657328
def get_my_ip():
    """"""
    ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1]
    return ip.strip()