Load and filter the server list for only the servers we care about
357033
def prepareList(self, listFile=False, noSample=False):
        

        logging.debug("Loading resolver file")

        listFileLocation = self.listLocal if not listFile else listFile

        # Resolve the user part of the path
        listLocal = os.path.expanduser(listFileLocation)

        # Check local file location exists and is writable
        assert os.path.isdir(os.path.dirname(listLocal)),\
            "{0} is not a directory!".format(os.path.dirname(listLocal))
        assert os.access(os.path.dirname(listLocal), os.W_OK),\
            "{0} is not writable!".format(os.path.dirname(listLocal))

        # Open and yaml parse the resolver list
        with open(listLocal) as ll:
            raw = ll.read()
            # Use safe_load, just to be safe.
            serverList = yaml.safe_load(raw)

        # Remove all but the specified countries from the server list
        if self.country is not None:
            logging.debug("Filtering serverList for country {0}"
                          .format(self.country))

            serverList = [d for d in serverList
                          if d['country'] == self.country]

            if len(serverList) == 0:
                raise ValueError("There are no servers avaliable "
                                 "with the country code {0}"
                                 .format(self.country))

        # Get selected number of servers
        if self.maxServers == 'ALL' or noSample:
            # Set servers to the number of servers we have
            self.maxServers = len(serverList)
        elif self.maxServers > len(serverList):
            # We were asked for more servers than exist in the list
            logging.warning(
                "You asked me to query {0} servers, but I only have "
                "{1} servers in my serverlist".format(
                    self.maxServers,
                    len(serverList)
                )
            )

            # Fallback to setting it to all
            self.maxServers = len(serverList)

        # Get a random selection of the specified number
        # of servers from the list
        self.serverList = random.sample(serverList, self.maxServers)

        return self.serverList
427650
def set_server(self, server_pos, key, value):
        """"""
        self._server_list[server_pos][key] = value
774807
def _ServerActions(action,alias,servers):
		
		if alias is None:  alias = clc.v1.Account.GetAlias()
		results = []
		for server in servers:
			r = clc.v1.API.Call('post','Server/%sServer' % (action), {'AccountAlias': alias, 'Name': server })
			if int(r['StatusCode']) == 0:  results.append(r)
		return(results)
732301
def servers(self):
        """"""
        url = "%s/servers" % self.root
        return Servers(url=url,
                       securityHandler=self._securityHandler,
                       proxy_url=self._proxy_url,
                       proxy_port=self._proxy_port)
127515
def servers(self):
        """"""
        self.__init()
        items = []
        for k,v in self._json_dict.items():
            if k == "servers":
                for s in v:
                    if 'id' in s:
                        url = "%s/%s" % (self.root, s['id'])
                        items.append(
                            self.Server(url=url,
                                        securityHandler=self._securityHandler,
                                        proxy_url=self._proxy_url,
                                        proxy_port=self._proxy_port))
            del k,v
        return items
824375
def filter(self, table, items, filter_string):
        """"""
        query = filter_string.lower()
        return [item for item in items
                if query in item.name.lower()]
294715
def filter(self, table, domains, filter_string):
        """"""
        q = filter_string.lower()

        def comp(domain):
            if q in domain.name.lower():
                return True
            return False

        return filter(comp, domains)
1272144
def server_show(self, server_id):
        '''
        
        '''
        ret = {}
        try:
            servers = self.server_list_detailed()
        except AttributeError:
            raise SaltCloudSystemExit('Corrupt server in server_list_detailed. Remove corrupt servers.')
        for server_name, server in six.iteritems(servers):
            if six.text_type(server['id']) == server_id:
                ret[server_name] = server
        return ret
268221
def filter(self, table, cgroups, filter_string):
        """"""
        query = filter_string.lower()
        return [cgroup for cgroup in cgroups
                if query in cgroup.name.lower()]
913372
def get_servers_by_deployment(names)
      servers = []
      all_instances = Connection.all_instances

      if @exact
        result = all_instances.select {|i| names.any? {|n| i['links']['deployment']['name'].eql? n }}
      else
        result = all_instances.select {|i| names.any? {|n| i['links']['deployment']['name'] =~ /#{n}/ }}
      end
      servers = result

      return(servers)
    end
742343
def local_bind_hosts(self):
        
        self._check_is_started()
        return [_server.local_host for _server in self._server_list if
                _server.local_host is not None]
675682
def filter(self, resource_manager, **params):
        """"""
        m = self.resolve(resource_manager.resource_type)
        client = local_session(self.session_factory).client(m.service)

        enum_op, path, extra_args = m.enum_spec
        if extra_args:
            params.update(extra_args)

        parent_type, parent_key, annotate_parent = m.parent_spec
        parents = self.manager.get_resource_manager(parent_type)
        parent_ids = [p[parents.resource_type.id] for p in parents.resources()]

        # Bail out with no parent ids...
        existing_param = parent_key in params
        if not existing_param and len(parent_ids) == 0:
            return []

        # Handle a query with parent id
        if existing_param:
            return self._invoke_client_enum(client, enum_op, params, path)

        # Have to query separately for each parent's children.
        results = []
        for parent_id in parent_ids:
            merged_params = self.get_parent_parameters(params, parent_id, parent_key)
            subset = self._invoke_client_enum(
                client, enum_op, merged_params, path, retry=self.manager.retry)
            if annotate_parent:
                for r in subset:
                    r[self.parent_key] = parent_id
            if subset and self.capture_parent_id:
                results.extend([(parent_id, s) for s in subset])
            elif subset:
                results.extend(subset)
        return results
1291928
def get_servers():
    '''
    
    '''
    cmd = ['w32tm', '/query', '/configuration']
    lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    for line in lines:
        try:
            if line.startswith('NtpServer:'):
                _, ntpsvrs = line.rsplit(' (', 1)[0].split(':', 1)
                return sorted(ntpsvrs.split())
        except ValueError as e:
            return False
    return False
538235
def _get_index_servers(self):
        """"""
        idx_srvs = []
        if 'index-servers' in self.conf.options('distutils'):
            idx = self.conf.get('distutils', 'index-servers')
            idx_srvs = [srv.strip() for srv in idx.split('\n') if srv.strip()]
        return idx_srvs
755236
def file_list(self, load):
        '''
        
        '''
        if 'env' in load:
            # "env" is not supported; Use "saltenv".
            load.pop('env')

        ret = set()
        if 'saltenv' not in load:
            return []
        if not isinstance(load['saltenv'], six.string_types):
            load['saltenv'] = six.text_type(load['saltenv'])

        for fsb in self.backends(load.pop('fsbackend', None)):
            fstr = '{0}.file_list'.format(fsb)
            if fstr in self.servers:
                ret.update(self.servers[fstr](load))
        # some *fs do not handle prefix. Ensure it is filtered
        prefix = load.get('prefix', '').strip('/')
        if prefix != '':
            ret = [f for f in ret if f.startswith(prefix)]
        return sorted(ret)
212550
def server_by_name(name, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.server_by_name(name)
825430
def cmd_server_load(self):
        
        servers = defaultdict(int)
        for line in self._valid_lines:
            servers[line.server_name] += 1
        return servers