Convert hostname to IP address.
502015
def _resolv_name(self, hostname):
        """"""
        ip = hostname
        try:
            ip = socket.gethostbyname(hostname)
        except Exception as e:
            logger.debug("{}: Cannot convert {} to IP address ({})".format(self.plugin_name, hostname, e))
        return ip
281110
def hostname_with_port(self):
        ''''''
        default_port = RELATIVE_SCHEME_DEFAULT_PORTS.get(self.scheme)
        if not default_port:
            return ''

        assert '[' not in self.hostname
        assert ']' not in self.hostname

        if self.is_ipv6():
            hostname = '[{}]'.format(self.hostname)
        else:
            hostname = self.hostname

        if default_port != self.port:
            return '{}:{}'.format(hostname, self.port)
        else:
            return hostname
243046
def url_to_host(url):
    

    regex_url = r"([a-z][a-z0-9+\-.]*://)?" + \
                r"([a-z0-9\-._~%!$&'()*+,;=]+@)?" + \
                r"([a-z0-9\-._~%]+" + \
                r"|\[[a-z0-9\-._~%!$&'()*+,;=:]+\])?" + \
                r"(:(?P<port>[0-9]+))?"

    m = re.match(regex_url, url, re.IGNORECASE)
    if m and m.group(3):
        return url[m.start(3): m.end(3)]
    else:
        raise ValueError("URL without a valid host or ip")
965036
def normalize_hostname(hostname):
    ''''''
    try:
        new_hostname = hostname.encode('idna').decode('ascii').lower()
    except UnicodeError as error:
        raise UnicodeError('Hostname {} rejected: {}'.format(hostname, error)) from error

    if hostname != new_hostname:
        # Check for round-trip. May raise UnicodeError
        new_hostname.encode('idna')

    return new_hostname
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);
  });
}
268199
def _ipaddress_match(ipname, host_ip):
    
    # OpenSSL may add a trailing newline to a subjectAltName's IP address
    ip = ipaddress.ip_address(six.text_type(ipname.rstrip()))
    return ip == host_ip
965100
def to_ip(self, values, from_unit):
        """"""
        if from_unit == 'Btu/h-ft2-F':
            return values, from_unit
        else:
            return self.to_unit(values, 'Btu/h-ft2-F', from_unit), 'Btu/h-ft2-F'
430949
def normalize_host(host):
    """"""
    if 'xn--' not in host:
        return host
    return '.'.join([_idna_decode(p) for p in host.split('.')])
1298628
def mac_address(ip):
    """"""
    mac = ''
    for line in os.popen('/sbin/ifconfig'):
        s = line.split()
        if len(s) > 3:
            if s[3] == 'HWaddr':
                mac = s[4]
            elif s[2] == ip:
                break
    return {'MAC': mac}
743879
def hostname_for_event(self, clean_server_name):
        """"""
        uri = urlsplit(clean_server_name)
        if '@' in uri.netloc:
            hostname = uri.netloc.split('@')[1].split(':')[0]
        else:
            hostname = uri.netloc.split(':')[0]
        if hostname == 'localhost':
            hostname = self.hostname
        return hostname
1175655
public HostName toHostName() {
		HostName host = fromHost;
		if(host == null) {
			fromHost = host = toCanonicalHostName();
		}
		return host;
	}
381683
def host_names(urls):
    '''
    
    '''
    host_names = StringCounter()
    for url in urls:
        host_names[urlparse(url).netloc] += urls[url]
    return host_names
161154
def get_by_ip(cls, ip):
        ''
        ret = cls.hosts_by_ip.get(ip)
        if ret is None:
            ret = cls.hosts_by_ip[ip] = [Host(ip)]
        return ret
135931
public static String getIpByHost(String hostName) {
		try {
			return InetAddress.getByName(hostName).getHostAddress();
		} catch (UnknownHostException e) {
			return hostName;
		}
	}
486141
public static String stripDomain(String hostname)
    {
        String ret = hostname;
        int pos = hostname.indexOf(".");
        if(pos != -1)
            ret = hostname.substring(0,pos);
        return ret;
    }
276244
def from_hostname(cls, hostname):
        """"""
        result = cls.list({'items_per_page': 500})
        paas_hosts = {}
        for host in result:
            paas_hosts[host['name']] = host['id']

        return paas_hosts.get(hostname)
1012960
def hostname=(new_hostname)
      if new_hostname &&
          (new_hostname.respond_to?(:ipv4?) || new_hostname.respond_to?(:ipv6?))
        new_hostname = new_hostname.to_s
      elsif new_hostname && !new_hostname.respond_to?(:to_str)
        raise TypeError, "Can't convert #{new_hostname.class} into String."
      end
      v = new_hostname ? new_hostname.to_str : nil
      v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
      self.host = v
    end