Search is not available for this dataset
text
stringlengths
75
104k
def render(jinja_template_text=None, jinja_template_function='highstate_doc.markdown_default_jinja_template', **kwargs): ''' Render highstate to a text format (default Markdown) if `jinja_template_text` is not set, `jinja_template_function` is used. jinja_template_text: jinja text that the render uses...
def proccess_lowstates(**kwargs): ''' return proccessed lowstate data that was not blacklisted render_module_function is used to provide your own. defaults to from_lowstate ''' states = [] config = _get_config(**kwargs) proccesser = config.get('proccesser') ls = __salt__['state.show...
def _state_data_to_yaml_string(data, whitelist=None, blacklist=None): ''' return a data dict in yaml string format. ''' y = {} if blacklist is None: # TODO: use salt defined STATE_REQUISITE_IN_KEYWORDS STATE_RUNTIME_KEYWORDS STATE_INTERNAL_KEYWORDS blacklist = ['__env__', '__id__',...
def _format_markdown_requisite(state, stateid, makelink=True): ''' format requisite as a link users can click ''' fmt_id = '{0}: {1}'.format(state, stateid) if makelink: return ' * [{0}](#{1})\n'.format(fmt_id, _format_markdown_link(fmt_id)) else: return ' * `{0}`\n'.format(fmt_i...
def proccesser_markdown(lowstate_item, config, **kwargs): ''' Takes low state data and returns a dict of proccessed data that is by default used in a jinja template when rendering a markdown highstate_doc. This `lowstate_item_markdown` given a lowstate item, returns a dict like: .. code-block:: ya...
def os_version_info_ex(): ''' Helper function to return the results of the GetVersionExW Windows API call. It is a ctypes Structure that contains Windows OS Version information. Returns: class: An instance of a class containing version info ''' if not HAS_WIN32: return clas...
def get_join_info(): ''' Gets information about the domain/workgroup. This will tell you if the system is joined to a domain or a workgroup .. version-added:: 2018.3.4 Returns: dict: A dictionary containing the domain/workgroup and it's status ''' info = win32net.NetGetJoinInformat...
def _dscl(cmd, ctype='create'): ''' Run a dscl -create command ''' if __grains__['osrelease_info'] < (10, 8): source, noderoot = '.', '' else: source, noderoot = 'localhost', '/Local/Default' if noderoot: cmd[0] = noderoot + cmd[0] return __salt__['cmd.run_all']( ...
def add(name, uid=None, gid=None, groups=None, home=None, shell=None, fullname=None, createhome=True, **kwargs): ''' Add a user to the minion CLI Example: .. code-block:: bash salt '*' user.add name <uid> <gid> <groups> <home> <s...
def delete(name, remove=False, force=False): ''' Remove a user from the minion CLI Example: .. code-block:: bash salt '*' user.delete name remove=True force=True ''' if salt.utils.stringutils.contains_whitespace(name): raise SaltInvocationError('Username cannot contain whitesp...
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...
def chuid(name, uid): ''' Change the uid for a named user CLI Example: .. code-block:: bash salt '*' user.chuid foo 4376 ''' if not isinstance(uid, int): raise SaltInvocationError('uid must be an integer') pre_info = info(name) if not pre_info: raise CommandExe...
def chgid(name, gid): ''' Change the default group of the user CLI Example: .. code-block:: bash salt '*' user.chgid foo 4376 ''' if not isinstance(gid, int): raise SaltInvocationError('gid must be an integer') pre_info = info(name) if not pre_info: raise Comma...
def chshell(name, shell): ''' Change the default shell of the user CLI Example: .. code-block:: bash salt '*' user.chshell foo /bin/zsh ''' pre_info = info(name) if not pre_info: raise CommandExecutionError('User \'{0}\' does not exist'.format(name)) if shell == pre_in...
def chhome(name, home, **kwargs): ''' Change the home directory of the user CLI Example: .. code-block:: bash salt '*' user.chhome foo /Users/foo ''' kwargs = salt.utils.args.clean_kwargs(**kwargs) persist = kwargs.pop('persist', False) if kwargs: salt.utils.args.inval...
def chfullname(name, fullname): ''' Change the user's Full Name CLI Example: .. code-block:: bash salt '*' user.chfullname foo 'Foo Bar' ''' fullname = salt.utils.data.decode(fullname) pre_info = info(name) if not pre_info: raise CommandExecutionError('User \'{0}\' doe...
def chgroups(name, groups, append=False): ''' Change the groups to which the user belongs. Note that the user's primary group does not have to be one of the groups passed, membership in the user's primary group is automatically assumed. groups Groups to which the user should belong, can be ...
def _format_info(data): ''' Return user information in a pretty way ''' return {'gid': data.pw_gid, 'groups': list_groups(data.pw_name), 'home': data.pw_dir, 'name': data.pw_name, 'shell': data.pw_shell, 'uid': data.pw_uid, 'fullnam...
def list_groups(name): ''' Return a list of groups the named user belongs to. name The name of the user for which to list groups. Starting in Salt 2016.11.0, all groups for the user, including groups beginning with an underscore will be listed. .. versionchanged:: 2016.11....
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...
def get_auto_login(): ''' .. versionadded:: 2016.3.0 Gets the current setting for Auto Login :return: If enabled, returns the user name, otherwise returns False :rtype: str, bool CLI Example: .. code-block:: bash salt '*' user.get_auto_login ''' cmd = ['defaults', ...
def _kcpassword(password): ''' Internal function for obfuscating the password used for AutoLogin This is later written as the contents of the ``/etc/kcpassword`` file .. versionadded:: 2017.7.3 Adapted from: https://github.com/timsutton/osx-vm-templates/blob/master/scripts/support/set_kcpasswo...
def enable_auto_login(name, password): ''' .. versionadded:: 2016.3.0 Configures the machine to auto login with the specified user Args: name (str): The user account use for auto login password (str): The password to user for auto login .. versionadded:: 2017.7.3 Re...
def disable_auto_login(): ''' .. versionadded:: 2016.3.0 Disables auto login on the machine Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt '*' user.disable_auto_login ''' # Remove the kcpassword file cmd = 'rm -f...
def __apf_cmd(cmd): ''' Return the apf location ''' apf_cmd = '{0} {1}'.format(salt.utils.path.which('apf'), cmd) out = __salt__['cmd.run_all'](apf_cmd) if out['retcode'] != 0: if not out['stderr']: msg = out['stdout'] else: msg = out['stderr'] ra...
def _status_apf(): ''' Return True if apf is running otherwise return False ''' status = 0 table = iptc.Table(iptc.Table.FILTER) for chain in table.chains: if 'sanity' in chain.name.lower(): status = 1 return True if status else False
def did_composer_install(dir): ''' Test to see if the vendor directory exists in this directory dir Directory location of the composer.json file CLI Example: .. code-block:: bash salt '*' composer.did_composer_install /var/www/application ''' lockFile = "{0}/vendor".forma...
def _run_composer(action, directory=None, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimiz...
def install(directory, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimize=None, no_dev=None, quiet=False, composer_home='...
def selfupdate(composer=None, php=None, runas=None, quiet=False, composer_home='/root'): ''' Update composer itself. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` pa...
def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync all custom types saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelist : None dictionary of modules...
def sync_auth(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync execution modules from ``salt://_auth`` to the master saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelis...
def avail_images(call=None): ''' Return available Packet os images. CLI Example: .. code-block:: bash salt-cloud --list-images packet-provider salt-cloud -f avail_images packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_images fu...
def avail_locations(call=None): ''' Return available Packet datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations packet-provider salt-cloud -f avail_locations packet-provider ''' if call == 'action': raise SaltCloudException( ...
def avail_sizes(call=None): ''' Return available Packet sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes packet-provider salt-cloud -f avail_sizes packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_locations functi...
def avail_projects(call=None): ''' Return available Packet projects. CLI Example: .. code-block:: bash salt-cloud -f avail_projects packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_projects function must be called with -f or --function....
def _wait_for_status(status_type, object_id, status=None, timeout=500, quiet=True): ''' Wait for a certain status from Packet. status_type device or volume object_id The ID of the Packet device or volume to wait on. Required. status The status to wait for. timeout ...
def create(vm_): ''' Create a single Packet VM. ''' name = vm_['name'] if not is_profile_configured(vm_): return False __utils__['cloud.fire_event']( 'event', 'starting create', 'salt/cloud/{0}/creating'.format(name), args=__utils__['cloud.filter_event']...
def list_nodes_full(call=None): ''' List devices, with all available information. CLI Example: .. code-block:: bash salt-cloud -F salt-cloud --full-query salt-cloud -f list_nodes_full packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
def list_nodes_min(call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt...
def list_nodes(call=None): ''' Returns a list of devices, keeping only a brief listing. CLI Example: .. code-block:: bash salt-cloud -Q salt-cloud --query salt-cloud -f list_nodes packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
def destroy(name, call=None): ''' Destroys a Packet device by name. name The hostname of VM to be be destroyed. CLI Example: .. code-block:: bash salt-cloud -d name ''' if call == 'function': raise SaltCloudException( 'The destroy action must be called...
def beacon(config): ''' Poll imgadm and compare available images ''' ret = [] # NOTE: lookup current images current_images = __salt__['imgadm.list'](verbose=True) # NOTE: apply configuration if IMGADM_STATE['first_run']: log.info('Applying configuration for imgadm beacon') ...
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument ''' Optionally mock a decorator that takes parameters E.g.: @blah(stuff=True) def things(): pass ''' def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument if hasattr(fn, '__...
def absent(name, user=None, signal=None): ''' Ensures that the named command is not running. name The pattern to match. user The user to which the process belongs signal Signal to send to the process(es). ''' ret = {'name': name, 'changes': {}, ...
def ext_pillar(minion_id, pillar, *args, **kwargs): ''' Query NetBox API for minion data ''' if minion_id == '*': log.info('There\'s no data to collect from NetBox for the Master') return {} # Pull settings from kwargs api_url = kwargs['api_url'].rstrip('/') api_token = kwarg...
def top(**kwargs): ''' Run the command configured ''' if 'id' not in kwargs['opts']: return {} cmd = '{0} {1}'.format( __opts__['master_tops']['ext_nodes'], kwargs['opts']['id'] ) ndata = salt.utils.yaml.safe_load( subprocess.Popen( ...
def _check_current_value(gnome_kwargs, value): ''' Check the current value with the passed value ''' current_value = __salt__['gnome.get'](**gnome_kwargs) return six.text_type(current_value) == six.text_type(value)
def _do(name, gnome_kwargs, preferences): ''' worker function for the others to use this handles all the gsetting magic ''' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} messages = [] for pref in preferences: key = pref ...
def wm_preferences(name, user=None, action_double_click_titlebar=None, action_middle_click_titlebar=None, action_right_click_titlebar=None, application_based=None, audible_bell=None, auto...
def desktop_lockdown(name, user=None, disable_application_handlers=None, disable_command_line=None, disable_lock_screen=None, disable_log_out=None, disable_print_setup=None, ...
def desktop_interface(name, user=None, automatic_mnemonics=None, buttons_have_icons=None, can_change_accels=None, clock_format=None, clock_show_date=None, clock_show_...
def deserialize(stream_or_string, **options): ''' Deserialize from TOML into Python data structure. :param stream_or_string: toml stream or string to deserialize. :param options: options given to lower pytoml module. ''' try: if not isinstance(stream_or_string, (bytes, six.string_types...
def serialize(obj, **options): ''' Serialize Python data to TOML. :param obj: the data structure to serialize. :param options: options given to lower pytoml module. ''' try: if 'file_out' in options: return toml.dump(obj, options['file_out'], **options) else: ...
def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws): ''' Render the template_file, passing the functions and grains into the Mako rendering system. :rtype: string ''' tmp_data = salt.utils.templates.MAKO(template_file, to_str=True, salt=__sa...
def init(opts): ''' This function gets called when the proxy starts up. We check opts to see if a fallback user and password are supplied. If they are present, and the primary credentials don't work, then we try the backup before failing. Whichever set of credentials works is placed in the pers...
def _grains(host, user, password): ''' Get the grains from the proxied device ''' r = __salt__['dracr.system_info'](host=host, admin_username=user, admin_password=password) if r.get('retcode', 0) == 0: GRAINS_CACHE =...
def find_credentials(): ''' Cycle through all the possible credentials and return the first one that works ''' usernames = [__pillar__['proxy'].get('admin_username', 'root')] if 'fallback_admin_username' in __pillar__.get('proxy'): usernames.append(__pillar__['proxy'].get('fallback_admin...
def chconfig(cmd, *args, **kwargs): ''' This function is called by the :mod:`salt.modules.chassis.cmd <salt.modules.chassis.cmd>` shim. It then calls whatever is passed in ``cmd`` inside the :mod:`salt.modules.dracr <salt.modules.dracr>` module. :param cmd: The command to call inside salt.modu...
def ping(): ''' Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise. ''' r = __salt__['dracr.system_info'](host=DETAILS['host'], admin_username=DETAILS['admin_username'], admin_p...
def store(bank, key, data): ''' Store a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: c_data = __context__['serial'].dumps(data) api.kv.put(c_key, c_data) except Exception as exc: raise SaltCacheError( 'There was an error writing the key, {0}: {1}'.f...
def fetch(bank, key): ''' Fetch a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: _, value = api.kv.get(c_key) if value is None: return {} return __context__['serial'].loads(value['Value']) except Exception as exc: raise SaltCacheError( ...
def flush(bank, key=None): ''' Remove the key from the cache bank with all the key content. ''' if key is None: c_key = bank else: c_key = '{0}/{1}'.format(bank, key) try: return api.kv.delete(c_key, recurse=key is None) except Exception as exc: raise SaltCach...
def list_(bank): ''' Return an iterable object containing all entries stored in the specified bank. ''' try: _, keys = api.kv.get(bank + '/', keys=True, separator='/') except Exception as exc: raise SaltCacheError( 'There was an error getting the key "{0}": {1}'.format( ...
def contains(bank, key): ''' Checks if the specified bank contains the specified key. ''' if key is None: return True # any key could be a branch and a leaf at the same time in Consul else: try: c_key = '{0}/{1}'.format(bank, key) _, value = api.kv.get(c_key)...
def set_pixel(x, y, color): ''' Sets a single pixel on the LED matrix to a specified color. x The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right. y The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom. color The new color of the ...
def show_message(message, msg_type=None, text_color=None, back_color=None, scroll_speed=0.1): ''' Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: ...
def show_letter(letter, text_color=None, back_color=None): ''' Displays a single letter on the LED matrix. letter The letter to display text_color The color in which the letter is shown. Defaults to '[255, 255, 255]' (white). back_color The background color of the display. D...
def _add(app, endpoint, payload): ''' POST a payload ''' nb = _nb_obj(auth_required=True) try: return getattr(getattr(nb, app), endpoint).create(**payload) except RequestError as e: log.error('%s, %s, %s', e.req.request.headers, e.request_body, e.error) return False
def slugify(value): '''' Slugify given value. Credit to Djangoproject https://docs.djangoproject.com/en/2.0/_modules/django/utils/text/#slugify ''' value = re.sub(r'[^\w\s-]', '', value).strip().lower() return re.sub(r'[-\s]+', '-', value)
def _get(app, endpoint, id=None, auth_required=False, **kwargs): ''' Helper function to do a GET request to Netbox. Returns the actual pynetbox object, which allows manipulation from other functions. ''' nb = _nb_obj(auth_required=auth_required) if id: item = getattr(getattr(nb, app), en...
def filter_(app, endpoint, **kwargs): ''' Get a list of items from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` kwargs Optional arguments that can be used to filter. ...
def get_(app, endpoint, id=None, **kwargs): ''' Get a single item from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` Returns a single dictionary To get an item based on ID. ...
def create_manufacturer(name): ''' .. versionadded:: 2019.2.0 Create a device manufacturer. name The name of the manufacturer, e.g., ``Juniper`` CLI Example: .. code-block:: bash salt myminion netbox.create_manufacturer Juniper ''' nb_man = get_('dcim', 'manufacturer...
def create_device_type(model, manufacturer): ''' .. versionadded:: 2019.2.0 Create a device type. If the manufacturer doesn't exist, create a new manufacturer. model String of device model, e.g., ``MX480`` manufacturer String of device manufacturer, e.g., ``Juniper`` CLI Examp...
def create_device_role(role, color): ''' .. versionadded:: 2019.2.0 Create a device role role String of device role, e.g., ``router`` CLI Example: .. code-block:: bash salt myminion netbox.create_device_role router ''' nb_role = get_('dcim', 'device-roles', name=role...
def create_platform(platform): ''' .. versionadded:: 2019.2.0 Create a new device platform platform String of device platform, e.g., ``junos`` CLI Example: .. code-block:: bash salt myminion netbox.create_platform junos ''' nb_platform = get_('dcim', 'platforms', slu...
def create_site(site): ''' .. versionadded:: 2019.2.0 Create a new device site site String of device site, e.g., ``BRU`` CLI Example: .. code-block:: bash salt myminion netbox.create_site BRU ''' nb_site = get_('dcim', 'sites', name=site) if nb_site: retu...
def create_device(name, role, model, manufacturer, site): ''' .. versionadded:: 2019.2.0 Create a new device with a name, role, model, manufacturer and site. All these components need to be already in Netbox. name The ...
def update_device(name, **kwargs): ''' .. versionadded:: 2019.2.0 Add attributes to an existing device, identified by name. name The name of the device, e.g., ``edge_router`` kwargs Arguments to change in device, e.g., ``serial=JN2932930`` CLI Example: .. code-block:: bash...
def create_inventory_item(device_name, item_name, manufacturer_name=None, serial='', part_id='', description=''): ''' .. versionadded:: 2019.2.0 Add an inventory item to an exis...
def delete_inventory_item(item_id): ''' .. versionadded:: 2019.2.0 Remove an item from a devices inventory. Identified by the netbox id item_id Integer of item to be deleted CLI Example: .. code-block:: bash salt myminion netbox.delete_inventory_item 1354 ''' nb_inve...
def create_interface_connection(interface_a, interface_b): ''' .. versionadded:: 2019.2.0 Create an interface connection between 2 interfaces interface_a Interface id for Side A interface_b Interface id for Side B CLI Example: .. code-block:: bash salt myminion n...
def get_interfaces(device_name=None, **kwargs): ''' .. versionadded:: 2019.2.0 Returns interfaces for a specific device using arbitrary netbox filters device_name The name of the device, e.g., ``edge_router`` kwargs Optional arguments to be used for filtering CLI Example: ...
def openconfig_interfaces(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-interfaces <http://ops.openconfig.net/branches/master/openconfig-interfaces.html>`_ YANG model, containing physical and configuration data available in Netbo...
def openconfig_lacp(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-lacp <http://ops.openconfig.net/branches/master/openconfig-lacp.html>`_ YANG model, with configuration data for Link Aggregation Control Protocol (LACP) for ag...
def create_interface(device_name, interface_name, mac_address=None, description=None, enabled=None, lag=None, lag_parent=None, form_factor=None): ''' .. versionadded...
def update_interface(device_name, interface_name, **kwargs): ''' .. versionadded:: 2019.2.0 Update an existing interface with new attributes. device_name The name of the device, e.g., ``edge_router`` interface_name The name of the interface, e.g., ``ae13`` kwargs Argume...
def delete_interface(device_name, interface_name): ''' .. versionadded:: 2019.2.0 Delete an interface from a device. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface, e.g., ``ae13`` CLI Example: .. code-block:: bash ...
def make_interface_child(device_name, interface_name, parent_name): ''' .. versionadded:: 2019.2.0 Set an interface as part of a LAG. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface to be attached to LAG, e.g., ``xe-1/0/2``. ...
def create_ipaddress(ip_address, family, device=None, interface=None): ''' .. versionadded:: 2019.2.0 Add an IP address, and optionally attach it to an interface. ip_address The IP address and CIDR, e.g., ``192.168.1.1/24`` family Integer of IP family, e.g., ``4`` device ...
def delete_ipaddress(ipaddr_id): ''' .. versionadded:: 2019.2.0 Delete an IP address. IP addresses in Netbox are a combination of address and the interface it is assigned to. id The Netbox id for the IP address. CLI Example: .. code-block:: bash salt myminion netbox.dele...
def create_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit provider name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_provid...
def get_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Get a circuit provider with a given name and optional ASN. name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.ge...
def create_circuit_type(name): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit type. name The name of the circuit type CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_type Transit ''' nb_circuit_type = get_('circuits', 'circuit-types'...
def create_circuit(name, provider_id, circuit_type, description=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit name Name of the circuit provider_id The netbox id of the circuit provider circuit_type The name of the circuit type asn The ASN...
def create_circuit_termination(circuit, interface, device, speed, xconnect_id=None, term_side='A'): ''' .. versionadded:: 2019.2.0 Terminate a circuit on an interface circuit The name of the circuit interface The name of the interface to terminate on device The name of ...
def _cfg(key, default=None): ''' Return the requested value from the aws_kms key in salt configuration. If it's not set, return the default. ''' root_cfg = __salt__.get('config.get', __opts__.get) kms_cfg = root_cfg('aws_kms', {}) return kms_cfg.get(key, default)
def _session(): ''' Return the boto3 session to use for the KMS client. If aws_kms:profile_name is set in the salt configuration, use that profile. Otherwise, fall back on the default aws profile. We use the boto3 profile system to avoid having to duplicate individual boto3 configuration setti...
def _api_decrypt(): ''' Return the response dictionary from the KMS decrypt API call. ''' kms = _kms() data_key = _cfg_data_key() try: return kms.decrypt(CiphertextBlob=data_key) except botocore.exceptions.ClientError as orig_exc: error_code = orig_exc.response.get('Error', {...