Returns a best guess for the hostname registered with OpenStack for this host
501508
def get_my_hostname(self, split_hostname_on_first_period=False):
        

        hostname = self.init_config.get("os_host") or self.hostname
        if split_hostname_on_first_period:
            hostname = hostname.split('.')[0]

        return hostname
3678
def _retrieve_stack_host_zone_name(awsclient, default_stack_name=None):
    
    global _host_zone_name

    if _host_zone_name is not None:
        return _host_zone_name

    env = get_env()

    if env is None:
        print("Please set environment...")
        # TODO: why is there a sys.exit in library code used by cloudformation!!!
        sys.exit()

    if default_stack_name is None:
        # TODO why 'dp-<env>'? - this should not be hardcoded!
        default_stack_name = 'dp-%s' % env
    default_stack_output = get_outputs_for_stack(awsclient, default_stack_name)

    if HOST_ZONE_NAME__STACK_OUTPUT_NAME not in default_stack_output:
        print("Please debug why default stack '{}' does not contain '{}'...".format(
                default_stack_name,
                HOST_ZONE_NAME__STACK_OUTPUT_NAME,
        ))
        # TODO: why is there a sys.exit in library code used by cloudformation!!!
        sys.exit()

    _host_zone_name = default_stack_output[HOST_ZONE_NAME__STACK_OUTPUT_NAME] + "."
    return _host_zone_name
24540
def get_name(self):
        
        dependent_host_name = 'unknown'
        if getattr(self, 'dependent_host_name', None):
            dependent_host_name = getattr(
                getattr(self, 'dependent_host_name'), 'host_name', 'unknown'
            )
        host_name = 'unknown'
        if getattr(self, 'host_name', None):
            host_name = getattr(getattr(self, 'host_name'), 'host_name', 'unknown')
        return dependent_host_name + '/' + host_name
816029
def _lookup_host(name, rdtype, timeout=None, server=None):
    '''
    
    '''
    cmd = 'host -t {0} '.format(rdtype)

    if timeout:
        cmd += '-W {0} '.format(int(timeout))
    cmd += name
    if server is not None:
        cmd += ' {0}'.format(server)

    cmd = __salt__['cmd.run_all'](cmd, python_shell=False, output_loglevel='quiet')

    if 'invalid type' in cmd['stderr']:
        raise ValueError('Invalid DNS type {}'.format(rdtype))
    elif cmd['retcode'] != 0:
        log.warning('host returned (%s): %s', cmd['retcode'], cmd['stderr'])
        return False
    elif 'has no' in cmd['stdout']:
        return []

    res = []
    _stdout = cmd['stdout'] if server is None else cmd['stdout'].split('\n\n')[-1]
    for line in _stdout.splitlines():
        if rdtype != 'CNAME' and 'is an alias' in line:
            continue
        line = line.split(' ', 3)[-1]
        for prefix in ('record', 'address', 'handled by', 'alias for'):
            if line.startswith(prefix):
                line = line[len(prefix) + 1:]
                break
        res.append(_data_clean(line))

    return res
1208045
def hostname(self):
        """"""
        from six.moves.urllib.parse import urlparse
        return urlparse(self._base_url).netloc.split(':', 1)[0]
162722
function getHostType(host) {
  if (net.isIPv4(host)) {
    return ATYP_V4;
  }
  if (net.isIPv6(host)) {
    return ATYP_V6;
  }
  return ATYP_DOMAIN;
}
357523
def _parse_hostname(self):
        
        value = 'localhost'
        match = re.search(r'^hostname ([^\s]+)$', self.config, re.M)
        if match:
            value = match.group(1)
        return dict(hostname=value)
1360290
def get_config(self, hostname):
        
        version, config = self._get(
            self.associations.get(hostname)
        )
        return config
252579
def get_host_name():
    

    if sys.platform == 'win32':
        host = os.getenv('COMPUTERNAME')
    else:
        host = os.uname()[1]


    return host
