INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Cleans the local cache of fetched remote packages
def clean(jail=None, chroot=None, root=None, clean_all=False, dryrun=False): ''' Cleans the local cache of fetched remote packages CLI Example: .. code-block:: bash salt '*' pkg.clean jail Cleans the package cache in the specified jail ...
Sanity checks installed packages
def check(jail=None, chroot=None, root=None, depends=False, recompute=False, checksum=False): ''' Sanity checks installed packages jail Perform the sanity check in the specified jail CLI Example: .. code-block:: bash s...
Displays which package installed a specific file
def which(path, jail=None, chroot=None, root=None, origin=False, quiet=False): ''' Displays which package installed a specific file CLI Example: .. code-block:: bash salt '*' pkg.which <file name> jail Perform the check in the specified jail CLI Example: .. code...
Searches in remote package repositories
def search(name, jail=None, chroot=None, root=None, exact=False, glob=False, regex=False, pcre=False, comment=False, desc=False, full=False, depends=False, size=False, quiet=Fal...
Fetches remote packages
def fetch(name, jail=None, chroot=None, root=None, fetch_all=False, quiet=False, fromrepo=None, glob=True, regex=False, pcre=False, local=False, depends=False): ''' Fetches remote packages CLI Exam...
Displays UPDATING entries of software packages
def updating(name, jail=None, chroot=None, root=None, filedate=None, filename=None): '''' Displays UPDATING entries of software packages CLI Example: .. code-block:: bash salt '*' pkg.updating foo jail Perform the a...
Version - lock packages
def hold(name=None, pkgs=None, **kwargs): # pylint: disable=W0613 ''' Version-lock packages .. note:: This function is provided primarily for compatibilty with some parts of :py:mod:`states.pkg <salt.states.pkg>`. Consider using Consider using :py:func:`pkg.lock <salt.modules.pkgng...
Query the package database those packages which are locked against reinstallation modification or deletion.
def list_locked(**kwargs): ''' Query the package database those packages which are locked against reinstallation, modification or deletion. Returns returns a list of package names with version strings CLI Example: .. code-block:: bash salt '*' pkg.list_locked jail List l...
Helper function for lock and unlock commands because their syntax is identical.
def _lockcmd(subcmd, pkgname=None, **kwargs): ''' Helper function for lock and unlock commands, because their syntax is identical. Run the lock/unlock command, and return a list of locked packages ''' jail = kwargs.pop('jail', None) chroot = kwargs.pop('chroot', None) root = kwargs.pop('ro...
List those packages for which an upgrade is available
def list_upgrades(refresh=True, **kwargs): ''' List those packages for which an upgrade is available The ``fromrepo`` argument is also supported, as used in pkg states. CLI Example: .. code-block:: bash salt '*' pkg.list_upgrades jail List upgrades within the specified jail ...
Parse the output from the pkg upgrade -- dry - run command
def _parse_upgrade(stdout): ''' Parse the output from the ``pkg upgrade --dry-run`` command Returns a dictionary of the expected actions: .. code-block:: yaml 'upgrade': pkgname: 'repo': repository 'reason': reason 'version': 'curren...
Do a cmp - style comparison on two packages. Return - 1 if pkg1 < pkg2 0 if pkg1 == pkg2 and 1 if pkg1 > pkg2. Return None if there was a problem making the comparison.
def version_cmp(pkg1, pkg2, ignore_epoch=False, **kwargs): ''' Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem making the comparison. CLI Example: .. code-block:: bash salt '*' pkg.version...
.. versionadded:: 2015. 8. 0
def bin_pkg_info(path, saltenv='base'): ''' .. versionadded:: 2015.8.0 Parses RPM metadata and returns a dictionary of information about the package (name, version, etc.). path Path to the file. Can either be an absolute path to a file on the minion, or a salt fileserver URL (e.g. ...
Change package selection for each package specified to install
def unpurge(*packages): ''' Change package selection for each package specified to 'install' CLI Example: .. code-block:: bash salt '*' lowpkg.unpurge curl ''' if not packages: return {} old = __salt__['pkg.list_pkgs'](purge_desired=True) ret = {} __salt__['cmd.run...
List the packages currently installed in a dict::
def list_pkgs(*packages, **kwargs): ''' List the packages currently installed in a dict:: {'<package_name>': '<version>'} External dependencies:: Virtual package resolution requires aptitude. Because this function uses dpkg, virtual packages will be reported as not installed. ...
List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system s package database ( not generally recommended ).
def file_list(*packages, **kwargs): ''' List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bash salt '*' lowpkg.file_list httpd salt...
List the files that belong to a package grouped by package. Not specifying any packages will return a list of _every_ file on the system s package database ( not generally recommended ).
def file_dict(*packages, **kwargs): ''' List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bash salt '*' lowpkg.file_lis...
Get package build time if possible.
def _get_pkg_build_time(name): ''' Get package build time, if possible. :param name: :return: ''' iso_time = iso_time_t = None changelog_dir = os.path.join('/usr/share/doc', name) if os.path.exists(changelog_dir): for fname in os.listdir(changelog_dir): try: ...
Return list of package information. If packages parameter is empty then data about all installed packages will be returned.
def _get_pkg_info(*packages, **kwargs): ''' Return list of package information. If 'packages' parameter is empty, then data about all installed packages will be returned. :param packages: Specified packages. :param failhard: Throw an exception if no packages found. :return: ''' kwargs =...
Try to get a license from the package. Based on https:// www. debian. org/ doc/ packaging - manuals/ copyright - format/ 1. 0/
def _get_pkg_license(pkg): ''' Try to get a license from the package. Based on https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ :param pkg: :return: ''' licenses = set() cpr = "/usr/share/doc/{0}/copyright".format(pkg) if os.path.exists(cpr): with salt.util...
Return package install time based on the/ var/ lib/ dpkg/ info/ <package >. list
def _get_pkg_install_time(pkg, arch=None): ''' Return package install time, based on the /var/lib/dpkg/info/<package>.list :return: ''' iso_time = iso_time_t = None loc_root = '/var/lib/dpkg/info' if pkg is not None: locations = [] if arch is not None and arch != 'all': ...
Get the package information of the available packages maintained by dselect. Note this will be not very useful if dselect isn t installed.
def _get_pkg_ds_avail(): ''' Get the package information of the available packages, maintained by dselect. Note, this will be not very useful, if dselect isn't installed. :return: ''' avail = "/var/lib/dpkg/available" if not salt.utils.path.which('dselect') or not os.path.exists(avail): ...
Returns a detailed summary of package information for provided package names. If no packages are specified all packages will be returned.
def info(*packages, **kwargs): ''' Returns a detailed summary of package information for provided package names. If no packages are specified, all packages will be returned. .. versionadded:: 2015.8.1 packages The names of the packages for which to return information. failhard ...
Override specific variables within a function s global context.
def func_globals_inject(func, **overrides): ''' Override specific variables within a function's global context. ''' # recognize methods if hasattr(func, 'im_func'): func = func.__func__ # Get a reference to the function globals dictionary func_globals = func.__globals__ # Save t...
Clone this context and return the ChildContextDict
def clone(self, **kwargs): ''' Clone this context, and return the ChildContextDict ''' child = ChildContextDict(parent=self, threadsafe=self._threadsafe, overrides=kwargs) return child
Execute salt - cp
def run(self): ''' Execute salt-cp ''' self.parse_args() # Setup file logging! self.setup_logfile_logger() salt.utils.verify.verify_log(self.config) cp_ = SaltCP(self.config) cp_.run()
Get a list of all specified files
def _recurse(self, path): ''' Get a list of all specified files ''' files = {} empty_dirs = [] try: sub_paths = os.listdir(path) except OSError as exc: if exc.errno == errno.ENOENT: # Path does not exist sys....
Take a path and return the contents of the file as a string
def _file_dict(self, fn_): ''' Take a path and return the contents of the file as a string ''' if not os.path.isfile(fn_): err = 'The referenced file, {0} is not available.'.format(fn_) sys.stderr.write(err + '\n') sys.exit(42) with salt.utils....
Parse the files indicated in opts [ src ] and load them into a python object for transport
def _load_files(self): ''' Parse the files indicated in opts['src'] and load them into a python object for transport ''' files = {} for fn_ in self.opts['src']: if os.path.isfile(fn_): files.update(self._file_dict(fn_)) elif os.path...
Make the salt client call
def run(self): ''' Make the salt client call ''' if self.opts['chunked']: ret = self.run_chunked() else: ret = self.run_oldstyle() salt.output.display_output( ret, self.opts.get('output', 'nested'), ...
Make the salt client call in old - style all - in - one call method
def run_oldstyle(self): ''' Make the salt client call in old-style all-in-one call method ''' arg = [self._load_files(), self.opts['dest']] local = salt.client.get_local_client(self.opts['conf_file']) args = [self.opts['tgt'], 'cp.recv', ar...
Make the salt client call in the new fasion chunked multi - call way
def run_chunked(self): ''' Make the salt client call in the new fasion chunked multi-call way ''' files, empty_dirs = self._list_files() dest = self.opts['dest'] gzip = self.opts['gzip'] tgt = self.opts['tgt'] timeout = self.opts['timeout'] selecte...
List the RAID devices.
def list_(): ''' List the RAID devices. CLI Example: .. code-block:: bash salt '*' raid.list ''' ret = {} for line in (__salt__['cmd.run_stdout'] (['mdadm', '--detail', '--scan'], python_shell=False).splitlines()): if ' ' not in lin...
Show detail for a specified RAID device
def detail(device='/dev/md0'): ''' Show detail for a specified RAID device CLI Example: .. code-block:: bash salt '*' raid.detail '/dev/md0' ''' ret = {} ret['members'] = {} # Lets make sure the device exists before running mdadm if not os.path.exists(device): msg...
Destroy a RAID device.
def destroy(device): ''' Destroy a RAID device. WARNING This will zero the superblock of all members of the RAID array.. CLI Example: .. code-block:: bash salt '*' raid.destroy /dev/md0 ''' try: details = detail(device) except CommandExecutionError: return Fal...
Create a RAID device.
def create(name, level, devices, metadata='default', test_mode=False, **kwargs): ''' Create a RAID device. .. versionchanged:: 2014.7.0 .. warning:: Use with CAUTION, as this function can be very destructive if not used properly! ...
Save RAID configuration to config file.
def save_config(): ''' Save RAID configuration to config file. Same as: mdadm --detail --scan >> /etc/mdadm/mdadm.conf Fixes this issue with Ubuntu REF: http://askubuntu.com/questions/209702/why-is-my-raid-dev-md1-showing-up-as-dev-md126-is-mdadm-conf-being-ignored CLI Example: .. co...
Assemble a RAID device.
def assemble(name, devices, test_mode=False, **kwargs): ''' Assemble a RAID device. CLI Examples: .. code-block:: bash salt '*' raid.assemble /dev/md0 ['/dev/xvdd', '/dev/xvde'] .. note:: Adding ``test_mode=True`` as an argument will print ...
Show detail for a specified RAID component device
def examine(device, quiet=False): ''' Show detail for a specified RAID component device device Device to examine, that is part of the RAID quiet If the device is not part of the RAID, do not show any error CLI Example: .. code-block:: bash salt '*' raid.examine '/dev...
Add new device to RAID array.
def add(name, device): ''' Add new device to RAID array. CLI Example: .. code-block:: bash salt '*' raid.add /dev/md0 /dev/sda1 ''' cmd = 'mdadm --manage {0} --add {1}'.format(name, device) if __salt__['cmd.retcode'](cmd) == 0: return True return False
Given a domain name check to see if the given domain exists.
def exists(DomainName, region=None, key=None, keyid=None, profile=None): ''' Given a domain name, check to see if the given domain exists. Returns True if the given domain exists and returns False if the given function does not exist. CLI Example: .. code-block:: bash salt...
Given a domain name describe its status.
def status(DomainName, region=None, key=None, keyid=None, profile=None): ''' Given a domain name describe its status. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_elasticsearch_domain.status mydomain ''' conn ...
Given a domain name describe its properties.
def describe(DomainName, region=None, key=None, keyid=None, profile=None): ''' Given a domain name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_elasticsearch_domain.describe mydomain ''' ...
Given a valid config create a domain.
def create(DomainName, ElasticsearchClusterConfig=None, EBSOptions=None, AccessPolicies=None, SnapshotOptions=None, AdvancedOptions=None, region=None, key=None, keyid=None, profile=None, ElasticsearchVersion=None): ''' Given a valid config, create a domain. Returns {created...
Given a domain name delete it.
def delete(DomainName, region=None, key=None, keyid=None, profile=None): ''' Given a domain name, delete it. Returns {deleted: true} if the domain was deleted and returns {deleted: false} if the domain was not deleted. CLI Example: .. code-block:: bash salt myminion boto_elasticsearc...
Add tags to a domain
def add_tags(DomainName=None, ARN=None, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Add tags to a domain Returns {tagged: true} if the domain was tagged and returns {tagged: False} if the domain was not tagged. CLI Example: .. code-block:: bash salt mym...
Remove tags from a trail
def remove_tags(TagKeys, DomainName=None, ARN=None, region=None, key=None, keyid=None, profile=None): ''' Remove tags from a trail Returns {tagged: true} if the trail was tagged and returns {tagged: False} if the trail was not tagged. CLI Example: .. code-block:: bash salt...
List tags of a trail
def list_tags(DomainName=None, ARN=None, region=None, key=None, keyid=None, profile=None): ''' List tags of a trail Returns: tags: - {...} - {...} CLI Example: .. code-block:: bash salt myminion boto_cloudtrail.list_tags my_trail ''' try: ...
Ensure a security group exists.
def present(name, auth=None, **kwargs): ''' Ensure a security group exists. You can supply either project_name or project_id. Creating a default security group will not show up as a change; it gets created through the lookup process. name Name of the security group description ...
Ensure a security group does not exist
def absent(name, auth=None, **kwargs): ''' Ensure a security group does not exist name Name of the security group ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} kwargs = __utils__['args.clean_kwargs'](**kwargs) __salt__['ne...
Parse a logrotate configuration file.
def _parse_conf(conf_file=_DEFAULT_CONF): ''' Parse a logrotate configuration file. Includes will also be parsed, and their configuration will be stored in the return dict, as if they were part of the main config file. A dict of which configs came from which includes will be stored in the 'include ...
Get the value for a specific configuration line.
def get(key, value=None, conf_file=_DEFAULT_CONF): ''' Get the value for a specific configuration line. :param str key: The command or stanza block to configure. :param str value: The command value or command of the block specified by the key parameter. :param str conf_file: The logrotate configura...
Set a new value for a specific configuration line.
def set_(key, value, setting=None, conf_file=_DEFAULT_CONF): ''' Set a new value for a specific configuration line. :param str key: The command or block to configure. :param str value: The command value or command of the block specified by the key parameter. :param str setting: The command value fo...
Convert a dict to a multi - line stanza
def _dict_to_stanza(key, stanza): ''' Convert a dict to a multi-line stanza ''' ret = '' for skey in stanza: if stanza[skey] is True: stanza[skey] = '' ret += ' {0} {1}\n'.format(skey, stanza[skey]) return '{0} {{\n{1}}}'.format(key, ret)
Block state execution until you are able to get the lock ( or hit the timeout )
def lock(name, zk_hosts=None, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None, default_acl=None): ''' Block state execution until you are abl...
Remove lease from semaphore.
def unlock(name, zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example) identifier=None, max_concurrency=1, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None,...
Ensure that there are min_nodes in the party at name optionally blocking if not available.
def min_party(name, zk_hosts, min_nodes, blocking=False, profile=None, scheme=None, username=None, password=None, default_acl=None): ''' Ensure that there are `min_nodes` in the party at `name`, optio...
Execute a list of CLI commands.
def _cli_command(commands, method='cli', **kwargs): ''' Execute a list of CLI commands. ''' if not isinstance(commands, (list, tuple)): commands = [commands] rpc_responses = rpc(commands, method=method, **kwarg...
Execute an arbitrary RPC request via the Nexus API.
def rpc(commands, method='cli', **kwargs): ''' Execute an arbitrary RPC request via the Nexus API. commands The commands to be executed. method: ``cli`` The type of the response, i.e., raw text (``cli_ascii``) or structured document (``cli``). Defaults to ``cli`...
Execute one or more show ( non - configuration ) commands.
def show(commands, raw_text=True, **kwargs): ''' Execute one or more show (non-configuration) commands. commands The commands to be executed. raw_text: ``True`` Whether to return raw text or structured data. transport: ``https`` Specifies the type of conn...
Configures the Nexus switch with the specified commands.
def config(commands=None, config_file=None, template_engine='jinja', context=None, defaults=None, saltenv='base', **kwargs): ''' Configures the Nexus switch with the specified commands. This method is used to send configuration commands to t...
Describe which levels are allowed to do deep merging.
def levelise(level): ''' Describe which levels are allowed to do deep merging. level can be: True all levels are True False all levels are False an int only the first levels are True, the others are False a sequence it describes which levels are True, it ...
Convert obj into an Aggregate instance
def mark(obj, map_class=Map, sequence_class=Sequence): ''' Convert obj into an Aggregate instance ''' if isinstance(obj, Aggregate): return obj if isinstance(obj, dict): return map_class(obj) if isinstance(obj, (list, tuple, set)): return sequence_class(obj) else: ...
Merge obj_b into obj_a.
def aggregate(obj_a, obj_b, level=False, map_class=Map, sequence_class=Sequence): ''' Merge obj_b into obj_a. >>> aggregate('first', 'second', True) == ['first', 'second'] True ''' deep, subdeep = levelise(level) if deep: obj_a = mark(obj_a, map_class=map_class, sequence_class=sequ...
Migrate old minion and master pki file paths to new ones.
def migrate_paths(opts): ''' Migrate old minion and master pki file paths to new ones. ''' oldpki_dir = os.path.join(syspaths.CONFIG_DIR, 'pki') if not os.path.exists(oldpki_dir): # There's not even a pki directory, don't bother migrating return newpki_dir = opts['pki_dir'] ...
Simple internal wrapper for cmdmod. retcode
def _check_retcode(cmd): ''' Simple internal wrapper for cmdmod.retcode ''' return salt.modules.cmdmod.retcode(cmd, output_loglevel='quiet', ignore_retcode=True) == 0
Simple internal wrapper for cmdmod. run
def _exec(**kwargs): ''' Simple internal wrapper for cmdmod.run ''' if 'ignore_retcode' not in kwargs: kwargs['ignore_retcode'] = True if 'output_loglevel' not in kwargs: kwargs['output_loglevel'] = 'quiet' return salt.modules.cmdmod.run_all(**kwargs)
Merge values all values after X into the last value
def _merge_last(values, merge_after, merge_with=' '): ''' Merge values all values after X into the last value ''' if len(values) > merge_after: values = values[0:(merge_after-1)] + [merge_with.join(values[(merge_after-1):])] return values
Detect the datatype of a property
def _property_detect_type(name, values): ''' Detect the datatype of a property ''' value_type = 'str' if values.startswith('on | off'): value_type = 'bool' elif values.startswith('yes | no'): value_type = 'bool_alt' elif values in ['<size>', '<size> | none']: value_ty...
Create a property dict
def _property_create_dict(header, data): ''' Create a property dict ''' prop = dict(zip(header, _merge_last(data, len(header)))) prop['name'] = _property_normalize_name(prop['property']) prop['type'] = _property_detect_type(prop['name'], prop['values']) prop['edit'] = from_bool(prop['edit'])...
Parse output of zpool/ zfs get command
def _property_parse_cmd(cmd, alias=None): ''' Parse output of zpool/zfs get command ''' if not alias: alias = {} properties = {} # NOTE: append get to command if cmd[-3:] != 'get': cmd += ' get' # NOTE: parse output prop_hdr = [] for prop_data in _exec(cmd=cmd)[...
Internal magic for from_auto and to_auto
def _auto(direction, name, value, source='auto', convert_to_human=True): ''' Internal magic for from_auto and to_auto ''' # NOTE: check direction if direction not in ['to', 'from']: return value # NOTE: collect property data props = property_data_zpool() if source == 'zfs': ...
Build and properly escape a zfs command
def _command(source, command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, pool_properties=None, target=None): ''' Build and properly escape a zfs command .. note:: Input is not considered safe and will be passed...
Check the system for ZFS support
def is_supported(): ''' Check the system for ZFS support ''' # Check for supported platforms # NOTE: ZFS on Windows is in development # NOTE: ZFS on NetBSD is in development on_supported_platform = False if salt.utils.platform.is_sunos(): on_supported_platform = True elif sal...
Check if zpool - features is available
def has_feature_flags(): ''' Check if zpool-features is available ''' # get man location man = salt.utils.path.which('man') return _check_retcode('{man} zpool-features'.format( man=man )) if man else False
Return a dict of zpool properties
def property_data_zpool(): ''' Return a dict of zpool properties .. note:: Each property will have an entry with the following info: - edit : boolean - is this property editable after pool creation - type : str - either bool, bool_alt, size, numeric, or string -...
Convert zfs bool to python bool
def from_bool(value): ''' Convert zfs bool to python bool ''' if value in ['on', 'yes']: value = True elif value in ['off', 'no']: value = False elif value == 'none': value = None return value
Convert python bool to zfs on/ off bool
def to_bool(value): ''' Convert python bool to zfs on/off bool ''' value = from_bool(value) if isinstance(value, bool): value = 'on' if value else 'off' elif value is None: value = 'none' return value
Convert python to zfs yes/ no value
def to_bool_alt(value): ''' Convert python to zfs yes/no value ''' value = from_bool_alt(value) if isinstance(value, bool): value = 'yes' if value else 'no' elif value is None: value = 'none' return value
Convert zfs size ( human readble ) to python int ( bytes )
def from_size(value): ''' Convert zfs size (human readble) to python int (bytes) ''' match_size = re_zfs_size.match(str(value)) if match_size: v_unit = match_size.group(2).upper()[0] v_size = float(match_size.group(1)) v_multiplier = math.pow(1024, zfs_size.index(v_unit) + 1)...
Convert python int ( bytes ) to zfs size
def to_size(value, convert_to_human=True): ''' Convert python int (bytes) to zfs size NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114 ''' value = from_size(value) if value is None: value = 'none' if isinstance(value, Number) and value > 10...
Decode zfs safe string ( used for name path... )
def from_str(value): ''' Decode zfs safe string (used for name, path, ...) ''' if value == 'none': value = None if value: value = str(value) if value.startswith('"') and value.endswith('"'): value = value[1:-1] value = value.replace('\\"', '"') return...
Encode zfs safe string ( used for name path... )
def to_str(value): ''' Encode zfs safe string (used for name, path, ...) ''' value = from_str(value) if value: value = value.replace('"', '\\"') if ' ' in value: value = '"' + value + '"' elif value is None: value = 'none' return value
Convert python value to zfs value
def to_auto(name, value, source='auto', convert_to_human=True): ''' Convert python value to zfs value ''' return _auto('to', name, value, source, convert_to_human)
Pass an entire dictionary to from_auto
def from_auto_dict(values, source='auto'): ''' Pass an entire dictionary to from_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = from_auto(name, value, source) return values
Pass an entire dictionary to to_auto
def to_auto_dict(values, source='auto', convert_to_human=True): ''' Pass an entire dictionary to to_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = to_auto(name, value, source, convert_to_human) return values
Build and properly escape a zpool command
def zpool_command(command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, pool_properties=None, target=None): ''' Build and properly escape a zpool command .. note:: Input is not considered safe and will be passed through to_au...
Parse the result of a zpool/ zfs command
def parse_command_result(res, label=None): ''' Parse the result of a zpool/zfs command .. note:: Output on failure is rather predicatable. - retcode > 0 - each 'error' is a line on stderr - optional 'Usage:' block under those with hits We simple check those and ret...
Read the log file and return match whole string
def beacon(config): ''' Read the log file and return match whole string .. code-block:: yaml beacons: log: - file: <path> - tags: <tag>: regex: <pattern> .. note:: regex matching is based on the `re`_ modul...
Convert key/ value to tree
def key_value_to_tree(data): ''' Convert key/value to tree ''' tree = {} for flatkey, value in six.iteritems(data): t = tree keys = flatkey.split(__opts__['pepa_delimiter']) for i, key in enumerate(keys, 1): if i == len(keys): t[key] = value ...
Evaluate Pepa templates
def ext_pillar(minion_id, pillar, resource, sequence, subkey=False, subkey_only=False): ''' Evaluate Pepa templates ''' roots = __opts__['pepa_roots'] # Default input inp = {} inp['default'] = 'default' inp['hostname'] = minion_id if 'environment' in pillar: inp['environmen...
Validate Pepa templates
def validate(output, resource): ''' Validate Pepa templates ''' try: import cerberus # pylint: disable=import-error except ImportError: log.critical('You need module cerberus in order to use validation') return roots = __opts__['pepa_roots'] valdir = os.path.join(r...
Return list of disk devices
def disks(): ''' Return list of disk devices ''' if salt.utils.platform.is_freebsd(): return _freebsd_geom() elif salt.utils.platform.is_linux(): return _linux_disks() elif salt.utils.platform.is_windows(): return _windows_disks() else: log.trace('Disk grain d...
Return list of disk devices and work out if they are SSD or HDD.
def _linux_disks(): ''' Return list of disk devices and work out if they are SSD or HDD. ''' ret = {'disks': [], 'SSDs': []} for entry in glob.glob('/sys/block/*/queue/rotational'): try: with salt.utils.files.fopen(entry) as entry_fp: device = entry.split('/')[3]...
Ensure that the VirtualBox Guest Additions are installed. Uses the CD connected by VirtualBox.
def additions_installed(name, reboot=False, upgrade_os=False): ''' Ensure that the VirtualBox Guest Additions are installed. Uses the CD, connected by VirtualBox. name The name has no functional value and is only used as a tracking reference. reboot : False Restart OS to com...
Ensure that the VirtualBox Guest Additions are removed. Uses the CD connected by VirtualBox.
def additions_removed(name, force=False): ''' Ensure that the VirtualBox Guest Additions are removed. Uses the CD, connected by VirtualBox. To connect VirtualBox Guest Additions via VirtualBox graphical interface press 'Host+D' ('Host' is usually 'Right Ctrl'). name The name has no fun...
Grant access to auto - mounted shared folders to the users.
def grant_access_to_shared_folders_to(name, users=None): ''' Grant access to auto-mounted shared folders to the users. User is specified by it's name. To grant access for several users use argument `users`. name Name of the user to grant access to auto-mounted shared folders to. users ...
Perform a lightweight check to see if the master daemon is running
def _is_master_running(self): ''' Perform a lightweight check to see if the master daemon is running Note, this will return an invalid success if the master crashed or was not shut down cleanly. ''' # Windows doesn't have IPC. Assume the master is running. # At w...
Execute the specified function in the specified client by passing the lowstate
def run(self, low): ''' Execute the specified function in the specified client by passing the lowstate ''' # Eauth currently requires a running daemon and commands run through # this method require eauth so perform a quick check to raise a # more meaningful error....
Run: ref: execution modules <all - salt. modules > asynchronously
def local_async(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` asynchronously Wraps :py:meth:`salt.client.LocalClient.run_job`. :return: job ID ''' local = salt.client.get_local_client(mopts=self.opts) ret = local.run_job(*args, **kw...