INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bash salt '*' pkg.file_list httpd salt '*' pkg.file_list httpd postfi...
def file_dict(*packages, **kwargs): # pylint: disable=unused-argument ''' List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bas...
Return the name of the package that owns the file. Multiple file paths can be passed. Like :mod:`pkg.version <salt.modules.opkg.version`, if a single path is passed, a string will be returned, and if multiple paths are passed, a dictionary of file/package name pairs will be returned. If the file is not...
def owner(*paths, **kwargs): # pylint: disable=unused-argument ''' Return the name of the package that owns the file. Multiple file paths can be passed. Like :mod:`pkg.version <salt.modules.opkg.version`, if a single path is passed, a string will be returned, and if multiple paths are passed, a dic...
send a email to inform user of account creation
def _send_email(name, email): "send a email to inform user of account creation" config = __salt__['config.option']('splunk') email_object = config.get('email') if email_object: cc = email_object.get('cc') subject = email_object.get('subject') message = email_object.get('message')...
Return the splunk client, cached into __context__ for performance
def _get_splunk(profile): ''' Return the splunk client, cached into __context__ for performance ''' config = __salt__['config.option'](profile) key = "splunk.{0}:{1}:{2}:{3}".format( config.get('host'), config.get('port'), config.get('username'), config.get('password...
List all users in the splunk DB CLI Example: salt myminion splunk.list_users
def list_users(profile="splunk"): ''' List all users in the splunk DB CLI Example: salt myminion splunk.list_users ''' config = __salt__['config.option'](profile) key = "splunk.users.{0}".format( config.get('host') ) if key not in __context__: _populate_cache(...
Get a splunk user by name/email CLI Example: salt myminion splunk.get_user 'user@example.com' user_details=false salt myminion splunk.get_user 'user@example.com' user_details=true
def get_user(email, profile="splunk", **kwargs): ''' Get a splunk user by name/email CLI Example: salt myminion splunk.get_user 'user@example.com' user_details=false salt myminion splunk.get_user 'user@example.com' user_details=true ''' user_map = list_users(profile) user_foun...
create a splunk user by name/email CLI Example: salt myminion splunk.create_user user@example.com roles=['user'] realname="Test User" name=testuser
def create_user(email, profile="splunk", **kwargs): ''' create a splunk user by name/email CLI Example: salt myminion splunk.create_user user@example.com roles=['user'] realname="Test User" name=testuser ''' client = _get_splunk(profile) email = email.lower() user = list_users(p...
Create a splunk user by email CLI Example: salt myminion splunk.update_user example@domain.com roles=['user'] realname="Test User"
def update_user(email, profile="splunk", **kwargs): ''' Create a splunk user by email CLI Example: salt myminion splunk.update_user example@domain.com roles=['user'] realname="Test User" ''' client = _get_splunk(profile) email = email.lower() user = list_users(profile).get(email...
Delete a splunk user by email CLI Example: salt myminion splunk_user.delete 'user@example.com'
def delete_user(email, profile="splunk"): ''' Delete a splunk user by email CLI Example: salt myminion splunk_user.delete 'user@example.com' ''' client = _get_splunk(profile) user = list_users(profile).get(email) if user: try: client.users.delete(user.name) ...
Return the default shell to use on this system
def shell(): ''' Return the default shell to use on this system ''' # Provides: # shell if salt.utils.platform.is_windows(): env_var = 'COMSPEC' default = r'C:\Windows\system32\cmd.exe' else: env_var = 'SHELL' default = '/bin/sh' return {'shell': os.env...
Return the grains set in the grains file
def config(): ''' Return the grains set in the grains file ''' if 'conf_file' not in __opts__: return {} if os.path.isdir(__opts__['conf_file']): if salt.utils.platform.is_proxy(): gfn = os.path.join( __opts__['conf_file'], 'proxy.d...
Get the output volume (range 0 to 100) CLI Example: .. code-block:: bash salt '*' desktop.get_output_volume
def get_output_volume(): ''' Get the output volume (range 0 to 100) CLI Example: .. code-block:: bash salt '*' desktop.get_output_volume ''' cmd = 'osascript -e "get output volume of (get volume settings)"' call = __salt__['cmd.run_all']( cmd, output_loglevel='debu...
Set the volume of sound. volume The level of volume. Can range from 0 to 100. CLI Example: .. code-block:: bash salt '*' desktop.set_output_volume <volume>
def set_output_volume(volume): ''' Set the volume of sound. volume The level of volume. Can range from 0 to 100. CLI Example: .. code-block:: bash salt '*' desktop.set_output_volume <volume> ''' cmd = 'osascript -e "set volume output volume {0}"'.format(volume) call =...
Launch the screensaver. CLI Example: .. code-block:: bash salt '*' desktop.screensaver
def screensaver(): ''' Launch the screensaver. CLI Example: .. code-block:: bash salt '*' desktop.screensaver ''' cmd = 'open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app' call = __salt__['cmd.run_all']( cmd, output_lo...
Say some words. words The words to execute the say command with. CLI Example: .. code-block:: bash salt '*' desktop.say <word0> <word1> ... <wordN>
def say(*words): ''' Say some words. words The words to execute the say command with. CLI Example: .. code-block:: bash salt '*' desktop.say <word0> <word1> ... <wordN> ''' cmd = 'say {0}'.format(' '.join(words)) call = __salt__['cmd.run_all']( cmd, ou...
Check the output of the cmd.run_all function call.
def _check_cmd(call): ''' Check the output of the cmd.run_all function call. ''' if call['retcode'] != 0: comment = '' std_err = call.get('stderr') std_out = call.get('stdout') if std_err: comment += std_err if std_out: comment += std_out ...
r''' Create a list of Counter objects to be used in the pdh query Args: counter_list (list): A list of tuples containing counter information. Each tuple should contain the object, instance, and counter name. For example, to get the ``% Processor Time`` counter for al...
def build_counter_list(counter_list): r''' Create a list of Counter objects to be used in the pdh query Args: counter_list (list): A list of tuples containing counter information. Each tuple should contain the object, instance, and counter name. For example, to g...
Get the values for the passes list of counters Args: counter_list (list): A list of counters to lookup Returns: dict: A dictionary of counters and their values
def get_counters(counter_list): ''' Get the values for the passes list of counters Args: counter_list (list): A list of counters to lookup Returns: dict: A dictionary of counters and their values ''' if not isinstance(counter_list, list): raise CommandExecut...
r''' Makes a fully resolved counter path. Counter names are formatted like this: ``\Processor(*)\% Processor Time`` The above breaks down like this: obj = 'Processor' instance = '*' counter = '% Processor Time' Args: obj (str):...
def build_counter(obj, instance, instance_index, counter): r''' Makes a fully resolved counter path. Counter names are formatted like this: ``\Processor(*)\% Processor Time`` The above breaks down like this: obj = 'Processor' instance = '*' ...
Add the current path to the query Args: query (obj): The handle to the query to add the counter
def add_to_query(self, query): ''' Add the current path to the query Args: query (obj): The handle to the query to add the counter ''' self.handle = win32pdh.AddCounter(query, self.path)
Get information about the counter .. note:: GetCounterInfo sometimes crashes in the wrapper code. Fewer crashes if this is called after sampling data.
def get_info(self): ''' Get information about the counter .. note:: GetCounterInfo sometimes crashes in the wrapper code. Fewer crashes if this is called after sampling data. ''' if not self.info: ci = win32pdh.GetCounterInfo(self.handle, 0) ...
Return the counter value Returns: long: The counter value
def value(self): ''' Return the counter value Returns: long: The counter value ''' (counter_type, value) = win32pdh.GetFormattedCounterValue( self.handle, win32pdh.PDH_FMT_DOUBLE) self.type = counter_type return value
Returns the names of the flags that are set in the Type field It can be used to format the counter.
def type_string(self): ''' Returns the names of the flags that are set in the Type field It can be used to format the counter. ''' type = self.get_info()['type'] type_list = [] for member in dir(self): if member.startswith("PERF_"): bi...
Add the directory to the system PATH at index location index Position where the directory should be placed in the PATH. This is 0-indexed, so 0 means to prepend at the very start of the PATH. .. note:: If the index is not specified, and the directory needs to be added ...
def exists(name, index=None): ''' Add the directory to the system PATH at index location index Position where the directory should be placed in the PATH. This is 0-indexed, so 0 means to prepend at the very start of the PATH. .. note:: If the index is not specified, and...
Return a unique ID for this proxy minion. This ID MUST NOT CHANGE. If it changes while the proxy is running the salt-master will get really confused and may stop talking to this minion
def id(opts): ''' Return a unique ID for this proxy minion. This ID MUST NOT CHANGE. If it changes while the proxy is running the salt-master will get really confused and may stop talking to this minion ''' r = salt.utils.http.query(opts['proxy']['url']+'id', decode_type='json', decode=True) ...
Get the grains from the proxied device
def grains(): ''' Get the grains from the proxied device ''' if not DETAILS.get('grains_cache', {}): r = salt.utils.http.query(DETAILS['url']+'info', decode_type='json', decode=True) DETAILS['grains_cache'] = r['dict'] return DETAILS['grains_cache']
Start a "service" on the REST server
def service_start(name): ''' Start a "service" on the REST server ''' r = salt.utils.http.query(DETAILS['url']+'service/start/'+name, decode_type='json', decode=True) return r['dict']
List "services" on the REST server
def service_list(): ''' List "services" on the REST server ''' r = salt.utils.http.query(DETAILS['url']+'service/list', decode_type='json', decode=True) return r['dict']
Install a "package" on the REST server
def package_install(name, **kwargs): ''' Install a "package" on the REST server ''' cmd = DETAILS['url']+'package/install/'+name if kwargs.get('version', False): cmd += '/'+kwargs['version'] else: cmd += '/1.0' r = salt.utils.http.query(cmd, decode_type='json', decode=True) ...
Is the REST server up?
def ping(): ''' Is the REST server up? ''' r = salt.utils.http.query(DETAILS['url']+'ping', decode_type='json', decode=True) try: return r['dict'].get('ret', False) except Exception: return False
Make sure the given attributes exist on the file/directory name The path to the file/directory attributes The attributes that should exist on the file/directory, this is accepted as an array, with key and value split with an equals sign, if you want to specify a hex value then ...
def exists(name, attributes): ''' Make sure the given attributes exist on the file/directory name The path to the file/directory attributes The attributes that should exist on the file/directory, this is accepted as an array, with key and value split with an equals sign, if you...
Make sure the given attributes are deleted from the file/directory name The path to the file/directory attributes The attributes that should be removed from the file/directory, this is accepted as an array.
def delete(name, attributes): ''' Make sure the given attributes are deleted from the file/directory name The path to the file/directory attributes The attributes that should be removed from the file/directory, this is accepted as an array. ''' ret = {'name': name, ...
Check if a given path is writeable by the current user. :param path: The path to check :param check_parent: If the path to check does not exist, check for the ability to write to the parent directory instead :returns: True or False
def is_writeable(path, check_parent=False): ''' Check if a given path is writeable by the current user. :param path: The path to check :param check_parent: If the path to check does not exist, check for the ability to write to the parent directory instead :returns: True or False ''' ...
Check if a given path is readable by the current user. :param path: The path to check :returns: True or False
def is_readable(path): ''' Check if a given path is readable by the current user. :param path: The path to check :returns: True or False ''' if os.access(path, os.F_OK) and os.access(path, os.R_OK): # The path exists and is readable return True # The path does not exist ...
This function will parse the raw syslog data, dynamically create the topic according to the topic specified by the user (if specified) and decide whether to send the syslog data as an event on the master bus, based on the constraints given by the user. :param data: The raw syslog event ...
def parseData(self, data, host, port, options): ''' This function will parse the raw syslog data, dynamically create the topic according to the topic specified by the user (if specified) and decide whether to send the syslog data as an event on the master bus, based on the constr...
This function identifies whether the engine is running on the master or the minion and sends the data to the master event bus accordingly. :param result: It's a dictionary which has the final data and topic.
def send_event_to_salt(self, result): ''' This function identifies whether the engine is running on the master or the minion and sends the data to the master event bus accordingly. :param result: It's a dictionary which has the final data and topic. ''' if result['send'...
Get a value from a db, using a uri in the form of ``sdb://<profile>/<key>``. If the uri provided does not start with ``sdb://``, then it will be returned as-is.
def sdb_get(uri, opts, utils=None): ''' Get a value from a db, using a uri in the form of ``sdb://<profile>/<key>``. If the uri provided does not start with ``sdb://``, then it will be returned as-is. ''' if not isinstance(uri, string_types) or not uri.startswith('sdb://'): return uri i...
Check if value exists in sdb. If it does, return, otherwise generate a random string and store it. This can be used for storing secrets in a centralized place.
def sdb_get_or_set_hash(uri, opts, length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)', utils=None): ''' Check if value exists in sdb. If it does, return, otherwise generate a random string and ...
List all users. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.get_users
def get_users(profile='grafana'): ''' List all users. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.get_users ''' if isinstance(profile, string_types): profi...
Show a single user. login Login of the user. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.get_user <login>
def get_user(login, profile='grafana'): ''' Show a single user. login Login of the user. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.get_user <login> ''' ...
Update an existing user. userid Id of the user. login Optional - Login of the user. email Optional - Email of the user. name Optional - Full name of the user. orgid Optional - Default Organization of the user. profile Configuration profile us...
def update_user(userid, profile='grafana', orgid=None, **kwargs): ''' Update an existing user. userid Id of the user. login Optional - Login of the user. email Optional - Email of the user. name Optional - Full name of the user. orgid Optional - D...
Switch the current organization. name Name of the organization to switch to. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.switch_org <name>
def switch_org(orgname, profile='grafana'): ''' Switch the current organization. name Name of the organization to switch to. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*...
Update user role in the organization. userid Id of the user. loginOrEmail Login or email of the user. role Role of the user for this organization. Should be one of: - Admin - Editor - Read Only Editor - Viewer orgname Na...
def update_org_user(userid, orgname=None, profile='grafana', **kwargs): ''' Update user role in the organization. userid Id of the user. loginOrEmail Login or email of the user. role Role of the user for this organization. Should be one of: - Admin ...
Show a single datasource in an organisation. name Name of the datasource. orgname Name of the organization. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.g...
def get_datasource(name, orgname=None, profile='grafana'): ''' Show a single datasource in an organisation. name Name of the datasource. orgname Name of the organization. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. ...
Delete a datasource. datasourceid Id of the datasource. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash salt '*' grafana4.delete_datasource <datasource_id>
def delete_datasource(datasourceid, orgname=None, profile='grafana'): ''' Delete a datasource. datasourceid Id of the datasource. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. CLI Example: .. code-block:: bash sa...
Read in the generated libvirt keys
def ext_pillar(minion_id, pillar, # pylint: disable=W0613 command): # pylint: disable=W0613 ''' Read in the generated libvirt keys ''' key_dir = os.path.join( __opts__['pki_dir'], 'libvirt', minion_id) cacert = os.path.join(__opts__...
Generate the keys to be used by libvirt hypervisors, this routine gens the keys and applies them to the pillar for the hypervisor minions
def gen_hyper_keys(minion_id, country='US', state='Utah', locality='Salt Lake City', organization='Salted', expiration_days='365'): ''' Generate the keys to be used by libvirt hypervisors, this routine gens the ke...
Ensure key pair is present.
def key_present(name, save_private=None, upload_public=None, region=None, key=None, keyid=None, profile=None): ''' Ensure key pair is present. ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {} } exists = __salt__['boto_e...
Deletes a key pair
def key_absent(name, region=None, key=None, keyid=None, profile=None): ''' Deletes a key pair ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {} } exists = __salt__['boto_ec2.get_key'](name, region, key, keyid, profile) if exists: ...
Ensure the EC2 ENI exists. .. versionadded:: 2016.3.0 name Name tag associated with the ENI. subnet_id The VPC subnet ID the ENI will exist within. subnet_name The VPC subnet name the ENI will exist within. private_ip_address The private ip address to use for thi...
def eni_present( name, subnet_id=None, subnet_name=None, private_ip_address=None, description=None, groups=None, source_dest_check=True, allocate_eip=None, arecords=None, region=None, key=None, keyid=None, profile=No...
Ensure the EC2 ENI is absent. .. versionadded:: 2016.3.0 name Name tag associated with the ENI. release_eip True/False - release any EIP associated with the ENI region Region to connect to. key Secret key to be used. keyid Access key to be used. ...
def eni_absent( name, release_eip=False, region=None, key=None, keyid=None, profile=None): ''' Ensure the EC2 ENI is absent. .. versionadded:: 2016.3.0 name Name tag associated with the ENI. release_eip True/False - release any EIP a...
Create a snapshot from the given instance .. versionadded:: 2016.3.0
def snapshot_created(name, ami_name, instance_name, wait_until_available=True, wait_timeout_seconds=300, **kwargs): ''' Create a snapshot from the given instance .. versionadded:: 2016.3.0 ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {} ...
Ensure an EC2 instance is running with the given attributes and state. name (string) - The name of the state definition. Recommended that this match the instance_name attribute (generally the FQDN of the instance). instance_name (string) - The name of the instance, generally its FQDN. ...
def instance_present(name, instance_name=None, instance_id=None, image_id=None, image_name=None, tags=None, key_name=None, security_groups=None, user_data=None, instance_type=None, placement=None, kernel_id=None, ramdisk_id=None, vpc_id...
Ensure an EC2 instance does not exist (is stopped and removed). .. versionchanged:: 2016.11.0 name (string) - The name of the state definition. instance_name (string) - The name of the instance. instance_id (string) - The ID of the instance. release_eip (bool) - R...
def instance_absent(name, instance_name=None, instance_id=None, release_eip=False, region=None, key=None, keyid=None, profile=None, filters=None): ''' Ensure an EC2 instance does not exist (is stopped and removed). .. versionchanged:: 2016.11.0 name (str...
Ensure the EC2 volume is detached and absent. .. versionadded:: 2016.11.0 name State definition name. volume_name Name tag associated with the volume. For safety, if this matches more than one volume, the state will refuse to apply. volume_id Resource ID of the volum...
def volume_absent(name, volume_name=None, volume_id=None, instance_name=None, instance_id=None, device=None, region=None, key=None, keyid=None, profile=None): ''' Ensure the EC2 volume is detached and absent. .. versionadded:: 2016.11.0 name State definition name. volume...
Ensure EC2 volume(s) matching the given filters have the defined tags. .. versionadded:: 2016.11.0 name State definition name. tag_maps List of dicts of filters and tags, where 'filters' is a dict suitable for passing to the 'filters' argument of boto_ec2.get_all_volumes(), and 't...
def volumes_tagged(name, tag_maps, authoritative=False, region=None, key=None, keyid=None, profile=None): ''' Ensure EC2 volume(s) matching the given filters have the defined tags. .. versionadded:: 2016.11.0 name State definition name. tag_maps List of dicts of...
Ensure the EC2 volume is present and attached. .. name State definition name. volume_name The Name tag value for the volume. If no volume with that matching name tag is found, a new volume will be created. If multiple volumes are matched, the state will fail. volume_id ...
def volume_present(name, volume_name=None, volume_id=None, instance_name=None, instance_id=None, device=None, size=None, snapshot_id=None, volume_type=None, iops=None, encrypted=False, kms_key_id=None, region=None, key=None, keyid=None, profile=None): ''' ...
Ensure an ENI has secondary private ip addresses associated with it name (String) - State definition name network_interface_id (String) - The EC2 network interface id, example eni-123456789 private_ip_addresses (List or String) - The secondary private ip address(es) that should be p...
def private_ips_present(name, network_interface_name=None, network_interface_id=None, private_ip_addresses=None, allow_reassignment=False, region=None, key=None, keyid=None, profile=None): ''' Ensure an ENI has secondary private ip addresses associated with it ...
Ensure an ENI does not have secondary private ip addresses associated with it name (String) - State definition name network_interface_id (String) - The EC2 network interface id, example eni-123456789 private_ip_addresses (List or String) - The secondary private ip address(es) that s...
def private_ips_absent(name, network_interface_name=None, network_interface_id=None, private_ip_addresses=None, region=None, key=None, keyid=None, profile=None): ''' Ensure an ENI does not have secondary private ip addresses associated with it name (String) - State definitio...
Additional network-specific post-translation processing
def _post_processing(kwargs, skip_translate, invalid): # pylint: disable=unused-argument ''' Additional network-specific post-translation processing ''' # If any defaults were not expicitly passed, add them for item in DEFAULTS: if item not in kwargs: kwargs[item] = DEFAULTS[ite...
.. versionadded:: 2014.7.0 Read in the config and return the correct LocalClient object based on the configured transport :param IOLoop io_loop: io_loop used for events. Pass in an io_loop if you want asynchronous operation for obtaining events. Eg use...
def get_local_client( c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, skip_perm_errors=False, io_loop=None, auto_reconnect=False): ''' .. versionadded:: 2014.7.0 Read in the config and return the correct LocalClient object based on the configured ...
Read in the rotating master authentication key
def __read_master_key(self): ''' Read in the rotating master authentication key ''' key_user = self.salt_user if key_user == 'root': if self.opts.get('user', 'root') != 'root': key_user = self.opts.get('user', 'root') if key_user.startswith('su...
convert a seco.range range into a list target
def _convert_range_to_list(self, tgt): ''' convert a seco.range range into a list target ''' range_ = seco.range.Range(self.opts['range_server']) try: return range_.expand(tgt) except seco.range.RangeException as err: print('Range server exception:...
Return the timeout to use
def _get_timeout(self, timeout): ''' Return the timeout to use ''' if timeout is None: return self.opts['timeout'] if isinstance(timeout, int): return timeout if isinstance(timeout, six.string_types): try: return int(tim...
Return the information about a given job
def gather_job_info(self, jid, tgt, tgt_type, listen=True, **kwargs): ''' Return the information about a given job ''' log.debug('Checking whether jid %s is still running', jid) timeout = int(kwargs.get('gather_job_timeout', self.opts['gather_job_timeout'])) pub_data = s...
Common checks on the pub_data data structure returned from running pub
def _check_pub_data(self, pub_data, listen=True): ''' Common checks on the pub_data data structure returned from running pub ''' if pub_data == '': # Failed to authenticate, this could be a bunch of things raise EauthAuthenticationError( 'Failed to...
Asynchronously send a command to connected minions Prep the job directory and publish a command to any targeted minions. :return: A dictionary of (validated) ``pub_data`` or an empty dictionary on failure. The ``pub_data`` contains the job ID and a list of all minions that are ...
def run_job_async( self, tgt, fun, arg=(), tgt_type='glob', ret='', timeout=None, jid='', kwarg=None, listen=True, io_loop=None, **kwargs): ''' Asynchronously s...
Asynchronously send a command to connected minions Prep the job directory and publish a command to any targeted minions. :return: A dictionary of (validated) ``pub_data`` or an empty dictionary on failure. The ``pub_data`` contains the job ID and a list of all minions that are ...
def run_job( self, tgt, fun, arg=(), tgt_type='glob', ret='', timeout=None, jid='', kwarg=None, listen=False, **kwargs): ''' Asynchronously send a command to connected mini...
Asynchronously send a command to connected minions The function signature is the same as :py:meth:`cmd` with the following exceptions. :returns: A job ID or 0 on failure. .. code-block:: python >>> local.cmd_async('*', 'test.sleep', [300]) '2013121921592185771...
def cmd_async( self, tgt, fun, arg=(), tgt_type='glob', ret='', jid='', kwarg=None, **kwargs): ''' Asynchronously send a command to connected minions The function signature is the same as...
Execute a command on a random subset of the targeted systems The function signature is the same as :py:meth:`cmd` with the following exceptions. :param sub: The number of systems to execute on :param cli: When this is set to True, a generator is returned, otherwise ...
def cmd_subset( self, tgt, fun, arg=(), tgt_type='glob', ret='', kwarg=None, sub=3, cli=False, progress=False, full_return=False, **kwargs): ''' Execute a comma...
Iteratively execute a command on subsets of minions at a time The function signature is the same as :py:meth:`cmd` with the following exceptions. :param batch: The batch identifier of systems to execute on :returns: A generator of minion returns .. code-block:: python ...
def cmd_batch( self, tgt, fun, arg=(), tgt_type='glob', ret='', kwarg=None, batch='10%', **kwargs): ''' Iteratively execute a command on subsets of minions at a time The function signatur...
Synchronously execute a command on targeted minions The cmd method will execute and wait for the timeout period for all minions to reply, then it will return all minion data at once. .. code-block:: python >>> import salt.client >>> local = salt.client.LocalClient() ...
def cmd(self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', jid='', full_return=False, kwarg=None, **kwargs): ''' Synchronously execute a command on targeted minions ...
Used by the :command:`salt` CLI. This method returns minion returns as they come back and attempts to block until all minions return. The function signature is the same as :py:meth:`cmd` with the following exceptions. :param verbose: Print extra information about the running command ...
def cmd_cli( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', verbose=False, kwarg=None, progress=False, **kwargs): ''' Used by the :command:`salt` CLI. This ...
Yields the individual minion returns as they come in The function signature is the same as :py:meth:`cmd` with the following exceptions. Normally :py:meth:`cmd_iter` does not yield results for minions that are not connected. If you want it to return results for disconnected min...
def cmd_iter( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, **kwargs): ''' Yields the individual minion returns as they come in The function signature is the ...
Yields the individual minion returns as they come in, or None when no returns are available. The function signature is the same as :py:meth:`cmd` with the following exceptions. :returns: A generator yielding the individual minion returns, or None when no returns are ava...
def cmd_iter_no_block( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, show_jid=False, verbose=False, **kwargs): ''' Yields the individual minion...
Execute a salt command and return
def cmd_full_return( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', verbose=False, kwarg=None, **kwargs): ''' Execute a salt command and return ''' was_...
Starts a watcher looking at the return data for a specified JID :returns: all of the information for the JID
def get_cli_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', verbose=False, show_jid=False, **kwargs): ''' Starts a watcher looking at the return data for a specified JID ...
Raw function to just return events of jid excluding timeout logic Yield either the raw event data or None Pass a list of additional regular expressions as `tags_regex` to search the event bus for non-return data, such as minion lists returned from syndics.
def get_returns_no_block( self, tag, match_type=None): ''' Raw function to just return events of jid excluding timeout logic Yield either the raw event data or None Pass a list of additional regular expressions as `tags_regex` to search the e...
Watch the event system and return job data as it comes in :returns: all of the information for the JID
def get_iter_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', expect_minions=False, block=True, **kwargs): ''' Watch the event system and return job data as it comes in ...
Get the returns for the command line interface via the event system
def get_returns( self, jid, minions, timeout=None): ''' Get the returns for the command line interface via the event system ''' minions = set(minions) if timeout is None: timeout = self.opts['timeout'] start = in...
This method starts off a watcher looking at the return data for a specified jid, it returns all of the information for the jid
def get_full_returns(self, jid, minions, timeout=None): ''' This method starts off a watcher looking at the return data for a specified jid, it returns all of the information for the jid ''' # TODO: change this from ret to return... or the other way. # Its inconsist...
Execute a single pass to gather the contents of the job cache
def get_cache_returns(self, jid): ''' Execute a single pass to gather the contents of the job cache ''' ret = {} try: data = self.returners['{0}.get_jid'.format(self.opts['master_job_cache'])](jid) except Exception as exc: raise SaltClientError('C...
Get the returns for the command line interface via the event system
def get_cli_static_event_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', verbose=False, show_timeout=False, show_jid=False): ''' Get the returns for the command line interface...
Get the returns for the command line interface via the event system
def get_cli_event_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', verbose=False, progress=False, show_timeout=False, show_jid=False, **kwargs): ''' Get...
Gather the return data from the event system, break hard when timeout is reached.
def get_event_iter_returns(self, jid, minions, timeout=None): ''' Gather the return data from the event system, break hard when timeout is reached. ''' log.trace('entered - function get_event_iter_returns()') if timeout is None: timeout = self.opts['timeout'] ...
Set up the payload_kwargs to be sent down to the master
def _prep_pub(self, tgt, fun, arg, tgt_type, ret, jid, timeout, **kwargs): ''' Set up the payload_kwargs to be sent down to the master ''' if tg...
Take the required arguments and publish the given command. Arguments: tgt: The tgt is a regex or a glob used to match up the ids on the minions. Salt works by always publishing every command to all of the minions and then the minions determine if ...
def pub_async(self, tgt, fun, arg=(), tgt_type='glob', ret='', jid='', timeout=5, io_loop=None, listen=True, **kwargs): ''' ...
Find out what functions are available on the minion
def __load_functions(self): ''' Find out what functions are available on the minion ''' return set(self.local.cmd(self.minion, 'sys.list_functions').get(self.minion, []))
Return a function that executes the arguments passed via the local client
def run_key(self, key): ''' Return a function that executes the arguments passed via the local client ''' def func(*args, **kwargs): ''' Run a remote call ''' args = list(args) for _key, _val in kwargs: a...
Call an execution module with the given arguments and keyword arguments .. versionchanged:: 2015.8.0 Added the ``cmd`` method for consistency with the other Salt clients. The existing ``function`` and ``sminion.functions`` interfaces still exist but have been removed from th...
def cmd(self, fun, *args, **kwargs): ''' Call an execution module with the given arguments and keyword arguments .. versionchanged:: 2015.8.0 Added the ``cmd`` method for consistency with the other Salt clients. The existing ``function`` and ``sminion.functions`` interfa...
Call a single salt function
def function(self, fun, *args, **kwargs): ''' Call a single salt function ''' func = self.sminion.functions[fun] args, kwargs = salt.minion.load_args_and_kwargs( func, salt.utils.args.parse_input(args, kwargs=kwargs),) return func(*args, **kwargs)
Call an execution module with the given arguments and keyword arguments .. code-block:: python caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz') caller.cmd('event.send', 'myco/myevent/something', data={'foo': 'Foo'}, with_env=['GIT_COMMIT'], with_grains=True)
def cmd(self, fun, *args, **kwargs): ''' Call an execution module with the given arguments and keyword arguments .. code-block:: python caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz') caller.cmd('event.send', 'myco/myevent/something', data={'foo': 'Foo'...
Get the value of the setting for the provided class.
def _get_wmi_setting(wmi_class_name, setting, server): ''' Get the value of the setting for the provided class. ''' with salt.utils.winapi.Com(): try: connection = wmi.WMI(namespace=_WMI_NAMESPACE) wmi_class = getattr(connection, wmi_class_name) objs = wmi_cl...
Set the value of the setting for the provided class.
def _set_wmi_setting(wmi_class_name, setting, value, server): ''' Set the value of the setting for the provided class. ''' with salt.utils.winapi.Com(): try: connection = wmi.WMI(namespace=_WMI_NAMESPACE) wmi_class = getattr(connection, wmi_class_name) objs =...
Get all available log format names and ids. :return: A dictionary of the log format names and ids. :rtype: dict CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_log_format_types
def get_log_format_types(): ''' Get all available log format names and ids. :return: A dictionary of the log format names and ids. :rtype: dict CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_log_format_types ''' ret = dict() prefix = 'logging/' with s...
Get the SMTP virtual server names. :return: A list of the SMTP virtual servers. :rtype: list CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_servers
def get_servers(): ''' Get the SMTP virtual server names. :return: A list of the SMTP virtual servers. :rtype: list CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_servers ''' ret = list() with salt.utils.winapi.Com(): try: connection =...
Get the value of the setting for the SMTP virtual server. :param str settings: A list of the setting names. :param str server: The SMTP server name. :return: A dictionary of the provided settings and their values. :rtype: dict CLI Example: .. code-block:: bash salt '*' win_smtp_serv...
def get_server_setting(settings, server=_DEFAULT_SERVER): ''' Get the value of the setting for the SMTP virtual server. :param str settings: A list of the setting names. :param str server: The SMTP server name. :return: A dictionary of the provided settings and their values. :rtype: dict ...
Set the value of the setting for the SMTP virtual server. .. note:: The setting names are case-sensitive. :param str settings: A dictionary of the setting names and their values. :param str server: The SMTP server name. :return: A boolean representing whether all changes succeeded. :rtyp...
def set_server_setting(settings, server=_DEFAULT_SERVER): ''' Set the value of the setting for the SMTP virtual server. .. note:: The setting names are case-sensitive. :param str settings: A dictionary of the setting names and their values. :param str server: The SMTP server name. :r...
Get the active log format for the SMTP virtual server. :param str server: The SMTP server name. :return: A string of the log format name. :rtype: str CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_log_format
def get_log_format(server=_DEFAULT_SERVER): ''' Get the active log format for the SMTP virtual server. :param str server: The SMTP server name. :return: A string of the log format name. :rtype: str CLI Example: .. code-block:: bash salt '*' win_smtp_server.get_log_format '''...
Set the active log format for the SMTP virtual server. :param str log_format: The log format name. :param str server: The SMTP server name. :return: A boolean representing whether the change succeeded. :rtype: bool CLI Example: .. code-block:: bash salt '*' win_smtp_server.set_log_f...
def set_log_format(log_format, server=_DEFAULT_SERVER): ''' Set the active log format for the SMTP virtual server. :param str log_format: The log format name. :param str server: The SMTP server name. :return: A boolean representing whether the change succeeded. :rtype: bool CLI Example: ...