295700
def GET_name_info( self, path_info, name ):
        
        if not check_name(name) and not check_subdomain(name):
            return self._reply_json({'error': 'Invalid name or subdomain'}, status_code=400)

        blockstackd_url = get_blockstackd_url()

        name_rec = None
        try:
            name_rec = blockstackd_client.get_name_record(name, include_history=False, hostport=blockstackd_url)
        except ValueError:
            return self._reply_json({'error': 'Invalid argument: not a well-formed name or subdomain'}, status_code=400)

        if 'error' in name_rec:
            if 'not found' in name_rec['error'].lower():
                return self._reply_json({'status': 'available'}, status_code=404)

            elif 'failed to load subdomain' in name_rec['error'].lower():

                # try to redirect to resolver, if given
                _, _, domain_name = blockstackd_scripts.is_address_subdomain(name)
                domain_rec = blockstackd_client.get_name_record(domain_name, include_history=False, hostport=blockstackd_url)

                if 'error' in domain_rec:
                    # no resolver known for on-chain name
                    return self._reply_json({'status': 'available', 'more': 'failed to look up parent domain'}, status_code=404)

                resolver_target = domain_rec.get('resolver', None)
                if resolver_target is None:
                    # no _resolver
                    return self._reply_json({'status': 'available',  'more': 'failed to find parent domain\'s resolver'}, status_code=404)

                redirect_location = resolver_target + '/v1/names/' + name
                log.debug("Redirect lookup on {} to {}".format(name, redirect_location))

                self._send_headers(status_code=301, more_headers={ 'Location': redirect_location })
                return self.wfile.write(json.dumps({'status': 'redirect'}))

            elif 'expired' in name_rec['error'].lower():
                return self._reply_json({'error': name_rec['error']}, status_code=404)

            else:
                return self._reply_json({'error': 'Blockstack daemon error: {}'.format(name_rec['error'])}, status_code=name_rec.get('http_status', 502))


        zonefile_txt = None

        if 'zonefile' in name_rec:
            zonefile_txt = base64.b64decode(name_rec['zonefile'])

        ret = {}

        if blockstackd_scripts.is_subdomain(name):
            # subdomain
            address = name_rec['address']
            if address:
                address = virtualchain.address_reencode(str(address))

            log.debug("{} is registered_subdomain".format(name))
            ret = {
                'status': 'registered_subdomain',
                'zonefile': zonefile_txt,
                'zonefile_hash': name_rec['value_hash'],
                'address': name_rec['address'],
                'blockchain': 'bitcoin',
                'last_txid': name_rec['txid'],
                'did': name_rec.get('did', {'error': 'Not supported for this name'})
            }

        else:
            status = 'revoked' if name_rec['revoked'] else 'registered'
            address = name_rec['address']
            if address:
                address = virtualchain.address_reencode(str(address))

            log.debug("{} is {}".format(name, status))
            ret = {
                'status': status,
                'zonefile': zonefile_txt,
                'zonefile_hash': name_rec['value_hash'],
                'address': address,
                'last_txid': name_rec['txid'],
                'blockchain': 'bitcoin',
                'expire_block': name_rec['expire_block'],      # expire_block is what blockstack.js expects
                'renewal_deadline': name_rec['renewal_deadline'],
                'grace_period': name_rec.get('grace_period', False),
                'resolver': name_rec.get('resolver', None),
                'did': name_rec.get('did', {'error': 'Not supported for this name'})
            }

        return self._reply_json(ret)
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)
450290
def get_canonical_host(self):
        
        host = self.host.lower()
        if self.port is not None:
            host = "%s:%s" % (host, self.port)
        return host
1030177
private String chooseHost(String[] dbHosts) {
        String host = null;
        synchronized (m_lastHostLock) {
            if (dbHosts.length == 1) {
                host = dbHosts[0];
            } else if (!Utils.isEmpty(m_lastHost)) {
                for (int index = 0; host == null && index < dbHosts.length; index++) {
                    if (dbHosts[index].equals(m_lastHost)) {
                        host = dbHosts[(++index) % dbHosts.length];
                    }
                }
            }
            if (host == null) {
                host = dbHosts[new Random().nextInt(dbHosts.length)];
            }
            m_lastHost = host;
        }
        return host;
    }
17464
function ___GET_ENV_HOSTNAME() {
	try {
		if ( HAS_NODE_BUFFER ) {
			return require( 'os' ).hostname;
		}
		else
		if ( typeof window !== "undefined" ) {
			return window.location.hostname;
		}
		else {
			throw new Error("");
		}
	}
	catch(e) {
		return 'unknown.' + DumpHexStringLE(RandomBytes(32));
	}
}
602264
private void findHostname() {
    String startupInfo = Environment.runCommand(
        "grep --max-count=1 STARTUP_MSG:\\s*host " + file.getName()).toString();
    Pattern pattern = Pattern.compile("\\s+(\\w+/.+)\\s+");
    Matcher matcher = pattern.matcher(startupInfo);
    if (matcher.find(0)) {
      hostname = matcher.group(1).split("/")[0];
      ips = new String[1];
      ips[0] = matcher.group(1).split("/")[1];
    }
  }
356584
def _determine_host(data, omit=''):
    '''
    
    '''
    # This is just checking for the host with the most free ram, this needs
    # to be much more complicated.
    host = ''
    bestmem = 0
    for hv_, comps in six.iteritems(data):
        if hv_ == omit:
            continue
        if not isinstance(comps, dict):
            continue
        if comps.get('freemem', 0) > bestmem:
            bestmem = comps['freemem']
            host = hv_
    return 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)