INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Retrieve all info's for all disks parse 'em into a nice dict (which, considering hdparms output, is quite a hassle) .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' disk.hdparms /dev/sda
def hdparms(disks, args=None): ''' Retrieve all info's for all disks parse 'em into a nice dict (which, considering hdparms output, is quite a hassle) .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' disk.hdparms /dev/sda ''' all_parms = 'aAbBcCdgHiJkM...
Fetch SMART attributes Providing attributes will deliver only requested attributes Providing values will deliver only requested values for attributes Default is the Backblaze recommended set (https://www.backblaze.com/blog/hard-drive-smart-stats/): (5,187,188,197,198) .. versionadded:: 2016.3....
def smart_attributes(dev, attributes=None, values=None): ''' Fetch SMART attributes Providing attributes will deliver only requested attributes Providing values will deliver only requested values for attributes Default is the Backblaze recommended set (https://www.backblaze.com/blog/hard-drive-...
Gather and return (averaged) IO stats. .. versionadded:: 2016.3.0 .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' disk.iostat 1 5 disks=sda
def iostat(interval=1, count=5, disks=None): ''' Gather and return (averaged) IO stats. .. versionadded:: 2016.3.0 .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' disk.iostat 1 5 disks=sda ''' if salt.utils.platform.is_l...
Transpose collected data, average it, stomp it in dict using header Use Decimals so we can properly calc & round, convert to float 'caus' we can't transmit Decimals over 0mq
def _iostats_dict(header, stats): ''' Transpose collected data, average it, stomp it in dict using header Use Decimals so we can properly calc & round, convert to float 'caus' we can't transmit Decimals over 0mq ''' stats = [float((sum(stat) / len(stat)).quantize(decimal.Decimal('.01'))) for stat i...
Tested on FreeBSD, quite likely other BSD's only need small changes in cmd syntax
def _iostat_fbsd(interval, count, disks): ''' Tested on FreeBSD, quite likely other BSD's only need small changes in cmd syntax ''' if disks is None: iostat_cmd = 'iostat -xC -w {0} -c {1} '.format(interval, count) elif isinstance(disks, six.string_types): iostat_cmd = 'iostat -x -w ...
AIX support to gather and return (averaged) IO stats.
def _iostat_aix(interval, count, disks): ''' AIX support to gather and return (averaged) IO stats. ''' log.debug('DGM disk iostat entry') if disks is None: iostat_cmd = 'iostat -dD {0} {1} '.format(interval, count) elif isinstance(disks, six.string_types): iostat_cmd = 'iostat -...
Validate the beacon configuration
def validate(config): ''' Validate the beacon configuration ''' valid = True messages = [] if not isinstance(config, list): valid = False messages.append('[-] Configuration for %s beacon must be a list', config) else: _config = {} list(map(_config.update, con...
Check on different service status reported by the django-server-status library. .. code-block:: yaml beacons: http_status: - sites: example-site-1: url: "https://example.com/status" timeout: 30 content-type: js...
def beacon(config): ''' Check on different service status reported by the django-server-status library. .. code-block:: yaml beacons: http_status: - sites: example-site-1: url: "https://example.com/status" timeout: 30 ...
Query a resource, and decode the return data Passes through all the parameters described in the :py:func:`utils.http.query function <salt.utils.http.query>`: .. autofunction:: salt.utils.http.query CLI Example: .. code-block:: bash salt '*' http.query http://somelink.com/ salt '...
def query(url, **kwargs): ''' Query a resource, and decode the return data Passes through all the parameters described in the :py:func:`utils.http.query function <salt.utils.http.query>`: .. autofunction:: salt.utils.http.query CLI Example: .. code-block:: bash salt '*' http.que...
Query a resource until a successful response, and decode the return data CLI Example: .. code-block:: bash salt '*' http.wait_for_successful_query http://somelink.com/ wait_for=160
def wait_for_successful_query(url, wait_for=300, **kwargs): ''' Query a resource until a successful response, and decode the return data CLI Example: .. code-block:: bash salt '*' http.wait_for_successful_query http://somelink.com/ wait_for=160 ''' starttime = time.time() while ...
Update the local CA bundle file from a URL .. versionadded:: 2015.5.0 CLI Example: .. code-block:: bash salt '*' http.update_ca_bundle salt '*' http.update_ca_bundle target=/path/to/cacerts.pem salt '*' http.update_ca_bundle source=https://example.com/cacerts.pem If the ``ta...
def update_ca_bundle(target=None, source=None, merge_files=None): ''' Update the local CA bundle file from a URL .. versionadded:: 2015.5.0 CLI Example: .. code-block:: bash salt '*' http.update_ca_bundle salt '*' http.update_ca_bundle target=/path/to/cacerts.pem salt '*'...
Check to see if a security group exists. CLI example:: salt myminion boto_secgroup.exists mysecgroup
def exists(name=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None, group_id=None): ''' Check to see if a security group exists. CLI example:: salt myminion boto_secgroup.exists mysecgroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, p...
Split rules with combined grants into individual rules. Amazon returns a set of rules with the same protocol, from and to ports together as a single rule with a set of grants. Authorizing and revoking rules, however, is done as a split set of rules. This function splits the rules up.
def _split_rules(rules): ''' Split rules with combined grants into individual rules. Amazon returns a set of rules with the same protocol, from and to ports together as a single rule with a set of grants. Authorizing and revoking rules, however, is done as a split set of rules. This function splits...
Get a group object given a name, name and vpc_id/vpc_name or group_id. Return a boto.ec2.securitygroup.SecurityGroup object if the group is found, else return None.
def _get_group(conn=None, name=None, vpc_id=None, vpc_name=None, group_id=None, region=None, key=None, keyid=None, profile=None): # pylint: disable=W0613 ''' Get a group object given a name, name and vpc_id/vpc_name or group_id. Return a boto.ec2.securitygroup.SecurityGroup object if the gro...
Return a list of all Security Groups matching the given criteria and filters. Note that the 'groupnames' argument only functions correctly for EC2 Classic and default VPC Security Groups. To find groups by name in other VPCs you'll want to use the 'group-name' filter instead. Valid keys for the filte...
def get_all_security_groups(groupnames=None, group_ids=None, filters=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all Security Groups matching the given criteria and filters. Note that the 'groupnames' argument only functions correctly for EC2 Cla...
Get a Group ID given a Group Name or Group Name and VPC ID CLI example:: salt myminion boto_secgroup.get_group_id mysecgroup
def get_group_id(name, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Get a Group ID given a Group Name or Group Name and VPC ID CLI example:: salt myminion boto_secgroup.get_group_id mysecgroup ''' conn = _get_conn(region=region, key=key...
Given a list of security groups and a vpc_id, convert_to_group_ids will convert all list items in the given list to security group ids. CLI example:: salt myminion boto_secgroup.convert_to_group_ids mysecgroup vpc-89yhh7h
def convert_to_group_ids(groups, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Given a list of security groups and a vpc_id, convert_to_group_ids will convert all list items in the given list to security group ids. CLI example:: salt...
Create a security group. CLI example:: salt myminion boto_secgroup.create mysecgroup 'My Security Group'
def create(name, description, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Create a security group. CLI example:: salt myminion boto_secgroup.create mysecgroup 'My Security Group' ''' conn = _get_conn(region=region, key=key, keyid=keyid, prof...
Get the configuration for a security group. CLI example:: salt myminion boto_secgroup.get_config mysecgroup
def get_config(name=None, group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None): ''' Get the configuration for a security group. CLI example:: salt myminion boto_secgroup.get_config mysecgroup ''' conn = _get_conn(region=region, key=key,...
Delete a security group. CLI example:: salt myminion boto_secgroup.delete mysecgroup
def delete(name=None, group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None): ''' Delete a security group. CLI example:: salt myminion boto_secgroup.delete mysecgroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Add a new rule to an existing security group. CLI example:: salt myminion boto_secgroup.authorize mysecgroup ip_protocol=tcp from_port=80 to_port=80 cidr_ip='['10.0.0.0/8', '192.168.0.0/24']'
def authorize(name=None, source_group_name=None, source_group_owner_id=None, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None, group_id=None, source_group_group_id=None, region=None, key=None, keyid=None, profile=None, vpc_id=None, vpc_name=None, egres...
Given VPC properties, find and return matching VPC ids. Borrowed from boto_vpc; these could be refactored into a common library
def _find_vpcs(vpc_id=None, vpc_name=None, cidr=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Given VPC properties, find and return matching VPC ids. Borrowed from boto_vpc; these could be refactored into a common library ''' if all((vpc_id, vpc_name)): ...
sets tags on a security group .. versionadded:: 2016.3.0 tags a dict of key:value pair of tags to set on the security group name the name of the security group group_id the group id of the security group (in lie of a name/vpc combo) vpc_name the name of the vpc t...
def set_tags(tags, name=None, group_id=None, vpc_name=None, vpc_id=None, region=None, key=None, keyid=None, profile=None): ''' sets tags on a security group .. versionadded:: 2016.3.0 tags a...
deletes tags from a security group .. versionadded:: 2016.3.0 tags a list of tags to remove name the name of the security group group_id the group id of the security group (in lie of a name/vpc combo) vpc_name the name of the vpc to search the named group for ...
def delete_tags(tags, name=None, group_id=None, vpc_name=None, vpc_id=None, region=None, key=None, keyid=None, profile=None): ''' deletes tags from a security group .. versionadde...
List all available package upgrades on this system refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.list...
def list_upgrades(refresh=True, root=None, **kwargs): ''' List all available package upgrades on this system refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed. root operate on a different root directory. ...
Return the information of the named package available for the system. refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed or not. root operate on a different root directory. CLI example: .. code-block:: bash ...
def info_available(*names, **kwargs): ''' Return the information of the named package available for the system. refresh force a refresh if set to True (default). If set to False it depends on zypper if a refresh is executed or not. root operate on a different root direc...
.. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ``True`` to ignore the epoch when comparing versions .. versio...
def version_cmp(ver1, ver2, ignore_epoch=False, **kwargs): ''' .. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ...
List the packages currently installed as a dict. By default, the dict contains versions as a comma separated string:: {'<package_name>': '<version>[,<version>...]'} versions_as_list: If set to true, the versions are provided as a list {'<package_name>': ['<version>', '<version>']} ...
def list_pkgs(versions_as_list=False, root=None, includes=None, **kwargs): ''' List the packages currently installed as a dict. By default, the dict contains versions as a comma separated string:: {'<package_name>': '<version>[,<version>...]'} versions_as_list: If set to true, the vers...
.. versionadded:: 2017.7.5,2018.3.1 Returns all available packages. Optionally, package names (and name globs) can be passed and the results will be filtered to packages matching those names. This is recommended as it speeds up the function considerably. This function can be helpful in discovering the...
def list_repo_pkgs(*args, **kwargs): ''' .. versionadded:: 2017.7.5,2018.3.1 Returns all available packages. Optionally, package names (and name globs) can be passed and the results will be filtered to packages matching those names. This is recommended as it speeds up the function considerably. ...
Get all the info about repositories from the configurations.
def _get_configured_repos(root=None): ''' Get all the info about repositories from the configurations. ''' repos = os.path.join(root, os.path.relpath(REPOS, os.path.sep)) if root else REPOS repos_cfg = configparser.ConfigParser() if os.path.exists(repos): repos_cfg.read([repos + '/' + f...
Get one repo meta-data.
def _get_repo_info(alias, repos_cfg=None, root=None): ''' Get one repo meta-data. ''' try: meta = dict((repos_cfg or _get_configured_repos(root=root)).items(alias)) meta['alias'] = alias for key, val in six.iteritems(meta): if val in ['0', '1']: meta[k...
Lists all repos. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.list_repos
def list_repos(root=None, **kwargs): ''' Lists all repos. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.list_repos ''' repos_cfg = _get_configured_repos(root=root) all_repos = {} for alias in repos_cfg.sections(): ...
Delete a repo. root operate on a different root directory. CLI Examples: .. code-block:: bash salt '*' pkg.del_repo alias
def del_repo(repo, root=None): ''' Delete a repo. root operate on a different root directory. CLI Examples: .. code-block:: bash salt '*' pkg.del_repo alias ''' repos_cfg = _get_configured_repos(root=root) for alias in repos_cfg.sections(): if alias == repo: ...
Modify one or more values for a repo. If the repo does not exist, it will be created, so long as the following values are specified: repo or alias alias by which Zypper refers to the repo url, mirrorlist or baseurl the URL for Zypper to reference enabled Enable or disable (Tru...
def mod_repo(repo, **kwargs): ''' Modify one or more values for a repo. If the repo does not exist, it will be created, so long as the following values are specified: repo or alias alias by which Zypper refers to the repo url, mirrorlist or baseurl the URL for Zypper to reference ...
Force a repository refresh by calling ``zypper refresh --force``, return a dict:: {'<database name>': Bool} root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db
def refresh_db(root=None): ''' Force a repository refresh by calling ``zypper refresh --force``, return a dict:: {'<database name>': Bool} root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.refresh_db ''' # Remove rtag file...
Form a package names list, find prefixes of packages types.
def _find_types(pkgs): '''Form a package names list, find prefixes of packages types.''' return sorted({pkg.split(':', 1)[0] for pkg in pkgs if len(pkg.split(':', 1)) == 2})
.. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done to keep systemd from killing any zypper commands spawned by Sa...
def install(name=None, refresh=False, fromrepo=None, pkgs=None, sources=None, downloadonly=None, skip_verify=False, version=None, ignore_repo_failure=False, no_recommends=False, root=None, ...
.. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done to keep systemd from killing any zypper commands spawned by Sa...
def upgrade(refresh=True, dryrun=False, dist_upgrade=False, fromrepo=None, novendorchange=False, skip_verify=False, no_recommends=False, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:...
Remove and purge do identical things but with different Zypper commands, this function performs the common logic.
def _uninstall(name=None, pkgs=None, root=None): ''' Remove and purge do identical things but with different Zypper commands, this function performs the common logic. ''' try: pkg_params = __salt__['pkg_resource.parse_targets'](name, pkgs)[0] except MinionError as exc: raise Comm...
.. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done to keep systemd from killing any zypper commands spawned by Sa...
def remove(name=None, pkgs=None, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemo...
.. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done to keep systemd from killing any zypper commands spawned by Sa...
def purge(name=None, pkgs=None, root=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon...
List current package locks. root operate on a different root directory. Return a dict containing the locked package with attributes:: {'<package>': {'case_sensitive': '<case_sensitive>', 'match_type': '<match_type>' 'type': '<type>'}} CLI Exa...
def list_locks(root=None): ''' List current package locks. root operate on a different root directory. Return a dict containing the locked package with attributes:: {'<package>': {'case_sensitive': '<case_sensitive>', 'match_type': '<match_type>' ...
Remove unused locks that do not currently (with regard to repositories used) lock any package. root Operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.clean_locks
def clean_locks(root=None): ''' Remove unused locks that do not currently (with regard to repositories used) lock any package. root Operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.clean_locks ''' LCK = "removed" out = {LCK: 0}...
Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,<package2>,<package3> salt '*' pkg.remove_lock pkgs='["foo", "bar"]'
def remove_lock(packages, root=None, **kwargs): # pylint: disable=unused-argument ''' Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,...
Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,<package2>,<package3> salt '*' pkg.remove_lock pkgs='["foo", "bar"]'
def unhold(name=None, pkgs=None, **kwargs): ''' Remove specified package lock. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.remove_lock <package name> salt '*' pkg.remove_lock <package1>,<package2>,<package3> salt '*' ...
Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg.add_lock <package1>,<package2>,<package3> salt '*' pkg.add_lock pkgs='["foo", "bar"]...
def hold(name=None, pkgs=None, **kwargs): ''' Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg.add_lock <package1>,<package2>,<packag...
Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg.add_lock <package1>,<package2>,<package3> salt '*' pkg.add_lock pkgs='["foo", "bar"]...
def add_lock(packages, root=None, **kwargs): # pylint: disable=unused-argument ''' Add a package lock. Specify packages to lock by exact name. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.add_lock <package name> salt '*' pkg....
List all known patterns in repos.
def _get_patterns(installed_only=None, root=None): ''' List all known patterns in repos. ''' patterns = {} for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'pattern').getElementsByTagName('solvable'): installed = element.getAttribute('status') == 'installed' if (insta...
List all known patterns from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI Examples: .. code-block:: bash salt '*' pkg.list_pat...
def list_patterns(refresh=False, root=None): ''' List all known patterns from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI Examples:...
List known packages, available to the system. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. match (str) One of `exact`, `words`, `substrings`. Search for an `exact` match or for the whole `words` only. D...
def search(criteria, refresh=False, **kwargs): ''' List known packages, available to the system. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. match (str) One of `exact`, `words`, `substrings`. Search fo...
Extract text from the first occurred DOM aggregate.
def _get_first_aggregate_text(node_list): ''' Extract text from the first occurred DOM aggregate. ''' if not node_list: return '' out = [] for node in node_list[0].childNodes: if node.nodeType == dom.Document.TEXT_NODE: out.append(node.nodeValue) return '\n'.join...
List all available or installed SUSE products. all List all products available or only installed. Default is False. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root dir...
def list_products(all=False, refresh=False, root=None): ''' List all available or installed SUSE products. all List all products available or only installed. Default is False. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is...
Download packages to the local disk. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI example: .. code-block:: bash salt '*' pkg.download httpd ...
def download(*packages, **kwargs): ''' Download packages to the local disk. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI example: .. code-block:...
List all known patches in repos.
def _get_patches(installed_only=False, root=None): ''' List all known patches in repos. ''' patches = {} for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'patch').getElementsByTagName('solvable'): installed = element.getAttribute('status') == 'installed' if (installed...
.. versionadded:: 2017.7.0 List all known advisory patches from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate on a different root directory. CLI Examples: .. code-blo...
def list_patches(refresh=False, root=None, **kwargs): ''' .. versionadded:: 2017.7.0 List all known advisory patches from available repos. refresh force a refresh if set to True. If set to False (default) it depends on zypper if a refresh is executed. root operate ...
.. versionadded:: 2018.3.0 List package provides of installed packages as a dict. {'<provided_name>': ['<package_name>', '<package_name>', ...]} root operate on a different root directory. CLI Examples: .. code-block:: bash salt '*' pkg.list_provides
def list_provides(root=None, **kwargs): ''' .. versionadded:: 2018.3.0 List package provides of installed packages as a dict. {'<provided_name>': ['<package_name>', '<package_name>', ...]} root operate on a different root directory. CLI Examples: .. code-block:: bash sal...
.. versionadded:: 2018.3.0 Convert name provides in ``pkgs`` into real package names if ``resolve_capabilities`` parameter is set to True. In case of ``resolve_capabilities`` is set to False the package list is returned unchanged. refresh force a refresh if set to True. If set to F...
def resolve_capabilities(pkgs, refresh=False, root=None, **kwargs): ''' .. versionadded:: 2018.3.0 Convert name provides in ``pkgs`` into real package names if ``resolve_capabilities`` parameter is set to True. In case of ``resolve_capabilities`` is set to False the package list is returned unc...
Resets values of the call setup. :return:
def _reset(self): ''' Resets values of the call setup. :return: ''' self.__cmd = ['zypper', '--non-interactive'] self.__exit_code = 0 self.__call_result = dict() self.__error_msg = '' self.__env = salt.utils.environment.get_module_environment(glob...
Is this is an error code? :return:
def _is_error(self): ''' Is this is an error code? :return: ''' if self.exit_code: msg = self.SUCCESS_EXIT_CODES.get(self.exit_code) if msg: log.info(msg) msg = self.WARNING_EXIT_CODES.get(self.exit_code) if msg: ...
Is Zypper's output is in XML format? :return:
def _is_xml_mode(self): ''' Is Zypper's output is in XML format? :return: ''' return [itm for itm in self.XML_DIRECTIVES if itm in self.__cmd] and True or False
Check and set the result of a zypper command. In case of an error, either raise a CommandExecutionError or extract the error. result The result of a zypper command called with cmd.run_all
def _check_result(self): ''' Check and set the result of a zypper command. In case of an error, either raise a CommandExecutionError or extract the error. result The result of a zypper command called with cmd.run_all ''' if not self.__call_result: ...
Call Zypper. :param state: :return:
def __call(self, *args, **kwargs): ''' Call Zypper. :param state: :return: ''' self.__called = True if self.__xml: self.__cmd.append('--xmlout') if not self.__refresh and '--no-refresh' not in args: self.__cmd.append('--no-refresh'...
Get available versions of the package. :return:
def _get_available_versions(self): ''' Get available versions of the package. :return: ''' solvables = self.zypper.nolock.xml.call('se', '-xv', self.name).getElementsByTagName('solvable') if not solvables: raise CommandExecutionError('No packages found matchin...
Get available difference between next possible matches. :return:
def _get_scope_versions(self, pkg_versions): ''' Get available difference between next possible matches. :return: ''' get_in_versions = [] for p_version in pkg_versions: if fnmatch.fnmatch(p_version, self.version): get_in_versions.append(p_ver...
Stash operator from the version, if any. :return:
def _set_version(self, version): ''' Stash operator from the version, if any. :return: ''' if not version: return exact_version = re.sub(r'[<>=+]*', '', version) self._op = version.replace(exact_version, '') or None if self._op and self._op n...
Make sure that any terminal processes still running when __del__ was called to the waited and cleaned up.
def _cleanup(): ''' Make sure that any terminal processes still running when __del__ was called to the waited and cleaned up. ''' for inst in _ACTIVE[:]: res = inst.isalive() if res is not True: try: _ACTIVE.remove(inst) except ValueError: ...
Send the provided data to the terminal appending a line feed.
def sendline(self, data, linesep=os.linesep): ''' Send the provided data to the terminal appending a line feed. ''' return self.send('{0}{1}'.format(data, linesep))
Receive data from the terminal as a (``stdout``, ``stderr``) tuple. If any of those is ``None`` we can no longer communicate with the terminal's child process.
def recv(self, maxsize=None): ''' Receive data from the terminal as a (``stdout``, ``stderr``) tuple. If any of those is ``None`` we can no longer communicate with the terminal's child process. ''' if maxsize is None: maxsize = 1024 elif maxsize < 1: ...
Close the communication with the terminal's child. If ``terminate`` is ``True`` then additionally try to terminate the terminal, and if ``kill`` is also ``True``, kill the terminal if terminating it was not enough.
def close(self, terminate=True, kill=False): ''' Close the communication with the terminal's child. If ``terminate`` is ``True`` then additionally try to terminate the terminal, and if ``kill`` is also ``True``, kill the terminal if terminating it was not enough. ''' ...
Ensure the RackSpace queue exists. name Name of the Rackspace queue. provider Salt Cloud Provider
def present(name, provider): ''' Ensure the RackSpace queue exists. name Name of the Rackspace queue. provider Salt Cloud Provider ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} is_present = list(__salt__['cloud.action']('queues_exists', provider=pr...
Ensure the named Rackspace queue is deleted. name Name of the Rackspace queue. provider Salt Cloud provider
def absent(name, provider): ''' Ensure the named Rackspace queue is deleted. name Name of the Rackspace queue. provider Salt Cloud provider ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} is_present = list(__salt__['cloud.action']('queues_exists', pr...
Connect to the DRAC
def __connect(hostname, timeout=20, username=None, password=None): ''' Connect to the DRAC ''' drac_cred = __opts__.get('drac') err_msg = 'No drac login credentials found. Please add the \'username\' and \'password\' ' \ 'fields beneath a \'drac\' key in the master configuration file. ...
Grab DRAC version
def __version(client): ''' Grab DRAC version ''' versions = {9: 'CMC', 8: 'iDRAC6', 10: 'iDRAC6', 11: 'iDRAC6', 16: 'iDRAC7', 17: 'iDRAC7'} if isinstance(client, paramiko.SSHClient): (stdin, stdout, stderr) = cl...
Connect to the Dell DRAC and have the boot order set to PXE and power cycle the system to PXE boot CLI Example: .. code-block:: bash salt-run drac.pxe example.com
def pxe(hostname, timeout=20, username=None, password=None): ''' Connect to the Dell DRAC and have the boot order set to PXE and power cycle the system to PXE boot CLI Example: .. code-block:: bash salt-run drac.pxe example.com ''' _cmds = [ 'racadm config -g cfgServerInfo...
Reboot a server using the Dell DRAC CLI Example: .. code-block:: bash salt-run drac.reboot example.com
def reboot(hostname, timeout=20, username=None, password=None): ''' Reboot a server using the Dell DRAC CLI Example: .. code-block:: bash salt-run drac.reboot example.com ''' client = __connect(hostname, timeout, username, password) if isinstance(client, paramiko.SSHClient): ...
Display the version of DRAC CLI Example: .. code-block:: bash salt-run drac.version example.com
def version(hostname, timeout=20, username=None, password=None): ''' Display the version of DRAC CLI Example: .. code-block:: bash salt-run drac.version example.com ''' return __version(__connect(hostname, timeout, username, password))
Emit the status of a connected display to the minion Mainly this is used to detect when the display fails to connect for whatever reason. .. code-block:: yaml beacons: glxinfo: - user: frank - screen_event: True
def beacon(config): ''' Emit the status of a connected display to the minion Mainly this is used to detect when the display fails to connect for whatever reason. .. code-block:: yaml beacons: glxinfo: - user: frank - screen_event: True ''' log.t...
Retrieve master config options, with optional nesting via the delimiter argument. **Arguments** default If the key is not found, the default will be returned instead delimiter Override the delimiter used to separate nested levels of a data structure. CLI Example: ....
def get(key, default='', delimiter=':'): ''' Retrieve master config options, with optional nesting via the delimiter argument. **Arguments** default If the key is not found, the default will be returned instead delimiter Override the delimiter used to separate nested levels ...
Reissues a purchased SSL certificate. Returns a dictionary of result values. csr_file Path to Certificate Signing Request file certificate_id Unique ID of the SSL certificate you wish to activate web_server_type The type of certificate format to return. Possible values include...
def reissue(csr_file, certificate_id, web_server_type, approver_email=None, http_dc_validation=False, **kwargs): ''' Reissues a purchased SSL certificate. Returns a dictionary of result values. csr_file Path to Certificate Signing Requ...
Renews an SSL certificate if it is ACTIVE and Expires <= 30 days. Returns the following information: - The certificate ID - The order ID - The transaction ID - The amount charged for the order years : 1 Number of years to register certificate_id Unique ID of the SSL certif...
def renew(years, certificate_id, certificate_type, promotion_code=None): ''' Renews an SSL certificate if it is ACTIVE and Expires <= 30 days. Returns the following information: - The certificate ID - The order ID - The transaction ID - The amount charged for the order years : 1 ...
Creates a new SSL certificate. Returns the following information: - Whether or not the SSL order was successful - The certificate ID - The order ID - The transaction ID - The amount charged for the order - The date on which the certificate was created - The date on which the certificate wil...
def create(years, certificate_type, promotion_code=None, sans_to_add=None): ''' Creates a new SSL certificate. Returns the following information: - Whether or not the SSL order was successful - The certificate ID - The order ID - The transaction ID - The amount charged for the order - T...
Parses the CSR. Returns a dictionary of result values. csr_file Path to Certificate Signing Request file certificate_type Type of SSL Certificate. Possible values include: - EV Multi Domain SSL - EV SSL - EV SSL SGC - EssentialSSL - EssentialSSL Wildcar...
def parse_csr(csr_file, certificate_type, http_dc_validation=False): ''' Parses the CSR. Returns a dictionary of result values. csr_file Path to Certificate Signing Request file certificate_type Type of SSL Certificate. Possible values include: - EV Multi Domain SSL - ...
Returns a list of SSL certificates for a particular user ListType : All Possible values: - All - Processing - EmailSent - TechnicalProblem - InProgress - Completed - Deactivated - Active - Cancelled - NewPurchase - New...
def get_list(**kwargs): ''' Returns a list of SSL certificates for a particular user ListType : All Possible values: - All - Processing - EmailSent - TechnicalProblem - InProgress - Completed - Deactivated - Active - Cancelled...
Retrieves information about the requested SSL certificate. Returns a dictionary of information about the SSL certificate with two keys: - **ssl** - Contains the metadata information - **certificate** - Contains the details for the certificate such as the CSR, Approver, and certificate data certi...
def get_info(certificate_id, returncertificate=False, returntype=None): ''' Retrieves information about the requested SSL certificate. Returns a dictionary of information about the SSL certificate with two keys: - **ssl** - Contains the metadata information - **certificate** - Contains the details ...
Return the changes
def _check_cron(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None, comment=None, commented=None, identifier=None, special=None): ''...
Return the environment changes
def _check_cron_env(user, name, value=None): ''' Return the environment changes ''' if value is None: value = "" # Matching value set in salt.modules.cron._render_tab lst = __salt__['cron.list_tab'](user) for env in lst['env']: if name == ...
Returns the proper group owner and path to the cron directory
def _get_cron_info(): ''' Returns the proper group owner and path to the cron directory ''' owner = 'root' if __grains__['os'] == 'FreeBSD': group = 'wheel' crontab_dir = '/var/cron/tabs' elif __grains__['os'] == 'OpenBSD': group = 'crontab' crontab_dir = '/var/cr...
Verifies that the specified cron job is present for the specified user. It is recommended to use `identifier`. Otherwise the cron job is installed twice if you change the name. For more advanced information about what exactly can be set in the cron timing parameters, check your cron system's documentati...
def present(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*', comment=None, commented=False, identifier=False, special=None): ''' Verifies that the specified cron ...
Verifies that the specified cron job is absent for the specified user; only the name is matched when removing a cron job. name The command that should be absent in the user crontab. user The name of the user whose crontab needs to be modified, defaults to the root user identif...
def absent(name, user='root', identifier=False, special=None, **kwargs): ''' Verifies that the specified cron job is absent for the specified user; only the name is matched when removing a cron job. name The command that should be absent in the user c...
Provides file.managed-like functionality (templating, etc.) for a pre-made crontab file, to be assigned to a given user. name The source file to be used as the crontab. This source file can be hosted on either the salt master server, or on an HTTP or FTP server. For files hosted on the ...
def file(name, source_hash='', source_hash_name=None, user='root', template=None, context=None, replace=True, defaults=None, backup='', **kwargs): ''' Provides file.managed-like functionality (templating, etc.) for a pre-made c...
Verifies that the specified environment variable is absent from the crontab for the specified user name The name of the environment variable to remove from the user crontab user The name of the user whose crontab needs to be modified, defaults to the root user
def env_absent(name, user='root'): ''' Verifies that the specified environment variable is absent from the crontab for the specified user name The name of the environment variable to remove from the user crontab user The name of the user whose crontab needs to be mod...
Verifies that the specified environment variable is present in the crontab for the specified user. name The name of the environment variable to set in the user crontab user The name of the user whose crontab needs to be modified, defaults to the root user value The val...
def env_present(name, value=None, user='root'): ''' Verifies that the specified environment variable is present in the crontab for the specified user. name The name of the environment variable to set in the user crontab user The name of the user whos...
The HighState Outputter is only meant to be used with the state.highstate function, or a function that returns highstate return data.
def output(data, **kwargs): # pylint: disable=unused-argument ''' The HighState Outputter is only meant to be used with the state.highstate function, or a function that returns highstate return data. ''' if len(data.keys()) == 1: # account for nested orchs via saltutil.runner if 're...
Main highstate formatter. can be called recursively if a nested highstate contains other highstates (ie in an orchestration)
def _format_host(host, data, indent_level=1): ''' Main highstate formatter. can be called recursively if a nested highstate contains other highstates (ie in an orchestration) ''' host = salt.utils.data.decode(host) colors = salt.utils.color.get_colors( __opts__.get('color'), ...
Print the changes data using the nested outputter
def _nested_changes(changes): ''' Print the changes data using the nested outputter ''' ret = '\n' ret += salt.output.out_format( changes, 'nested', __opts__, nested_indent=14) return ret
Format the changes dict based on what the data is
def _format_changes(changes, orchestration=False): ''' Format the changes dict based on what the data is ''' if not changes: return False, '' if orchestration: return True, _nested_changes(changes) if not isinstance(changes, dict): return True, 'Invalid Changes data: {0...
Terse formatting of a message.
def _format_terse(tcolor, comps, ret, colors, tabular): ''' Terse formatting of a message. ''' result = 'Clean' if ret['changes']: result = 'Changed' if ret['result'] is False: result = 'Failed' elif ret['result'] is None: result = 'Differs' if tabular is True: ...
The kernerpkg watcher, called to invoke the watch command. When called, execute a kernelpkg state based on a watch or listen call. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for th...
def mod_watch(name, sfun, **kwargs): ''' The kernerpkg watcher, called to invoke the watch command. When called, execute a kernelpkg state based on a watch or listen call. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should n...
PRIVATE METHOD Checks to see if the value of a primitive or built-in container such as a list, dict, set, tuple etc is empty or none. None type is returned if the value is empty/None/False. Number data types that are 0 will return None. value : obj The primitive or built-in container to evaluat...
def _get_none_or_value(value): ''' PRIVATE METHOD Checks to see if the value of a primitive or built-in container such as a list, dict, set, tuple etc is empty or none. None type is returned if the value is empty/None/False. Number data types that are 0 will return None. value : obj The...
PRIVATE METHOD Creates a new return dict with default values. Defaults may be overwritten. success : boolean (True) True indicates a successful result. data : dict<str,obj> ({}) Data to be returned to the caller. errors : list<str> ([()]) A list of error messages to be returned ...
def _get_return_dict(success=True, data=None, errors=None, warnings=None): ''' PRIVATE METHOD Creates a new return dict with default values. Defaults may be overwritten. success : boolean (True) True indicates a successful result. data : dict<str,obj> ({}) Data to be returned to the...