Get variables about a specific host
965654
def get_host(self, host):
        '''  '''

        if len(self.index) == 0:
            # Need to load index from cache
            self.load_index_from_cache()

        if not host in self.index:
            # try updating the cache
            self.do_api_calls_update_cache()
            if not host in self.index:
                # host might not exist anymore
                return {}

        (region, instance_id) = self.index[host]

        instance = self.get_instance(region, instance_id)
        return self.get_host_info_dict_from_instance(instance)
554320
def get_config_variable(self, config_id, offset):
        """"""

        config = self._config_variables.get(config_id)
        if config is None:
            return [b""]

        return [bytes(config.current_value[offset:offset + 20])]
946638
def get_by_ip_hostname(self, ip_hostname):
        
        resources = self._client.get_all()

        resources_filtered = [x for x in resources if x['credentials']['ip_hostname'] == ip_hostname]

        if resources_filtered:
            return resources_filtered[0]
        else:
            return None
1172309
def hostname_text(self):
        """"""
        if self._hostname_text is None:
            self.chain.connection.log("Collecting hostname information")
            self._hostname_text = self.driver.get_hostname_text()
            if self._hostname_text:
                self.chain.connection.log("Hostname info collected")
            else:
                self.chain.connection.log("Hostname info not collected")
        return self._hostname_text
220789
def cmd_extract_hostname(infile, check, verbose, jsonout):
    

    if verbose:
        logging.basicConfig(level=logging.INFO, format='%(message)s')

    data = infile.read()

    result = extract_hostname(data)

    if check:
        logging.info('Checking against DNS...')
        for candidate in result:
            try:
                socket.getaddrinfo(candidate, None)
            except socket.gaierror:
                result.remove(candidate)

    if jsonout:
        print(json.dumps(result, indent=4))
    else:
        print('\n'.join(result))
1062518
def get_host_lock(url):
    """"""
    hostname = get_hostname(url)
    return host_locks.setdefault(hostname, threading.Lock())
1080707
def fetch_host_ip(host: str) -> str:
    
    try:
        ip = socket.gethostbyname(host)
    except socket.gaierror:
        return ''

    return ip
410998
def __get_known_node_by_host(self, hostname):
        '''
        
        '''
        for n in self.nodes:
            if (n.name == hostname):
                return n
        return None
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);
  });
}
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)
362232
def get(self):
        """"""
        environment_variables_output = [html_for_env_var(key)
                                        for key in sorted(os.environ)]

        cgi_arguments_output = []
        if os.getenv('CONTENT_TYPE') == 'application/x-www-form-urlencoded':
            # Note: a blank Content-type header will still sometimes
            # (in dev_appserver) show up as 'application/x-www-form-urlencoded'
            form = cgi.FieldStorage()
            if not form:
                cgi_arguments_output.append('No CGI arguments given...')
            else:
                for cgi_argument in form:
                    cgi_arguments_output.append(
                            html_for_cgi_argument(cgi_argument, form))
        else:
            data = ''
            cgi_arguments_output.append(STDIN_TEMPLATE.format(len(data)))
            cgi_arguments_output.append(cgi.escape(data))

        modules_api_output = [
            html_for_modules_method('get_current_module_name'),
            html_for_modules_method('get_current_version_name'),
            html_for_modules_method('get_current_instance_id'),
            html_for_modules_method('get_modules'),
            html_for_modules_method('get_versions'),
            html_for_modules_method('get_default_version'),
            html_for_modules_method('get_hostname'),
        ]

        result = PAGE_TEMPLATE.format(
            users.CreateLoginURL(self.request.url),
            users.CreateLogoutURL(self.request.url),
            '<br>\n'.join(environment_variables_output),
            '<br>\n'.join(cgi_arguments_output),
            '<br>\n'.join(modules_api_output),
        )

        self.response.write(result)
414423
def from_hostname(cls, hostname):
        """"""
        result = cls.list({'hostname': str(hostname)})
        if result:
            return result[0]['id']
398724
def get_execution_host_info():
    
    host = os.environ.get('HOSTNAME', None)
    cluster = os.environ.get('SGE_O_HOST', None)
    if host is None:
        try:
            import socket
            host = host or socket.gethostname()
        except:
            pass
    return host or 'unknown', cluster or 'unknown'
525629
def get_unit_hostnames(self, units):
        """"""
        host_names = {}
        for unit in units:
            host_names[unit.info['unit_name']] = \
                str(unit.file_contents('/etc/hostname').strip())
        self.log.debug('Unit host names: {}'.format(host_names))
        return host_names
1367556
async def query(
            cls, *,
            hostnames: typing.Iterable[str] = None,
            domains: typing.Iterable[str] = None,
            zones: typing.Iterable[str] = None,
            macs: typing.Iterable[str] = None,
            system_ids: typing.Iterable[str] = None,
            agent_name: str = None,
            level: typing.Union[Level, int, str] = None,
            before: int = None,
            after: int = None,
            limit: int = None,
            owner: typing.Union[User, str] = None):
        """"""

        if before is not None and after is not None:
            raise ValueError("Specify either `before` or `after`, not both.")

        params = {}

        if hostnames is not None:
            params["hostname"] = list(hostnames)
        if domains is not None:
            params["domain"] = list(domains)
        if zones is not None:
            params["zone"] = list(zones)
        if macs is not None:
            params["mac_address"] = list(macs)
        if system_ids is not None:
            params["id"] = list(system_ids)
        if agent_name is not None:
            params["agent_name"] = [agent_name]
        if level is not None:
            level = Level.normalise(level)
            params["level"] = [level.name]
        if before is not None:
            params["before"] = ["{:d}".format(before)]
        if after is not None:
            params["after"] = ["{:d}".format(after)]
        if limit is not None:
            params["limit"] = ["{:d}".format(limit)]
        if owner is not None:
            if isinstance(owner, User):
                params["owner"] = [owner.username]
            elif isinstance(owner, str):
                params["owner"] = [owner]
            else:
                raise TypeError(
                    "owner must be either User or str, not %s" % (
                        type(owner).__name__))

        data = await cls._handler.query(**params)
        return cls(data)
765758
def get_by_hostname(self, hostname):
        
        resources = self._client.get_all()

        resources_filtered = [x for x in resources if x['hostname'] == hostname]

        if resources_filtered:
            return resources_filtered[0]
        else:
            return None
1288907
def sessions_info(self, hosts):
        
        info_by_id = {}

        for server_endpoint, dump in self.dump_by_server(hosts).items():
            server_ip, server_port = server_endpoint
            for line in dump.split("\n"):
                mat = self.IP_PORT_REGEX.match(line)
                if mat is None:
                    continue
                ip, port, sid = mat.groups()
                info_by_id[sid] = ClientInfo(sid, ip, port, server_ip, server_port)

        return info_by_id