Get ips for given name

 First the local resolver is used. On POSIX-systems /etc/hosts is used. On
 Windows C:\Windows\System32\drivers\etc\hosts is used.

 @param [String] name
   The name which should be resolved.
518665
def ips_for(name)
      resolvers.each do |r|
        ips = r.getaddresses(name)

        return ips unless ips.nil? || ips.empty?
      end

      []
    end
516825
def ResolveHostnameToIP(host, port):
  """"""
  ip_addrs = socket.getaddrinfo(host, port, socket.AF_UNSPEC, 0,
                                socket.IPPROTO_TCP)
  # getaddrinfo returns tuples (family, socktype, proto, canonname, sockaddr).
  # We are interested in sockaddr which is in turn a tuple
  # (address, port) for IPv4 or (address, port, flow info, scope id)
  # for IPv6. In both cases, we want the first element, the address.
  result = ip_addrs[0][4][0]
  # TODO: In Python 2, this value is a byte string instead of UTF-8
  # string. To ensure type correctness until support for Python 2 is dropped,
  # we always decode this value.
  if compatibility.PY2:
    result = result.decode("ascii")
  return result
1310376
def get_by_name(self, name): # pylint: disable=invalid-name,redefined-builtin
        
        rs, _ = self.list(filter=field('name').eq(name), limit=1)
        if len(rs) is 0:
            raise CDRouterError('no such device')
        return rs[0]
632574
public OvhIpxe ipxeScript_name_GET(String name) throws IOException {
		String qPath = "/me/ipxeScript/{name}";
		StringBuilder sb = path(qPath, name);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhIpxe.class);
	}
1079330
def lookup_server(req)
      @virtual_hosts.find{|s|
        (s[:BindAddress].nil? || req.addr[3] == s[:BindAddress]) &&
        (s[:Port].nil?        || req.port == s[:Port])           &&
        ((s[:ServerName].nil?  || req.host == s[:ServerName]) ||
         (!s[:ServerAlias].nil? && s[:ServerAlias].find{|h| h === req.host}))
      }
    end
155366
function performGssapiCanonicalizeHostName(canonicalizeHostName, host, callback) {
      if (!canonicalizeHostName) return callback();

      // Attempt to resolve the host name
      dns.resolveCname(host, (err, r) => {
        if (err) return callback(err);

        // Get the first resolve host id
        if (Array.isArray(r) && r.length > 0) {
          self.host = r[0];
        }

        callback();
      });
    }
539549
def update_name(options)
      if options.key?(:name) && options[:name].is_a?(String) && options[:name].length > 0
        return
      end
      hostname = if options.key?(:hostname) then
                   options[:hostname]
                 else
                   @args.default_values[:hostname]
                 end
      hostname = hostname[0] if hostname.is_a?(Array)
      options[:name] = hostname.gsub(/[^A-Za-z0-9_-]/, '-')
    end
858063
def dns_lookup(host, port, afi=socket.AF_UNSPEC):
    """"""
    # XXX: all DNS functions in Python are blocking. If we really
    # want to be non-blocking here, we need to use a 3rd-party
    # library like python-adns, or move resolution onto its
    # own thread. This will be subject to the default libc
    # name resolution timeout (5s on most Linux boxes)
    try:
        return list(filter(is_inet_4_or_6,
                           socket.getaddrinfo(host, port, afi,
                                              socket.SOCK_STREAM)))
    except socket.gaierror as ex:
        log.warning('DNS lookup failed for %s:%d,'
                    ' exception was %s. Is your'
                    ' advertised.listeners (called'
                    ' advertised.host.name before Kafka 9)'
                    ' correct and resolvable?',
                    host, port, ex)
        return []
893952
private void resolve(String hostname, List<InetAddress> inetAddresses) throws NamingException, UnknownHostException {

        if (preferIpv6 || (!preferIpv4 && !preferIpv6)) {

            inetAddresses.addAll(resolve(hostname, "AAAA"));
            inetAddresses.addAll(resolve(hostname, "A"));
        } else {

            inetAddresses.addAll(resolve(hostname, "A"));
            inetAddresses.addAll(resolve(hostname, "AAAA"));
        }

        if (inetAddresses.isEmpty()) {
            inetAddresses.addAll(resolveCname(hostname));
        }
    }
1189012
def get_existing_domain(conn, name)
      return conn.lookup_domain_by_name(name)
    rescue Libvirt::Error => e
      return nil if e.libvirt_code == 42 # If domain not defined
      raise # Otherwise reraise
    end
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);
  });
}
363760
@SneakyThrows
    public static String getCasServerHostAddress(final String name) {
        val host = getByName(name);
        if (host != null) {
            return host.getHostAddress();
        }
        return null;
    }
97757
def _get_interface_ip(self, interface_name):
        
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        children = parse.find_children("^interface %s" % interface_name)
        for line in children:
            if 'ip address' in line:
                ip_address = line.strip().split(' ')[2]
                LOG.debug("IP Address:%s", ip_address)
                return ip_address
        LOG.warning("Cannot find interface: %s", interface_name)
        return None
257902
public static InetAddress[]
    getAllByName(String name) throws UnknownHostException {
        try {
            InetAddress addr = getByAddress(name);
            return new InetAddress[]{addr};
        } catch (UnknownHostException e) {
            Record[] records = lookupHostName(name);
            InetAddress[] addrs = new InetAddress[records.length];
            for (int i = 0; i < records.length; i++)
                addrs[i] = addrFromRecord(name, records[i]);
            return addrs;
        }
    }
891178
def allowed?(name, ip)
      if name or ip
        # This is probably unnecessary, and can cause some weirdness in
        # cases where we're operating over localhost but don't have a real
        # IP defined.
        raise Puppet::DevError, _("Name and IP must be passed to 'allowed?'") unless name and ip
        # else, we're networked and such
      else
        # we're local
        return true
      end

      # yay insecure overrides
      return true if globalallow?

      if decl = declarations.find { |d| d.match?(name, ip) }
        return decl.result
      end

      info _("defaulting to no access for %{name}") % { name: name }
      false
    end
12362
def determine_hosts_path(platform=None):
        
        if not platform:
            platform = sys.platform
        if platform.startswith('win'):
            result = r"c:\windows\system32\drivers\etc\hosts"
            return result
        else:
            return '/etc/hosts'
313560
def get_host_set(name)
      begin
        @host_set.get_host_set(name)
      rescue => ex
        Util.log_exception(ex, caller_locations(1, 1)[0].label)
        raise ex
      end
    end