Uptade targets in case hostname was directly passed without the roster.
        :return:
438598
def _update_targets(self):
        '''
        
        '''

        hostname = self.opts.get('tgt', '')
        if '@' in hostname:
            user, hostname = hostname.split('@', 1)
        else:
            user = self.opts.get('ssh_user')
        if hostname == '*':
            hostname = ''

        if salt.utils.network.is_reachable_host(hostname):
            hostname = salt.utils.network.ip_to_host(hostname)
            self.opts['tgt'] = hostname
            self.targets[hostname] = {
                'passwd': self.opts.get('ssh_passwd', ''),
                'host': hostname,
                'user': user,
            }
            if self.opts.get('ssh_update_roster'):
                self._update_roster()
1169730
def resolve_name(target)
      if (group = @group_lookup[target])
        group.node_names
      else
        # Try to wildcard match nodes in inventory
        # Ignore case because hostnames are generally case-insensitive
        regexp = Regexp.new("^#{Regexp.escape(target).gsub('\*', '.*?')}$", Regexp::IGNORECASE)

        nodes = @groups.node_names.select { |node| node =~ regexp }
        nodes += @groups.node_aliases.select { |target_alias, _node| target_alias =~ regexp }.values

        if nodes.empty?
          raise(WildcardError, target) if target.include?('*')
          [target]
        else
          nodes
        end
      end
    end
1093060
def targets(tgt, tgt_type='glob', **kwargs):  # pylint: disable=W0613
    '''
    
    '''
    roster_file = os.path.abspath('terraform.tfstate')
    if __opts__.get('roster_file'):
        roster_file = os.path.abspath(__opts__['roster_file'])

    if not os.path.isfile(roster_file):
        log.error("Can't find terraform state file '%s'", roster_file)
        return {}

    log.debug('terraform roster: using %s state file', roster_file)

    if not roster_file.endswith('.tfstate'):
        log.error("Terraform roster can only be used with terraform state files")
        return {}

    raw = _parse_state_file(roster_file)
    log.debug('%s hosts in terraform state file', len(raw))
    return __utils__['roster_matcher.targets'](raw, tgt, tgt_type, 'ipv4')
1098329
def possible_target_profiles(nickname, server, all_profiles_dict,
                             org_vm, autonomous=True, output='path'):
    
    assert output in ['path', 'name']
    profiles_in_svr = get_profiles_in_svr(nickname, server,
                                          all_profiles_dict,
                                          org_vm)
    # list of possible autonomous profiles for testing
    possible_profiles = []

    for profile_inst in profiles_in_svr:
        profile_org_name = profile_name(org_vm, profile_inst, short=True)
        if autonomous:
            if all_profiles_dict[profile_org_name].type == 'autonomous':
                possible_profiles.append(profile_inst)
        else:
            if not all_profiles_dict[profile_org_name].type == 'component':
                possible_profiles.append(profile_inst)

    if output == 'path':
        possible_profiles = [inst.path for inst in possible_profiles]
    elif output == 'name':
        possible_profiles = [profile_name(org_vm, inst)
                             for inst in possible_profiles]

    return possible_profiles
1013485
private boolean inHostsList(TaskTrackerStatus status) {
    Set<String> hostsList = hostsReader.getHosts();
    return (hostsList.isEmpty() || hostsList.contains(status.getHost()));
  }
238945
def hostname(self, value):
        
        if value is None:
            value = socket.gethostname()
        self._hostname = value
1347686
def hosts_in_group(self, groupname):
        
        result = []
        for hostname, hostinfo in self.hosts.items():
            if groupname == 'all':
                result.append(hostname)
            elif 'groups' in hostinfo:
                if groupname in hostinfo['groups']:
                    result.append(hostname)
            else:
                hostinfo['groups'] = [groupname]
        return result
554096
def imported_targets(self):
    
    libs = []
    for spec in self.imported_target_specs(payload=self.payload):
      resolved_target = self._build_graph.get_target_from_spec(spec,
                                                               relative_to=self.address.spec_path)
      if not resolved_target:
        raise self.UnresolvedImportError(
          'Could not find target {spec} referenced from {relative_to}'
          .format(spec=spec, relative_to=self.address.spec))
      try:
        libs.append(self.expected_target_constraint.validate_satisfied_by(resolved_target))
      except TypeConstraintError as e:
        raise self.WrongTargetTypeError(
          'Wrong target type {spec} referenced from remote sources target {relative_to}: {err}'
          .format(spec=spec, relative_to=self.address.spec, err=str(e)),
          e)
    return libs
