INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Check if the specified filename has correct permissions
def check_permissions(self, filename): ''' Check if the specified filename has correct permissions ''' if salt.utils.platform.is_windows(): return True # After we've ascertained we're not on windows groups = salt.utils.user.get_gid_list(self.opts['user'], inc...
Check a keyid for membership in a signing file
def check_signing_file(self, keyid, signing_file): ''' Check a keyid for membership in a signing file ''' if not signing_file or not os.path.exists(signing_file): return False if not self.check_permissions(signing_file): log.warning('Wrong permissions for...
Check a keyid for membership in a autosign directory.
def check_autosign_dir(self, keyid): ''' Check a keyid for membership in a autosign directory. ''' autosign_dir = os.path.join(self.opts['pki_dir'], 'minions_autosign') # cleanup expired files expire_minutes = self.opts.get('autosign_timeout', 120) if expire_minu...
Check for matching grains in the autosign_grains_dir.
def check_autosign_grains(self, autosign_grains): ''' Check for matching grains in the autosign_grains_dir. ''' if not autosign_grains or 'autosign_grains_dir' not in self.opts: return False autosign_grains_dir = self.opts['autosign_grains_dir'] for root, dir...
Checks if the specified keyid should automatically be signed.
def check_autosign(self, keyid, autosign_grains=None): ''' Checks if the specified keyid should automatically be signed. ''' if self.opts['auto_accept']: return True if self.check_signing_file(keyid, self.opts.get('autosign_file', None)): return True ...
Set the local file objects from the file server interface
def __setup_fileserver(self): ''' Set the local file objects from the file server interface ''' fs_ = salt.fileserver.Fileserver(self.opts) self._serve_file = fs_.serve_file self._file_find = fs_._find_file self._file_hash = fs_.file_hash self._file_list =...
Verify that the passed information authorized a minion to execute
def __verify_minion_publish(self, load): ''' Verify that the passed information authorized a minion to execute ''' # Verify that the load is valid if 'peer' not in self.opts: return False if not isinstance(self.opts['peer'], dict): return False ...
Return the master options to the minion
def _master_opts(self, load): ''' Return the master options to the minion ''' mopts = {} file_roots = {} envs = self._file_envs() for saltenv in envs: if saltenv not in file_roots: file_roots[saltenv] = [] mopts['file_roots'] = ...
Return the results from master_tops if configured
def _master_tops(self, load, skip_verify=False): ''' Return the results from master_tops if configured ''' if not skip_verify: if 'id' not in load: log.error('Received call for external nodes without an id') return {} if not salt.ut...
Gathers the data from the specified minions' mine
def _mine_get(self, load, skip_verify=False): ''' Gathers the data from the specified minions' mine ''' if not skip_verify: if any(key not in load for key in ('id', 'tgt', 'fun')): return {} if isinstance(load['fun'], six.string_types): fu...
Return the mine data
def _mine(self, load, skip_verify=False): ''' Return the mine data ''' if not skip_verify: if 'id' not in load or 'data' not in load: return False if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False): c...
Allow the minion to delete a specific function from its own mine
def _mine_delete(self, load): ''' Allow the minion to delete a specific function from its own mine ''' if 'id' not in load or 'fun' not in load: return False if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False): cbank ...
Allow the minion to delete all of its own mine contents
def _mine_flush(self, load, skip_verify=False): ''' Allow the minion to delete all of its own mine contents ''' if not skip_verify and 'id' not in load: return False if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False): ...
Allows minions to send files to the master, files are sent to the master file cache
def _file_recv(self, load): ''' Allows minions to send files to the master, files are sent to the master file cache ''' if any(key not in load for key in ('id', 'path', 'loc')): return False if not self.opts['file_recv'] or os.path.isabs(load['path']): ...
Return the pillar data for the minion
def _pillar(self, load): ''' Return the pillar data for the minion ''' if any(key not in load for key in ('id', 'grains')): return False # pillar = salt.pillar.Pillar( log.debug('Master _pillar using ext: %s', load.get('ext')) pillar = salt.pillar.get_p...
Receive an event from the minion and fire it on the master event interface
def _minion_event(self, load): ''' Receive an event from the minion and fire it on the master event interface ''' if 'id' not in load: return False if 'events' not in load and ('tag' not in load or 'data' not in load): return False if 'even...
Handle the return data sent from the minions
def _return(self, load): ''' Handle the return data sent from the minions ''' # Generate EndTime endtime = salt.utils.jid.jid_to_time(salt.utils.jid.gen_jid(self.opts)) # If the return data is invalid, just ignore it if any(key not in load for key in ('return', 'j...
Receive a syndic minion return and format it to look like returns from individual minions.
def _syndic_return(self, load): ''' Receive a syndic minion return and format it to look like returns from individual minions. ''' # Verify the load if any(key not in load for key in ('return', 'jid', 'id')): return None # if we have a load, save it ...
Execute a runner from a minion, return the runner's function data
def minion_runner(self, load): ''' Execute a runner from a minion, return the runner's function data ''' if 'peer_run' not in self.opts: return {} if not isinstance(self.opts['peer_run'], dict): return {} if any(key not in load for key in ('fun', '...
Request the return data from a specific jid, only allowed if the requesting minion also initialted the execution.
def pub_ret(self, load, skip_verify=False): ''' Request the return data from a specific jid, only allowed if the requesting minion also initialted the execution. ''' if not skip_verify and any(key not in load for key in ('jid', 'id')): return {} else: ...
Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt f...
def minion_pub(self, load): ''' Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions...
Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt f...
def minion_publish(self, load): ''' Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt funct...
Allow a minion to request revocation of its own key
def revoke_auth(self, load): ''' Allow a minion to request revocation of its own key ''' if 'id' not in load: return False keyapi = salt.key.Key(self.opts) keyapi.delete_key(load['id'], preserve_minions=load.get('preserve_minion_cache...
Send a master control function back to the runner system
def runner(self, load): ''' Send a master control function back to the runner system ''' # All runner opts pass through eauth auth_type, err_name, key = self._prep_auth_info(load) # Authenticate auth_check = self.loadauth.check_authentication(load, auth_type) ...
Send a master control function back to the wheel system
def wheel(self, load): ''' Send a master control function back to the wheel system ''' # All wheel ops pass through eauth auth_type, err_name, key = self._prep_auth_info(load) # Authenticate auth_check = self.loadauth.check_authentication( load, ...
Create and return an authentication token, the clear load needs to contain the eauth key and the needed authentication creds.
def mk_token(self, load): ''' Create and return an authentication token, the clear load needs to contain the eauth key and the needed authentication creds. ''' token = self.loadauth.mk_token(load) if not token: log.warning('Authentication failure of type "eaut...
This method sends out publications to the minions, it can only be used by the LocalClient.
def publish(self, load): ''' This method sends out publications to the minions, it can only be used by the LocalClient. ''' extra = load.get('kwargs', {}) publisher_acl = salt.acl.PublisherACL(self.opts['publisher_acl_blacklist']) if publisher_acl.user_is_blackl...
Listen to slack events and forward them to salt, new version
def start(token, control=False, trigger='!', groups=None, groups_pillar_name=None, fire_all=False, tag='salt/engines/slack'): ''' Listen to slack events and forward them to salt, new version ''' if (not token) or (not token.startswith('xoxb'))...
Get all users from Slack
def get_slack_users(self, token): ''' Get all users from Slack ''' ret = salt.utils.slack.query(function='users', api_key=token, opts=__opts__) users = {} if 'message' in ret: for item ...
Get all channel names from Slack
def get_slack_channels(self, token): ''' Get all channel names from Slack ''' ret = salt.utils.slack.query( function='rooms', api_key=token, # These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged opts={...
get info from groups in config, and from the named pillar todo: add specification for the minion to use to recover pillar
def get_config_groups(self, groups_conf, groups_pillar_name): ''' get info from groups in config, and from the named pillar todo: add specification for the minion to use to recover pillar ''' # Get groups # Default to returning something that'll never match ret_g...
pillar_prefix is the pillar.get syntax for the pillar to be queried. Group name is gotten via the equivalent of using ``salt['pillar.get']('{}:{}'.format(pillar_prefix, group_name))`` in a jinja template. returns a dictionary (unless the pillar is mis-formatted) XXX: instead of ...
def _groups_from_pillar(self, pillar_name): ''' pillar_prefix is the pillar.get syntax for the pillar to be queried. Group name is gotten via the equivalent of using ``salt['pillar.get']('{}:{}'.format(pillar_prefix, group_name))`` in a jinja template. returns a dictiona...
Break out the permissions into the following: Check whether a user is in any group, including whether a group has the '*' membership :type user: str :param user: The username being checked against :type command: str :param command: The command that is being invoked (e.g. test....
def can_user_run(self, user, command, groups): ''' Break out the permissions into the following: Check whether a user is in any group, including whether a group has the '*' membership :type user: str :param user: The username being checked against :type command: str ...
This replaces a function in main called 'fire' It fires an event into the salt bus.
def fire(self, tag, msg): ''' This replaces a function in main called 'fire' It fires an event into the salt bus. ''' if __opts__.get('__role') == 'master': fire_master = salt.utils.event.get_master_event( __opts__, __opts__['sock_dir'...
cmdline_str is the string of the command line trigger_string is the trigger string, to be removed
def commandline_to_list(self, cmdline_str, trigger_string): ''' cmdline_str is the string of the command line trigger_string is the trigger string, to be removed ''' cmdline = salt.utils.args.shlex_split(cmdline_str[len(trigger_string):]) # Remove slack url parsing ...
Returns a tuple of (target, cmdline,) for the response Raises IndexError if a user can't be looked up from all_slack_users Returns (False, False) if the user doesn't have permission These are returned together because the commandline and the targeting interact with the group config (s...
def control_message_target(self, slack_user_name, text, loaded_groups, trigger_string): '''Returns a tuple of (target, cmdline,) for the response Raises IndexError if a user can't be looked up from all_slack_users Returns (False, False) if the user doesn't have permission These are re...
Raises ValueError if a value doesn't work out, and TypeError if this isn't a message type
def message_text(self, m_data): ''' Raises ValueError if a value doesn't work out, and TypeError if this isn't a message type ''' if m_data.get('type') != 'message': raise TypeError('This is not a message') # Edited messages have text in message _text ...
slack_token = string trigger_string = string input_valid_users = set input_valid_commands = set When the trigger_string prefixes the message text, yields a dictionary of:: { 'message_data': m_data, 'cmdline': cmdline_list, # this is a...
def generate_triggered_messages(self, token, trigger_string, groups, groups_pillar_name): ''' slack_token = string trigger_string = string input_valid_users = set input_valid_commands = set When the trigger_string prefixes the message text, yields a dictionary of...
When we are permitted to run a command on a target, look to see what the default targeting is for that group, and for that specific command (if provided). It's possible for None or False to be the result of either, which means that it's expected that the caller provide a specific target...
def get_target(self, permitted_group, cmdline, alias_cmdline): ''' When we are permitted to run a command on a target, look to see what the default targeting is for that group, and for that specific command (if provided). It's possible for None or False to be the result of eithe...
Print out YAML using the block mode
def format_return_text(self, data, function, **kwargs): # pylint: disable=unused-argument ''' Print out YAML using the block mode ''' # emulate the yaml_out output formatter. It relies on a global __opts__ object which # we can't obviously pass in try: try: ...
cmdline: list returns tuple of: args (list), kwargs (dict)
def parse_args_and_kwargs(self, cmdline): ''' cmdline: list returns tuple of: args (list), kwargs (dict) ''' # Parse args and kwargs args = [] kwargs = {} if len(cmdline) > 1: for item in cmdline[1:]: if '=' in item: ...
Given a list of job_ids, return a dictionary of those job_ids that have completed and their results. Query the salt event bus via the jobs runner. jobs.list_job will show a job in progress, jobs.lookup_jid will return a job that has completed. returns a dictionary of job id: re...
def get_jobs_from_runner(self, outstanding_jids): ''' Given a list of job_ids, return a dictionary of those job_ids that have completed and their results. Query the salt event bus via the jobs runner. jobs.list_job will show a job in progress, jobs.lookup_jid will return a job t...
Pull any pending messages from the message_generator, sending each one to either the event bus, the command_async or both, depending on the values of fire_all and command
def run_commands_from_slack_async(self, message_generator, fire_all, tag, control, interval=1): ''' Pull any pending messages from the message_generator, sending each one to either the event bus, the command_async or both, depending on the values of fire_all and command ''' ...
:type message_generator: generator of dict :param message_generator: Generates messages from slack that should be run :type fire_all: bool :param fire_all: Whether to also fire messages to the event bus :type tag: str :param tag: The tag to send to use to send to the event bus ...
def run_command_async(self, msg): ''' :type message_generator: generator of dict :param message_generator: Generates messages from slack that should be run :type fire_all: bool :param fire_all: Whether to also fire messages to the event bus :type tag: str :para...
Return a Pg cursor
def _get_serv(ret=None, commit=False): ''' Return a Pg cursor ''' _options = _get_options(ret) try: conn = psycopg2.connect(host=_options.get('host'), user=_options.get('user'), password=_options.get('passwd'), ...
Return data to a postgres server
def returner(ret): ''' Return data to a postgres server ''' try: with _get_serv(ret, commit=True) as cur: sql = '''INSERT INTO salt_returns (fun, jid, return, id, success, full_ret) VALUES (%s, %s, %s, %s, %s, %s)''' cur.execute( ...
Return a list of all job ids
def get_jids(): ''' Return a list of all job ids ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT jid, load FROM jids''' cur.execute(sql) data = cur.fetchall() ret = {} for jid, load in data: ret[jid] = salt.utils.jid...
Ensures that the host group exists, eventually creates new host group. .. versionadded:: 2016.3.0 :param name: name of the host group :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix password (can...
def present(name, **kwargs): ''' Ensures that the host group exists, eventually creates new host group. .. versionadded:: 2016.3.0 :param name: name of the host group :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_...
Ensures that the host group does not exist, eventually delete host group. .. versionadded:: 2016.3.0 :param name: name of the host group :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix password (...
def absent(name, **kwargs): ''' Ensures that the host group does not exist, eventually delete host group. .. versionadded:: 2016.3.0 :param name: name of the host group :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connectio...
Encode json values in unicode to match that of the API
def _json_to_unicode(data): ''' Encode json values in unicode to match that of the API ''' ret = {} for key, value in data.items(): if not isinstance(value, six.text_type): if isinstance(value, dict): ret[key] = _json_to_unicode(value) else: ...
Compare the API results to the current statefile data
def _is_updated(old_conf, new_conf): ''' Compare the API results to the current statefile data ''' changed = {} # Dirty json hacking to get parameters in the same format new_conf = _json_to_unicode(salt.utils.json.loads( salt.utils.json.dumps(new_conf, ensure_ascii=False))) old_conf...
Generic function to create or update an element
def _do_element_present(name, elem_type, data, server=None): ''' Generic function to create or update an element ''' ret = {'changes': {}, 'update': False, 'create': False, 'error': None} try: elements = __salt__['glassfish.enum_{0}'.format(elem_type)]() except requests.ConnectionError a...
Generic function to delete an element
def _do_element_absent(name, elem_type, data, server=None): ''' Generic function to delete an element ''' ret = {'delete': False, 'error': None} try: elements = __salt__['glassfish.enum_{0}'.format(elem_type)]() except requests.ConnectionError as error: if __opts__['test']: ...
Ensures that the Connection Factory is present name Name of the connection factory restype Type of the connection factory, can be either ``connection_factory``, ``queue_connection_factory` or ``topic_connection_factory``, defaults to ``connection_factory`` description ...
def connection_factory_present(name, restype='connection_factory', description='', enabled=True, min_size=1, max_size=250, resize_quan...
Ensures the transaction factory is absent. name Name of the connection factory both Delete both the pool and the resource, defaults to ``true``
def connection_factory_absent(name, both=True, server=None): ''' Ensures the transaction factory is absent. name Name of the connection factory both Delete both the pool and the resource, defaults to ``true`` ''' ret = {'name': name, 'result': None, 'comment': None, 'changes': ...
Ensures that the JMS Destination Resource (queue or topic) is present name The JMS Queue/Topic name physical The Physical destination name restype The JMS Destination resource type, either ``queue`` or ``topic``, defaults is ``queue`` description A description of the ...
def destination_present(name, physical, restype='queue', description='', enabled=True, server=None): ''' Ensures that the JMS Destination Resource (queue or topic) is present name ...
Ensures that the JMS Destination doesn't exists name Name of the JMS Destination
def destination_absent(name, server=None): ''' Ensures that the JMS Destination doesn't exists name Name of the JMS Destination ''' ret = {'name': name, 'result': None, 'comment': None, 'changes': {}} jms_ret = _do_element_absent(name, 'admin_object_resource', {}, server) if not jms...
Ensures that the JDBC Datasource exists name Name of the datasource description Description of the datasource enabled Is the datasource enabled? defaults to ``true`` restype Resource type, can be ``datasource``, ``xa_datasource``, ``connection_pool_datasource`...
def jdbc_datasource_present(name, description='', enabled=True, restype='datasource', vendor='mysql', sql_url='', sql_user='', ...
Ensures the JDBC Datasource doesn't exists name Name of the datasource both Delete both the pool and the resource, defaults to ``true``
def jdbc_datasource_absent(name, both=True, server=None): ''' Ensures the JDBC Datasource doesn't exists name Name of the datasource both Delete both the pool and the resource, defaults to ``true`` ''' ret = {'name': name, 'result': None, 'comment': None, 'changes': {}} pool...
Ensures that the system properties are present properties The system properties
def system_properties_present(server=None, **kwargs): ''' Ensures that the system properties are present properties The system properties ''' ret = {'name': '', 'result': None, 'comment': None, 'changes': {}} del kwargs['name'] try: data = __salt__['glassfish.get_system_pro...
Ensures that the system property doesn't exists name Name of the system property
def system_properties_absent(name, server=None): ''' Ensures that the system property doesn't exists name Name of the system property ''' ret = {'name': '', 'result': None, 'comment': None, 'changes': {}} try: data = __salt__['glassfish.get_system_properties'](server=server) ...
Get the grains/pillar for a specific minion. If minion is None, it will return the grains/pillar for the first minion it finds. Return value is a tuple of the minion ID, grains, and pillar
def get_minion_data(minion, opts): ''' Get the grains/pillar for a specific minion. If minion is None, it will return the grains/pillar for the first minion it finds. Return value is a tuple of the minion ID, grains, and pillar ''' grains = None pillar = None if opts.get('minion_data_c...
Recursively expand ``nodegroup`` from ``nodegroups``; ignore nodegroups in ``skip`` If a top-level (non-recursive) call finds no nodegroups, return the original nodegroup definition (for backwards compatibility). Keep track of recursive calls via `first_call` argument
def nodegroup_comp(nodegroup, nodegroups, skip=None, first_call=True): ''' Recursively expand ``nodegroup`` from ``nodegroups``; ignore nodegroups in ``skip`` If a top-level (non-recursive) call finds no nodegroups, return the original nodegroup definition (for backwards compatibility). Keep track of r...
Gathers the data from the specified minions' mine, pass in the target, function to look up and the target type
def mine_get(tgt, fun, tgt_type='glob', opts=None): ''' Gathers the data from the specified minions' mine, pass in the target, function to look up and the target type ''' ret = {} serial = salt.payload.Serial(opts) checker = CkMinions(opts) _res = checker.check_minions( tgt, ...
Return minions found by looking at nodegroups
def _check_nodegroup_minions(self, expr, greedy): # pylint: disable=unused-argument ''' Return minions found by looking at nodegroups ''' return self._check_compound_minions(nodegroup_comp(expr, self.opts['nodegroups']), DEFAULT_TARGET_DELIM, greedy)
Return the minions found by looking via a list
def _check_list_minions(self, expr, greedy, ignore_missing=False): # pylint: disable=unused-argument ''' Return the minions found by looking via a list ''' if isinstance(expr, six.string_types): expr = [m for m in expr.split(',') if m] minions = self._pki_minions() ...
Return the minions found by looking via regular expressions
def _check_pcre_minions(self, expr, greedy): # pylint: disable=unused-argument ''' Return the minions found by looking via regular expressions ''' reg = re.compile(expr) return {'minions': [m for m in self._pki_minions() if reg.match(m)], 'missing': []}
Retreive complete minion list from PKI dir. Respects cache if configured
def _pki_minions(self): ''' Retreive complete minion list from PKI dir. Respects cache if configured ''' minions = [] pki_cache_fn = os.path.join(self.opts['pki_dir'], self.acc, '.key_cache') try: os.makedirs(os.path.dirname(pki_cache_fn)) exce...
Helper function to search for minions in master caches If 'greedy', then return accepted minions matched by the condition or those absent from the cache. If not 'greedy' return the only minions have cache data and matched by the condition.
def _check_cache_minions(self, expr, delimiter, greedy, search_type, regex_match=False, exact_match=False): ''' Helper function to...
Return the minions found by looking via grains
def _check_grain_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via grains ''' return self._check_cache_minions(expr, delimiter, greedy, 'grains')
Return the minions found by looking via grains with PCRE
def _check_grain_pcre_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via grains with PCRE ''' return self._check_cache_minions(expr, delimiter, greedy, ...
Return the minions found by looking via pillar
def _check_pillar_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via pillar ''' return self._check_cache_minions(expr, delimiter, greedy, 'pillar')
Return the minions found by looking via pillar with PCRE
def _check_pillar_pcre_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via pillar with PCRE ''' return self._check_cache_minions(expr, delimiter, greedy, ...
Return the minions found by looking via pillar
def _check_pillar_exact_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via pillar ''' return self._check_cache_minions(expr, delimiter, greedy, ...
Return the minions found by looking via ipcidr
def _check_ipcidr_minions(self, expr, greedy): ''' Return the minions found by looking via ipcidr ''' cache_enabled = self.opts.get('minion_data_cache', False) if greedy: minions = self._pki_minions() elif cache_enabled: minions = self.cache.list(...
Return the minions found by looking via range expression
def _check_range_minions(self, expr, greedy): ''' Return the minions found by looking via range expression ''' if not HAS_RANGE: raise CommandExecutionError( 'Range matcher unavailable (unable to import seco.range, ' 'module most likely not ins...
Return the minions found by looking via compound matcher Disable pillar glob matching
def _check_compound_pillar_exact_minions(self, expr, delimiter, greedy): ''' Return the minions found by looking via compound matcher Disable pillar glob matching ''' return self._check_compound_minions(expr, delimiter, ...
Return the minions found by looking via compound matcher
def _check_compound_minions(self, expr, delimiter, greedy, pillar_exact=False): # pylint: disable=unused-argument ''' Return the minions found by looking via compound matcher ...
Return a set of all connected minion ids, optionally within a subset
def connected_ids(self, subset=None, show_ip=False, show_ipv4=None, include_localhost=None): ''' Return a set of all connected minion ids, optionally within a subset ''' if include_localhost is not None: salt.utils.versions.warn_until( 'Sodium', ...
Return a list of all minions that have auth'd
def _all_minions(self, expr=None): ''' Return a list of all minions that have auth'd ''' mlist = [] for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join(self.opts['pki_dir'], self.acc))): if not fn_.startswith('.') and os.path.isfile(os.path.join(self....
Check the passed regex against the available minions' public keys stored for authentication. This should return a set of ids which match the regex, this will then be used to parse the returns to make sure everyone has checked back in.
def check_minions(self, expr, tgt_type='glob', delimiter=DEFAULT_TARGET_DELIM, greedy=True): ''' Check the passed regex against the available minions' public keys stored for authentication. This should return...
Return a Bool. This function returns if the expression sent in is within the scope of the valid expression
def validate_tgt(self, valid, expr, tgt_type, minions=None, expr_form=None): ''' Return a Bool. This function returns if the expression sent in is within the scope of the valid expression ''' v_minions = set(self.check_minions(valid, 'compound').get('minions', [])) if mi...
Validate a single regex to function comparison, the function argument can be a list of functions. It is all or nothing for a list of functions
def match_check(self, regex, fun): ''' Validate a single regex to function comparison, the function argument can be a list of functions. It is all or nothing for a list of functions ''' vals = [] if isinstance(fun, six.string_types): fun = [fun] ...
Read in the form and determine which auth check routine to execute
def any_auth(self, form, auth_list, fun, arg, tgt=None, tgt_type='glob'): ''' Read in the form and determine which auth check routine to execute ''' # This function is only called from salt.auth.Authorize(), which is also # deprecated and will be removed in Neon. salt.uti...
Returns a bool which defines if the requested function is authorized. Used to evaluate the standard structure under external master authentication interfaces, like eauth, peer, peer_run, etc.
def auth_check(self, auth_list, funs, args, tgt, tgt_type='glob', groups=None, publish_validate=False, minions=None, whitelist=None): ''' ...
Returns a list of authorisation matchers that a user is eligible for. This list is a combination of the provided personal matchers plus the matchers of any group the user is in.
def fill_auth_list_from_groups(self, auth_provider, user_groups, auth_list): ''' Returns a list of authorisation matchers that a user is eligible for. This list is a combination of the provided personal matchers plus the matchers of any group the user is in. ''' group_nam...
Returns a list of authorisation matchers that a user is eligible for. This list is a combination of the provided personal matchers plus the matchers of any group the user is in.
def fill_auth_list(self, auth_provider, name, groups, auth_list=None, permissive=None): ''' Returns a list of authorisation matchers that a user is eligible for. This list is a combination of the provided personal matchers plus the matchers of any group the user is in. ''' ...
Check special API permissions
def wheel_check(self, auth_list, fun, args): ''' Check special API permissions ''' return self.spec_check(auth_list, fun, args, 'wheel')
Check special API permissions
def runner_check(self, auth_list, fun, args): ''' Check special API permissions ''' return self.spec_check(auth_list, fun, args, 'runner')
Check special API permissions
def spec_check(self, auth_list, fun, args, form): ''' Check special API permissions ''' if not auth_list: return False if form != 'cloud': comps = fun.split('.') if len(comps) != 2: # Hint at a syntax error when command is passe...
Check the given function name (fun) and its arguments (args) against the list of conditions.
def __fun_check(self, valid, fun, args=None, kwargs=None): ''' Check the given function name (fun) and its arguments (args) against the list of conditions. ''' if not isinstance(valid, list): valid = [valid] for cond in valid: # Function name match ...
valid is a dicts: {'args': [...], 'kwargs': {...}} or a list of such dicts.
def __args_check(self, valid, args=None, kwargs=None): ''' valid is a dicts: {'args': [...], 'kwargs': {...}} or a list of such dicts. ''' if not isinstance(valid, list): valid = [valid] for cond in valid: if not isinstance(cond, dict): # I...
Return a list of the VMs that are on the provider
def list_nodes_full(call=None, for_output=True): ''' Return a list of the VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or --function.' ) creds = get_creds() clc.v1.SetCredentials(...
Return a list of the VMs that are on the provider
def get_monthly_estimate(call=None, for_output=True): ''' Return a list of the VMs that are on the provider ''' creds = get_creds() clc.v1.SetCredentials(creds["token"], creds["token_pass"]) if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be...
Return a list of alerts from CLC as reported by their infra
def get_server_alerts(call=None, for_output=True, **kwargs): ''' Return a list of alerts from CLC as reported by their infra ''' for key, value in kwargs.items(): servername = "" if key == "servername": servername = value creds = get_creds() clc.v2.SetCredentials(cred...
Return a list of the VMs that are on the provider usage: "salt-cloud -f get_group_estimate clc group=Dev location=VA1"
def get_group_estimate(call=None, for_output=True, **kwargs): ''' Return a list of the VMs that are on the provider usage: "salt-cloud -f get_group_estimate clc group=Dev location=VA1" ''' for key, value in kwargs.items(): group = "" location = "" if key == "group": ...
returns a list of images available to you
def avail_images(call=None): ''' returns a list of images available to you ''' all_servers = list_nodes_full() templates = {} for server in all_servers: if server["IsTemplate"]: templates.update({"Template Name": server["Name"]}) return templates
returns a list of locations available to you
def avail_locations(call=None): ''' returns a list of locations available to you ''' creds = get_creds() clc.v1.SetCredentials(creds["token"], creds["token_pass"]) locations = clc.v1.Account.GetLocations() return locations
get the build status from CLC to make sure we dont return to early
def get_build_status(req_id, nodename): ''' get the build status from CLC to make sure we dont return to early ''' counter = 0 req_id = six.text_type(req_id) while counter < 10: queue = clc.v1.Blueprint.GetStatus(request_id=(req_id)) if queue["PercentComplete"] == 100: ...
get the system build going
def create(vm_): ''' get the system build going ''' creds = get_creds() clc.v1.SetCredentials(creds["token"], creds["token_pass"]) cloud_profile = config.is_provider_configured( __opts__, __active_provider_name__ or __virtualname__, ('token',) ) group = config.get...