INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Recursive version of the default dict. update
def update(dest, upd, recursive_update=True, merge_lists=False): ''' Recursive version of the default dict.update Merges upd recursively into dest If recursive_update=False, will use the classic dict.update, or fall back on a manual merge (helpful for non-dict types like FunctionWrapper) If m...
Ensures that in_dict contains the series of recursive keys defined in keys.
def ensure_dict_key( in_dict, keys, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. :param dict in_dict: The dict to work with. :param str keys: The delimited string with one or more key...
Helper function to: - Ensure all but the last key in keys exist recursively in in_dict. - Return the dict at the one - to - last key and the last key
def _dict_rpartition( in_dict, keys, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Helper function to: - Ensure all but the last key in `keys` exist recursively in `in_dict`. - Return the dict at the one-to-last key, and the last key :param dict in_dict: T...
Ensures that in_dict contains the series of recursive keys defined in keys. Also sets whatever is at the end of in_dict traversed with keys to value.
def set_dict_key_value( in_dict, keys, value, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. Also sets whatever is at the end of `in_dict` traversed with `keys` to `value`. :par...
Ensures that in_dict contains the series of recursive keys defined in keys. Also updates the dict that is at the end of in_dict traversed with keys with value.
def update_dict_key_value( in_dict, keys, value, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. Also updates the dict, that is at the end of `in_dict` traversed with `keys`, with...
Ensures that in_dict contains the series of recursive keys defined in keys. Also appends value to the list that is at the end of in_dict traversed with keys.
def append_dict_key_value( in_dict, keys, value, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. Also appends `value` to the list that is at the end of `in_dict` traversed with `k...
Ensures that in_dict contains the series of recursive keys defined in keys. Also extends the list that is at the end of in_dict traversed with keys with value.
def extend_dict_key_value( in_dict, keys, value, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. Also extends the list, that is at the end of `in_dict` traversed with `keys`, with...
Return the active number of minions to maintain
def get_bnum(opts, minions, quiet): ''' Return the active number of minions to maintain ''' partition = lambda x: float(x) / 100.0 * len(minions) try: if '%' in opts['batch']: res = partition(float(opts['batch'].strip('%'))) if res < 1: return int(math...
Return a list of minions to use for the batch run
def __gather_minions(self): ''' Return a list of minions to use for the batch run ''' args = [self.opts['tgt'], 'test.ping', [], self.opts['timeout'], ] selected_target_option = self.opts.get('selected_target_option...
Execute the batch run
def run(self): ''' Execute the batch run ''' args = [[], self.opts['fun'], self.opts['arg'], self.opts['timeout'], 'list', ] bnum = self.get_bnum() # No targets to run if not self.mini...
Return the status for a service via dummy returns a bool whether the service is running.
def status(name, sig=None): ''' Return the status for a service via dummy, returns a bool whether the service is running. .. versionadded:: 2016.11.3 CLI Example: .. code-block:: bash salt '*' service.status <service name> ''' proxy_fn = 'dummy.service_status' resp = __p...
Send a message to an XMPP user
def send_msg(name, recipient, profile): ''' Send a message to an XMPP user .. code-block:: yaml server-warning-message: xmpp.send_msg: - name: 'This is a server warning message' - profile: my-xmpp-account - recipient: admins@xmpp.example.com/salt ...
Send a message to an list of recipients or rooms
def send_msg_multi(name, profile, recipients=None, rooms=None): ''' Send a message to an list of recipients or rooms .. code-block:: yaml server-warning-message: xmpp.send_msg: - name: 'This is a server warning message'...
Ensures a record is present.
def zone_present(domain, type, profile): ''' Ensures a record is present. :param domain: Zone name, i.e. the domain name :type domain: ``str`` :param type: Zone type (master / slave), defaults to master :type type: ``str`` :param profile: The profile key :type profile: ``str`` ...
Ensures a record is absent.
def zone_absent(domain, profile): ''' Ensures a record is absent. :param domain: Zone name, i.e. the domain name :type domain: ``str`` :param profile: The profile key :type profile: ``str`` ''' zones = __salt__['libcloud_dns.list_zones'](profile) matching_zone = [z for z in zones...
Ensures a record is present.
def record_present(name, zone, type, data, profile): ''' Ensures a record is present. :param name: Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string ('') for this ar...
Ensures a record is absent.
def record_absent(name, zone, type, data, profile): ''' Ensures a record is absent. :param name: Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string ('') for this argu...
.. versionadded:: 2014. 7. 0
def hash(value, algorithm='sha512'): ''' .. versionadded:: 2014.7.0 Encodes a value with the specified encoder. value The value to be hashed. algorithm : sha512 The algorithm to use. May be any valid algorithm supported by hashlib. CLI Example: .. code-block:: ba...
.. versionadded:: 2014. 7. 0
def str_encode(value, encoder='base64'): ''' .. versionadded:: 2014.7.0 value The value to be encoded. encoder : base64 The encoder to use on the subsequent string. CLI Example: .. code-block:: bash salt '*' random.str_encode 'I am a new string' base64 ''' if...
Generates a salted hash suitable for/ etc/ shadow.
def shadow_hash(crypt_salt=None, password=None, algorithm='sha512'): ''' Generates a salted hash suitable for /etc/shadow. crypt_salt : None Salt to be used in the generation of the hash. If one is not provided, a random salt will be generated. password : None Value to be salte...
Returns a random integer number between the start and end number.
def rand_int(start=1, end=10, seed=None): ''' Returns a random integer number between the start and end number. .. versionadded: 2015.5.3 start : 1 Any valid integer number end : 10 Any valid integer number seed : Optional hashable object .. versionchanged:: 2019...
Returns a random number within a range. Optional hash argument can be any hashable object. If hash is omitted or None the id of the minion is used.
def seed(range=10, hash=None): ''' Returns a random number within a range. Optional hash argument can be any hashable object. If hash is omitted or None, the id of the minion is used. .. versionadded: 2015.8.0 hash: None Any hashable object. range: 10 Any valid integer number ...
Grab MySQL Connection Details
def __get_connection_info(): ''' Grab MySQL Connection Details ''' conn_info = {} try: conn_info['hostname'] = __opts__['mysql_auth']['hostname'] conn_info['username'] = __opts__['mysql_auth']['username'] conn_info['password'] = __opts__['mysql_auth']['password'] con...
Authenticate using a MySQL user table
def auth(username, password): ''' Authenticate using a MySQL user table ''' _info = __get_connection_info() if _info is None: return False try: conn = MySQLdb.connect(_info['hostname'], _info['username'], _info['pass...
Create a check on a given URL.
def create(name, **params): '''Create a check on a given URL. Additional parameters can be used and are passed to API (for example interval, maxTime, etc). See the documentation https://github.com/fzaninotto/uptime for a full list of the parameters. CLI Example: .. code-block:: bash ...
Delete a check on a given URL
def delete(name): ''' Delete a check on a given URL CLI Example: .. code-block:: bash salt '*' uptime.delete http://example.org ''' if not check_exists(name): msg = "Trying to delete check that doesn't exists : {0}".format(name) log.error(msg) raise CommandExec...
List URL checked by uptime
def checks_list(): ''' List URL checked by uptime CLI Example: .. code-block:: bash salt '*' uptime.checks_list ''' application_url = _get_application_url() log.debug('[uptime] get checks') jcontent = requests.get('{0}/api/checks'.format(application_url)).json() return [x[...
Obtain/ renew a certificate from an ACME CA probably Let s Encrypt.
def cert(name, aliases=None, email=None, webroot=None, test_cert=False, renew=None, keysize=None, server=None, owner='root', group='root', mode='0640', certname=None, preferred_challenges=None, tls_sni_0...
Helper to call the vagrant functions. Wildcards supported.
def _vagrant_call(node, function, section, comment, status_when_done=None, **kwargs): ''' Helper to call the vagrant functions. Wildcards supported. :param node: The Salt-id or wildcard :param function: the vagrant submodule to call :param section: the name for the state call. :param comment: w...
r Defines and starts a new VM with specified arguments or restart a VM ( or group of VMs ). ( Runs vagrant up. )
def running(name, **kwargs): r''' Defines and starts a new VM with specified arguments, or restart a VM (or group of VMs). (Runs ``vagrant up``.) :param name: the Salt_id node name you wish your VM to have. If ``name`` contains a "?" or "*" then it will re-start a group of VMs which have been...
look for changes from any previous init of machine.
def _find_init_change(name, ret, **kwargs): ''' look for changes from any previous init of machine. :return: modified ret and kwargs ''' kwargs = salt.utils.args.clean_kwargs(**kwargs) if 'vm' in kwargs: kwargs.update(kwargs.pop('vm')) # the state processing eats 'runas' so we renam...
r Defines a new VM with specified arguments but does not start it.
def initialized(name, **kwargs): r''' Defines a new VM with specified arguments, but does not start it. :param name: the Salt_id node name you wish your VM to have. Each machine must be initialized individually using this function or the "vagrant.running" function, or the vagrant.init execution mo...
Retrieve GECOS field info and return it in dictionary form
def _get_gecos(name): ''' Retrieve GECOS field info and return it in dictionary form ''' try: gecos_field = pwd.getpwnam(name).pw_gecos.split(',', 3) except KeyError: raise CommandExecutionError( 'User \'{0}\' does not exist'.format(name) ) if not gecos_field:...
Add a user to the minion
def add(name, uid=None, gid=None, groups=None, home=None, shell=None, unique=True, fullname='', roomnumber='', workphone='', homephone='', createhome=True, loginclass=None, **kwargs): ''' Add a user to the mi...
Return the list of all info for all users
def getent(refresh=False): ''' Return the list of all info for all users CLI Example: .. code-block:: bash salt '*' user.getent ''' if 'user.getent' in __context__ and not refresh: return __context__['user.getent'] ret = [] for data in pwd.getpwall(): ret.appe...
Change the uid for a named user
def chuid(name, uid): ''' Change the uid for a named user CLI Example: .. code-block:: bash salt '*' user.chuid foo 4376 ''' pre_info = info(name) if not pre_info: raise CommandExecutionError( 'User \'{0}\' does not exist'.format(name) ) if uid == p...
Change the default login class of the user
def chloginclass(name, loginclass, root=None): ''' Change the default login class of the user .. versionadded:: 2016.3.5 CLI Example: .. code-block:: bash salt '*' user.chloginclass foo staff ''' if loginclass == get_loginclass(name): return True cmd = ['pw', 'usermo...
Return user information
def info(name): ''' Return user information CLI Example: .. code-block:: bash salt '*' user.info root ''' ret = {} try: data = pwd.getpwnam(name) ret['gid'] = data.pw_gid ret['groups'] = list_groups(name) ret['home'] = data.pw_dir ret['name'...
Get the login class of the user
def get_loginclass(name): ''' Get the login class of the user .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' user.get_loginclass foo ''' userinfo = __salt__['cmd.run_stdout'](['pw', 'usershow', '-n', name]) userinfo = userinfo.split(':') return u...
Change the username for a named user
def rename(name, new_name): ''' Change the username for a named user CLI Example: .. code-block:: bash salt '*' user.rename name new_name ''' current_info = info(name) if not current_info: raise CommandExecutionError('User \'{0}\' does not exist'.format(name)) new_info...
Open the connection to the Nexsu switch over the NX - API.
def init(opts): ''' Open the connection to the Nexsu switch over the NX-API. As the communication is HTTP based, there is no connection to maintain, however, in order to test the connectivity and make sure we are able to bring up this Minion, we are executing a very simple command (``show clock``) ...
Executes an RPC request over the NX - API.
def rpc(commands, method='cli', **kwargs): ''' Executes an RPC request over the NX-API. ''' conn_args = nxos_device['conn_args'] conn_args.update(kwargs) return __utils__['nxos_api.rpc'](commands, method=method, **conn_args)
Warning this is a picklable decorator !
def communicator(func): '''Warning, this is a picklable decorator !''' def _call(queue, args, kwargs): '''called with [queue, args, kwargs] as first optional arg''' kwargs['queue'] = queue ret = None try: ret = func(*args, **kwargs) queue.put('END') ...
Manage a multiprocessing pool
def enter_mainloop(target, mapped_args=None, args=None, kwargs=None, pool=None, pool_size=None, callback=None, queue=None): ''' Manage a multiprocessing pool - If the queue d...
This function will be called from another process when running a map in parallel mode. The result from the create is always a json object.
def create_multiprocessing(parallel_data, queue=None): ''' This function will be called from another process when running a map in parallel mode. The result from the create is always a json object. ''' salt.utils.crypt.reinit_crypto() parallel_data['opts']['output'] = 'json' cloud = Cloud(p...
This function will be called from another process when running a map in parallel mode. The result from the destroy is always a json object.
def destroy_multiprocessing(parallel_data, queue=None): ''' This function will be called from another process when running a map in parallel mode. The result from the destroy is always a json object. ''' salt.utils.crypt.reinit_crypto() parallel_data['opts']['output'] = 'json' clouds = salt...
This function will be called from another process when building the providers map.
def run_parallel_map_providers_query(data, queue=None): ''' This function will be called from another process when building the providers map. ''' salt.utils.crypt.reinit_crypto() cloud = Cloud(data['opts']) try: with salt.utils.context.func_globals_inject( cloud.clouds[...
Set the opts dict to defaults and allow for opts to be overridden in the kwargs
def _opts_defaults(self, **kwargs): ''' Set the opts dict to defaults and allow for opts to be overridden in the kwargs ''' # Let's start with the default salt cloud configuration opts = salt.config.DEFAULT_CLOUD_OPTS.copy() # Update it with the loaded configurati...
Pass the cloud function and low data structure to run
def low(self, fun, low): ''' Pass the cloud function and low data structure to run ''' l_fun = getattr(self, fun) f_call = salt.utils.args.format_call(l_fun, low) return l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))
List all available sizes in configured cloud systems
def list_sizes(self, provider=None): ''' List all available sizes in configured cloud systems ''' mapper = salt.cloud.Map(self._opts_defaults()) return salt.utils.data.simple_types_filter( mapper.size_list(provider) )
List all available images in configured cloud systems
def list_images(self, provider=None): ''' List all available images in configured cloud systems ''' mapper = salt.cloud.Map(self._opts_defaults()) return salt.utils.data.simple_types_filter( mapper.image_list(provider) )
List all available locations in configured cloud systems
def list_locations(self, provider=None): ''' List all available locations in configured cloud systems ''' mapper = salt.cloud.Map(self._opts_defaults()) return salt.utils.data.simple_types_filter( mapper.location_list(provider) )
Query select instance information
def min_query(self, query_type='list_nodes_min'): ''' Query select instance information ''' mapper = salt.cloud.Map(self._opts_defaults()) mapper.opts['selected_query_option'] = 'list_nodes_min' return mapper.map_providers_parallel(query_type)
Pass in a profile to create names is a list of vm names to allocate
def profile(self, profile, names, vm_overrides=None, **kwargs): ''' Pass in a profile to create, names is a list of vm names to allocate vm_overrides is a special dict that will be per node options overrides Example: .. code-block:: python >>> clie...
To execute a map
def map_run(self, path=None, **kwargs): ''' To execute a map ''' kwarg = {} if path: kwarg['map'] = path kwarg.update(kwargs) mapper = salt.cloud.Map(self._opts_defaults(**kwarg)) dmap = mapper.map_data() return salt.utils.data.simple_t...
Destroy the named VMs
def destroy(self, names): ''' Destroy the named VMs ''' mapper = salt.cloud.Map(self._opts_defaults(destroy=True)) if isinstance(names, six.string_types): names = names.split(',') return salt.utils.data.simple_types_filter( mapper.destroy(names) ...
Create the named VMs without using a profile
def create(self, provider, names, **kwargs): ''' Create the named VMs, without using a profile Example: .. code-block:: python client.create(provider='my-ec2-config', names=['myinstance'], image='ami-1624987f', size='t1.micro', ssh_username='ec2-user', ...
Perform actions with block storage devices
def extra_action(self, names, provider, action, **kwargs): ''' Perform actions with block storage devices Example: .. code-block:: python client.extra_action(names=['myblock'], action='volume_create', provider='my-nova', kwargs={'voltype': 'SSD', 'size': 10...
Execute a single action via the cloud plugin backend
def action( self, fun=None, cloudmap=None, names=None, provider=None, instance=None, kwargs=None ): ''' Execute a single action via the cloud plugin backend Examples: .. code-block:: python client.action(fun='show...
Return the configured providers
def get_configured_providers(self): ''' Return the configured providers ''' providers = set() for alias, drivers in six.iteritems(self.opts['providers']): if len(drivers) > 1: for driver in drivers: providers.add('{0}:{1}'.format(al...
Get a dict describing the configured providers
def lookup_providers(self, lookup): ''' Get a dict describing the configured providers ''' if lookup is None: lookup = 'all' if lookup == 'all': providers = set() for alias, drivers in six.iteritems(self.opts['providers']): for ...
Return a dictionary describing the configured profiles
def lookup_profiles(self, provider, lookup): ''' Return a dictionary describing the configured profiles ''' if provider is None: provider = 'all' if lookup is None: lookup = 'all' if lookup == 'all': profiles = set() provid...
Return a mapping of what named VMs are running on what VM providers based on what providers are defined in the configuration and VMs
def map_providers(self, query='list_nodes', cached=False): ''' Return a mapping of what named VMs are running on what VM providers based on what providers are defined in the configuration and VMs ''' if cached is True and query in self.__cached_provider_queries: retur...
Return a mapping of what named VMs are running on what VM providers based on what providers are defined in the configuration and VMs
def map_providers_parallel(self, query='list_nodes', cached=False): ''' Return a mapping of what named VMs are running on what VM providers based on what providers are defined in the configuration and VMs Same as map_providers but query in parallel. ''' if cached is True...
Return an optimized mapping of available providers
def _optimize_providers(self, providers): ''' Return an optimized mapping of available providers ''' new_providers = {} provider_by_driver = {} for alias, driver in six.iteritems(providers): for name, data in six.iteritems(driver): if name not...
Return a mapping of all image data for available providers
def image_list(self, lookup='all'): ''' Return a mapping of all image data for available providers ''' data = {} lookups = self.lookup_providers(lookup) if not lookups: return data for alias, driver in lookups: fun = '{0}.avail_images'.fo...
Return a mapping of all image data for available providers
def provider_list(self, lookup='all'): ''' Return a mapping of all image data for available providers ''' data = {} lookups = self.lookup_providers(lookup) if not lookups: return data for alias, driver in lookups: if alias not in data: ...
Return a mapping of all configured profiles
def profile_list(self, provider, lookup='all'): ''' Return a mapping of all configured profiles ''' data = {} lookups = self.lookup_profiles(provider, lookup) if not lookups: return data for alias, driver in lookups: if alias not in data:...
Create/ Verify the VMs in the VM data
def create_all(self): ''' Create/Verify the VMs in the VM data ''' ret = [] for vm_name, vm_details in six.iteritems(self.opts['profiles']): ret.append( {vm_name: self.create(vm_details)} ) return ret
Destroy the named VMs
def destroy(self, names, cached=False): ''' Destroy the named VMs ''' processed = {} names = set(names) matching = self.get_running_by_names(names, cached=cached) vms_to_destroy = set() parallel_data = [] for alias, drivers in six.iteritems(matchin...
Reboot the named VMs
def reboot(self, names): ''' Reboot the named VMs ''' ret = [] pmap = self.map_providers_parallel() acts = {} for prov, nodes in six.iteritems(pmap): acts[prov] = [] for node in nodes: if node in names: a...
Create a single VM
def create(self, vm_, local_master=True): ''' Create a single VM ''' output = {} minion_dict = salt.config.get_cloud_config_value( 'minion', vm_, self.opts, default={} ) alias, driver = vm_['provider'].split(':') fun = '{0}.create'.format(dri...
Create vm config.
def vm_config(name, main, provider, profile, overrides): ''' Create vm config. :param str name: The name of the vm :param dict main: The main cloud config :param dict provider: The provider config :param dict profile: The profile config :param dict overrides: The...
Extra actions
def extras(self, extra_): ''' Extra actions ''' output = {} alias, driver = extra_['provider'].split(':') fun = '{0}.{1}'.format(driver, extra_['action']) if fun not in self.clouds: log.error( 'Creating \'%s\' using \'%s\' as the provi...
Parse over the options passed on the command line and determine how to handle them
def run_profile(self, profile, names, vm_overrides=None): ''' Parse over the options passed on the command line and determine how to handle them ''' if profile not in self.opts['profiles']: msg = 'Profile {0} is not defined'.format(profile) log.error(msg) ...
Perform an action on a VM which may be specific to this cloud provider
def do_action(self, names, kwargs): ''' Perform an action on a VM which may be specific to this cloud provider ''' ret = {} invalid_functions = {} names = set(names) for alias, drivers in six.iteritems(self.map_providers_parallel()): if not names: ...
Perform a function against a cloud provider
def do_function(self, prov, func, kwargs): ''' Perform a function against a cloud provider ''' matches = self.lookup_providers(prov) if len(matches) > 1: raise SaltCloudSystemExit( 'More than one results matched \'{0}\'. Please specify ' ...
Remove any mis - configured cloud providers from the available listing
def __filter_non_working_providers(self): ''' Remove any mis-configured cloud providers from the available listing ''' for alias, drivers in six.iteritems(self.opts['providers'].copy()): for driver in drivers.copy(): fun = '{0}.get_configured_provider'.format(...
Read in the specified map and return the map structure
def read(self): ''' Read in the specified map and return the map structure ''' map_ = None if self.opts.get('map', None) is None: if self.opts.get('map_data', None) is None: if self.opts.get('map_pillar', None) is None: pass ...
Create a data map of what to execute on
def map_data(self, cached=False): ''' Create a data map of what to execute on ''' ret = {'create': {}} pmap = self.map_providers_parallel(cached=cached) exist = set() defined = set() rendered_map = copy.deepcopy(self.rendered_map) for profile_name,...
Execute the contents of the VM map
def run_map(self, dmap): ''' Execute the contents of the VM map ''' if self._has_loop(dmap): msg = 'Uh-oh, that cloud map has a dependency loop!' log.error(msg) raise SaltCloudException(msg) # Go through the create list and calc dependencies ...
Wrapper for user. info Salt function
def _get_user_info(user=None): ''' Wrapper for user.info Salt function ''' if not user: # Get user Salt runnining as user = __salt__['config.option']('user') userinfo = __salt__['user.info'](user) if not userinfo: if user == 'salt': # Special case with `salt...
Return default GnuPG home directory path for a user
def _get_user_gnupghome(user): ''' Return default GnuPG home directory path for a user ''' if user == 'salt': gnupghome = os.path.join(__salt__['config.get']('config_dir'), 'gpgkeys') else: gnupghome = os.path.join(_get_user_info(user)['home'], '.gnupg') return gnupghome
Create the GPG object
def _create_gpg(user=None, gnupghome=None): ''' Create the GPG object ''' if not gnupghome: gnupghome = _get_user_gnupghome(user) if GPG_1_3_1: gpg = gnupg.GPG(homedir=gnupghome) else: gpg = gnupg.GPG(gnupghome=gnupghome) return gpg
Helper function for Listing keys
def _list_keys(user=None, gnupghome=None, secret=False): ''' Helper function for Listing keys ''' gpg = _create_gpg(user, gnupghome) _keys = gpg.list_keys(secret) return _keys
Helper function for searching keys from keyserver
def _search_keys(text, keyserver, user=None): ''' Helper function for searching keys from keyserver ''' gpg = _create_gpg(user) if keyserver: _keys = gpg.search_keys(text, keyserver) else: _keys = gpg.search_keys(text) return _keys
Search keys from keyserver
def search_keys(text, keyserver=None, user=None): ''' Search keys from keyserver text Text to search the keyserver for, e.g. email address, keyID or fingerprint. keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu. user Which user's keychain to a...
List keys in GPG keychain
def list_keys(user=None, gnupghome=None): ''' List keys in GPG keychain user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``. gnupghome Specify the location...
Create a key in the GPG keychain
def create_key(key_type='RSA', key_length=1024, name_real='Autogenerated Key', name_comment='Generated by SaltStack', name_email=None, subkey_type=None, subkey_length=None, expire_date=None, use_passp...
Get a key from the GPG keychain
def delete_key(keyid=None, fingerprint=None, delete_secret=False, user=None, gnupghome=None): ''' Get a key from the GPG keychain keyid The keyid of the key to be deleted. fingerprint The fingerprint of the key to be deleted. ...
Get a key from the GPG keychain
def get_key(keyid=None, fingerprint=None, user=None, gnupghome=None): ''' Get a key from the GPG keychain keyid The key ID (short or long) of the key to be retrieved. fingerprint The fingerprint of the key to be retrieved. user Which user's keychain to access, defaults to ...
r Import a key from text or file
def import_key(text=None, filename=None, user=None, gnupghome=None): r''' Import a key from text or file text The text containing to import. filename The filename containing the key to import. user Which user's keychain to acces...
Export a key from the GPG keychain
def export_key(keyids=None, secret=False, user=None, gnupghome=None): ''' Export a key from the GPG keychain keyids The key ID(s) of the key(s) to be exported. Can be specified as a comma separated string or a list. Anything which GnuPG itself accepts to identify a key - for example...
Receive key ( s ) from keyserver and add them to keychain
def receive_keys(keyserver=None, keys=None, user=None, gnupghome=None): ''' Receive key(s) from keyserver and add them to keychain keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu keys The keyID(s) to retrieve from the keyserver. Can be specified as a com...
Set the trust level for a key in GPG keychain
def trust_key(keyid=None, fingerprint=None, trust_level=None, user=None): ''' Set the trust level for a key in GPG keychain keyid The keyid of the key to set the trust level for. fingerprint The fingerprint of the key to set the trust level for...
Sign message or file
def sign(user=None, keyid=None, text=None, filename=None, output=None, use_passphrase=False, gnupghome=None): ''' Sign message or file user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`...
Verify a message or file
def verify(text=None, user=None, filename=None, gnupghome=None, signature=None, trustmodel=None): ''' Verify a message or file text The text to verify. filename The filename to verify. user Which user's keychain to acc...
Encrypt a message or file
def encrypt(user=None, recipients=None, text=None, filename=None, output=None, sign=None, use_passphrase=False, gnupghome=None, bare=False): ''' Encrypt a message or file user Which user's keychain to ac...
Decrypt a message or file
def decrypt(user=None, text=None, filename=None, output=None, use_passphrase=False, gnupghome=None, bare=False): ''' Decrypt a message or file user Which user's keychain to access, defaults to user Salt is running as. P...
.. versionadded:: 2018. 3. 4
def pack(o, stream, **kwargs): ''' .. versionadded:: 2018.3.4 Wraps msgpack.pack and ensures that the passed object is unwrapped if it is a proxy. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate ms...