Return only first element of the hostname from all possible list.

    :return:
320871
def generate_minion_id():
    '''
    
    '''
    try:
        ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first())
    except TypeError:
        ret = None
    return ret or 'localhost'
723375
def get_host_info():
    
    host_info = {}
    for k, v in host_info_gatherers.items():
        try:
            host_info[k] = v()
        except IgnoreHostInfo:
            pass
    return host_info
594710
async def read(cls, *, hostnames: typing.Sequence[str] = None):
        
        params = {}
        if hostnames:
            params["hostname"] = [
                normalize_hostname(hostname)
                for hostname in hostnames
            ]
        data = await cls._handler.read(**params)
        return cls(map(cls._object, data))
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
715547
def get_host_port_names(self, host_name):
        
        port_names = list()
        host = self.get_hosts_by_name(host_name)
        fc_ports = host.fc_ports
        iscsi_ports = host.iscsi_ports
        port_names.extend(fc_ports.split(',') if fc_ports != '' else [])
        port_names.extend(iscsi_ports.split(',') if iscsi_ports != '' else [])
        return port_names
791480
def _get_ids_from_hostname(self, hostname):
        """"""
        results = self.list_instances(hostname=hostname, mask="id")
        return [result['id'] for result in results]
497202
def get_hosts_info(self):
        
        result = []
        index = 0
        while index < self.host_numbers:
            host = self.get_generic_host_entry(index)
            result.append({
                'ip': host['NewIPAddress'],
                'name': host['NewHostName'],
                'mac': host['NewMACAddress'],
                'status': host['NewActive']})
            index += 1
        return result
1179133
def parseSLURM(string):
    """"""
    # Use scontrol utility to get the hosts list
    import subprocess, os
    hostsstr = subprocess.check_output(["scontrol", "show", "hostnames", string])
    if sys.version_info.major > 2:
        hostsstr = hostsstr.decode()
    # Split using endline
    hosts = hostsstr.split(os.linesep)
    # Take out last empty host
    hosts = filter(None, hosts)
    # Create the desired pair of host and number of hosts
    hosts = [(host, 1) for host in hosts]
    return hosts
253704
def GetStoredHostname(self):
    
    store_number = len(self._hostnames)
    return self._hostnames.get(store_number, None)
1359614
def _get_ids_from_hostname(self, hostname):
        """"""
        results = self.list_hardware(hostname=hostname, mask="id")
        return [result['id'] for result in results]
743825
def _sub_hostname(self, line):
        '''
        
        '''
        try:
            for od,d in self.dn_db.items():
                #regex = re.compile(r'\w*\.%s' % d)
                regex = re.compile(r'(?![\W\-\:\ \.])[a-zA-Z0-9\-\_\.]*\.%s' % d)
                hostnames = [each for each in regex.findall(line)]
                if len(hostnames) > 0:
                    for hn in hostnames:
                        new_hn = self._hn2db(hn)
                        self.logger.debug("Obfuscating FQDN - %s > %s", hn, new_hn)
                        line = line.replace(hn, new_hn)
            if self.hostname:
                line = line.replace(self.hostname, self._hn2db(self.hostname))  #catch any non-fqdn instances of the system hostname

            return line
        except Exception as e: # pragma: no cover
            self.logger.exception(e)
            raise Exception('SubHostnameError: Unable to Substitute Hostname/Domainname')
915534
def filter_host_by_regex(regex):
    
    host_re = re.compile(regex)

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

    return inner_filter
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
783423
def _get_host(name, array):
    ''''''
    host = None
    for temp in array.list_hosts():
        if temp['name'] == name:
            host = temp
            break
    return host
1114472
def hostloc(self):
        """"""
        hostloc = self.hostname
        if self.port:
            hostloc = '{hostloc}:{port}'.format(hostloc=hostloc, port=self.port)

        return hostloc
1313307
def get_name(default: str = 'no name set'):
    
    try:
        with open('/etc/machine-info') as emi:
            contents = emi.read()
    except OSError:
        LOG.exception(
            "Couldn't read /etc/machine-info")
        contents = ''
    for line in contents.split('\n'):
        if line.startswith('PRETTY_HOSTNAME='):
            return '='.join(line.split('=')[1:])
    LOG.warning(f"No PRETTY_HOSTNAME in {contents}, defaulting to {default}")
    try:
        _update_pretty_hostname(default)
    except OSError:
        LOG.exception("Could not write new pretty hostname!")
    return default
489951
def getHosts(filename=None, hostlist=None):
    """"""
    if filename:
        return getHostsFromFile(filename)
    elif hostlist:
        return getHostsFromList(hostlist)
    elif getEnv() == "SLURM":
        return getHostsFromSLURM()
    elif getEnv() == "PBS":
        return getHostsFromPBS()
    elif getEnv() == "SGE":
        return getHostsFromSGE()
    else:
        return getDefaultHosts()