text stringlengths 81 112k |
|---|
Render a formatted multi-line XML string from a complex Python
data structure. Supports tag attributes and nested dicts/lists.
:param value: Complex data structure representing XML contents
:returns: Formatted XML string rendered with newlines and indentation
:rtype: str
def format_xml... |
Ensure that the index alias is absent.
name
Name of the index alias to remove
index
Name of the index for the alias
def alias_absent(name, index):
'''
Ensure that the index alias is absent.
name
Name of the index alias to remove
index
Name of the index for the ... |
Ensure that the named index alias is present.
name
Name of the alias
index
Name of the index
definition
Optional dict for filters as per https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
**Example:**
.. code-block:: yaml
mytestal... |
Ensure that the named index template is absent.
name
Name of the index to remove
def index_template_absent(name):
'''
Ensure that the named index template is absent.
name
Name of the index to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
t... |
Ensure that the named index template is present.
name
Name of the index to add
definition
Required dict for creation parameters as per https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
check_definition
If the template already exists and the defin... |
Ensure that the named pipeline is absent
name
Name of the pipeline to remove
def pipeline_absent(name):
'''
Ensure that the named pipeline is absent
name
Name of the pipeline to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
pi... |
Ensure that the named pipeline is present.
name
Name of the index to add
definition
Required dict for creation parameters as per https://www.elastic.co/guide/en/elasticsearch/reference/master/pipeline.html
**Example:**
.. code-block:: yaml
test_pipeline:
elasticsear... |
Ensure that the search template is absent
name
Name of the search template to remove
def search_template_absent(name):
'''
Ensure that the search template is absent
name
Name of the search template to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': '... |
Ensure that the named search template is present.
name
Name of the search template to add
definition
Required dict for creation parameters as per http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
**Example:**
.. code-block:: yaml
test_pipelin... |
Returns the prefix for a pkg command, using -j if a jail is specified, or
-c if chroot is specified.
def _pkg(jail=None, chroot=None, root=None):
'''
Returns the prefix for a pkg command, using -j if a jail is specified, or
-c if chroot is specified.
'''
ret = ['pkg']
if jail:
ret.e... |
return the version of 'pkg'
def _get_pkgng_version(jail=None, chroot=None, root=None):
'''
return the version of 'pkg'
'''
cmd = _pkg(jail, chroot, root) + ['--version']
return __salt__['cmd.run'](cmd).strip() |
``pkg search`` will return all packages for which the pattern is a match.
Narrow this down and return the package version, or None if no exact match.
def _get_version(name, results):
'''
``pkg search`` will return all packages for which the pattern is a match.
Narrow this down and return the package ve... |
As this module is designed to manipulate packages in jails and chroots, use
the passed jail/chroot to ensure that a key in the __context__ dict that is
unique to that jail/chroot is used.
def _contextkey(jail=None, chroot=None, root=None, prefix='pkg.list_pkgs'):
'''
As this module is designed to manip... |
Return dict of uncommented global variables.
CLI Example:
.. code-block:: bash
salt '*' pkg.parse_config
``NOTE:`` not working properly right now
def parse_config(file_name='/usr/local/etc/pkg.conf'):
'''
Return dict of uncommented global variables.
CLI Example:
.. code-block:... |
Returns a string representing the package version or an empty string if not
installed. If more than one package name is specified, a dict of
name/version pairs is returned.
.. note::
This function can accessed using ``pkg.info`` in addition to
``pkg.version``, to more closely match the CLI... |
Refresh PACKAGESITE contents
.. note::
This function can accessed using ``pkg.update`` in addition to
``pkg.refresh_db``, to more closely match the CLI usage of ``pkg(8)``.
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
jail
Refresh the pkg database withi... |
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
jail
List the packages in the specified jail
chroot
List the packages in the specified chroot (ignored if ``jail`` is
specified)
root
List the packages in the specified root (ignored... |
Return pkgng stats.
CLI Example:
.. code-block:: bash
salt '*' pkg.stats
local
Display stats only for the local package database.
CLI Example:
.. code-block:: bash
salt '*' pkg.stats local=True
remote
Display stats only for the remote package d... |
Export installed packages into yaml+mtree file
CLI Example:
.. code-block:: bash
salt '*' pkg.backup /tmp/pkg
jail
Backup packages from the specified jail. Note that this will run the
command within the jail, and so the path to the backup file will be
relative to the root... |
Reads archive created by pkg backup -d and recreates the database.
CLI Example:
.. code-block:: bash
salt '*' pkg.restore /tmp/pkg
jail
Restore database to the specified jail. Note that this will run the
command within the jail, and so the path to the file from which the pkg
... |
Audits installed packages against known vulnerabilities
CLI Example:
.. code-block:: bash
salt '*' pkg.audit
jail
Audit packages within the specified jail
CLI Example:
.. code-block:: bash
salt '*' pkg.audit jail=<jail name or id>
chroot
Audit ... |
Install package(s) from a repository
name
The name of the package to install
CLI Example:
.. code-block:: bash
salt '*' pkg.install <package name>
jail
Install the package into the specified jail
chroot
Install the package into the specified chroot (... |
Remove a package from the database and system
.. note::
This function can accessed using ``pkg.delete`` in addition to
``pkg.remove``, to more closely match the CLI usage of ``pkg(8)``.
name
The package to remove
CLI Example:
.. code-block:: bash
salt '*... |
Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
omitted, the operation is executed on all packages.
Returns a dictionary containing the changes:
.. code-block:: python
{'<package>': {'old': '<old-version>',
'new': '<new-version>'}}
CLI Ex... |
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
CLI Example:
.. code-block:: bash
salt '*' pkg.clean jail=<jail name or id>
chroot
Cleans... |
Sanity checks installed packages
jail
Perform the sanity check in the specified jail
CLI Example:
.. code-block:: bash
salt '*' pkg.check jail=<jail name or id>
chroot
Perform the sanity check in the specified chroot (ignored if ``jail``
is specified)
... |
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-block:: bash
salt '*' pkg.which <file name> jail=<jail name or id>
chroo... |
Searches in remote package repositories
CLI Example:
.. code-block:: bash
salt '*' pkg.search pattern
jail
Perform the search using the ``pkg.conf(5)`` from the specified jail
CLI Example:
.. code-block:: bash
salt '*' pkg.search pattern jail=<jail name or ... |
Fetches remote packages
CLI Example:
.. code-block:: bash
salt '*' pkg.fetch <package name>
jail
Fetch package in the specified jail
CLI Example:
.. code-block:: bash
salt '*' pkg.fetch <package name> jail=<jail name or id>
chroot
Fetch package... |
Displays UPDATING entries of software packages
CLI Example:
.. code-block:: bash
salt '*' pkg.updating foo
jail
Perform the action in the specified jail
CLI Example:
.. code-block:: bash
salt '*' pkg.updating foo jail=<jail name or id>
chroot
P... |
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.lock>` instead. instead.
name
The name of the package to be held.... |
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 locked packages within the specified jai... |
Helper function for lock and unlock commands, because their syntax is identical.
Run the lock/unlock command, and return a list of locked packages
def _lockcmd(subcmd, pkgname=None, **kwargs):
'''
Helper function for lock and unlock commands, because their syntax is identical.
Run the lock/unlock com... |
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
CLI Example:
.. code-block:: bash
... |
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':
'current': n.n.n
'new': n.n.n
... |
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_cmp '2.1.11' '2.1.12'
def version_cmp(pkg1, pkg2, ignore_epoch=False,... |
.. 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. ``salt://path/to/file.rpm``).
If a salt file... |
Change package selection for each package specified to 'install'
CLI Example:
.. code-block:: bash
salt '*' lowpkg.unpurge curl
def unpurge(*packages):
'''
Change package selection for each package specified to 'install'
CLI Example:
.. code-block:: bash
salt '*' lowpkg.un... |
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.
CLI Example:
.. code-block:: bash
... |
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 '*' lowpkg.file_list httpd postfix
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).
CLI Examples:
.. code-block:: bash
salt '*' lowpkg.file_list httpd
salt '*' lowpkg.file_list httpd ... |
Get package build time, if possible.
:param name:
:return:
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):
... |
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:
def _get_pkg_info(*packages, **kwargs):
'''
Return list of pack... |
Try to get a license from the package.
Based on https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
:param pkg:
:return:
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 ... |
Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return:
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 ... |
Get the package information of the available packages, maintained by dselect.
Note, this will be not very useful, if dselect isn't installed.
:return:
def _get_pkg_ds_avail():
'''
Get the package information of the available packages, maintained by dselect.
Note, this will be not very useful, if d... |
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
Whether to throw an exception if none of t... |
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 gl... |
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 ... |
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(... |
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']:
... |
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', ... |
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 = [... |
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 = sel... |
List the RAID devices.
CLI Example:
.. code-block:: bash
salt '*' raid.list
def list_():
'''
List the RAID devices.
CLI Example:
.. code-block:: bash
salt '*' raid.list
'''
ret = {}
for line in (__salt__['cmd.run_stdout']
(['mdadm', '--detai... |
Show detail for a specified RAID device
CLI Example:
.. code-block:: bash
salt '*' raid.detail '/dev/md0'
def detail(device='/dev/md0'):
'''
Show detail for a specified RAID device
CLI Example:
.. code-block:: bash
salt '*' raid.detail '/dev/md0'
'''
ret = {}
r... |
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
def destroy(device):
'''
Destroy a RAID device.
WARNING This will zero the superblock of all members of the RAID array..
... |
Create a RAID device.
.. versionchanged:: 2014.7.0
.. warning::
Use with CAUTION, as this function can be very destructive if not used
properly!
CLI Examples:
.. code-block:: bash
salt '*' raid.create /dev/md0 level=1 chunk=256 devices="['/dev/xvdd', '/dev/xvde']" test_mode=... |
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:
.. code-block:: bash
salt '... |
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 out the mdadm
command that would have been run.
name
The name of the array to assemble... |
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/sda1'
def examine(device, quiet=False):
... |
Add new device to RAID array.
CLI Example:
.. code-block:: bash
salt '*' raid.add /dev/md0 /dev/sda1
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} --ad... |
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 myminion boto_elasticsearch_domain.exists mydomain
def exists(DomainName,
region=No... |
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
def status(DomainName,
region=None, key=None, keyid=None, profile=None):
'''
Given a domain nam... |
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
def describe(DomainName,
region=None, key=None, keyid=None, profile=None):
'''
Given a do... |
Given a valid config, create a domain.
Returns {created: true} if the domain was created and returns
{created: False} if the domain was not created.
CLI Example:
.. code-block:: bash
salt myminion boto_elasticsearch_domain.create mydomain \\
{'InstanceType': 't2.micro.elasticse... |
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_elasticsearch_domain.delete mydomain
def delete(DomainName, region=None, key=None, keyid=None, p... |
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 myminion boto_elasticsearch_domain.add_tags mydomain tag_a=tag_value tag_b=tag_value
def add_tags(DomainName=None, ARN=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 myminion boto_cloudtrail.remove_tags my_trail tag_a=tag_value tag_b=tag_value
def remove_tags(TagKeys, DomainName=None, ARN... |
List tags of a trail
Returns:
tags:
- {...}
- {...}
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.list_tags my_trail
def list_tags(DomainName=None, ARN=None,
region=None, key=None, keyid=None, profile=None):
'''
List tags of a tra... |
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
Description of the security group
project... |
Ensure a security group does not exist
name
Name of the security group
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,
'c... |
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 files' dict
inside the return dict, for later refe... |
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 configuration file.
:return: The value for a specific configuration... |
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 for the command specified by the value parameter.
:param str conf_file:... |
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}}}'.form... |
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,
... |
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=N... |
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,
... |
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... |
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`` (structured data).
transport: ``https``
Specifies the ty... |
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 connection transport to use. Valid values for the
connection are ``http... |
Configures the Nexus switch with the specified commands.
This method is used to send configuration commands to the switch. It
will take either a string or a list and prepend the necessary commands
to put the session into config mode.
.. warning::
All the commands will be applied directly int... |
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 can be:
* a list of bool... |
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)):
... |
Merge obj_b into obj_a.
>>> aggregate('first', 'second', True) == ['first', 'second']
True
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... |
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 mig... |
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_al... |
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>',... |
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'] =... |
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 = ... |
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... |
Build and properly escape a zfs command
.. note::
Input is not considered safe and will be passed through
to_auto(from_auto('input_here')), you do not need to do so
your self first.
def _command(source, command, flags=None, opts=None,
property_name=None, property_value=None,
... |
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_supp... |
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
.. 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
- values : str - list of possible values... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.