Get a single host by name.
343055
def get_host(self, name, default=NoHostError):
        '''
        
        '''

        if name in self.hosts:
            return self.hosts[name]

        if default is NoHostError:
            raise NoHostError('No such host: {0}'.format(name))

        return default
486819
def for_host(parent, host):
        
        account = AccountProxy(parent)
        account.host = host
        if account.acquire():
            return account
        return None
894127
def from_vhost(cls, vhost):
        """"""
        result = Vhost().list()
        paas_hosts = {}
        for host in result:
            paas_hosts[host['name']] = host['paas_id']

        return paas_hosts.get(vhost)
579384
def from_name(cls, name):
        """"""
        sshkeys = cls.list({'name': name})
        if len(sshkeys) == 1:
            return sshkeys[0]['id']
        elif not sshkeys:
            return

        raise DuplicateResults('sshkey name %s is ambiguous.' % name)
650627
def get_host_system_failfast(
            self,
            name,
            verbose=False,
            host_system_term='HS'
    ):
        
        if verbose:
            print("Finding HostSystem named %s..." % name)

        hs = self.get_host_system(name)

        if hs is None:
            print("Error: %s '%s' does not exist" % (host_system_term, name))
            sys.exit(1)

        if verbose:
            print("Found HostSystem: {0} Name: {1}" % (hs, hs.name))

        return hs
983304
def get_name(self, host_name):
        
        if wildcard_match(self._pattern, host_name):
            return host_name
        else:
            return self._fallback
658216
def hostname(name):
    '''
    
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': True,
        'comment': ''
    }

    current_hostname = __salt__['system.get_hostname']()

    if current_hostname.upper() == name.upper():
        ret['comment'] = "Hostname is already set to '{0}'".format(name)
        return ret

    out = __salt__['system.set_hostname'](name)

    if out:
        ret['comment'] = "The current hostname is '{0}', " \
                         "but will be changed to '{1}' on the next reboot".format(current_hostname, name)
        ret['changes'] = {'hostname': name}
    else:
        ret['result'] = False
        ret['comment'] = 'Unable to set hostname'

    return ret
1114472
def hostloc(self):
        """"""
        hostloc = self.hostname
        if self.port:
            hostloc = '{hostloc}:{port}'.format(hostloc=hostloc, port=self.port)

        return hostloc
994220
def get_connection_by_name(self, name):
        ''''''
        with self._mutex:
            for conn in self.connections:
                if conn.name == name:
                    return conn
            return None
136152
def get_hostname(url):
        

        if url not in URLHelper.__cache:
            URLHelper.__cache[url] = urlparse(url)

        parts = URLHelper.__cache[url].netloc.split(".")

        if len(parts) == 1:
            return parts[0]
        else:
            return ".".join(parts[-2:-1])
786096
def get_by_name(self, name, alias=None):
        """"""
        search_filter = "[?name=='{}']".format(name)

        if alias:
            if self.version == 1:
                search_filter = "accounts[?name=='{name}' || contains(alias, '{name}')]".format(name=name)

            elif self.version == 2:
                search_filter = "[?name=='{name}' || contains(aliases, '{name}')]".format(name=name)

        return self.get_all(search_filter)
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);
  });
}
212550
def server_by_name(name, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.server_by_name(name)
372153
public static String getServiceName(String hostname) throws IOException {
    int i = hostname.lastIndexOf(".");
    if (i <= 0) {
      throw badHostName(hostname);
    }
    String service = hostname.substring(i + 1);
    if (service.isEmpty() || service.contains(".")) {
      throw badHostName(hostname);
    }
    return service;
  }
581474
def split_hostname_from_port(cls, hostname):
        """"""
        bits = hostname.split(":", 2)
        p = None
        d = bits[0]
        if len(bits) == 2:
            p = int(bits[1])

        return d, p
960835
def get_host_ip(hostname, fallback=None):
    
    if is_ip(hostname):
        return hostname

    ip_addr = ns_query(hostname)
    if not ip_addr:
        try:
            ip_addr = socket.gethostbyname(hostname)
        except Exception:
            log("Failed to resolve hostname '%s'" % (hostname),
                level=WARNING)
            return fallback
    return ip_addr
1145147
def get_vhost(self, name):
        
        return self._api_get('/api/vhosts/{0}'.format(
            urllib.parse.quote_plus(name)
        ))