125080
def target(self):
        
        # MAINT: I don't like this, but will deal later
        os.environ['PREDIX_SPACE_GUID'] = self.guid
        os.environ['PREDIX_SPACE_NAME'] = self.name
        os.environ['PREDIX_ORGANIZATION_GUID'] = self.org.guid
        os.environ['PREDIX_ORGANIZATION_NAME'] = self.org.name
1178582
def parse_ssh_config(lines):
    '''
    
    '''
    # transform the list of individual lines into a list of sublists where each
    # sublist represents a single Host definition
    hosts = []
    for line in lines:
        line = salt.utils.stringutils.to_unicode(line)
        if not line or line.startswith('#'):
            continue
        elif line.startswith('Host '):
            hosts.append([])
        hosts[-1].append(line)

    # construct a dictionary of Host names to mapped roster properties
    targets = collections.OrderedDict()
    for host_data in hosts:
        target = collections.OrderedDict()
        hostnames = host_data[0].split()[1:]
        for line in host_data[1:]:
            for field in _ROSTER_FIELDS:
                match = re.match(field.pattern, line)
                if match:
                    target[field.target_field] = match.group(1)
        for hostname in hostnames:
            targets[hostname] = target

    # apply matching for glob hosts
    wildcard_targets = []
    non_wildcard_targets = []
    for target in targets.keys():
        if '*' in target or '?' in target:
            wildcard_targets.append(target)
        else:
            non_wildcard_targets.append(target)
    for pattern in wildcard_targets:
        for candidate in non_wildcard_targets:
            if fnmatch.fnmatch(candidate, pattern):
                targets[candidate].update(targets[pattern])
        del targets[pattern]

    # finally, update the 'host' to refer to its declaration in the SSH config
    # so that its connection parameters can be utilized
    for target in targets:
        targets[target]['host'] = target
    return targets
1289032
def _get_host(self, hostname):
        
        if hostname not in self.hosts:
            self.hosts[hostname] = {
                'groups': set(),
                'hostvars': {}
            }
        return self.hosts[hostname]
596546
private boolean inExcludedHostsList(TaskTrackerStatus status) {
    Set<String> excludeList = hostsReader.getExcludedHosts();
    return excludeList.contains(status.getHost());
  }
1079461
def _hosts_by_success(self, hosts=[]):
        
        hosts = hosts if hosts else self.hosts
        return sorted(hosts, key=lambda h: self._host_errors[h])
558796
def complete_hosts(self, text, line, begidx, endidx):
        ""

        commands = ["add", "remove", "dc"]

        mline = line.partition(' ')[2]
        offs = len(mline) - len(text)
        return [s[offs:] for s in commands if s.startswith(mline)]
909601
def targets(tgt, tgt_type='glob', **kwargs):  # pylint: disable=W0613
    '''
    
    '''
    ret = {}

    cloud_opts = salt.config.cloud_config(
        os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud')
    )

    minions = __runner__['cache.cloud'](tgt)
    for minion_id, full_info in minions.items():
        profile, provider = full_info.get('profile', None), full_info.get('provider', None)
        vm_ = {
            'driver': provider,
            'profile': profile,
        }
        public_ips = full_info.get('public_ips', [])
        private_ips = full_info.get('private_ips', [])
        ip_list = []
        for item in (public_ips, private_ips):
            if isinstance(item, list):
                ip_list = ip_list + item
            elif isinstance(item, string_types):
                ip_list.append(item)

        roster_order = __opts__.get('roster_order', (
            'public', 'private', 'local'
        ))
        preferred_ip = extract_ipv4(roster_order, ip_list)

        ret[minion_id] = copy.deepcopy(__opts__.get('roster_defaults', {}))
        ret[minion_id].update({'host': preferred_ip})

        ssh_username = salt.utils.cloud.ssh_usernames(vm_, cloud_opts)
        if isinstance(ssh_username, string_types):
            ret[minion_id]['user'] = ssh_username
        elif isinstance(ssh_username, list):
            if ssh_username[0] != 'root':
                ret[minion_id]['user'] = ssh_username[0]

        password = salt.config.get_cloud_config_value(
            'ssh_password', vm_, cloud_opts, search_global=False, default=None
        )
        if password:
            ret[minion_id]['password'] = password

        key_filename = salt.config.get_cloud_config_value(
            'private_key', vm_, cloud_opts, search_global=False, default=None
        )
        if key_filename:
            ret[minion_id]['priv'] = key_filename

        sudo = salt.config.get_cloud_config_value(
            'sudo', vm_, cloud_opts, search_global=False, default=None
        )
        if sudo:
            ret[minion_id]['sudo'] = sudo

    return ret
127125
async def set_as_host_manager(self, addr, timeout=5):
        
        return await self.menv.set_host_manager(addr, timeout=timeout)
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