partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | clean | 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... | salt/modules/pkgng.py | 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
... | 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
... | [
"Cleans",
"the",
"local",
"cache",
"of",
"fetched",
"remote",
"packages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1215-L1288 | [
"def",
"clean",
"(",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"clean_all",
"=",
"False",
",",
"dryrun",
"=",
"False",
")",
":",
"opts",
"=",
"''",
"if",
"clean_all",
":",
"opts",
"+=",
"'a'",
"if",
"dryrun",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | check | 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)
... | salt/modules/pkgng.py | 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... | 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... | [
"Sanity",
"checks",
"installed",
"packages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1326-L1407 | [
"def",
"check",
"(",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"depends",
"=",
"False",
",",
"recompute",
"=",
"False",
",",
"checksum",
"=",
"False",
")",
":",
"if",
"not",
"any",
"(",
"(",
"depends",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | which | 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... | salt/modules/pkgng.py | 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... | 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... | [
"Displays",
"which",
"package",
"installed",
"a",
"specific",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1410-L1477 | [
"def",
"which",
"(",
"path",
",",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"origin",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"opts",
"=",
"''",
"if",
"quiet",
":",
"opts",
"+=",
"'q'",
"if",
"o... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | search | 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 ... | salt/modules/pkgng.py | 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... | 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... | [
"Searches",
"in",
"remote",
"package",
"repositories"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1480-L1673 | [
"def",
"search",
"(",
"name",
",",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"exact",
"=",
"False",
",",
"glob",
"=",
"False",
",",
"regex",
"=",
"False",
",",
"pcre",
"=",
"False",
",",
"comment",
"=",
"Fals... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | fetch | 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... | salt/modules/pkgng.py | 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... | 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... | [
"Fetches",
"remote",
"packages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1676-L1821 | [
"def",
"fetch",
"(",
"name",
",",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"fetch_all",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"fromrepo",
"=",
"None",
",",
"glob",
"=",
"True",
",",
"regex",
"=",
"F... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | updating | 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... | salt/modules/pkgng.py | 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... | 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... | [
"Displays",
"UPDATING",
"entries",
"of",
"software",
"packages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1824-L1896 | [
"def",
"updating",
"(",
"name",
",",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"filedate",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"opts",
"=",
"''",
"if",
"filedate",
":",
"opts",
"+=",
"'d {0}'",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | hold | 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.... | salt/modules/pkgng.py | 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... | 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... | [
"Version",
"-",
"lock",
"packages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L1899-L1961 | [
"def",
"hold",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"targets",
"=",
"[",
"]",
"if",
"pkgs",
":",
"targets",
".",
"extend",
"(",
"pkgs",
")",
"else",
":",
"targets",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_locked | 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... | salt/modules/pkgng.py | 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... | 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... | [
"Query",
"the",
"package",
"database",
"those",
"packages",
"which",
"are",
"locked",
"against",
"reinstallation",
"modification",
"or",
"deletion",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L2029-L2073 | [
"def",
"list_locked",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"'{0}-{1}'",
".",
"format",
"(",
"pkgname",
",",
"version",
"(",
"pkgname",
",",
"*",
"*",
"kwargs",
")",
")",
"for",
"pkgname",
"in",
"_lockcmd",
"(",
"'lock'",
",",
"name",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _lockcmd | Helper function for lock and unlock commands, because their syntax is identical.
Run the lock/unlock command, and return a list of locked packages | salt/modules/pkgng.py | 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... | 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... | [
"Helper",
"function",
"for",
"lock",
"and",
"unlock",
"commands",
"because",
"their",
"syntax",
"is",
"identical",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L2221-L2261 | [
"def",
"_lockcmd",
"(",
"subcmd",
",",
"pkgname",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"jail",
"=",
"kwargs",
".",
"pop",
"(",
"'jail'",
",",
"None",
")",
"chroot",
"=",
"kwargs",
".",
"pop",
"(",
"'chroot'",
",",
"None",
")",
"root",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_upgrades | 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
... | salt/modules/pkgng.py | 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
... | 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
... | [
"List",
"those",
"packages",
"for",
"which",
"an",
"upgrade",
"is",
"available"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L2264-L2322 | [
"def",
"list_upgrades",
"(",
"refresh",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"jail",
"=",
"kwargs",
".",
"pop",
"(",
"'jail'",
",",
"None",
")",
"chroot",
"=",
"kwargs",
".",
"pop",
"(",
"'chroot'",
",",
"None",
")",
"root",
"=",
"kwargs... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_upgrade | 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
... | salt/modules/pkgng.py | 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... | 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... | [
"Parse",
"the",
"output",
"from",
"the",
"pkg",
"upgrade",
"--",
"dry",
"-",
"run",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L2325-L2441 | [
"def",
"_parse_upgrade",
"(",
"stdout",
")",
":",
"# Match strings like 'python36: 3.6.3 -> 3.6.4 [FreeBSD]'",
"upgrade_regex",
"=",
"re",
".",
"compile",
"(",
"r'^\\s+([^:]+):\\s([0-9a-z_,.]+)\\s+->\\s+([0-9a-z_,.]+)\\s*(\\[([^]]+)\\])?\\s*(\\(([^)]+)\\))?'",
")",
"# Match strings lik... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | version_cmp | 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' | salt/modules/pkgng.py | 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... | 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... | [
"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",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L2444-L2476 | [
"def",
"version_cmp",
"(",
"pkg1",
",",
"pkg2",
",",
"ignore_epoch",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"del",
"ignore_epoch",
"# Unused parameter",
"# Don't worry about ignore_epoch since we're shelling out to pkg.",
"sym",
"=",
"{",
"'<'",
":",
"-",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | bin_pkg_info | .. 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... | salt/modules/dpkg_lowpkg.py | 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. ... | 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. ... | [
"..",
"versionadded",
"::",
"2015",
".",
"8",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L37-L110 | [
"def",
"bin_pkg_info",
"(",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"# If the path is a valid protocol, pull it down using cp.cache_file",
"if",
"__salt__",
"[",
"'config.valid_fileproto'",
"]",
"(",
"path",
")",
":",
"newpath",
"=",
"__salt__",
"[",
"'cp.cac... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | unpurge | Change package selection for each package specified to 'install'
CLI Example:
.. code-block:: bash
salt '*' lowpkg.unpurge curl | salt/modules/dpkg_lowpkg.py | 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... | 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... | [
"Change",
"package",
"selection",
"for",
"each",
"package",
"specified",
"to",
"install"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L113-L135 | [
"def",
"unpurge",
"(",
"*",
"packages",
")",
":",
"if",
"not",
"packages",
":",
"return",
"{",
"}",
"old",
"=",
"__salt__",
"[",
"'pkg.list_pkgs'",
"]",
"(",
"purge_desired",
"=",
"True",
")",
"ret",
"=",
"{",
"}",
"__salt__",
"[",
"'cmd.run'",
"]",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_pkgs | 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
... | salt/modules/dpkg_lowpkg.py | 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.
... | 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",
"packages",
"currently",
"installed",
"in",
"a",
"dict",
"::"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L138-L169 | [
"def",
"list_pkgs",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"pkgs",
"=",
"{",
"}",
"cmd",
"=",
"'dpkg -l {0}'",
".",
"format",
"(",
"' '",
".",
"join",
"(",
"packages",
")",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | file_list | 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... | salt/modules/dpkg_lowpkg.py | 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... | 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",
".",
"Not",
"specifying",
"any",
"packages",
"will",
"return",
"a",
"list",
"of",
"_every_",
"file",
"on",
"the",
"system",
"s",
"package",
"database",
"(",
"not",
"generally",
"recommended",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L172-L211 | [
"def",
"file_list",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"ret",
"=",
"set",
"(",
"[",
"]",
")",
"pkgs",
"=",
"{",
"}",
"cmd",
"=",
"'dpkg -l {0}'",
".",
"format",
"(",
"' '",
".",
"join",
"(",
"packa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | file_dict | 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 ... | salt/modules/dpkg_lowpkg.py | 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... | 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... | [
"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",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L214-L252 | [
"def",
"file_dict",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"ret",
"=",
"{",
"}",
"pkgs",
"=",
"{",
"}",
"cmd",
"=",
"'dpkg -l {0}'",
".",
"format",
"(",
"' '",
".",
"join",
"(",
"packages",
")",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_pkg_build_time | Get package build time, if possible.
:param name:
:return: | salt/modules/dpkg_lowpkg.py | 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:
... | 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:
... | [
"Get",
"package",
"build",
"time",
"if",
"possible",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L255-L284 | [
"def",
"_get_pkg_build_time",
"(",
"name",
")",
":",
"iso_time",
"=",
"iso_time_t",
"=",
"None",
"changelog_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'/usr/share/doc'",
",",
"name",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"changelog_dir",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_pkg_info | 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: | salt/modules/dpkg_lowpkg.py | 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 =... | 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 =... | [
"Return",
"list",
"of",
"package",
"information",
".",
"If",
"packages",
"parameter",
"is",
"empty",
"then",
"data",
"about",
"all",
"installed",
"packages",
"will",
"be",
"returned",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L287-L354 | [
"def",
"_get_pkg_info",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"failhard",
"=",
"kwargs",
".",
"pop",
"(",
"'failhard'",
",",
"True... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_pkg_license | Try to get a license from the package.
Based on https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
:param pkg:
:return: | salt/modules/dpkg_lowpkg.py | 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... | 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... | [
"Try",
"to",
"get",
"a",
"license",
"from",
"the",
"package",
".",
"Based",
"on",
"https",
":",
"//",
"www",
".",
"debian",
".",
"org",
"/",
"doc",
"/",
"packaging",
"-",
"manuals",
"/",
"copyright",
"-",
"format",
"/",
"1",
".",
"0",
"/"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L357-L373 | [
"def",
"_get_pkg_license",
"(",
"pkg",
")",
":",
"licenses",
"=",
"set",
"(",
")",
"cpr",
"=",
"\"/usr/share/doc/{0}/copyright\"",
".",
"format",
"(",
"pkg",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cpr",
")",
":",
"with",
"salt",
".",
"utils... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_pkg_install_time | Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return: | salt/modules/dpkg_lowpkg.py | 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':
... | 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':
... | [
"Return",
"package",
"install",
"time",
"based",
"on",
"the",
"/",
"var",
"/",
"lib",
"/",
"dpkg",
"/",
"info",
"/",
"<package",
">",
".",
"list"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L376-L401 | [
"def",
"_get_pkg_install_time",
"(",
"pkg",
",",
"arch",
"=",
"None",
")",
":",
"iso_time",
"=",
"iso_time_t",
"=",
"None",
"loc_root",
"=",
"'/var/lib/dpkg/info'",
"if",
"pkg",
"is",
"not",
"None",
":",
"locations",
"=",
"[",
"]",
"if",
"arch",
"is",
"n... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _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: | salt/modules/dpkg_lowpkg.py | 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):
... | 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):
... | [
"Get",
"the",
"package",
"information",
"of",
"the",
"available",
"packages",
"maintained",
"by",
"dselect",
".",
"Note",
"this",
"will",
"be",
"not",
"very",
"useful",
"if",
"dselect",
"isn",
"t",
"installed",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L404-L432 | [
"def",
"_get_pkg_ds_avail",
"(",
")",
":",
"avail",
"=",
"\"/var/lib/dpkg/available\"",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'dselect'",
")",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"avail",
")",
":",
"return",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | info | 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... | salt/modules/dpkg_lowpkg.py | 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
... | 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
... | [
"Returns",
"a",
"detailed",
"summary",
"of",
"package",
"information",
"for",
"provided",
"package",
"names",
".",
"If",
"no",
"packages",
"are",
"specified",
"all",
"packages",
"will",
"be",
"returned",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L435-L507 | [
"def",
"info",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get the missing information from the /var/lib/dpkg/available, if it is there.",
"# However, this file is operated by dselect which has to be installed.",
"dselect_pkg_avail",
"=",
"_get_pkg_ds_avail",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | func_globals_inject | Override specific variables within a function's global context. | salt/utils/context.py | 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... | 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... | [
"Override",
"specific",
"variables",
"within",
"a",
"function",
"s",
"global",
"context",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/context.py#L28-L61 | [
"def",
"func_globals_inject",
"(",
"func",
",",
"*",
"*",
"overrides",
")",
":",
"# recognize methods",
"if",
"hasattr",
"(",
"func",
",",
"'im_func'",
")",
":",
"func",
"=",
"func",
".",
"__func__",
"# Get a reference to the function globals dictionary",
"func_glob... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ContextDict.clone | Clone this context, and return the ChildContextDict | salt/utils/context.py | def clone(self, **kwargs):
'''
Clone this context, and return the ChildContextDict
'''
child = ChildContextDict(parent=self, threadsafe=self._threadsafe, overrides=kwargs)
return child | def clone(self, **kwargs):
'''
Clone this context, and return the ChildContextDict
'''
child = ChildContextDict(parent=self, threadsafe=self._threadsafe, overrides=kwargs)
return child | [
"Clone",
"this",
"context",
"and",
"return",
"the",
"ChildContextDict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/context.py#L95-L100 | [
"def",
"clone",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"child",
"=",
"ChildContextDict",
"(",
"parent",
"=",
"self",
",",
"threadsafe",
"=",
"self",
".",
"_threadsafe",
",",
"overrides",
"=",
"kwargs",
")",
"return",
"child"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCPCli.run | Execute salt-cp | salt/cli/cp.py | 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() | 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() | [
"Execute",
"salt",
"-",
"cp"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L41-L52 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"parse_args",
"(",
")",
"# Setup file logging!",
"self",
".",
"setup_logfile_logger",
"(",
")",
"salt",
".",
"utils",
".",
"verify",
".",
"verify_log",
"(",
"self",
".",
"config",
")",
"cp_",
"=",
"SaltCP... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP._recurse | Get a list of all specified files | salt/cli/cp.py | 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.... | 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.... | [
"Get",
"a",
"list",
"of",
"all",
"specified",
"files"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L71-L95 | [
"def",
"_recurse",
"(",
"self",
",",
"path",
")",
":",
"files",
"=",
"{",
"}",
"empty_dirs",
"=",
"[",
"]",
"try",
":",
"sub_paths",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP._file_dict | Take a path and return the contents of the file as a string | salt/cli/cp.py | 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.... | 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.... | [
"Take",
"a",
"path",
"and",
"return",
"the",
"contents",
"of",
"the",
"file",
"as",
"a",
"string"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L106-L116 | [
"def",
"_file_dict",
"(",
"self",
",",
"fn_",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fn_",
")",
":",
"err",
"=",
"'The referenced file, {0} is not available.'",
".",
"format",
"(",
"fn_",
")",
"sys",
".",
"stderr",
".",
"write",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP._load_files | Parse the files indicated in opts['src'] and load them into a python
object for transport | salt/cli/cp.py | 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... | 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... | [
"Parse",
"the",
"files",
"indicated",
"in",
"opts",
"[",
"src",
"]",
"and",
"load",
"them",
"into",
"a",
"python",
"object",
"for",
"transport"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L118-L133 | [
"def",
"_load_files",
"(",
"self",
")",
":",
"files",
"=",
"{",
"}",
"for",
"fn_",
"in",
"self",
".",
"opts",
"[",
"'src'",
"]",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"fn_",
")",
":",
"files",
".",
"update",
"(",
"self",
".",
"_file... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP.run | Make the salt client call | salt/cli/cp.py | 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'),
... | 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"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L135-L147 | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"opts",
"[",
"'chunked'",
"]",
":",
"ret",
"=",
"self",
".",
"run_chunked",
"(",
")",
"else",
":",
"ret",
"=",
"self",
".",
"run_oldstyle",
"(",
")",
"salt",
".",
"output",
".",
"display_outpu... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP.run_oldstyle | Make the salt client call in old-style all-in-one call method | salt/cli/cp.py | 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... | 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",
"old",
"-",
"style",
"all",
"-",
"in",
"-",
"one",
"call",
"method"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L149-L165 | [
"def",
"run_oldstyle",
"(",
"self",
")",
":",
"arg",
"=",
"[",
"self",
".",
"_load_files",
"(",
")",
",",
"self",
".",
"opts",
"[",
"'dest'",
"]",
"]",
"local",
"=",
"salt",
".",
"client",
".",
"get_local_client",
"(",
"self",
".",
"opts",
"[",
"'c... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCP.run_chunked | Make the salt client call in the new fasion chunked multi-call way | salt/cli/cp.py | 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... | 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... | [
"Make",
"the",
"salt",
"client",
"call",
"in",
"the",
"new",
"fasion",
"chunked",
"multi",
"-",
"call",
"way"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/cp.py#L167-L286 | [
"def",
"run_chunked",
"(",
"self",
")",
":",
"files",
",",
"empty_dirs",
"=",
"self",
".",
"_list_files",
"(",
")",
"dest",
"=",
"self",
".",
"opts",
"[",
"'dest'",
"]",
"gzip",
"=",
"self",
".",
"opts",
"[",
"'gzip'",
"]",
"tgt",
"=",
"self",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_ | List the RAID devices.
CLI Example:
.. code-block:: bash
salt '*' raid.list | salt/modules/mdadm_raid.py | 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... | 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... | [
"List",
"the",
"RAID",
"devices",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L43-L66 | [
"def",
"list_",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"line",
"in",
"(",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"[",
"'mdadm'",
",",
"'--detail'",
",",
"'--scan'",
"]",
",",
"python_shell",
"=",
"False",
")",
".",
"splitlines",
"(",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | detail | Show detail for a specified RAID device
CLI Example:
.. code-block:: bash
salt '*' raid.detail '/dev/md0' | salt/modules/mdadm_raid.py | 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... | 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... | [
"Show",
"detail",
"for",
"a",
"specified",
"RAID",
"device"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L69-L111 | [
"def",
"detail",
"(",
"device",
"=",
"'/dev/md0'",
")",
":",
"ret",
"=",
"{",
"}",
"ret",
"[",
"'members'",
"]",
"=",
"{",
"}",
"# Lets make sure the device exists before running mdadm",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"device",
")",
":... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | destroy | 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 | salt/modules/mdadm_raid.py | 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... | 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... | [
"Destroy",
"a",
"RAID",
"device",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L114-L153 | [
"def",
"destroy",
"(",
"device",
")",
":",
"try",
":",
"details",
"=",
"detail",
"(",
"device",
")",
"except",
"CommandExecutionError",
":",
"return",
"False",
"stop_cmd",
"=",
"[",
"'mdadm'",
",",
"'--stop'",
",",
"device",
"]",
"zero_cmd",
"=",
"[",
"'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create | 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=... | salt/modules/mdadm_raid.py | 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!
... | 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!
... | [
"Create",
"a",
"RAID",
"device",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L174-L259 | [
"def",
"create",
"(",
"name",
",",
"level",
",",
"devices",
",",
"metadata",
"=",
"'default'",
",",
"test_mode",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"opts",
"=",
"[",
"]",
"raid_devices",
"=",
"len",
"(",
"devices",
")",
"for",
"key",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | 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:
.. code-block:: bash
salt '... | salt/modules/mdadm_raid.py | 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... | 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... | [
"Save",
"RAID",
"configuration",
"to",
"config",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L262-L306 | [
"def",
"save_config",
"(",
")",
":",
"scan",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'mdadm --detail --scan'",
",",
"python_shell",
"=",
"False",
")",
".",
"splitlines",
"(",
")",
"# Issue with mdadm and ubuntu",
"# REF: http://askubuntu.com/questions/209702/why-i... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | assemble | 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... | salt/modules/mdadm_raid.py | 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 ... | 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 ... | [
"Assemble",
"a",
"RAID",
"device",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L309-L360 | [
"def",
"assemble",
"(",
"name",
",",
"devices",
",",
"test_mode",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"opts",
"=",
"[",
"]",
"for",
"key",
"in",
"kwargs",
":",
"if",
"not",
"key",
".",
"startswith",
"(",
"'__'",
")",
":",
"opts",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | examine | 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' | salt/modules/mdadm_raid.py | 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... | 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... | [
"Show",
"detail",
"for",
"a",
"specified",
"RAID",
"component",
"device"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L363-L387 | [
"def",
"examine",
"(",
"device",
",",
"quiet",
"=",
"False",
")",
":",
"res",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'mdadm -Y -E {0}'",
".",
"format",
"(",
"device",
")",
",",
"python_shell",
"=",
"False",
",",
"ignore_retcode",
"=",
"quiet"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add | Add new device to RAID array.
CLI Example:
.. code-block:: bash
salt '*' raid.add /dev/md0 /dev/sda1 | salt/modules/mdadm_raid.py | 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 | 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 | [
"Add",
"new",
"device",
"to",
"RAID",
"array",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdadm_raid.py#L390-L405 | [
"def",
"add",
"(",
"name",
",",
"device",
")",
":",
"cmd",
"=",
"'mdadm --manage {0} --add {1}'",
".",
"format",
"(",
"name",
",",
"device",
")",
"if",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"cmd",
")",
"==",
"0",
":",
"return",
"True",
"return",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | exists | 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 | salt/modules/boto_elasticsearch_domain.py | 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... | 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",
"check",
"to",
"see",
"if",
"the",
"given",
"domain",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L127-L150 | [
"def",
"exists",
"(",
"DomainName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status | 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 | salt/modules/boto_elasticsearch_domain.py | 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 ... | 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",
"status",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L153-L181 | [
"def",
"status",
"(",
"DomainName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | describe | 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 | salt/modules/boto_elasticsearch_domain.py | 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
'''
... | 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",
"domain",
"name",
"describe",
"its",
"properties",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L184-L210 | [
"def",
"describe",
"(",
"DomainName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create | 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... | salt/modules/boto_elasticsearch_domain.py | 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... | 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",
"valid",
"config",
"create",
"a",
"domain",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L213-L264 | [
"def",
"create",
"(",
"DomainName",
",",
"ElasticsearchClusterConfig",
"=",
"None",
",",
"EBSOptions",
"=",
"None",
",",
"AccessPolicies",
"=",
"None",
",",
"SnapshotOptions",
"=",
"None",
",",
"AdvancedOptions",
"=",
"None",
",",
"region",
"=",
"None",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete | 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 | salt/modules/boto_elasticsearch_domain.py | 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... | 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... | [
"Given",
"a",
"domain",
"name",
"delete",
"it",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L267-L287 | [
"def",
"delete",
"(",
"DomainName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_tags | 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 | salt/modules/boto_elasticsearch_domain.py | 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... | 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... | [
"Add",
"tags",
"to",
"a",
"domain"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L340-L380 | [
"def",
"add_tags",
"(",
"DomainName",
"=",
"None",
",",
"ARN",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"conn",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove_tags | 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 | salt/modules/boto_elasticsearch_domain.py | 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... | 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... | [
"Remove",
"tags",
"from",
"a",
"trail"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L383-L419 | [
"def",
"remove_tags",
"(",
"TagKeys",
",",
"DomainName",
"=",
"None",
",",
"ARN",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_con... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_tags | List tags of a trail
Returns:
tags:
- {...}
- {...}
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.list_tags my_trail | salt/modules/boto_elasticsearch_domain.py | 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:
... | 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:
... | [
"List",
"tags",
"of",
"a",
"trail"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticsearch_domain.py#L422-L464 | [
"def",
"list_tags",
"(",
"DomainName",
"=",
"None",
",",
"ARN",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_conn",
"(",
"region",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | 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... | salt/states/neutron_secgroup.py | 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
... | 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",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/neutron_secgroup.py#L50-L120 | [
"def",
"present",
"(",
"name",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"kwargs",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure a security group does not exist
name
Name of the security group | salt/states/neutron_secgroup.py | 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... | 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... | [
"Ensure",
"a",
"security",
"group",
"does",
"not",
"exist"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/neutron_secgroup.py#L123-L159 | [
"def",
"absent",
"(",
"name",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"kwargs",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_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 files' dict
inside the return dict, for later refe... | salt/modules/logrotate.py | 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 ... | 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 ... | [
"Parse",
"a",
"logrotate",
"configuration",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logrotate.py#L57-L123 | [
"def",
"_parse_conf",
"(",
"conf_file",
"=",
"_DEFAULT_CONF",
")",
":",
"ret",
"=",
"{",
"}",
"mode",
"=",
"'single'",
"multi_names",
"=",
"[",
"]",
"multi",
"=",
"{",
"}",
"prev_comps",
"=",
"None",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get | 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... | salt/modules/logrotate.py | 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... | 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... | [
"Get",
"the",
"value",
"for",
"a",
"specific",
"configuration",
"line",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logrotate.py#L144-L170 | [
"def",
"get",
"(",
"key",
",",
"value",
"=",
"None",
",",
"conf_file",
"=",
"_DEFAULT_CONF",
")",
":",
"current_conf",
"=",
"_parse_conf",
"(",
"conf_file",
")",
"stanza",
"=",
"current_conf",
".",
"get",
"(",
"key",
",",
"False",
")",
"if",
"value",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_ | 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:... | salt/modules/logrotate.py | 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... | 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... | [
"Set",
"a",
"new",
"value",
"for",
"a",
"specific",
"configuration",
"line",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logrotate.py#L173-L273 | [
"def",
"set_",
"(",
"key",
",",
"value",
",",
"setting",
"=",
"None",
",",
"conf_file",
"=",
"_DEFAULT_CONF",
")",
":",
"conf",
"=",
"_parse_conf",
"(",
"conf_file",
")",
"for",
"include",
"in",
"conf",
"[",
"'include files'",
"]",
":",
"if",
"key",
"i... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dict_to_stanza | Convert a dict to a multi-line stanza | salt/modules/logrotate.py | 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) | 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) | [
"Convert",
"a",
"dict",
"to",
"a",
"multi",
"-",
"line",
"stanza"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logrotate.py#L276-L285 | [
"def",
"_dict_to_stanza",
"(",
"key",
",",
"stanza",
")",
":",
"ret",
"=",
"''",
"for",
"skey",
"in",
"stanza",
":",
"if",
"stanza",
"[",
"skey",
"]",
"is",
"True",
":",
"stanza",
"[",
"skey",
"]",
"=",
"''",
"ret",
"+=",
"' {0} {1}\\n'",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | lock | Block state execution until you are able to get the lock (or hit the timeout) | salt/states/zk_concurrency.py | 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... | 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... | [
"Block",
"state",
"execution",
"until",
"you",
"are",
"able",
"to",
"get",
"the",
"lock",
"(",
"or",
"hit",
"the",
"timeout",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zk_concurrency.py#L69-L112 | [
"def",
"lock",
"(",
"name",
",",
"zk_hosts",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"max_concurrency",
"=",
"1",
",",
"timeout",
"=",
"None",
",",
"ephemeral_lease",
"=",
"False",
",",
"profile",
"=",
"None",
",",
"scheme",
"=",
"None",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | unlock | Remove lease from semaphore. | salt/states/zk_concurrency.py | 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,... | 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,... | [
"Remove",
"lease",
"from",
"semaphore",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zk_concurrency.py#L115-L155 | [
"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",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | min_party | Ensure that there are `min_nodes` in the party at `name`, optionally blocking if not available. | salt/states/zk_concurrency.py | 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... | 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... | [
"Ensure",
"that",
"there",
"are",
"min_nodes",
"in",
"the",
"party",
"at",
"name",
"optionally",
"blocking",
"if",
"not",
"available",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zk_concurrency.py#L158-L198 | [
"def",
"min_party",
"(",
"name",
",",
"zk_hosts",
",",
"min_nodes",
",",
"blocking",
"=",
"False",
",",
"profile",
"=",
"None",
",",
"scheme",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"default_acl",
"=",
"None",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _cli_command | Execute a list of CLI commands. | salt/modules/nxos_api.py | 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... | 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",
"a",
"list",
"of",
"CLI",
"commands",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_api.py#L171-L194 | [
"def",
"_cli_command",
"(",
"commands",
",",
"method",
"=",
"'cli'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"commands",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"commands",
"=",
"[",
"commands",
"]",
"rpc_responses",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | rpc | 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... | salt/modules/nxos_api.py | 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`... | 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",
"an",
"arbitrary",
"RPC",
"request",
"via",
"the",
"Nexus",
"API",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_api.py#L201-L254 | [
"def",
"rpc",
"(",
"commands",
",",
"method",
"=",
"'cli'",
",",
"*",
"*",
"kwargs",
")",
":",
"nxos_api_kwargs",
"=",
"__salt__",
"[",
"'config.get'",
"]",
"(",
"'nxos_api'",
",",
"{",
"}",
")",
"nxos_api_kwargs",
".",
"update",
"(",
"*",
"*",
"kwargs... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show | 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... | salt/modules/nxos_api.py | 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... | 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... | [
"Execute",
"one",
"or",
"more",
"show",
"(",
"non",
"-",
"configuration",
")",
"commands",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_api.py#L257-L314 | [
"def",
"show",
"(",
"commands",
",",
"raw_text",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"raw_text",
":",
"method",
"=",
"'cli_ascii'",
"key",
"=",
"'msg'",
"else",
":",
"method",
"=",
"'cli'",
"key",
"=",
"'body... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | config | 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... | salt/modules/nxos_api.py | 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... | 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... | [
"Configures",
"the",
"Nexus",
"switch",
"with",
"the",
"specified",
"commands",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_api.py#L317-L427 | [
"def",
"config",
"(",
"commands",
"=",
"None",
",",
"config_file",
"=",
"None",
",",
"template_engine",
"=",
"'jinja'",
",",
"context",
"=",
"None",
",",
"defaults",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
",",
"*",
"*",
"kwargs",
")",
":",
"initia... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | levelise | 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... | salt/utils/aggregation.py | 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 ... | 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 ... | [
"Describe",
"which",
"levels",
"are",
"allowed",
"to",
"do",
"deep",
"merging",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/aggregation.py#L151-L185 | [
"def",
"levelise",
"(",
"level",
")",
":",
"if",
"not",
"level",
":",
"# False, 0, [] ...",
"return",
"False",
",",
"False",
"if",
"level",
"is",
"True",
":",
"return",
"True",
",",
"True",
"if",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"retur... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mark | Convert obj into an Aggregate instance | salt/utils/aggregation.py | 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:
... | 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:
... | [
"Convert",
"obj",
"into",
"an",
"Aggregate",
"instance"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/aggregation.py#L188-L199 | [
"def",
"mark",
"(",
"obj",
",",
"map_class",
"=",
"Map",
",",
"sequence_class",
"=",
"Sequence",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Aggregate",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | aggregate | Merge obj_b into obj_a.
>>> aggregate('first', 'second', True) == ['first', 'second']
True | salt/utils/aggregation.py | 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... | 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... | [
"Merge",
"obj_b",
"into",
"obj_a",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/aggregation.py#L202-L244 | [
"def",
"aggregate",
"(",
"obj_a",
",",
"obj_b",
",",
"level",
"=",
"False",
",",
"map_class",
"=",
"Map",
",",
"sequence_class",
"=",
"Sequence",
")",
":",
"deep",
",",
"subdeep",
"=",
"levelise",
"(",
"level",
")",
"if",
"deep",
":",
"obj_a",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | migrate_paths | Migrate old minion and master pki file paths to new ones. | salt/utils/migrations.py | 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']
... | 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']
... | [
"Migrate",
"old",
"minion",
"and",
"master",
"pki",
"file",
"paths",
"to",
"new",
"ones",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/migrations.py#L15-L54 | [
"def",
"migrate_paths",
"(",
"opts",
")",
":",
"oldpki_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"syspaths",
".",
"CONFIG_DIR",
",",
"'pki'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"oldpki_dir",
")",
":",
"# There's not even a pki... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_retcode | Simple internal wrapper for cmdmod.retcode | salt/utils/zfs.py | def _check_retcode(cmd):
'''
Simple internal wrapper for cmdmod.retcode
'''
return salt.modules.cmdmod.retcode(cmd, output_loglevel='quiet', ignore_retcode=True) == 0 | 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",
".",
"retcode"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L40-L44 | [
"def",
"_check_retcode",
"(",
"cmd",
")",
":",
"return",
"salt",
".",
"modules",
".",
"cmdmod",
".",
"retcode",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'quiet'",
",",
"ignore_retcode",
"=",
"True",
")",
"==",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _exec | Simple internal wrapper for cmdmod.run | salt/utils/zfs.py | 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) | 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) | [
"Simple",
"internal",
"wrapper",
"for",
"cmdmod",
".",
"run"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L47-L55 | [
"def",
"_exec",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"'ignore_retcode'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'ignore_retcode'",
"]",
"=",
"True",
"if",
"'output_loglevel'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'output_loglevel'",
"]",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _merge_last | Merge values all values after X into the last value | salt/utils/zfs.py | 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 | 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 | [
"Merge",
"values",
"all",
"values",
"after",
"X",
"into",
"the",
"last",
"value"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L58-L65 | [
"def",
"_merge_last",
"(",
"values",
",",
"merge_after",
",",
"merge_with",
"=",
"' '",
")",
":",
"if",
"len",
"(",
"values",
")",
">",
"merge_after",
":",
"values",
"=",
"values",
"[",
"0",
":",
"(",
"merge_after",
"-",
"1",
")",
"]",
"+",
"[",
"m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _property_detect_type | Detect the datatype of a property | salt/utils/zfs.py | 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... | 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... | [
"Detect",
"the",
"datatype",
"of",
"a",
"property"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L77-L94 | [
"def",
"_property_detect_type",
"(",
"name",
",",
"values",
")",
":",
"value_type",
"=",
"'str'",
"if",
"values",
".",
"startswith",
"(",
"'on | off'",
")",
":",
"value_type",
"=",
"'bool'",
"elif",
"values",
".",
"startswith",
"(",
"'yes | no'",
")",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _property_create_dict | Create a property dict | salt/utils/zfs.py | 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'])... | 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'])... | [
"Create",
"a",
"property",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L97-L108 | [
"def",
"_property_create_dict",
"(",
"header",
",",
"data",
")",
":",
"prop",
"=",
"dict",
"(",
"zip",
"(",
"header",
",",
"_merge_last",
"(",
"data",
",",
"len",
"(",
"header",
")",
")",
")",
")",
"prop",
"[",
"'name'",
"]",
"=",
"_property_normalize_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _property_parse_cmd | Parse output of zpool/zfs get command | salt/utils/zfs.py | 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)[... | 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)[... | [
"Parse",
"output",
"of",
"zpool",
"/",
"zfs",
"get",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L111-L150 | [
"def",
"_property_parse_cmd",
"(",
"cmd",
",",
"alias",
"=",
"None",
")",
":",
"if",
"not",
"alias",
":",
"alias",
"=",
"{",
"}",
"properties",
"=",
"{",
"}",
"# NOTE: append get to command",
"if",
"cmd",
"[",
"-",
"3",
":",
"]",
"!=",
"'get'",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _auto | Internal magic for from_auto and to_auto | salt/utils/zfs.py | 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':
... | 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':
... | [
"Internal",
"magic",
"for",
"from_auto",
"and",
"to_auto"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L153-L175 | [
"def",
"_auto",
"(",
"direction",
",",
"name",
",",
"value",
",",
"source",
"=",
"'auto'",
",",
"convert_to_human",
"=",
"True",
")",
":",
"# NOTE: check direction",
"if",
"direction",
"not",
"in",
"[",
"'to'",
",",
"'from'",
"]",
":",
"return",
"value",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _command | 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. | salt/utils/zfs.py | 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... | 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... | [
"Build",
"and",
"properly",
"escape",
"a",
"zfs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L196-L279 | [
"def",
"_command",
"(",
"source",
",",
"command",
",",
"flags",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"property_name",
"=",
"None",
",",
"property_value",
"=",
"None",
",",
"filesystem_properties",
"=",
"None",
",",
"pool_properties",
"=",
"None",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | is_supported | Check the system for ZFS support | salt/utils/zfs.py | 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... | 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",
"the",
"system",
"for",
"ZFS",
"support"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L282-L304 | [
"def",
"is_supported",
"(",
")",
":",
"# 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",
"(",
")",
":"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | has_feature_flags | Check if zpool-features is available | salt/utils/zfs.py | 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 | 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 | [
"Check",
"if",
"zpool",
"-",
"features",
"is",
"available"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L308-L316 | [
"def",
"has_feature_flags",
"(",
")",
":",
"# get man location",
"man",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'man'",
")",
"return",
"_check_retcode",
"(",
"'{man} zpool-features'",
".",
"format",
"(",
"man",
"=",
"man",
")",
")",
"if... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | 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
- values : str - list of possible values... | salt/utils/zfs.py | 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
-... | 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
-... | [
"Return",
"a",
"dict",
"of",
"zpool",
"properties"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L320-L372 | [
"def",
"property_data_zpool",
"(",
")",
":",
"# NOTE: man page also mentions a few short forms",
"property_data",
"=",
"_property_parse_cmd",
"(",
"_zpool_cmd",
"(",
")",
",",
"{",
"'allocated'",
":",
"'alloc'",
",",
"'autoexpand'",
":",
"'expand'",
",",
"'autoreplace'"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | from_bool | Convert zfs bool to python bool | salt/utils/zfs.py | 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 | 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",
"zfs",
"bool",
"to",
"python",
"bool"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L430-L441 | [
"def",
"from_bool",
"(",
"value",
")",
":",
"if",
"value",
"in",
"[",
"'on'",
",",
"'yes'",
"]",
":",
"value",
"=",
"True",
"elif",
"value",
"in",
"[",
"'off'",
",",
"'no'",
"]",
":",
"value",
"=",
"False",
"elif",
"value",
"==",
"'none'",
":",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_bool | Convert python bool to zfs on/off bool | salt/utils/zfs.py | 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 | 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",
"bool",
"to",
"zfs",
"on",
"/",
"off",
"bool"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L451-L461 | [
"def",
"to_bool",
"(",
"value",
")",
":",
"value",
"=",
"from_bool",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"value",
"=",
"'on'",
"if",
"value",
"else",
"'off'",
"elif",
"value",
"is",
"None",
":",
"value",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_bool_alt | Convert python to zfs yes/no value | salt/utils/zfs.py | 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 | 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",
"python",
"to",
"zfs",
"yes",
"/",
"no",
"value"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L464-L474 | [
"def",
"to_bool_alt",
"(",
"value",
")",
":",
"value",
"=",
"from_bool_alt",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"value",
"=",
"'yes'",
"if",
"value",
"else",
"'no'",
"elif",
"value",
"is",
"None",
":",
"value",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | from_size | Convert zfs size (human readble) to python int (bytes) | salt/utils/zfs.py | 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)... | 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",
"zfs",
"size",
"(",
"human",
"readble",
")",
"to",
"python",
"int",
"(",
"bytes",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L477-L492 | [
"def",
"from_size",
"(",
"value",
")",
":",
"match_size",
"=",
"re_zfs_size",
".",
"match",
"(",
"str",
"(",
"value",
")",
")",
"if",
"match_size",
":",
"v_unit",
"=",
"match_size",
".",
"group",
"(",
"2",
")",
".",
"upper",
"(",
")",
"[",
"0",
"]"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_size | Convert python int (bytes) to zfs size
NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114 | salt/utils/zfs.py | 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... | 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... | [
"Convert",
"python",
"int",
"(",
"bytes",
")",
"to",
"zfs",
"size"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L495-L527 | [
"def",
"to_size",
"(",
"value",
",",
"convert_to_human",
"=",
"True",
")",
":",
"value",
"=",
"from_size",
"(",
"value",
")",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"'none'",
"if",
"isinstance",
"(",
"value",
",",
"Number",
")",
"and",
"value"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | from_str | Decode zfs safe string (used for name, path, ...) | salt/utils/zfs.py | 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... | 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... | [
"Decode",
"zfs",
"safe",
"string",
"(",
"used",
"for",
"name",
"path",
"...",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L530-L542 | [
"def",
"from_str",
"(",
"value",
")",
":",
"if",
"value",
"==",
"'none'",
":",
"value",
"=",
"None",
"if",
"value",
":",
"value",
"=",
"str",
"(",
"value",
")",
"if",
"value",
".",
"startswith",
"(",
"'\"'",
")",
"and",
"value",
".",
"endswith",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_str | Encode zfs safe string (used for name, path, ...) | salt/utils/zfs.py | 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 | 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 | [
"Encode",
"zfs",
"safe",
"string",
"(",
"used",
"for",
"name",
"path",
"...",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L545-L558 | [
"def",
"to_str",
"(",
"value",
")",
":",
"value",
"=",
"from_str",
"(",
"value",
")",
"if",
"value",
":",
"value",
"=",
"value",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
"if",
"' '",
"in",
"value",
":",
"value",
"=",
"'\"'",
"+",
"value",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_auto | Convert python value to zfs value | salt/utils/zfs.py | 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) | 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) | [
"Convert",
"python",
"value",
"to",
"zfs",
"value"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L568-L572 | [
"def",
"to_auto",
"(",
"name",
",",
"value",
",",
"source",
"=",
"'auto'",
",",
"convert_to_human",
"=",
"True",
")",
":",
"return",
"_auto",
"(",
"'to'",
",",
"name",
",",
"value",
",",
"source",
",",
"convert_to_human",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | from_auto_dict | Pass an entire dictionary to from_auto
.. note::
The key will be passed as the name | salt/utils/zfs.py | 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 | 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",
"from_auto"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L575-L586 | [
"def",
"from_auto_dict",
"(",
"values",
",",
"source",
"=",
"'auto'",
")",
":",
"for",
"name",
",",
"value",
"in",
"values",
".",
"items",
"(",
")",
":",
"values",
"[",
"name",
"]",
"=",
"from_auto",
"(",
"name",
",",
"value",
",",
"source",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | to_auto_dict | Pass an entire dictionary to to_auto
.. note::
The key will be passed as the name | salt/utils/zfs.py | 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 | 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 | [
"Pass",
"an",
"entire",
"dictionary",
"to",
"to_auto"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L589-L599 | [
"def",
"to_auto_dict",
"(",
"values",
",",
"source",
"=",
"'auto'",
",",
"convert_to_human",
"=",
"True",
")",
":",
"for",
"name",
",",
"value",
"in",
"values",
".",
"items",
"(",
")",
":",
"values",
"[",
"name",
"]",
"=",
"to_auto",
"(",
"name",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | zpool_command | Build and properly escape a zpool 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. | salt/utils/zfs.py | 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... | 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... | [
"Build",
"and",
"properly",
"escape",
"a",
"zpool",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L648-L670 | [
"def",
"zpool_command",
"(",
"command",
",",
"flags",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"property_name",
"=",
"None",
",",
"property_value",
"=",
"None",
",",
"filesystem_properties",
"=",
"None",
",",
"pool_properties",
"=",
"None",
",",
"target",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | parse_command_result | 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 return a OrderedDict were
we set label = True|Fals... | salt/utils/zfs.py | 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... | 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... | [
"Parse",
"the",
"result",
"of",
"a",
"zpool",
"/",
"zfs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L673-L709 | [
"def",
"parse_command_result",
"(",
"res",
",",
"label",
"=",
"None",
")",
":",
"ret",
"=",
"OrderedDict",
"(",
")",
"if",
"label",
":",
"ret",
"[",
"label",
"]",
"=",
"res",
"[",
"'retcode'",
"]",
"==",
"0",
"if",
"res",
"[",
"'retcode'",
"]",
"!=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | beacon | 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`_ module
.. _re: https://docs.pyth... | salt/beacons/logs.py | 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... | 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... | [
"Read",
"the",
"log",
"file",
"and",
"return",
"match",
"whole",
"string"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/logs.py#L70-L157 | [
"def",
"beacon",
"(",
"config",
")",
":",
"_config",
"=",
"{",
"}",
"list",
"(",
"map",
"(",
"_config",
".",
"update",
",",
"config",
")",
")",
"ret",
"=",
"[",
"]",
"if",
"'file'",
"not",
"in",
"_config",
":",
"event",
"=",
"SKEL",
".",
"copy",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | key_value_to_tree | Convert key/value to tree | salt/pillar/pepa.py | 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
... | 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
... | [
"Convert",
"key",
"/",
"value",
"to",
"tree"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L359-L372 | [
"def",
"key_value_to_tree",
"(",
"data",
")",
":",
"tree",
"=",
"{",
"}",
"for",
"flatkey",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"data",
")",
":",
"t",
"=",
"tree",
"keys",
"=",
"flatkey",
".",
"split",
"(",
"__opts__",
"[",
"'pepa_delim... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ext_pillar | Evaluate Pepa templates | salt/pillar/pepa.py | 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... | 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... | [
"Evaluate",
"Pepa",
"templates"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L375-L506 | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"resource",
",",
"sequence",
",",
"subkey",
"=",
"False",
",",
"subkey_only",
"=",
"False",
")",
":",
"roots",
"=",
"__opts__",
"[",
"'pepa_roots'",
"]",
"# Default input",
"inp",
"=",
"{",
"}",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate | Validate Pepa templates | salt/pillar/pepa.py | 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... | 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... | [
"Validate",
"Pepa",
"templates"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L509-L542 | [
"def",
"validate",
"(",
"output",
",",
"resource",
")",
":",
"try",
":",
"import",
"cerberus",
"# pylint: disable=import-error",
"except",
"ImportError",
":",
"log",
".",
"critical",
"(",
"'You need module cerberus in order to use validation'",
")",
"return",
"roots",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | disks | Return list of disk devices | salt/grains/disks.py | 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... | 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"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/disks.py#L29-L40 | [
"def",
"disks",
"(",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_freebsd",
"(",
")",
":",
"return",
"_freebsd_geom",
"(",
")",
"elif",
"salt",
".",
"utils",
".",
"platform",
".",
"is_linux",
"(",
")",
":",
"return",
"_linux_disks",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _linux_disks | Return list of disk devices and work out if they are SSD or HDD. | salt/grains/disks.py | 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]... | 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]... | [
"Return",
"list",
"of",
"disk",
"devices",
"and",
"work",
"out",
"if",
"they",
"are",
"SSD",
"or",
"HDD",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/disks.py#L128-L152 | [
"def",
"_linux_disks",
"(",
")",
":",
"ret",
"=",
"{",
"'disks'",
":",
"[",
"]",
",",
"'SSDs'",
":",
"[",
"]",
"}",
"for",
"entry",
"in",
"glob",
".",
"glob",
"(",
"'/sys/block/*/queue/rotational'",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | additions_installed | 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 complete installation.
upgrade_os : False
Upgrade OS (to ensure th... | salt/states/vbox_guest.py | 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... | 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",
"installed",
".",
"Uses",
"the",
"CD",
"connected",
"by",
"VirtualBox",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L13-L52 | [
"def",
"additions_installed",
"(",
"name",
",",
"reboot",
"=",
"False",
",",
"upgrade_os",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | additions_removed | 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 functional value and is only used as a tracking
r... | salt/states/vbox_guest.py | 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... | 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... | [
"Ensure",
"that",
"the",
"VirtualBox",
"Guest",
"Additions",
"are",
"removed",
".",
"Uses",
"the",
"CD",
"connected",
"by",
"VirtualBox",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L55-L93 | [
"def",
"additions_removed",
"(",
"name",
",",
"force",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"current_state",
"=",
"__salt__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | grant_access_to_shared_folders_to | 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
List of names of users to grant access to auto-mounted shared... | salt/states/vbox_guest.py | 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
... | 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
... | [
"Grant",
"access",
"to",
"auto",
"-",
"mounted",
"shared",
"folders",
"to",
"the",
"users",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L96-L137 | [
"def",
"grant_access_to_shared_folders_to",
"(",
"name",
",",
"users",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"current_state",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient._is_master_running | 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. | salt/netapi/__init__.py | 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... | 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... | [
"Perform",
"a",
"lightweight",
"check",
"to",
"see",
"if",
"the",
"master",
"daemon",
"is",
"running"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L38-L56 | [
"def",
"_is_master_running",
"(",
"self",
")",
":",
"# Windows doesn't have IPC. Assume the master is running.",
"# At worse, it will error 500.",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"return",
"True",
"if",
"self",
".",
"opts... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.run | Execute the specified function in the specified client by passing the
lowstate | salt/netapi/__init__.py | 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.... | 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.... | [
"Execute",
"the",
"specified",
"function",
"in",
"the",
"specified",
"client",
"by",
"passing",
"the",
"lowstate"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L58-L80 | [
"def",
"run",
"(",
"self",
",",
"low",
")",
":",
"# 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.",
"if",
"not",
"self",
".",
"_is_master_running",
"(",
")",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.local_async | Run :ref:`execution modules <all-salt.modules>` asynchronously
Wraps :py:meth:`salt.client.LocalClient.run_job`.
:return: job ID | salt/netapi/__init__.py | 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... | 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... | [
"Run",
":",
"ref",
":",
"execution",
"modules",
"<all",
"-",
"salt",
".",
"modules",
">",
"asynchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L82-L92 | [
"def",
"local_async",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"local",
"=",
"salt",
".",
"client",
".",
"get_local_client",
"(",
"mopts",
"=",
"self",
".",
"opts",
")",
"ret",
"=",
"local",
".",
"run_job",
"(",
"*",
"args"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.