Retrieve a storage system by its hostname.

        Works only in API500 onwards.

        Args:
            hostname: Storage system hostname.

        Returns:
            dict
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
1160858
def _storage_get_key_names(bucket, pattern):
  
  return [item.metadata.name for item in _storage_get_keys(bucket, pattern)]
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
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()
888050
public static String getContainerName(String hostname,
      boolean serviceRequired) throws IOException {
    int i = hostname.lastIndexOf(".");
    if (i <= 0) {
      if (serviceRequired) {
        throw badHostName(hostname);
      }
      return hostname;
    }
    return hostname.substring(0, i);
  }
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)
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
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)
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
192311
def host(self, hostname=None):
        
        if (hostname is None) or (hostname == self.__hostname):
            return self.__hostname
        # when hostname change ensure old socket is close
        self.close()
        # IPv4 ?
        try:
            socket.inet_pton(socket.AF_INET, hostname)
            self.__hostname = hostname
            return self.__hostname
        except socket.error:
            pass
        # IPv6 ?
        try:
            socket.inet_pton(socket.AF_INET6, hostname)
            self.__hostname = hostname
            return self.__hostname
        except socket.error:
            pass
        # DNS name ?
        if re.match('^[a-z][a-z0-9\.\-]+$', hostname):
            self.__hostname = hostname
            return self.__hostname
        else:
            return None
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
1169583
def storage_get(attribute=None, storage_id=None):
    """"""
    _args = ['storage-get', '--format=json']
    if storage_id:
        _args.extend(('-s', storage_id))
    if attribute:
        _args.append(attribute)
    try:
        return json.loads(subprocess.check_output(_args).decode('UTF-8'))
    except ValueError:
        return None
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
755554
def hostname(self):
        """"""
        try:
            return self.data.get('identity').get('host_name')
        except (KeyError, AttributeError):
            return self.device_status_simple('')
1107107
def get_host_datastore_system(host_ref, hostname=None):
    '''
    
    '''

    if not hostname:
        hostname = get_managed_object_name(host_ref)
    service_instance = get_service_instance_from_managed_object(host_ref)
    traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
        path='configManager.datastoreSystem',
        type=vim.HostSystem,
        skip=False)
    objs = get_mors_with_properties(service_instance,
                                    vim.HostDatastoreSystem,
                                    property_list=['datastore'],
                                    container_ref=host_ref,
                                    traversal_spec=traversal_spec)
    if not objs:
        raise salt.exceptions.VMwareObjectRetrievalError(
            'Host\'s \'{0}\' datastore system was not retrieved'
            ''.format(hostname))
    log.trace('[%s] Retrieved datastore system', hostname)
    return objs[0]['object']
160130
def get_storage(self):
        '''
        '''

        if self.storage:
            return self.storage
        self.storage = self.reconnect_redis()

        return self.storage
429218
def get_hosts(self):
        
        limited_hosts = {}
        if self.limit is not None:
            # Find hosts and groups of hosts to include
            for include in self.limit['include']:
                # Include whole group
                for hostname in self.hosts_in_group(include):
                    limited_hosts[hostname] = self.hosts[hostname]
                # Include individual host
                if include in self.hosts:
                    limited_hosts[include] = self.hosts[include]
            # Find hosts and groups of hosts to exclude
            for exclude in self.limit["exclude"]:
                # Exclude whole group
                for hostname in self.hosts_in_group(exclude):
                    if hostname in limited_hosts:
                        limited_hosts.pop(hostname)
                # Exclude individual host
                if exclude in limited_hosts:
                    limited_hosts.pop(exclude)

            return limited_hosts
        else:
            # Return all hosts
            return self.hosts