If hostname is None, look at label_to_hostname setting
335145
def _get_hostname(self, hostname, sample, scraper_config):
        
        if (
            hostname is None
            and scraper_config['label_to_hostname'] is not None
            and scraper_config['label_to_hostname'] in sample[self.SAMPLE_LABELS]
        ):
            hostname = sample[self.SAMPLE_LABELS][scraper_config['label_to_hostname']]
            suffix = scraper_config['label_to_hostname_suffix']
            if suffix is not None:
                hostname += suffix

        return hostname
871725
def _commit_hostname_handler(self, cmd):
        """"""
        current_prompt = self.device.find_prompt().strip()
        terminating_char = current_prompt[-1]
        pattern = r"[>#{}]\s*$".format(terminating_char)
        # Look exclusively for trailing pattern that includes '#' and '>'
        output = self.device.send_command_expect(cmd, expect_string=pattern)
        # Reset base prompt in case hostname changed
        self.device.set_base_prompt()
        return output
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
501046
def ask_not_existing_hostname(project_root, environment)
      hostname = ask_hostname(project_root, environment)
      # Check if the node not exist
      if node_exists?(project_root, environment, hostname)
        error _('wizard.node.hostname_exist')
        ask_hostname(project_root, environment)
      else
        return hostname
      end
    end
681698
def node_label_absent(name, node, **kwargs):
    '''
    
    '''

    ret = {'name': name,
           'changes': {},
           'result': False,
           'comment': ''}

    labels = __salt__['kubernetes.node_labels'](node, **kwargs)

    if name not in labels:
        ret['result'] = True if not __opts__['test'] else None
        ret['comment'] = 'The label does not exist'
        return ret

    if __opts__['test']:
        ret['comment'] = 'The label is going to be deleted'
        ret['result'] = None
        return ret

    __salt__['kubernetes.node_remove_label'](
        node_name=node,
        label_name=name,
        **kwargs)

    ret['result'] = True
    ret['changes'] = {
        'kubernetes.node_label': {
            'new': 'absent', 'old': 'present'}}
    ret['comment'] = 'Label removed from node'

    return ret
945078
public static void setTlsExtHostName(long ssl, String hostname) {
        if (hostname != null && hostname.endsWith(".")) {
            // Strip trailing dot if included.
            // See https://github.com/netty/netty-tcnative/issues/400
            hostname = hostname.substring(0, hostname.length() - 1);
        }
        setTlsExtHostName0(ssl, hostname);
    }
556217
def get_by_hostname(self, hostname):
        """"""
        def filter_by_hostname(hostname, enclosure):
            is_primary_ip = ('activeOaPreferredIP' in enclosure and enclosure['activeOaPreferredIP'] == hostname)
            is_standby_ip = ('standbyOaPreferredIP' in enclosure and enclosure['standbyOaPreferredIP'] == hostname)
            return is_primary_ip or is_standby_ip

        enclosures = self.get_all()
        result = [x for x in enclosures if filter_by_hostname(hostname, x)]

        if result:
            new_resource = self.new(self._connection, result[0])
        else:
            new_resource = None

        return new_resource
859982
def is_ipaddress(hostname):
    
    if six.PY3 and isinstance(hostname, bytes):
        # IDN A-label bytes are ASCII compatible.
        hostname = hostname.decode('ascii')

    families = [socket.AF_INET]
    if hasattr(socket, 'AF_INET6'):
        families.append(socket.AF_INET6)

    for af in families:
        try:
            inet_pton(af, hostname)
        except (socket.error, ValueError, OSError):
            pass
        else:
            return True
    return False
1114644
function getFqdnForHostname(hostname, cb) {
  let addressIndex = 0;

  dns.lookup(hostname, { all: true }, function (err, addresses, family) {
    const tryNextAddressOrComplete = (err, fqdn) => {
      addressIndex++;
      if (!err) {
        cb(err, fqdn);
      } else if (addressIndex != addresses.length) {
        getFqdnForIpAddress(addresses[addressIndex].address, tryNextAddressOrComplete);
      } else {
        cb(err);
      }
    };

    if (!err) {
      getFqdnForIpAddress(addresses[addressIndex].address, tryNextAddressOrComplete);
    } else {
      cb(err);
    }
  });
}
414423
def from_hostname(cls, hostname):
        """"""
        result = cls.list({'hostname': str(hostname)})
        if result:
            return result[0]['id']
155422
def host_name=(newname)
      return if newname == host_name
      raise JSS::InvalidDataError, 'names must be String' unless name.is_a? String
      @host_name = name
      @need_to_update = true
    end
436516
def filter_service_by_host_bp_rule_label(label):
    

    def inner_filter(items):
        """Inner filter for service. Accept if label in service.host.labels"""
        service = items["service"]
        host = items["hosts"][service.host]
        if service is None or host is None:
            return False
        return label in host.labels

    return inner_filter
253704
def GetStoredHostname(self):
    
    store_number = len(self._hostnames)
    return self._hostnames.get(store_number, None)
802665
def filter_host_by_name(name):
    

    def inner_filter(items):
        """Inner filter for host. Accept if host_name == name"""
        host = items["host"]
        if host is None:
            return False
        return host.host_name == name

    return inner_filter
74725
def valid_hostname(host):
    
    if len(host) > 255:
        return False

    if host[-1:] == '.':
        host = host[:-1]

    return all(_hostname_re.match(c) for c in host.split('.'))
202597
def determine_hostname(display_name=None):
    
    if display_name:
        # if display_name is provided, just return the given name
        return display_name
    else:
        socket_gethostname = socket.gethostname()
        socket_fqdn = socket.getfqdn()

        try:
            socket_ex = socket.gethostbyname_ex(socket_gethostname)[0]
        except (LookupError, socket.gaierror):
            socket_ex = ''

        gethostname_len = len(socket_gethostname)
        fqdn_len = len(socket_fqdn)
        ex_len = len(socket_ex)

        if fqdn_len > gethostname_len or ex_len > gethostname_len:
            if "localhost" not in socket_ex and len(socket_ex):
                return socket_ex
            if "localhost" not in socket_fqdn:
                return socket_fqdn

        return socket_gethostname
1151048
def nic_name_to_host(nic_name):
	
	from netifaces import ifaddresses, AF_INET
	host = ifaddresses(nic_name).setdefault(AF_INET, [{'addr': 'No IP addr'}] )[0]['addr']
	return(host)