text
stringlengths
81
112k
Get flags for a given package or DEPEND atom. Warning: This only works if the configuration files tree is in the correct format (the one enforced by enforce_nice_config) CLI Example: .. code-block:: bash salt '*' portage_config.get_flags_from_package_conf license salt def get_flags_from_pack...
Verify if the given package or DEPEND atom has the given flag. Warning: This only works if the configuration files tree is in the correct format (the one enforced by enforce_nice_config) CLI Example: .. code-block:: bash salt '*' portage_config.has_flag license salt Apache-2.0 def has_flag(c...
Find out which of the given flags are currently not set. CLI Example: .. code-block:: bash salt '*' portage_config.get_missing_flags use salt "['ldap', '-libvirt', 'openssl']" def get_missing_flags(conf, atom, flags): ''' Find out which of the given flags are currently not set. CLI Exampl...
Tell if a given package or DEPEND atom is present in the configuration files tree. Warning: This only works if the configuration files tree is in the correct format (the one enforced by enforce_nice_config) CLI Example: .. code-block:: bash salt '*' portage_config.is_present unmask salt ...
.. versionadded:: 2015.8.0 Gets the current IUSE flags from the tree. @type: cpv: string @param cpv: cat/pkg @rtype list @returns [] or the list of IUSE flags def get_iuse(cp): ''' .. versionadded:: 2015.8.0 Gets the current IUSE flags from the tree. @type: cpv: string @para...
.. versionadded:: 2015.8.0 Gets the installed USE flags from the VARDB. @type: cp: string @param cp: cat/pkg @type use: string @param use: 1 of ["USE", "PKGUSE"] @rtype list @returns [] or the list of IUSE flags def get_installed_use(cp, use="USE"): ''' .. versionadded:: 2015.8.0 ...
.. versionadded:: 2015.8.0 Filter function to remove hidden or otherwise not normally visible USE flags from a list. @type use: list @param use: the USE flag list to be filtered. @type use_expand_hidden: list @param use_expand_hidden: list of flags hidden. @type usemasked: list @param...
.. versionadded:: 2015.8.0 Uses portage to determine final USE flags and settings for an emerge. @type cp: string @param cp: eg cat/pkg @rtype: lists @return use, use_expand_hidden, usemask, useforce def get_all_cpv_use(cp): ''' .. versionadded:: 2015.8.0 Uses portage to determine f...
.. versionadded:: 2015.8.0 Uses portage for compare use flags which is used for installing package and use flags which now exist int /etc/portage/package.use/ @type cp: string @param cp: eg cat/pkg @rtype: tuple @rparam: tuple with two lists - list of used flags and list of flags which wil...
.. versionadded:: 2015.8.0 Uses portage for determine if the use flags of installed package is compatible with use flags in portage configs. @type cp: string @param cp: eg cat/pkg def is_changed_uses(cp): ''' .. versionadded:: 2015.8.0 Uses portage for determine if the use flags of insta...
List existing device-mapper device details. def active(): ''' List existing device-mapper device details. ''' ret = {} # TODO: This command should be extended to collect more information, such as UUID. devices = __salt__['cmd.run_stdout']('dmsetup ls --target crypt') out_regex = re.compile(...
List the contents of the crypttab CLI Example: .. code-block:: bash salt '*' cryptdev.crypttab def crypttab(config='/etc/crypttab'): ''' List the contents of the crypttab CLI Example: .. code-block:: bash salt '*' cryptdev.crypttab ''' ret = {} if not os.path.i...
Remove the named mapping from the crypttab. If the described entry does not exist, nothing is changed, but the command succeeds by returning ``'absent'``. If a line is removed, it returns ``'change'``. CLI Example: .. code-block:: bash salt '*' cryptdev.rm_crypttab foo def rm_crypttab(name, ...
Verify that this device is represented in the crypttab, change the device to match the name passed, or add the name if it is not present. CLI Example: .. code-block:: bash salt '*' cryptdev.set_crypttab foo /dev/sdz1 mypassword swap,size=256 def set_crypttab( name, device, ...
Open a crypt device using ``cryptsetup``. The ``keyfile`` must not be ``None`` or ``'none'``, because ``cryptsetup`` will otherwise ask for the password interactively. CLI Example: .. code-block:: bash salt '*' cryptdev.open foo /dev/sdz1 /path/to/keyfile def open(name, device, keyfile): ...
Ensure domain exists and is up-to-date name Name of the domain domain The name or id of the domain enabled Boolean to control if domain is enabled description An arbitrary description of the domain password The user password email The users e...
Ensure that the named service is present. name The LVS server name protocol The service protocol service_address The LVS service address server_address The real server address. packet_forward_method The LVS packet forwarding method(``dr`` for direct routi...
Ensure the LVS Real Server in specified service is absent. name The name of the LVS server. protocol The service protocol(only support ``tcp``, ``udp`` and ``fwmark`` service). service_address The LVS service address. server_address The LVS real server address. def a...
Ensure that the cluster admin or database user is present. name The name of the user to manage passwd The password of the user database The database to create the user in user The user to connect as (must be able to create the user) password The password ...
List the packages currently installed as a dict:: {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs def list_pkgs(versions_as_list=False, **kwargs): ''' List the packages currently installed as a dict:: {'<package_name>': '<version>'} ...
Install the passed package Return a dict containing the new package names and versions:: {'<package>': {'old': '<old-version>', 'new': '<new-version>'}} CLI Example, Install one package: .. code-block:: bash salt '*' pkg.install <package name> CLI Example, In...
Remove a single package with pkg_delete Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ``name`` parameter will be ignored if this option is passed. .. versionadded:: 0.16.0 Returns a dict containing the changes. CLI Example: ...
Remove a package and extra configuration files. name The name of the package to be deleted. Multiple Package Options: pkgs A list of packages to delete. Must be passed as a python list. The ``name`` parameter will be ignored if this option is passed. .. versionadded:: 0.16.0...
Run a full package upgrade (``pkg_add -u``), or upgrade a specific package if ``name`` or ``pkgs`` is provided. ``name`` is ignored when ``pkgs`` is specified. Returns a dictionary containing the changes: .. versionadded:: 2019.2.0 .. code-block:: python {'<package>': {'old': '<old-versi...
Ensure the data pipeline exists with matching definition. name Name of the service to ensure a data pipeline exists for. pipeline_objects Pipeline objects to use. Will override objects read from pillars. pipeline_objects_from_pillars The pillar key to use for lookup. paramete...
Return true if the pipeline exists and the definition matches. name The name of the pipeline. expected_pipeline_objects Pipeline objects that must match the definition. expected_parameter_objects Parameter objects that must match the definition. expected_parameter_values ...
Return standardized pipeline objects to be used for comparing Remove year, month, and day components of the startDateTime so that data pipelines with the same time of day but different days are considered equal. def _cleaned(_pipeline_objects): """Return standardized pipeline objects to be used for co...
Return v1 == v2. Compares list, dict, recursively. def _recursive_compare(v1, v2): ''' Return v1 == v2. Compares list, dict, recursively. ''' if isinstance(v1, list): if v2 is None: v2 = [] if len(v1) != len(v2): return False v1.sort(key=_id_or_key) ...
Return the value at key 'id' or 'key'. def _id_or_key(list_item): ''' Return the value at key 'id' or 'key'. ''' if isinstance(list_item, dict): if 'id' in list_item: return list_item['id'] if 'key' in list_item: return list_item['key'] return list_item
Return string diff of pipeline definitions. def _diff(old_pipeline_definition, new_pipeline_definition): ''' Return string diff of pipeline definitions. ''' old_pipeline_definition.pop('ResponseMetadata', None) new_pipeline_definition.pop('ResponseMetadata', None) diff = salt.utils.data.decode...
Return standardized format for lists/dictionaries. Lists of dictionaries are sorted by the value of the dictionary at its primary key ('id' or 'key'). OrderedDict's are converted to basic dictionaries. def _standardize(structure): ''' Return standardized format for lists/dictionaries. Lists o...
Return a list of pipeline objects that compose the pipeline pipeline_objects_from_pillars The pillar key to use for lookup pipeline_object_overrides Pipeline objects to use. Will override objects read from pillars. def _pipeline_objects(pipeline_objects_from_pillars, pipeline_object_overrides...
Return a list of parameter objects that configure the pipeline parameter_objects_from_pillars The pillar key to use for lookup parameter_object_overrides Parameter objects to use. Will override objects read from pillars. def _parameter_objects(parameter_objects_from_pillars, parameter_object_...
Return a dictionary of parameter values that configure the pipeline parameter_values_from_pillars The pillar key to use for lookup parameter_value_overrides Parameter values to use. Will override values read from pillars. def _parameter_values(parameter_values_from_pillars, parameter_value_ov...
Convert a dictionary to a list of dictionaries, where each element has a key value pair {'id': key}. This makes it easy to override pillar values while still satisfying the boto api. def _dict_to_list_ids(objects): ''' Convert a dictionary to a list of dictionaries, where each element has a key val...
Transforms dictionary into pipeline object properties. The output format conforms to boto's specification. Example input: { 'a': '1', 'b': { 'ref': '2' }, } Example output: [ { 'key': 'a', ...
Ensure a pipeline with the service_name does not exist name Name of the service to ensure a data pipeline does not exist for. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, o...
Deserialize any string or stream like object into a Python data structure. :param stream_or_string: stream or string to deserialize. :param options: options given to lower json/simplejson module. def deserialize(stream_or_string, **options): ''' Deserialize any string or stream like object into a Pyth...
Serialize Python data to JSON. :param obj: the data structure to serialize :param options: options given to lower json/simplejson module. def serialize(obj, **options): ''' Serialize Python data to JSON. :param obj: the data structure to serialize :param options: options given to lower json/s...
Ensure that the named database is present with the specified properties name The name of the database to manage def present(name, character_set=None, collate=None, **connection_args): ''' Ensure that the named database is present with the specified properties name The name of the data...
Ensure that the named database is absent name The name of the database to remove def absent(name, **connection_args): ''' Ensure that the named database is absent name The name of the database to remove ''' ret = {'name': name, 'changes': {}, 'result': Tr...
Return the net.find runner options. def _get_net_runner_opts(): ''' Return the net.find runner options. ''' runner_opts = __opts__.get('runners', {}).get('net.find', {}) return { 'target': runner_opts.get('target', _DEFAULT_TARGET), 'expr_form': runner_opts.get('expr_form', _DEFAULT...
Return the mine function from all the targeted minions. Just a small helper to avoid redundant pieces of code. def _get_mine(fun): ''' Return the mine function from all the targeted minions. Just a small helper to avoid redundant pieces of code. ''' if fun in _CACHE and _CACHE[fun]: ret...
Display or return the rows. def _display_runner(rows, labels, title, display=_DEFAULT_DISPLAY): ''' Display or return the rows. ''' if display: net_runner_opts = _get_net_runner_opts() if net_runner_opts.get('outputter') == 'table': ret = salt.output.out_format({'rows': rows...
Helper to search the interfaces IPs using the MAC address. def _find_interfaces_ip(mac): ''' Helper to search the interfaces IPs using the MAC address. ''' try: mac = napalm_helpers.convert(napalm_helpers.mac, mac) except AddrFormatError: return ('', '', []) all_interfaces = _g...
Helper to get the interfaces hardware address using the IP Address. def _find_interfaces_mac(ip): # pylint: disable=invalid-name ''' Helper to get the interfaces hardware address using the IP Address. ''' all_interfaces = _get_mine('net.interfaces') all_ipaddrs = _get_mine('net.ipaddrs') for ...
Search for interfaces details in the following mine functions: - net.interfaces - net.ipaddrs Optional arguments: device Return interface data from a certain device only. interface Return data selecting by interface name. pattern Return interfaces that contain a cert...
Search for entries in the ARP tables using the following mine functions: - net.arp Optional arguments: device Return interface data from a certain device only. interface Return data selecting by interface name. mac Search using a specific MAC Address. ip Sea...
Search in the MAC Address tables, using the following mine functions: - net.mac Optional arguments: device Return interface data from a certain device only. interface Return data selecting by interface name. mac Search using a specific MAC Address. vlan Sear...
Search in the LLDP neighbors, using the following mine functions: - net.lldp Optional arguments: device Return interface data from a certain device only. interface Return data selecting by interface name. pattern Return LLDP neighbors that have contain this pattern in on...
Search in all possible entities (Interfaces, MAC tables, ARP tables, LLDP neighbors), using the following mine functions: - net.mac - net.arp - net.lldp - net.ipaddrs - net.interfaces This function has the advantage that it knows where to look, but the output might become quite long as...
Execute multiple search tasks. This function is based on the `find` function. Depending on the search items, some information might overlap. Optional arguments: best: ``True`` Return only the best match with the interfaces IP networks when the saerching pattern is a valid IP Address or...
Recursive generator providing the infrastructure for augtools print behavior. This function is based on test_augeas.py from Harald Hoyer <harald@redhat.com> in the python-augeas repository def _recurmatch(path, aug): ''' Recursive generator providing the infrastructure for augtools print ...
Return a copy of the string after the specified prefix was removed from the beginning of the string def _lstrip_word(word, prefix): ''' Return a copy of the string after the specified prefix was removed from the beginning of the string ''' if six.text_type(word).startswith(prefix): ret...
Checks the validity of the load_path, returns a sanitized version with invalid paths removed. def _check_load_paths(load_path): ''' Checks the validity of the load_path, returns a sanitized version with invalid paths removed. ''' if load_path is None or not isinstance(load_path, six.string_type...
Execute Augeas commands .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' augeas.execute /files/etc/redis/redis.conf \\ commands='["set bind 0.0.0.0", "set maxmemory 1G"]' context The Augeas context lens The Augeas lens to use commands ...
Get a value for a specific augeas path CLI Example: .. code-block:: bash salt '*' augeas.get /files/etc/hosts/1/ ipaddr path The path to get the value of value The optional value to get .. versionadded:: 2016.3.0 load_path A colon-spearated list of director...
Set a value for a specific augeas path CLI Example: .. code-block:: bash salt '*' augeas.setvalue /files/etc/hosts/1/canonical localhost This will set the first entry in /etc/hosts to localhost CLI Example: .. code-block:: bash salt '*' augeas.setvalue /files/etc/hosts/01/ipad...
Get matches for path expression CLI Example: .. code-block:: bash salt '*' augeas.match /files/etc/services/service-name ssh path The path to match value The value to match on .. versionadded:: 2016.3.0 load_path A colon-spearated list of directories that m...
Get matches for path expression CLI Example: .. code-block:: bash salt '*' augeas.remove \\ /files/etc/sysctl.conf/net.ipv4.conf.all.log_martians path The path to remove .. versionadded:: 2016.3.0 load_path A colon-spearated list of directories that modules shou...
List the direct children of a node CLI Example: .. code-block:: bash salt '*' augeas.ls /files/etc/passwd path The path to list .. versionadded:: 2016.3.0 load_path A colon-spearated list of directories that modules should be searched in. This is in addition to ...
Returns recursively the complete tree of a node CLI Example: .. code-block:: bash salt '*' augeas.tree /files/etc/ path The base of the recursive listing .. versionadded:: 2016.3.0 load_path A colon-spearated list of directories that modules should be searched i...
Return a list of all installed kernels. CLI Example: .. code-block:: bash salt '*' kernelpkg.list_installed def list_installed(): ''' Return a list of all installed kernels. CLI Example: .. code-block:: bash salt '*' kernelpkg.list_installed ''' pkg_re = re.compile...
Upgrade the kernel and optionally reboot the system. reboot : False Request a reboot if a new kernel is available. at_time : immediate Schedule the reboot at some point in the future. This argument is ignored if ``reboot=False``. See :py:func:`~salt.modules.system.reboot` for m...
Remove a specific version of the kernel. release The release number of an installed kernel. This must be the entire release number as returned by :py:func:`~salt.modules.kernelpkg_linux_apt.list_installed`, not the package name. CLI Example: .. code-block:: bash salt '*' ...
Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will ...
Compare function for package version sorting def _cmp_version(item1, item2): ''' Compare function for package version sorting ''' vers1 = _LooseVersion(item1) vers2 = _LooseVersion(item2) if vers1 < vers2: return -1 if vers1 > vers2: return 1 return 0
Ensure that the key exists in redis with the value specified name Redis key to manage value Data to persist in key expire Sets time to live for key in seconds expireat Sets expiration time for key via UNIX timestamp, overrides `expire` def string(name, value, expire=...
Ensure key absent from redis name Key to ensure absent from redis keys list of keys to ensure absent, name will be ignored if this is used def absent(name, keys=None, **connection_args): ''' Ensure key absent from redis name Key to ensure absent from redis keys ...
Set this redis instance as a slave. .. versionadded: 2016.3.0 name Master to make this a slave of sentinel_host Ip of the sentinel to check for the master sentinel_port Port of the sentinel to check for the master def slaveof(name, sentinel_host=None, sentinel_port=None, sen...
This module can also be run directly for testing Args: detail|list : Provide ``detail`` or version ``list``. system|system+user: System installed and System and User installs. def __main(): '''This module can also be run directly for testing Args: detail|list : P...
Squished GUID (SQUID) to GUID. A SQUID is a Squished/Compressed version of a GUID to use up less space in the registry. Args: squid (str): Squished GUID. Returns: str: the GUID if a valid SQUID provided. def __squid_to_guid(self, squid): ''' Sq...
Test for ``1`` as a number or a string and return ``True`` if it is. Args: value: string or number or None. Returns: bool: ``True`` if 1 otherwise ``False``. def __one_equals_true(value): ''' Test for ``1`` as a number or a string and return ``True`` if it is. ...
Calls RegQueryValueEx If PY2 ensure unicode string and expand REG_EXPAND_SZ before returning Remember to catch not found exceptions when calling. Args: handle (object): open registry handle. value_name (str): Name of the value you wished returned Returns: ...
Return the install time, or provide an estimate of install time. Installers or even self upgrading software must/should update the date held within InstallDate field when they change versions. Some installers do not set ``InstallDate`` at all so we use the last modified time on the regi...
For the uninstall section of the registry return the name value. Args: value_name (str): Registry value name. wanted_type (str): The type of value wanted if the type does not match None is return. wanted_type support values are ``str`` ``i...
For the product section of the registry return the name value. Args: value_name (str): Registry value name. wanted_type (str): The type of value wanted if the type does not match None is return. wanted_type support values are ``str`` ``int...
For installers which follow the Microsoft Installer standard, returns the ``Upgrade code``. Returns: value (str): ``Upgrade code`` GUID for installed software. def upgrade_code(self): ''' For installers which follow the Microsoft Installer standard, returns the ``Up...
For installers which follow the Microsoft Installer standard, returns a list of patches applied. Returns: value (list): Long name of the patch. def list_patches(self): ''' For installers which follow the Microsoft Installer standard, returns a list of patches applie...
Return version number which is stored in binary format. Returns: str: <major 0-255>.<minior 0-255>.<build 0-65535> or None if not found def version_binary(self): ''' Return version number which is stored in binary format. Returns: str: <major 0-255>.<minior 0-2...
Returns information on a package. Args: pkg_id (str): Package Id of the software/component. Returns: list: List of version numbers installed. def pkg_version_list(self, pkg_id): ''' Returns information on a package. Args: pkg_id (str): Pack...
Provided with a valid Windows Security Identifier (SID) and returns a Username Args: sid (str): Security Identifier (SID). Returns: str: Username in the format of username@realm or username@computer. def __sid_to_username(sid): ''' Provided with a valid Windows...
Determine the Package ID of a software/component using the software/component ``publisher``, ``name``, whether its a software or a component, and if its 32bit or 64bit archiecture. Args: publisher (str): Publisher of the software/component. name (str): Name of the softwa...
This returns the version and where the version string came from, based on instructions under ``version_capture``, if ``version_capture`` is missing, it defaults to value of display-version. Args: pkg_id (str): Publisher of the software/component. version_binary (str): Na...
Update data with the next software found def __collect_software_info(self, sid, key_software, use_32bit): ''' Update data with the next software found ''' reg_soft_info = RegSoftwareInfo(key_software, sid, use_32bit) # Check if the registry entry is a valid. # a) Canno...
This searches the uninstall keys in the registry to find a match in the sub keys, it will return a dict with the display name as the key and the version as the value .. sectionauthor:: Damon Atkins <https://github.com/damon-atkins> .. versionadded:: Carbon def __get_software_details(sel...
Force params to be strings unless they should remain a different type def enforce_types(key, val): ''' Force params to be strings unless they should remain a different type ''' non_string_params = { 'ssl_verify': bool, 'insecure_auth': bool, 'disable_saltenv_mapping': bool, ...
Return the names of remote refs (stripped of the remote name) and tags which are map to the branches and tags. def _get_envs_from_ref_paths(self, refs): ''' Return the names of remote refs (stripped of the remote name) and tags which are map to the branches and tags. ''' ...
Programmatically determine config value based on the desired saltenv def add_conf_overlay(cls, name): ''' Programmatically determine config value based on the desired saltenv ''' def _getconf(self, tgt_env='base'): strip_sep = lambda x: x.rstrip(os.sep) \ if ...
Check if the relative root path exists in the checked-out copy of the remote. Return the full path to that relative root if it does exist, otherwise return None. def check_root(self): ''' Check if the relative root path exists in the checked-out copy of the remote. Return the fu...
Remove stale refs so that they are no longer seen as fileserver envs def clean_stale_refs(self): ''' Remove stale refs so that they are no longer seen as fileserver envs ''' cleaned = [] cmd_str = 'git remote prune origin' # Attempt to force all output to plain ascii en...
Clear update.lk def clear_lock(self, lock_type='update'): ''' Clear update.lk ''' lock_file = self._get_lock_file(lock_type=lock_type) def _add_error(errlist, exc): msg = ('Unable to remove update lock for {0} ({1}): {2} ' .format(self.url, lock_f...
For the config options which need to be maintained in the git config, ensure that the git config file is configured as desired. def enforce_git_config(self): ''' For the config options which need to be maintained in the git config, ensure that the git config file is configured as desire...
Fetch the repo. If the local copy was updated, return True. If the local copy was already up-to-date, return False. This function requires that a _fetch() function be implemented in a sub-class. def fetch(self): ''' Fetch the repo. If the local copy was updated, return True. If...
Place a lock file if (and only if) it does not already exist. def _lock(self, lock_type='update', failhard=False): ''' Place a lock file if (and only if) it does not already exist. ''' try: fh_ = os.open(self._get_lock_file(lock_type), os.O_CREAT | ...
Place an lock file and report on the success/failure. This is an interface to be used by the fileserver runner, so it is hard-coded to perform an update lock. We aren't using the gen_lock() contextmanager here because the lock is meant to stay and not be automatically removed. def lock(...
Set and automatically clear a lock def gen_lock(self, lock_type='update', timeout=0, poll_interval=0.5): ''' Set and automatically clear a lock ''' if not isinstance(lock_type, six.string_types): raise GitLockError( errno.EINVAL, 'Invalid lock...
Check if an environment is exposed by comparing it against a whitelist and blacklist. def env_is_exposed(self, tgt_env): ''' Check if an environment is exposed by comparing it against a whitelist and blacklist. ''' return salt.utils.stringutils.check_whitelist_blacklist(...
Resolve dynamically-set branch def get_checkout_target(self): ''' Resolve dynamically-set branch ''' if self.role == 'git_pillar' and self.branch == '__env__': try: return self.all_saltenvs except AttributeError: # all_saltenvs not...
Return a tree object for the specified environment def get_tree(self, tgt_env): ''' Return a tree object for the specified environment ''' if not self.env_is_exposed(tgt_env): return None tgt_ref = self.ref(tgt_env) if tgt_ref is None: return Non...