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 | hold | .. versionadded:: 2014.7.0
Version-lock packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6 & 7: ``yum-plugin-versionlock``
- On Fedora: ``python-dnf-plugins-extras-versionlock``
name
... | salt/modules/yumpkg.py | def hold(name=None, pkgs=None, sources=None, normalize=True, **kwargs): # pylint: disable=W0613
'''
.. versionadded:: 2014.7.0
Version-lock packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6... | def hold(name=None, pkgs=None, sources=None, normalize=True, **kwargs): # pylint: disable=W0613
'''
.. versionadded:: 2014.7.0
Version-lock packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6... | [
"..",
"versionadded",
"::",
"2014",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2081-L2164 | [
"def",
"hold",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"_check_versionlock",
"(",
")",
"if",
"not",
"name",
"and",
"no... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | unhold | .. versionadded:: 2014.7.0
Remove version locks
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6 & 7: ``yum-plugin-versionlock``
- On Fedora: ``python-dnf-plugins-extras-versionlock``
name
... | salt/modules/yumpkg.py | def unhold(name=None, pkgs=None, sources=None, **kwargs): # pylint: disable=W0613
'''
.. versionadded:: 2014.7.0
Remove version locks
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6 & 7: ``yum-plu... | def unhold(name=None, pkgs=None, sources=None, **kwargs): # pylint: disable=W0613
'''
.. versionadded:: 2014.7.0
Remove version locks
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
- On RHEL 6 & 7: ``yum-plu... | [
"..",
"versionadded",
"::",
"2014",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2167-L2269 | [
"def",
"unhold",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"_check_versionlock",
"(",
")",
"if",
"not",
"name",
"and",
"not",
"pkgs",
"and",
"not",
"so... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_holds | r'''
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Function renamed from ``pkg.get_locked_pkgs`` to ``pkg.list_holds``.
List information on locked packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be installed:
- On RHEL 5: ``yum-versionlock``
... | salt/modules/yumpkg.py | def list_holds(pattern=__HOLD_PATTERN, full=True):
r'''
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Function renamed from ``pkg.get_locked_pkgs`` to ``pkg.list_holds``.
List information on locked packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be insta... | def list_holds(pattern=__HOLD_PATTERN, full=True):
r'''
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Function renamed from ``pkg.get_locked_pkgs`` to ``pkg.list_holds``.
List information on locked packages
.. note::
Requires the appropriate ``versionlock`` plugin package to be insta... | [
"r",
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"2015",
".",
"8",
".",
"4",
"2015",
".",
"5",
".",
"10",
"Function",
"renamed",
"from",
"pkg",
".",
"get_locked_pkgs",
"to",
"pkg",
".",
"list_holds",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2272-L2310 | [
"def",
"list_holds",
"(",
"pattern",
"=",
"__HOLD_PATTERN",
",",
"full",
"=",
"True",
")",
":",
"_check_versionlock",
"(",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"[",
"_yum",
"(",
")",
",",
"'versionlock'",
",",
"'list'",
"]",
",",
"p... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | group_list | .. versionadded:: 2014.1.0
Lists all groups known by yum on this system
CLI Example:
.. code-block:: bash
salt '*' pkg.group_list | salt/modules/yumpkg.py | def group_list():
'''
.. versionadded:: 2014.1.0
Lists all groups known by yum on this system
CLI Example:
.. code-block:: bash
salt '*' pkg.group_list
'''
ret = {'installed': [],
'available': [],
'installed environments': [],
'available environme... | def group_list():
'''
.. versionadded:: 2014.1.0
Lists all groups known by yum on this system
CLI Example:
.. code-block:: bash
salt '*' pkg.group_list
'''
ret = {'installed': [],
'available': [],
'installed environments': [],
'available environme... | [
"..",
"versionadded",
"::",
"2014",
".",
"1",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2341-L2395 | [
"def",
"group_list",
"(",
")",
":",
"ret",
"=",
"{",
"'installed'",
":",
"[",
"]",
",",
"'available'",
":",
"[",
"]",
",",
"'installed environments'",
":",
"[",
"]",
",",
"'available environments'",
":",
"[",
"]",
",",
"'available languages'",
":",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | group_info | .. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
The return data has changed. A new key ``type`` has been added to
distinguish environment groups from package groups. Also, keys for the
group name and group ID have been added. The ``mandatory packages``,
``o... | salt/modules/yumpkg.py | def group_info(name, expand=False):
'''
.. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
The return data has changed. A new key ``type`` has been added to
distinguish environment groups from package groups. Also, keys for the
group name and group ID have bee... | def group_info(name, expand=False):
'''
.. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
The return data has changed. A new key ``type`` has been added to
distinguish environment groups from package groups. Also, keys for the
group name and group ID have bee... | [
"..",
"versionadded",
"::",
"2014",
".",
"1",
".",
"0",
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"2015",
".",
"8",
".",
"4",
"2015",
".",
"5",
".",
"10",
"The",
"return",
"data",
"has",
"changed",
".",
"A",
"new",
"key",
"type",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2398-L2490 | [
"def",
"group_info",
"(",
"name",
",",
"expand",
"=",
"False",
")",
":",
"pkgtypes",
"=",
"(",
"'mandatory'",
",",
"'optional'",
",",
"'default'",
",",
"'conditional'",
")",
"ret",
"=",
"{",
"}",
"for",
"pkgtype",
"in",
"pkgtypes",
":",
"ret",
"[",
"pk... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | group_diff | .. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Environment groups are now supported. The key names have been renamed,
similar to the changes made in :py:func:`pkg.group_info
<salt.modules.yumpkg.group_info>`.
Lists which of a group's packages are installed an... | salt/modules/yumpkg.py | def group_diff(name):
'''
.. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Environment groups are now supported. The key names have been renamed,
similar to the changes made in :py:func:`pkg.group_info
<salt.modules.yumpkg.group_info>`.
Lists which of a... | def group_diff(name):
'''
.. versionadded:: 2014.1.0
.. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
Environment groups are now supported. The key names have been renamed,
similar to the changes made in :py:func:`pkg.group_info
<salt.modules.yumpkg.group_info>`.
Lists which of a... | [
"..",
"versionadded",
"::",
"2014",
".",
"1",
".",
"0",
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"2015",
".",
"8",
".",
"4",
"2015",
".",
"5",
".",
"10",
"Environment",
"groups",
"are",
"now",
"supported",
".",
"The",
"key",
"names... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2493-L2523 | [
"def",
"group_diff",
"(",
"name",
")",
":",
"pkgtypes",
"=",
"(",
"'mandatory'",
",",
"'optional'",
",",
"'default'",
",",
"'conditional'",
")",
"ret",
"=",
"{",
"}",
"for",
"pkgtype",
"in",
"pkgtypes",
":",
"ret",
"[",
"pkgtype",
"]",
"=",
"{",
"'inst... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | group_install | .. versionadded:: 2014.1.0
Install the passed package group(s). This is basically a wrapper around
:py:func:`pkg.install <salt.modules.yumpkg.install>`, which performs
package group resolution for the user. This function is currently
considered experimental, and should be expected to undergo changes.
... | salt/modules/yumpkg.py | def group_install(name,
skip=(),
include=(),
**kwargs):
'''
.. versionadded:: 2014.1.0
Install the passed package group(s). This is basically a wrapper around
:py:func:`pkg.install <salt.modules.yumpkg.install>`, which performs
package group res... | def group_install(name,
skip=(),
include=(),
**kwargs):
'''
.. versionadded:: 2014.1.0
Install the passed package group(s). This is basically a wrapper around
:py:func:`pkg.install <salt.modules.yumpkg.install>`, which performs
package group res... | [
"..",
"versionadded",
"::",
"2014",
".",
"1",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2526-L2617 | [
"def",
"group_install",
"(",
"name",
",",
"skip",
"=",
"(",
")",
",",
"include",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"groups",
"=",
"name",
".",
"split",
"(",
"','",
")",
"if",
"isinstance",
"(",
"name",
",",
"six",
".",
"string_typ... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_repos | Lists all repos in <basedir> (default: all dirs in `reposdir` yum option).
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
salt '*' pkg.list_repos basedir=/path/to/dir
salt '*' pkg.list_repos basedir=/path/to/dir,/path/to/another/dir | salt/modules/yumpkg.py | def list_repos(basedir=None, **kwargs):
'''
Lists all repos in <basedir> (default: all dirs in `reposdir` yum option).
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
salt '*' pkg.list_repos basedir=/path/to/dir
salt '*' pkg.list_repos basedir=/path/to/dir,/path/to/a... | def list_repos(basedir=None, **kwargs):
'''
Lists all repos in <basedir> (default: all dirs in `reposdir` yum option).
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
salt '*' pkg.list_repos basedir=/path/to/dir
salt '*' pkg.list_repos basedir=/path/to/dir,/path/to/a... | [
"Lists",
"all",
"repos",
"in",
"<basedir",
">",
"(",
"default",
":",
"all",
"dirs",
"in",
"reposdir",
"yum",
"option",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2623-L2651 | [
"def",
"list_repos",
"(",
"basedir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"basedirs",
"=",
"_normalize_basedir",
"(",
"basedir",
")",
"repos",
"=",
"{",
"}",
"log",
".",
"debug",
"(",
"'Searching for repos in %s'",
",",
"basedirs",
")",
"for",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_repo | Display a repo from <basedir> (default basedir: all dirs in ``reposdir``
yum option).
CLI Examples:
.. code-block:: bash
salt '*' pkg.get_repo myrepo
salt '*' pkg.get_repo myrepo basedir=/path/to/dir
salt '*' pkg.get_repo myrepo basedir=/path/to/dir,/path/to/another/dir | salt/modules/yumpkg.py | def get_repo(name, basedir=None, **kwargs): # pylint: disable=W0613
'''
Display a repo from <basedir> (default basedir: all dirs in ``reposdir``
yum option).
CLI Examples:
.. code-block:: bash
salt '*' pkg.get_repo myrepo
salt '*' pkg.get_repo myrepo basedir=/path/to/dir
... | def get_repo(name, basedir=None, **kwargs): # pylint: disable=W0613
'''
Display a repo from <basedir> (default basedir: all dirs in ``reposdir``
yum option).
CLI Examples:
.. code-block:: bash
salt '*' pkg.get_repo myrepo
salt '*' pkg.get_repo myrepo basedir=/path/to/dir
... | [
"Display",
"a",
"repo",
"from",
"<basedir",
">",
"(",
"default",
"basedir",
":",
"all",
"dirs",
"in",
"reposdir",
"yum",
"option",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2654-L2679 | [
"def",
"get_repo",
"(",
"name",
",",
"basedir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"repos",
"=",
"list_repos",
"(",
"basedir",
")",
"# Find out what file the repo lives in",
"repofile",
"=",
"''",
"for",
"repo",
"in",
"r... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | del_repo | Delete a repo from <basedir> (default basedir: all dirs in `reposdir` yum
option).
If the .repo file in which the repo exists does not contain any other repo
configuration, the file itself will be deleted.
CLI Examples:
.. code-block:: bash
salt '*' pkg.del_repo myrepo
salt '*' p... | salt/modules/yumpkg.py | def del_repo(repo, basedir=None, **kwargs): # pylint: disable=W0613
'''
Delete a repo from <basedir> (default basedir: all dirs in `reposdir` yum
option).
If the .repo file in which the repo exists does not contain any other repo
configuration, the file itself will be deleted.
CLI Examples:
... | def del_repo(repo, basedir=None, **kwargs): # pylint: disable=W0613
'''
Delete a repo from <basedir> (default basedir: all dirs in `reposdir` yum
option).
If the .repo file in which the repo exists does not contain any other repo
configuration, the file itself will be deleted.
CLI Examples:
... | [
"Delete",
"a",
"repo",
"from",
"<basedir",
">",
"(",
"default",
"basedir",
":",
"all",
"dirs",
"in",
"reposdir",
"yum",
"option",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2682-L2745 | [
"def",
"del_repo",
"(",
"repo",
",",
"basedir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"# this is so we know which dirs are searched for our error messages below",
"basedirs",
"=",
"_normalize_basedir",
"(",
"basedir",
")",
"repos",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mod_repo | Modify one or more values for a repo. If the repo does not exist, it will
be created, so long as the following values are specified:
repo
name by which the yum refers to the repo
name
a human-readable name for the repo
baseurl
the URL for yum to reference
mirrorlist
... | salt/modules/yumpkg.py | def mod_repo(repo, basedir=None, **kwargs):
'''
Modify one or more values for a repo. If the repo does not exist, it will
be created, so long as the following values are specified:
repo
name by which the yum refers to the repo
name
a human-readable name for the repo
baseurl
... | def mod_repo(repo, basedir=None, **kwargs):
'''
Modify one or more values for a repo. If the repo does not exist, it will
be created, so long as the following values are specified:
repo
name by which the yum refers to the repo
name
a human-readable name for the repo
baseurl
... | [
"Modify",
"one",
"or",
"more",
"values",
"for",
"a",
"repo",
".",
"If",
"the",
"repo",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"so",
"long",
"as",
"the",
"following",
"values",
"are",
"specified",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2748-L2903 | [
"def",
"mod_repo",
"(",
"repo",
",",
"basedir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Filter out '__pub' arguments, as well as saltenv",
"repo_opts",
"=",
"dict",
"(",
"(",
"x",
",",
"kwargs",
"[",
"x",
"]",
")",
"for",
"x",
"in",
"kwargs",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_repo_file | Turn a single repo file into a dict | salt/modules/yumpkg.py | def _parse_repo_file(filename):
'''
Turn a single repo file into a dict
'''
parsed = configparser.ConfigParser()
config = {}
try:
parsed.read(filename)
except configparser.MissingSectionHeaderError as err:
log.error(
'Failed to parse file %s, error: %s',
... | def _parse_repo_file(filename):
'''
Turn a single repo file into a dict
'''
parsed = configparser.ConfigParser()
config = {}
try:
parsed.read(filename)
except configparser.MissingSectionHeaderError as err:
log.error(
'Failed to parse file %s, error: %s',
... | [
"Turn",
"a",
"single",
"repo",
"file",
"into",
"a",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2906-L2952 | [
"def",
"_parse_repo_file",
"(",
"filename",
")",
":",
"parsed",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
"=",
"{",
"}",
"try",
":",
"parsed",
".",
"read",
"(",
"filename",
")",
"except",
"configparser",
".",
"MissingSectionHeaderError",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | owner | .. versionadded:: 2014.7.0
Return the name of the package that owns the file. Multiple file paths can
be passed. Like :mod:`pkg.version <salt.modules.yumpkg.version>`, if a
single path is passed, a string will be returned, and if multiple paths are
passed, a dictionary of file/package name pairs will b... | salt/modules/yumpkg.py | def owner(*paths, **kwargs):
'''
.. versionadded:: 2014.7.0
Return the name of the package that owns the file. Multiple file paths can
be passed. Like :mod:`pkg.version <salt.modules.yumpkg.version>`, if a
single path is passed, a string will be returned, and if multiple paths are
passed, a dic... | def owner(*paths, **kwargs):
'''
.. versionadded:: 2014.7.0
Return the name of the package that owns the file. Multiple file paths can
be passed. Like :mod:`pkg.version <salt.modules.yumpkg.version>`, if a
single path is passed, a string will be returned, and if multiple paths are
passed, a dic... | [
"..",
"versionadded",
"::",
"2014",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L2993-L3026 | [
"def",
"owner",
"(",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"paths",
":",
"return",
"''",
"ret",
"=",
"{",
"}",
"cmd_prefix",
"=",
"[",
"'rpm'",
",",
"'-qf'",
",",
"'--queryformat'",
",",
"'%{name}'",
"]",
"for",
"path",
"in"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | download | .. versionadded:: 2015.5.0
Download packages to the local disk. Requires ``yumdownloader`` from
``yum-utils`` package.
.. note::
``yum-utils`` will already be installed on the minion if the package
was installed from the Fedora / EPEL repositories.
CLI example:
.. code-block:: b... | salt/modules/yumpkg.py | def download(*packages, **kwargs):
'''
.. versionadded:: 2015.5.0
Download packages to the local disk. Requires ``yumdownloader`` from
``yum-utils`` package.
.. note::
``yum-utils`` will already be installed on the minion if the package
was installed from the Fedora / EPEL reposit... | def download(*packages, **kwargs):
'''
.. versionadded:: 2015.5.0
Download packages to the local disk. Requires ``yumdownloader`` from
``yum-utils`` package.
.. note::
``yum-utils`` will already be installed on the minion if the package
was installed from the Fedora / EPEL reposit... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L3081-L3150 | [
"def",
"download",
"(",
"*",
"packages",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"packages",
":",
"raise",
"SaltInvocationError",
"(",
"'No packages were specified'",
")",
"CACHE_DIR",
"=",
"'/var/cache/yum/packages'",
"if",
"not",
"os",
".",
"path",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | diff | Return a formatted diff between current files and original in a package.
NOTE: this function includes all files (configuration and not), but does
not work on binary content.
:param path: Full path to the installed file
:return: Difference string or raises and exception if examined file is binary.
... | salt/modules/yumpkg.py | def diff(*paths, **kwargs):
'''
Return a formatted diff between current files and original in a package.
NOTE: this function includes all files (configuration and not), but does
not work on binary content.
:param path: Full path to the installed file
:return: Difference string or raises and exc... | def diff(*paths, **kwargs):
'''
Return a formatted diff between current files and original in a package.
NOTE: this function includes all files (configuration and not), but does
not work on binary content.
:param path: Full path to the installed file
:return: Difference string or raises and exc... | [
"Return",
"a",
"formatted",
"diff",
"between",
"current",
"files",
"and",
"original",
"in",
"a",
"package",
".",
"NOTE",
":",
"this",
"function",
"includes",
"all",
"files",
"(",
"configuration",
"and",
"not",
")",
"but",
"does",
"not",
"work",
"on",
"bina... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L3153-L3187 | [
"def",
"diff",
"(",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"}",
"pkg_to_paths",
"=",
"{",
"}",
"for",
"pth",
"in",
"paths",
":",
"pth_pkg",
"=",
"__salt__",
"[",
"'lowpkg.owner'",
"]",
"(",
"pth",
")",
"if",
"not",
"pth... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_patches | List all known patches in repos. | salt/modules/yumpkg.py | def _get_patches(installed_only=False):
'''
List all known patches in repos.
'''
patches = {}
cmd = [_yum(), '--quiet', 'updateinfo', 'list', 'all']
ret = __salt__['cmd.run_stdout'](
cmd,
python_shell=False
)
for line in salt.utils.itertools.split(ret, os.linesep):
... | def _get_patches(installed_only=False):
'''
List all known patches in repos.
'''
patches = {}
cmd = [_yum(), '--quiet', 'updateinfo', 'list', 'all']
ret = __salt__['cmd.run_stdout'](
cmd,
python_shell=False
)
for line in salt.utils.itertools.split(ret, os.linesep):
... | [
"List",
"all",
"known",
"patches",
"in",
"repos",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L3190-L3210 | [
"def",
"_get_patches",
"(",
"installed_only",
"=",
"False",
")",
":",
"patches",
"=",
"{",
"}",
"cmd",
"=",
"[",
"_yum",
"(",
")",
",",
"'--quiet'",
",",
"'updateinfo'",
",",
"'list'",
",",
"'all'",
"]",
"ret",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | complete_transaction | .. versionadded:: Fluorine
Execute ``yum-complete-transaction``, which is provided by the ``yum-utils`` package.
cleanup_only
Specify if the ``--cleanup-only`` option should be supplied.
recursive
Specify if ``yum-complete-transaction`` should be called recursively
(it only comple... | salt/modules/yumpkg.py | def complete_transaction(cleanup_only=False, recursive=False, max_attempts=3):
'''
.. versionadded:: Fluorine
Execute ``yum-complete-transaction``, which is provided by the ``yum-utils`` package.
cleanup_only
Specify if the ``--cleanup-only`` option should be supplied.
recursive
S... | def complete_transaction(cleanup_only=False, recursive=False, max_attempts=3):
'''
.. versionadded:: Fluorine
Execute ``yum-complete-transaction``, which is provided by the ``yum-utils`` package.
cleanup_only
Specify if the ``--cleanup-only`` option should be supplied.
recursive
S... | [
"..",
"versionadded",
"::",
"Fluorine"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L3252-L3286 | [
"def",
"complete_transaction",
"(",
"cleanup_only",
"=",
"False",
",",
"recursive",
"=",
"False",
",",
"max_attempts",
"=",
"3",
")",
":",
"return",
"_complete_transaction",
"(",
"cleanup_only",
",",
"recursive",
",",
"max_attempts",
",",
"1",
",",
"[",
"]",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _complete_transaction | .. versionadded:: Fluorine
Called from ``complete_transaction`` to protect the arguments
used for tail recursion, ``run_count`` and ``cmd_ret_list``. | salt/modules/yumpkg.py | def _complete_transaction(cleanup_only, recursive, max_attempts, run_count, cmd_ret_list):
'''
.. versionadded:: Fluorine
Called from ``complete_transaction`` to protect the arguments
used for tail recursion, ``run_count`` and ``cmd_ret_list``.
'''
cmd = ['yum-complete-transaction']
if cle... | def _complete_transaction(cleanup_only, recursive, max_attempts, run_count, cmd_ret_list):
'''
.. versionadded:: Fluorine
Called from ``complete_transaction`` to protect the arguments
used for tail recursion, ``run_count`` and ``cmd_ret_list``.
'''
cmd = ['yum-complete-transaction']
if cle... | [
"..",
"versionadded",
"::",
"Fluorine"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L3289-L3320 | [
"def",
"_complete_transaction",
"(",
"cleanup_only",
",",
"recursive",
",",
"max_attempts",
",",
"run_count",
",",
"cmd_ret_list",
")",
":",
"cmd",
"=",
"[",
"'yum-complete-transaction'",
"]",
"if",
"cleanup_only",
":",
"cmd",
".",
"append",
"(",
"'--cleanup-only'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensure the Route53 record is present.
name
Name of the record.
value
Value of the record. As a special case, you can pass in:
`private:<Name tag>` to have the function autodetermine the private IP
`public:<Name tag>` to have the function autodetermine the public IP
... | salt/states/boto_route53.py | def present(name, value, zone, record_type, ttl=None, identifier=None, region=None, key=None,
keyid=None, profile=None, wait_for_sync=True, split_dns=False, private_zone=False):
'''
Ensure the Route53 record is present.
name
Name of the record.
value
Value of the record. A... | def present(name, value, zone, record_type, ttl=None, identifier=None, region=None, key=None,
keyid=None, profile=None, wait_for_sync=True, split_dns=False, private_zone=False):
'''
Ensure the Route53 record is present.
name
Name of the record.
value
Value of the record. A... | [
"Ensure",
"the",
"Route53",
"record",
"is",
"present",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_route53.py#L99-L256 | [
"def",
"present",
"(",
"name",
",",
"value",
",",
"zone",
",",
"record_type",
",",
"ttl",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure the Route53 record is deleted.
name
Name of the record.
zone
The zone to delete the record from.
record_type
The record type (A, NS, MX, TXT, etc.)
identifier
An identifier to match for deletion.
region
The region to connect to.
key
Se... | salt/states/boto_route53.py | def absent(
name,
zone,
record_type,
identifier=None,
region=None,
key=None,
keyid=None,
profile=None,
wait_for_sync=True,
split_dns=False,
private_zone=False):
'''
Ensure the Route53 record is deleted.
name
Nam... | def absent(
name,
zone,
record_type,
identifier=None,
region=None,
key=None,
keyid=None,
profile=None,
wait_for_sync=True,
split_dns=False,
private_zone=False):
'''
Ensure the Route53 record is deleted.
name
Nam... | [
"Ensure",
"the",
"Route53",
"record",
"is",
"deleted",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_route53.py#L263-L341 | [
"def",
"absent",
"(",
"name",
",",
"zone",
",",
"record_type",
",",
"identifier",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"wait_for_sync",
"=",
"True",
",",
"split... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | hosted_zone_present | Ensure a hosted zone exists with the given attributes. Note that most
things cannot be modified once a zone is created - it must be deleted and
re-spun to update these attributes:
- private_zone (AWS API limitation).
- comment (the appropriate call exists in the AWS API and in boto3, but has
not,... | salt/states/boto_route53.py | def hosted_zone_present(name, domain_name=None, private_zone=False, caller_ref=None, comment='',
vpc_id=None, vpc_name=None, vpc_region=None, region=None, key=None,
keyid=None, profile=None):
'''
Ensure a hosted zone exists with the given attributes. Note that mos... | def hosted_zone_present(name, domain_name=None, private_zone=False, caller_ref=None, comment='',
vpc_id=None, vpc_name=None, vpc_region=None, region=None, key=None,
keyid=None, profile=None):
'''
Ensure a hosted zone exists with the given attributes. Note that mos... | [
"Ensure",
"a",
"hosted",
"zone",
"exists",
"with",
"the",
"given",
"attributes",
".",
"Note",
"that",
"most",
"things",
"cannot",
"be",
"modified",
"once",
"a",
"zone",
"is",
"created",
"-",
"it",
"must",
"be",
"deleted",
"and",
"re",
"-",
"spun",
"to",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_route53.py#L344-L489 | [
"def",
"hosted_zone_present",
"(",
"name",
",",
"domain_name",
"=",
"None",
",",
"private_zone",
"=",
"False",
",",
"caller_ref",
"=",
"None",
",",
"comment",
"=",
"''",
",",
"vpc_id",
"=",
"None",
",",
"vpc_name",
"=",
"None",
",",
"vpc_region",
"=",
"N... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | hosted_zone_absent | Ensure the Route53 Hostes Zone described is absent
name
The name of the state definition.
domain_name
The FQDN (including final period) of the zone you wish absent. If not
provided, the value of name will be used. | salt/states/boto_route53.py | def hosted_zone_absent(name, domain_name=None, region=None, key=None,
keyid=None, profile=None):
'''
Ensure the Route53 Hostes Zone described is absent
name
The name of the state definition.
domain_name
The FQDN (including final period) of the zone you wish absen... | def hosted_zone_absent(name, domain_name=None, region=None, key=None,
keyid=None, profile=None):
'''
Ensure the Route53 Hostes Zone described is absent
name
The name of the state definition.
domain_name
The FQDN (including final period) of the zone you wish absen... | [
"Ensure",
"the",
"Route53",
"Hostes",
"Zone",
"described",
"is",
"absent"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_route53.py#L492-L532 | [
"def",
"hosted_zone_absent",
"(",
"name",
",",
"domain_name",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"domain_name",
"=",
"domain_name",
"if",
"domain_name",
"els... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPBase.get_self_ip | Find out localhost outside IP.
:return: | salt/utils/ssdp.py | def get_self_ip():
'''
Find out localhost outside IP.
:return:
'''
sck = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
sck.connect(('1.255.255.255', 1)) # Does not needs to be reachable
ip_addr = sck.getsockname()[0]
except Except... | def get_self_ip():
'''
Find out localhost outside IP.
:return:
'''
sck = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
sck.connect(('1.255.255.255', 1)) # Does not needs to be reachable
ip_addr = sck.getsockname()[0]
except Except... | [
"Find",
"out",
"localhost",
"outside",
"IP",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L89-L103 | [
"def",
"get_self_ip",
"(",
")",
":",
"sck",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"try",
":",
"sck",
".",
"connect",
"(",
"(",
"'1.255.255.255'",
",",
"1",
")",
")",
"# Does not needs to be re... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPFactory._sendto | On multi-master environments, running on the same machine,
transport sending to the destination can be allowed only at once.
Since every machine will immediately respond, high chance to
get sending fired at the same time, which will result to a PermissionError
at socket level. We are att... | salt/utils/ssdp.py | def _sendto(self, data, addr=None, attempts=10):
'''
On multi-master environments, running on the same machine,
transport sending to the destination can be allowed only at once.
Since every machine will immediately respond, high chance to
get sending fired at the same time, which... | def _sendto(self, data, addr=None, attempts=10):
'''
On multi-master environments, running on the same machine,
transport sending to the destination can be allowed only at once.
Since every machine will immediately respond, high chance to
get sending fired at the same time, which... | [
"On",
"multi",
"-",
"master",
"environments",
"running",
"on",
"the",
"same",
"machine",
"transport",
"sending",
"to",
"the",
"destination",
"can",
"be",
"allowed",
"only",
"at",
"once",
".",
"Since",
"every",
"machine",
"will",
"immediately",
"respond",
"high... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L141-L165 | [
"def",
"_sendto",
"(",
"self",
",",
"data",
",",
"addr",
"=",
"None",
",",
"attempts",
"=",
"10",
")",
":",
"tries",
"=",
"0",
"slp_time",
"=",
"lambda",
":",
"0.5",
"/",
"random",
".",
"randint",
"(",
"10",
",",
"30",
")",
"slp",
"=",
"slp_time"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPFactory.datagram_received | On datagram receive.
:param data:
:param addr:
:return: | salt/utils/ssdp.py | def datagram_received(self, data, addr):
'''
On datagram receive.
:param data:
:param addr:
:return:
'''
message = salt.utils.stringutils.to_unicode(data)
if message.startswith(self.signature):
try:
timestamp = float(message[le... | def datagram_received(self, data, addr):
'''
On datagram receive.
:param data:
:param addr:
:return:
'''
message = salt.utils.stringutils.to_unicode(data)
if message.startswith(self.signature):
try:
timestamp = float(message[le... | [
"On",
"datagram",
"receive",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L167-L210 | [
"def",
"datagram_received",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"message",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
"data",
")",
"if",
"message",
".",
"startswith",
"(",
"self",
".",
"signature",
")",
":",
"tr... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPDiscoveryServer.create_datagram_endpoint | Create datagram connection.
Based on code from Python 3.5 version, this method is used
only in Python 2.7+ versions, since Trollius library did not
ported UDP packets broadcast. | salt/utils/ssdp.py | def create_datagram_endpoint(loop, protocol_factory, local_addr=None, remote_addr=None, family=0, proto=0, flags=0):
'''
Create datagram connection.
Based on code from Python 3.5 version, this method is used
only in Python 2.7+ versions, since Trollius library did not
ported UDP... | def create_datagram_endpoint(loop, protocol_factory, local_addr=None, remote_addr=None, family=0, proto=0, flags=0):
'''
Create datagram connection.
Based on code from Python 3.5 version, this method is used
only in Python 2.7+ versions, since Trollius library did not
ported UDP... | [
"Create",
"datagram",
"connection",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L238-L305 | [
"def",
"create_datagram_endpoint",
"(",
"loop",
",",
"protocol_factory",
",",
"local_addr",
"=",
"None",
",",
"remote_addr",
"=",
"None",
",",
"family",
"=",
"0",
",",
"proto",
"=",
"0",
",",
"flags",
"=",
"0",
")",
":",
"if",
"not",
"(",
"local_addr",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPDiscoveryServer.run | Run server.
:return: | salt/utils/ssdp.py | def run(self):
'''
Run server.
:return:
'''
listen_ip = self._config.get(self.LISTEN_IP, self.DEFAULTS[self.LISTEN_IP])
port = self._config.get(self.PORT, self.DEFAULTS[self.PORT])
self.log.info('Starting service discovery listener on udp://%s:%s', listen_ip, port... | def run(self):
'''
Run server.
:return:
'''
listen_ip = self._config.get(self.LISTEN_IP, self.DEFAULTS[self.LISTEN_IP])
port = self._config.get(self.PORT, self.DEFAULTS[self.PORT])
self.log.info('Starting service discovery listener on udp://%s:%s', listen_ip, port... | [
"Run",
"server",
".",
":",
"return",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L307-L328 | [
"def",
"run",
"(",
"self",
")",
":",
"listen_ip",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"self",
".",
"LISTEN_IP",
",",
"self",
".",
"DEFAULTS",
"[",
"self",
".",
"LISTEN_IP",
"]",
")",
"port",
"=",
"self",
".",
"_config",
".",
"get",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPDiscoveryClient._query | Query the broadcast for defined services.
:return: | salt/utils/ssdp.py | def _query(self):
'''
Query the broadcast for defined services.
:return:
'''
query = salt.utils.stringutils.to_bytes(
"{}{}".format(self.signature, time.time()))
self._socket.sendto(query, ('<broadcast>', self.port))
return query | def _query(self):
'''
Query the broadcast for defined services.
:return:
'''
query = salt.utils.stringutils.to_bytes(
"{}{}".format(self.signature, time.time()))
self._socket.sendto(query, ('<broadcast>', self.port))
return query | [
"Query",
"the",
"broadcast",
"for",
"defined",
"services",
".",
":",
"return",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L355-L364 | [
"def",
"_query",
"(",
"self",
")",
":",
"query",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_bytes",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"signature",
",",
"time",
".",
"time",
"(",
")",
")",
")",
"self",
".",
"_socket",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPDiscoveryClient._collect_masters_map | Collect masters map from the network.
:return: | salt/utils/ssdp.py | def _collect_masters_map(self, response):
'''
Collect masters map from the network.
:return:
'''
while True:
try:
data, addr = self._socket.recvfrom(0x400)
if data:
if addr not in response:
re... | def _collect_masters_map(self, response):
'''
Collect masters map from the network.
:return:
'''
while True:
try:
data, addr = self._socket.recvfrom(0x400)
if data:
if addr not in response:
re... | [
"Collect",
"masters",
"map",
"from",
"the",
"network",
".",
":",
"return",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L366-L383 | [
"def",
"_collect_masters_map",
"(",
"self",
",",
"response",
")",
":",
"while",
"True",
":",
"try",
":",
"data",
",",
"addr",
"=",
"self",
".",
"_socket",
".",
"recvfrom",
"(",
"0x400",
")",
"if",
"data",
":",
"if",
"addr",
"not",
"in",
"response",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SSDPDiscoveryClient.discover | Gather the information of currently declared servers.
:return: | salt/utils/ssdp.py | def discover(self):
'''
Gather the information of currently declared servers.
:return:
'''
response = {}
masters = {}
self.log.info("Looking for a server discovery")
self._query()
self._collect_masters_map(response)
if not response:
... | def discover(self):
'''
Gather the information of currently declared servers.
:return:
'''
response = {}
masters = {}
self.log.info("Looking for a server discovery")
self._query()
self._collect_masters_map(response)
if not response:
... | [
"Gather",
"the",
"information",
"of",
"currently",
"declared",
"servers",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/ssdp.py#L385-L423 | [
"def",
"discover",
"(",
"self",
")",
":",
"response",
"=",
"{",
"}",
"masters",
"=",
"{",
"}",
"self",
".",
"log",
".",
"info",
"(",
"\"Looking for a server discovery\"",
")",
"self",
".",
"_query",
"(",
")",
"self",
".",
"_collect_masters_map",
"(",
"re... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | admin_password_present | Initial change of Zabbix Admin password to password taken from one of the sources (only the most prioritized one):
1. 'password' parameter
2. '_connection_password' parameter
3. pillar 'zabbix.password' setting
1) Tries to log in as Admin with password found in state password parameter or _... | salt/states/zabbix_user.py | def admin_password_present(name, password=None, **kwargs):
'''
Initial change of Zabbix Admin password to password taken from one of the sources (only the most prioritized one):
1. 'password' parameter
2. '_connection_password' parameter
3. pillar 'zabbix.password' setting
1) Tries ... | def admin_password_present(name, password=None, **kwargs):
'''
Initial change of Zabbix Admin password to password taken from one of the sources (only the most prioritized one):
1. 'password' parameter
2. '_connection_password' parameter
3. pillar 'zabbix.password' setting
1) Tries ... | [
"Initial",
"change",
"of",
"Zabbix",
"Admin",
"password",
"to",
"password",
"taken",
"from",
"one",
"of",
"the",
"sources",
"(",
"only",
"the",
"most",
"prioritized",
"one",
")",
":",
"1",
".",
"password",
"parameter",
"2",
".",
"_connection_password",
"para... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_user.py#L27-L118 | [
"def",
"admin_password_present",
"(",
"name",
",",
"password",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"dry_run",
"=",
"__opts__",
"[",
"'test'",
"]",
"default_zabbix_user",
"=",
"'Admin'",
"default_zabbix_password",
"=",
"'zabbix'",
"ret",
"=",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensures that the user exists, eventually creates new user.
NOTE: use argument firstname instead of name to not mess values with name from salt sls.
.. versionadded:: 2016.3.0
:param alias: user alias
:param passwd: user's password
:param usrgrps: user groups to add the user to
:param medias: O... | salt/states/zabbix_user.py | def present(alias, passwd, usrgrps, medias=None, password_reset=False, **kwargs):
'''
Ensures that the user exists, eventually creates new user.
NOTE: use argument firstname instead of name to not mess values with name from salt sls.
.. versionadded:: 2016.3.0
:param alias: user alias
:param p... | def present(alias, passwd, usrgrps, medias=None, password_reset=False, **kwargs):
'''
Ensures that the user exists, eventually creates new user.
NOTE: use argument firstname instead of name to not mess values with name from salt sls.
.. versionadded:: 2016.3.0
:param alias: user alias
:param p... | [
"Ensures",
"that",
"the",
"user",
"exists",
"eventually",
"creates",
"new",
"user",
".",
"NOTE",
":",
"use",
"argument",
"firstname",
"instead",
"of",
"name",
"to",
"not",
"mess",
"values",
"with",
"name",
"from",
"salt",
"sls",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_user.py#L121-L352 | [
"def",
"present",
"(",
"alias",
",",
"passwd",
",",
"usrgrps",
",",
"medias",
"=",
"None",
",",
"password_reset",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"medias",
"is",
"None",
":",
"medias",
"=",
"[",
"]",
"connection_args",
"=",
"{"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensures that the user does not exist, eventually delete user.
.. versionadded:: 2016.3.0
:param name: user alias
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts ... | salt/states/zabbix_user.py | def absent(name, **kwargs):
'''
Ensures that the user does not exist, eventually delete user.
.. versionadded:: 2016.3.0
:param name: user alias
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - z... | def absent(name, **kwargs):
'''
Ensures that the user does not exist, eventually delete user.
.. versionadded:: 2016.3.0
:param name: user alias
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - z... | [
"Ensures",
"that",
"the",
"user",
"does",
"not",
"exist",
"eventually",
"delete",
"user",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_user.py#L355-L421 | [
"def",
"absent",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"connection_args",
"=",
"{",
"}",
"if",
"'_connection_user'",
"in",
"kwargs",
":",
"connection_args",
"[",
"'_connection_user'",
"]",
"=",
"kwargs",
"[",
"'_connection_user'",
"]",
"if",
"'_con... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | query | PushOver object method function to construct and execute on the API URL.
:param token: The PushOver api key.
:param api_version: The PushOver API version to use, defaults to version 1.
:param function: The PushOver api function to perform.
:param method: The HTTP method, e.g. GET or POST.... | salt/utils/pushover.py | def query(function,
token=None,
api_version='1',
method='POST',
header_dict=None,
data=None,
query_params=None,
opts=None):
'''
PushOver object method function to construct and execute on the API URL.
:param token: The PushOver api... | def query(function,
token=None,
api_version='1',
method='POST',
header_dict=None,
data=None,
query_params=None,
opts=None):
'''
PushOver object method function to construct and execute on the API URL.
:param token: The PushOver api... | [
"PushOver",
"object",
"method",
"function",
"to",
"construct",
"and",
"execute",
"on",
"the",
"API",
"URL",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pushover.py#L32-L110 | [
"def",
"query",
"(",
"function",
",",
"token",
"=",
"None",
",",
"api_version",
"=",
"'1'",
",",
"method",
"=",
"'POST'",
",",
"header_dict",
"=",
"None",
",",
"data",
"=",
"None",
",",
"query_params",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate_sound | Send a message to a Pushover user or group.
:param sound: The sound that we want to verify
:param token: The PushOver token. | salt/utils/pushover.py | def validate_sound(sound,
token):
'''
Send a message to a Pushover user or group.
:param sound: The sound that we want to verify
:param token: The PushOver token.
'''
ret = {
'message': 'Sound is invalid',
'res': False
}
param... | def validate_sound(sound,
token):
'''
Send a message to a Pushover user or group.
:param sound: The sound that we want to verify
:param token: The PushOver token.
'''
ret = {
'message': 'Sound is invalid',
'res': False
}
param... | [
"Send",
"a",
"message",
"to",
"a",
"Pushover",
"user",
"or",
"group",
".",
":",
"param",
"sound",
":",
"The",
"sound",
"that",
"we",
"want",
"to",
"verify",
":",
"param",
"token",
":",
"The",
"PushOver",
"token",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pushover.py#L113-L145 | [
"def",
"validate_sound",
"(",
"sound",
",",
"token",
")",
":",
"ret",
"=",
"{",
"'message'",
":",
"'Sound is invalid'",
",",
"'res'",
":",
"False",
"}",
"parameters",
"=",
"dict",
"(",
")",
"parameters",
"[",
"'token'",
"]",
"=",
"token",
"response",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate_user | Send a message to a Pushover user or group.
:param user: The user or group name, either will work.
:param device: The device for the user.
:param token: The PushOver token. | salt/utils/pushover.py | def validate_user(user,
device,
token):
'''
Send a message to a Pushover user or group.
:param user: The user or group name, either will work.
:param device: The device for the user.
:param token: The PushOver token.
'''
res = {
... | def validate_user(user,
device,
token):
'''
Send a message to a Pushover user or group.
:param user: The user or group name, either will work.
:param device: The device for the user.
:param token: The PushOver token.
'''
res = {
... | [
"Send",
"a",
"message",
"to",
"a",
"Pushover",
"user",
"or",
"group",
".",
":",
"param",
"user",
":",
"The",
"user",
"or",
"group",
"name",
"either",
"will",
"work",
".",
":",
"param",
"device",
":",
"The",
"device",
"for",
"the",
"user",
".",
":",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pushover.py#L148-L183 | [
"def",
"validate_user",
"(",
"user",
",",
"device",
",",
"token",
")",
":",
"res",
"=",
"{",
"'message'",
":",
"'User key is invalid'",
",",
"'result'",
":",
"False",
"}",
"parameters",
"=",
"dict",
"(",
")",
"parameters",
"[",
"'user'",
"]",
"=",
"user"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | is_alive | Check if PID is still alive. | salt/modules/inspectlib/collector.py | def is_alive(pidfile):
'''
Check if PID is still alive.
'''
try:
with salt.utils.files.fopen(pidfile) as fp_:
os.kill(int(fp_.read().strip()), 0)
return True
except Exception as ex:
if os.access(pidfile, os.W_OK) and os.path.isfile(pidfile):
os.unlink(... | def is_alive(pidfile):
'''
Check if PID is still alive.
'''
try:
with salt.utils.files.fopen(pidfile) as fp_:
os.kill(int(fp_.read().strip()), 0)
return True
except Exception as ex:
if os.access(pidfile, os.W_OK) and os.path.isfile(pidfile):
os.unlink(... | [
"Check",
"if",
"PID",
"is",
"still",
"alive",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L475-L486 | [
"def",
"is_alive",
"(",
"pidfile",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"pidfile",
")",
"as",
"fp_",
":",
"os",
".",
"kill",
"(",
"int",
"(",
"fp_",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | main | Main analyzer routine. | salt/modules/inspectlib/collector.py | def main(dbfile, pidfile, mode):
'''
Main analyzer routine.
'''
Inspector(dbfile, pidfile).reuse_snapshot().snapshot(mode) | def main(dbfile, pidfile, mode):
'''
Main analyzer routine.
'''
Inspector(dbfile, pidfile).reuse_snapshot().snapshot(mode) | [
"Main",
"analyzer",
"routine",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L489-L493 | [
"def",
"main",
"(",
"dbfile",
",",
"pidfile",
",",
"mode",
")",
":",
"Inspector",
"(",
"dbfile",
",",
"pidfile",
")",
".",
"reuse_snapshot",
"(",
")",
".",
"snapshot",
"(",
"mode",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._syscall | Call an external system command. | salt/modules/inspectlib/collector.py | def _syscall(self, command, input=None, env=None, *params):
'''
Call an external system command.
'''
return Popen([command] + list(params), stdout=PIPE, stdin=PIPE, stderr=STDOUT,
env=env or os.environ).communicate(input=input) | def _syscall(self, command, input=None, env=None, *params):
'''
Call an external system command.
'''
return Popen([command] + list(params), stdout=PIPE, stdin=PIPE, stderr=STDOUT,
env=env or os.environ).communicate(input=input) | [
"Call",
"an",
"external",
"system",
"command",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L77-L82 | [
"def",
"_syscall",
"(",
"self",
",",
"command",
",",
"input",
"=",
"None",
",",
"env",
"=",
"None",
",",
"*",
"params",
")",
":",
"return",
"Popen",
"(",
"[",
"command",
"]",
"+",
"list",
"(",
"params",
")",
",",
"stdout",
"=",
"PIPE",
",",
"stdi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._get_cfg_pkgs | Package scanner switcher between the platforms.
:return: | salt/modules/inspectlib/collector.py | def _get_cfg_pkgs(self):
'''
Package scanner switcher between the platforms.
:return:
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_cfg_pkgs_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
... | def _get_cfg_pkgs(self):
'''
Package scanner switcher between the platforms.
:return:
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_cfg_pkgs_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
... | [
"Package",
"scanner",
"switcher",
"between",
"the",
"platforms",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L84-L95 | [
"def",
"_get_cfg_pkgs",
"(",
"self",
")",
":",
"if",
"self",
".",
"grains_core",
".",
"os_data",
"(",
")",
".",
"get",
"(",
"'os_family'",
")",
"==",
"'Debian'",
":",
"return",
"self",
".",
"__get_cfg_pkgs_dpkg",
"(",
")",
"elif",
"self",
".",
"grains_co... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.__get_cfg_pkgs_dpkg | Get packages with configuration files on Dpkg systems.
:return: | salt/modules/inspectlib/collector.py | def __get_cfg_pkgs_dpkg(self):
'''
Get packages with configuration files on Dpkg systems.
:return:
'''
# Get list of all available packages
data = dict()
for pkg_name in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None,
... | def __get_cfg_pkgs_dpkg(self):
'''
Get packages with configuration files on Dpkg systems.
:return:
'''
# Get list of all available packages
data = dict()
for pkg_name in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None,
... | [
"Get",
"packages",
"with",
"configuration",
"files",
"on",
"Dpkg",
"systems",
".",
":",
"return",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L97-L124 | [
"def",
"__get_cfg_pkgs_dpkg",
"(",
"self",
")",
":",
"# Get list of all available packages",
"data",
"=",
"dict",
"(",
")",
"for",
"pkg_name",
"in",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_str",
"(",
"self",
".",
"_syscall",
"(",
"'dpkg-query'",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.__get_cfg_pkgs_rpm | Get packages with configuration files on RPM systems. | salt/modules/inspectlib/collector.py | def __get_cfg_pkgs_rpm(self):
'''
Get packages with configuration files on RPM systems.
'''
out, err = self._syscall('rpm', None, None, '-qa', '--configfiles',
'--queryformat', '%{name}-%{version}-%{release}\\n')
data = dict()
pkg_name = N... | def __get_cfg_pkgs_rpm(self):
'''
Get packages with configuration files on RPM systems.
'''
out, err = self._syscall('rpm', None, None, '-qa', '--configfiles',
'--queryformat', '%{name}-%{version}-%{release}\\n')
data = dict()
pkg_name = N... | [
"Get",
"packages",
"with",
"configuration",
"files",
"on",
"RPM",
"systems",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L126-L152 | [
"def",
"__get_cfg_pkgs_rpm",
"(",
"self",
")",
":",
"out",
",",
"err",
"=",
"self",
".",
"_syscall",
"(",
"'rpm'",
",",
"None",
",",
"None",
",",
"'-qa'",
",",
"'--configfiles'",
",",
"'--queryformat'",
",",
"'%{name}-%{version}-%{release}\\\\n'",
")",
"data",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._get_changed_cfg_pkgs | Filter out unchanged packages on the Debian or RPM systems.
:param data: Structure {package-name -> [ file .. file1 ]}
:return: Same structure as data, except only files that were changed. | salt/modules/inspectlib/collector.py | def _get_changed_cfg_pkgs(self, data):
'''
Filter out unchanged packages on the Debian or RPM systems.
:param data: Structure {package-name -> [ file .. file1 ]}
:return: Same structure as data, except only files that were changed.
'''
f_data = dict()
for pkg_nam... | def _get_changed_cfg_pkgs(self, data):
'''
Filter out unchanged packages on the Debian or RPM systems.
:param data: Structure {package-name -> [ file .. file1 ]}
:return: Same structure as data, except only files that were changed.
'''
f_data = dict()
for pkg_nam... | [
"Filter",
"out",
"unchanged",
"packages",
"on",
"the",
"Debian",
"or",
"RPM",
"systems",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L154-L182 | [
"def",
"_get_changed_cfg_pkgs",
"(",
"self",
",",
"data",
")",
":",
"f_data",
"=",
"dict",
"(",
")",
"for",
"pkg_name",
",",
"pkg_files",
"in",
"data",
".",
"items",
"(",
")",
":",
"cfgs",
"=",
"list",
"(",
")",
"cfg_data",
"=",
"list",
"(",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._save_cfg_packages | Save configuration packages. (NG)
:param data:
:return: | salt/modules/inspectlib/collector.py | def _save_cfg_packages(self, data):
'''
Save configuration packages. (NG)
:param data:
:return:
'''
pkg_id = 0
pkg_cfg_id = 0
for pkg_name, pkg_configs in data.items():
pkg = Package()
pkg.id = pkg_id
pkg.name = pkg_nam... | def _save_cfg_packages(self, data):
'''
Save configuration packages. (NG)
:param data:
:return:
'''
pkg_id = 0
pkg_cfg_id = 0
for pkg_name, pkg_configs in data.items():
pkg = Package()
pkg.id = pkg_id
pkg.name = pkg_nam... | [
"Save",
"configuration",
"packages",
".",
"(",
"NG",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L184-L207 | [
"def",
"_save_cfg_packages",
"(",
"self",
",",
"data",
")",
":",
"pkg_id",
"=",
"0",
"pkg_cfg_id",
"=",
"0",
"for",
"pkg_name",
",",
"pkg_configs",
"in",
"data",
".",
"items",
"(",
")",
":",
"pkg",
"=",
"Package",
"(",
")",
"pkg",
".",
"id",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._save_payload | Save payload (unmanaged files)
:param files:
:param directories:
:param links:
:return: | salt/modules/inspectlib/collector.py | def _save_payload(self, files, directories, links):
'''
Save payload (unmanaged files)
:param files:
:param directories:
:param links:
:return:
'''
idx = 0
for p_type, p_list in (('f', files), ('d', directories), ('l', links,),):
for ... | def _save_payload(self, files, directories, links):
'''
Save payload (unmanaged files)
:param files:
:param directories:
:param links:
:return:
'''
idx = 0
for p_type, p_list in (('f', files), ('d', directories), ('l', links,),):
for ... | [
"Save",
"payload",
"(",
"unmanaged",
"files",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L209-L237 | [
"def",
"_save_payload",
"(",
"self",
",",
"files",
",",
"directories",
",",
"links",
")",
":",
"idx",
"=",
"0",
"for",
"p_type",
",",
"p_list",
"in",
"(",
"(",
"'f'",
",",
"files",
")",
",",
"(",
"'d'",
",",
"directories",
")",
",",
"(",
"'l'",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._get_managed_files | Build a in-memory data of all managed files. | salt/modules/inspectlib/collector.py | def _get_managed_files(self):
'''
Build a in-memory data of all managed files.
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_managed_files_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
re... | def _get_managed_files(self):
'''
Build a in-memory data of all managed files.
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_managed_files_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
re... | [
"Build",
"a",
"in",
"-",
"memory",
"data",
"of",
"all",
"managed",
"files",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L239-L248 | [
"def",
"_get_managed_files",
"(",
"self",
")",
":",
"if",
"self",
".",
"grains_core",
".",
"os_data",
"(",
")",
".",
"get",
"(",
"'os_family'",
")",
"==",
"'Debian'",
":",
"return",
"self",
".",
"__get_managed_files_dpkg",
"(",
")",
"elif",
"self",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.__get_managed_files_dpkg | Get a list of all system files, belonging to the Debian package manager. | salt/modules/inspectlib/collector.py | def __get_managed_files_dpkg(self):
'''
Get a list of all system files, belonging to the Debian package manager.
'''
dirs = set()
links = set()
files = set()
for pkg_name in salt.utils.stringutils.to_str(self._syscall("dpkg-query", None, None,
... | def __get_managed_files_dpkg(self):
'''
Get a list of all system files, belonging to the Debian package manager.
'''
dirs = set()
links = set()
files = set()
for pkg_name in salt.utils.stringutils.to_str(self._syscall("dpkg-query", None, None,
... | [
"Get",
"a",
"list",
"of",
"all",
"system",
"files",
"belonging",
"to",
"the",
"Debian",
"package",
"manager",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L250-L274 | [
"def",
"__get_managed_files_dpkg",
"(",
"self",
")",
":",
"dirs",
"=",
"set",
"(",
")",
"links",
"=",
"set",
"(",
")",
"files",
"=",
"set",
"(",
")",
"for",
"pkg_name",
"in",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_str",
"(",
"self",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.__get_managed_files_rpm | Get a list of all system files, belonging to the RedHat package manager. | salt/modules/inspectlib/collector.py | def __get_managed_files_rpm(self):
'''
Get a list of all system files, belonging to the RedHat package manager.
'''
dirs = set()
links = set()
files = set()
for line in salt.utils.stringutils.to_str(self._syscall("rpm", None, None, '-qlav')[0]).split(os.linesep):... | def __get_managed_files_rpm(self):
'''
Get a list of all system files, belonging to the RedHat package manager.
'''
dirs = set()
links = set()
files = set()
for line in salt.utils.stringutils.to_str(self._syscall("rpm", None, None, '-qlav')[0]).split(os.linesep):... | [
"Get",
"a",
"list",
"of",
"all",
"system",
"files",
"belonging",
"to",
"the",
"RedHat",
"package",
"manager",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L276-L296 | [
"def",
"__get_managed_files_rpm",
"(",
"self",
")",
":",
"dirs",
"=",
"set",
"(",
")",
"links",
"=",
"set",
"(",
")",
"files",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_str",
"(",
"self",
".",
"_s... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._get_all_files | Walk implementation. Version in python 2.x and 3.x works differently. | salt/modules/inspectlib/collector.py | def _get_all_files(self, path, *exclude):
'''
Walk implementation. Version in python 2.x and 3.x works differently.
'''
files = list()
dirs = list()
links = list()
if os.access(path, os.R_OK):
for obj in os.listdir(path):
obj = os.path... | def _get_all_files(self, path, *exclude):
'''
Walk implementation. Version in python 2.x and 3.x works differently.
'''
files = list()
dirs = list()
links = list()
if os.access(path, os.R_OK):
for obj in os.listdir(path):
obj = os.path... | [
"Walk",
"implementation",
".",
"Version",
"in",
"python",
"2",
".",
"x",
"and",
"3",
".",
"x",
"works",
"differently",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L298-L327 | [
"def",
"_get_all_files",
"(",
"self",
",",
"path",
",",
"*",
"exclude",
")",
":",
"files",
"=",
"list",
"(",
")",
"dirs",
"=",
"list",
"(",
")",
"links",
"=",
"list",
"(",
")",
"if",
"os",
".",
"access",
"(",
"path",
",",
"os",
".",
"R_OK",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._get_unmanaged_files | Get the intersection between all files and managed files. | salt/modules/inspectlib/collector.py | def _get_unmanaged_files(self, managed, system_all):
'''
Get the intersection between all files and managed files.
'''
m_files, m_dirs, m_links = managed
s_files, s_dirs, s_links = system_all
return (sorted(list(set(s_files).difference(m_files))),
sorted(... | def _get_unmanaged_files(self, managed, system_all):
'''
Get the intersection between all files and managed files.
'''
m_files, m_dirs, m_links = managed
s_files, s_dirs, s_links = system_all
return (sorted(list(set(s_files).difference(m_files))),
sorted(... | [
"Get",
"the",
"intersection",
"between",
"all",
"files",
"and",
"managed",
"files",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L329-L338 | [
"def",
"_get_unmanaged_files",
"(",
"self",
",",
"managed",
",",
"system_all",
")",
":",
"m_files",
",",
"m_dirs",
",",
"m_links",
"=",
"managed",
"s_files",
",",
"s_dirs",
",",
"s_links",
"=",
"system_all",
"return",
"(",
"sorted",
"(",
"list",
"(",
"set"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._scan_payload | Scan the system. | salt/modules/inspectlib/collector.py | def _scan_payload(self):
'''
Scan the system.
'''
# Get ignored points
allowed = list()
for allowed_dir in self.db.get(AllowedDir):
if os.path.exists(allowed_dir.path):
allowed.append(allowed_dir.path)
ignored = list()
if not a... | def _scan_payload(self):
'''
Scan the system.
'''
# Get ignored points
allowed = list()
for allowed_dir in self.db.get(AllowedDir):
if os.path.exists(allowed_dir.path):
allowed.append(allowed_dir.path)
ignored = list()
if not a... | [
"Scan",
"the",
"system",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L340-L369 | [
"def",
"_scan_payload",
"(",
"self",
")",
":",
"# Get ignored points",
"allowed",
"=",
"list",
"(",
")",
"for",
"allowed_dir",
"in",
"self",
".",
"db",
".",
"get",
"(",
"AllowedDir",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"allowed_dir",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._prepare_full_scan | Prepare full system scan by setting up the database etc. | salt/modules/inspectlib/collector.py | def _prepare_full_scan(self, **kwargs):
'''
Prepare full system scan by setting up the database etc.
'''
self.db.open(new=True)
# Add ignored filesystems
ignored_fs = set()
ignored_fs |= set(self.IGNORE_PATHS)
mounts = salt.utils.fsutils._get_mounts()
... | def _prepare_full_scan(self, **kwargs):
'''
Prepare full system scan by setting up the database etc.
'''
self.db.open(new=True)
# Add ignored filesystems
ignored_fs = set()
ignored_fs |= set(self.IGNORE_PATHS)
mounts = salt.utils.fsutils._get_mounts()
... | [
"Prepare",
"full",
"system",
"scan",
"by",
"setting",
"up",
"the",
"database",
"etc",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L371-L412 | [
"def",
"_prepare_full_scan",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"db",
".",
"open",
"(",
"new",
"=",
"True",
")",
"# Add ignored filesystems",
"ignored_fs",
"=",
"set",
"(",
")",
"ignored_fs",
"|=",
"set",
"(",
"self",
".",
"IG... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector._init_env | Initialize some Salt environment. | salt/modules/inspectlib/collector.py | def _init_env(self):
'''
Initialize some Salt environment.
'''
from salt.config import minion_config
from salt.grains import core as g_core
g_core.__opts__ = minion_config(self.DEFAULT_MINION_CONFIG_PATH)
self.grains_core = g_core | def _init_env(self):
'''
Initialize some Salt environment.
'''
from salt.config import minion_config
from salt.grains import core as g_core
g_core.__opts__ = minion_config(self.DEFAULT_MINION_CONFIG_PATH)
self.grains_core = g_core | [
"Initialize",
"some",
"Salt",
"environment",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L414-L421 | [
"def",
"_init_env",
"(",
"self",
")",
":",
"from",
"salt",
".",
"config",
"import",
"minion_config",
"from",
"salt",
".",
"grains",
"import",
"core",
"as",
"g_core",
"g_core",
".",
"__opts__",
"=",
"minion_config",
"(",
"self",
".",
"DEFAULT_MINION_CONFIG_PATH... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.snapshot | Take a snapshot of the system. | salt/modules/inspectlib/collector.py | def snapshot(self, mode):
'''
Take a snapshot of the system.
'''
self._init_env()
self._save_cfg_packages(self._get_changed_cfg_pkgs(self._get_cfg_pkgs()))
self._save_payload(*self._scan_payload()) | def snapshot(self, mode):
'''
Take a snapshot of the system.
'''
self._init_env()
self._save_cfg_packages(self._get_changed_cfg_pkgs(self._get_cfg_pkgs()))
self._save_payload(*self._scan_payload()) | [
"Take",
"a",
"snapshot",
"of",
"the",
"system",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L423-L430 | [
"def",
"snapshot",
"(",
"self",
",",
"mode",
")",
":",
"self",
".",
"_init_env",
"(",
")",
"self",
".",
"_save_cfg_packages",
"(",
"self",
".",
"_get_changed_cfg_pkgs",
"(",
"self",
".",
"_get_cfg_pkgs",
"(",
")",
")",
")",
"self",
".",
"_save_payload",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.request_snapshot | Take a snapshot of the system. | salt/modules/inspectlib/collector.py | def request_snapshot(self, mode, priority=19, **kwargs):
'''
Take a snapshot of the system.
'''
if mode not in self.MODE:
raise InspectorSnapshotException("Unknown mode: '{0}'".format(mode))
if is_alive(self.pidfile):
raise CommandExecutionError('Inspecti... | def request_snapshot(self, mode, priority=19, **kwargs):
'''
Take a snapshot of the system.
'''
if mode not in self.MODE:
raise InspectorSnapshotException("Unknown mode: '{0}'".format(mode))
if is_alive(self.pidfile):
raise CommandExecutionError('Inspecti... | [
"Take",
"a",
"snapshot",
"of",
"the",
"system",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L432-L445 | [
"def",
"request_snapshot",
"(",
"self",
",",
"mode",
",",
"priority",
"=",
"19",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mode",
"not",
"in",
"self",
".",
"MODE",
":",
"raise",
"InspectorSnapshotException",
"(",
"\"Unknown mode: '{0}'\"",
".",
"format",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.export | Export description for Kiwi.
:param local:
:param path:
:return: | salt/modules/inspectlib/collector.py | def export(self, description, local=False, path='/tmp', format='qcow2'):
'''
Export description for Kiwi.
:param local:
:param path:
:return:
'''
kiwiproc.__salt__ = __salt__
return kiwiproc.KiwiExporter(grains=__grains__,
... | def export(self, description, local=False, path='/tmp', format='qcow2'):
'''
Export description for Kiwi.
:param local:
:param path:
:return:
'''
kiwiproc.__salt__ = __salt__
return kiwiproc.KiwiExporter(grains=__grains__,
... | [
"Export",
"description",
"for",
"Kiwi",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L447-L457 | [
"def",
"export",
"(",
"self",
",",
"description",
",",
"local",
"=",
"False",
",",
"path",
"=",
"'/tmp'",
",",
"format",
"=",
"'qcow2'",
")",
":",
"kiwiproc",
".",
"__salt__",
"=",
"__salt__",
"return",
"kiwiproc",
".",
"KiwiExporter",
"(",
"grains",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Inspector.build | Build an image using Kiwi.
:param format:
:param path:
:return: | salt/modules/inspectlib/collector.py | def build(self, format='qcow2', path='/tmp'):
'''
Build an image using Kiwi.
:param format:
:param path:
:return:
'''
if kiwi is None:
msg = 'Unable to build the image due to the missing dependencies: Kiwi module is not available.'
log.err... | def build(self, format='qcow2', path='/tmp'):
'''
Build an image using Kiwi.
:param format:
:param path:
:return:
'''
if kiwi is None:
msg = 'Unable to build the image due to the missing dependencies: Kiwi module is not available.'
log.err... | [
"Build",
"an",
"image",
"using",
"Kiwi",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L459-L472 | [
"def",
"build",
"(",
"self",
",",
"format",
"=",
"'qcow2'",
",",
"path",
"=",
"'/tmp'",
")",
":",
"if",
"kiwi",
"is",
"None",
":",
"msg",
"=",
"'Unable to build the image due to the missing dependencies: Kiwi module is not available.'",
"log",
".",
"error",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | value_present | .. versionadded:: Neon
Manages a given XML file
name : string
The location of the XML file to manage, as an absolute path.
xpath : string
xpath location to manage
value : string
value to ensure present
.. code-block:: yaml
ensure_value_true:
xml.value_... | salt/states/xml.py | def value_present(name, xpath, value, **kwargs):
'''
.. versionadded:: Neon
Manages a given XML file
name : string
The location of the XML file to manage, as an absolute path.
xpath : string
xpath location to manage
value : string
value to ensure present
.. code-... | def value_present(name, xpath, value, **kwargs):
'''
.. versionadded:: Neon
Manages a given XML file
name : string
The location of the XML file to manage, as an absolute path.
xpath : string
xpath location to manage
value : string
value to ensure present
.. code-... | [
"..",
"versionadded",
"::",
"Neon"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/xml.py#L26-L76 | [
"def",
"value_present",
"(",
"name",
",",
"xpath",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"if",
"'t... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | thing_type_present | Ensure thing type exists.
.. versionadded:: 2016.11.0
name
The name of the state definition
thingTypeName
Name of the thing type
thingTypeDescription
Description of the thing type
searchableAttributesList
List of string attributes that are searchable for
... | salt/states/boto_iot.py | def thing_type_present(name, thingTypeName, thingTypeDescription,
searchableAttributesList,
region=None, key=None, keyid=None, profile=None):
'''
Ensure thing type exists.
.. versionadded:: 2016.11.0
name
The name of the state definition
thingTypeName
Name of the thing typ... | def thing_type_present(name, thingTypeName, thingTypeDescription,
searchableAttributesList,
region=None, key=None, keyid=None, profile=None):
'''
Ensure thing type exists.
.. versionadded:: 2016.11.0
name
The name of the state definition
thingTypeName
Name of the thing typ... | [
"Ensure",
"thing",
"type",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L97-L178 | [
"def",
"thing_type_present",
"(",
"name",
",",
"thingTypeName",
",",
"thingTypeDescription",
",",
"searchableAttributesList",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | thing_type_absent | Ensure thing type with passed properties is absent.
.. versionadded:: 2016.11.0
name
The name of the state definition.
thingTypeName
Name of the thing type.
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
pro... | salt/states/boto_iot.py | def thing_type_absent(name, thingTypeName,
region=None, key=None, keyid=None, profile=None):
'''
Ensure thing type with passed properties is absent.
.. versionadded:: 2016.11.0
name
The name of the state definition.
thingTypeName
Name of the thing type.
regi... | def thing_type_absent(name, thingTypeName,
region=None, key=None, keyid=None, profile=None):
'''
Ensure thing type with passed properties is absent.
.. versionadded:: 2016.11.0
name
The name of the state definition.
thingTypeName
Name of the thing type.
regi... | [
"Ensure",
"thing",
"type",
"with",
"passed",
"properties",
"is",
"absent",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L181-L296 | [
"def",
"thing_type_absent",
"(",
"name",
",",
"thingTypeName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"thingTypeName",
",",
"'result'",
":",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | policy_present | Ensure policy exists.
name
The name of the state definition
policyName
Name of the policy.
policyDocument
The JSON document that describes the policy. The length of the
policyDocument must be a minimum length of 1, with a maximum length of
2048, excluding whitespac... | salt/states/boto_iot.py | def policy_present(name, policyName, policyDocument,
region=None, key=None, keyid=None, profile=None):
'''
Ensure policy exists.
name
The name of the state definition
policyName
Name of the policy.
policyDocument
The JSON document that describes the policy. The... | def policy_present(name, policyName, policyDocument,
region=None, key=None, keyid=None, profile=None):
'''
Ensure policy exists.
name
The name of the state definition
policyName
Name of the policy.
policyDocument
The JSON document that describes the policy. The... | [
"Ensure",
"policy",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L299-L405 | [
"def",
"policy_present",
"(",
"name",
",",
"policyName",
",",
"policyDocument",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"policyName",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | policy_attached | Ensure policy is attached to the given principal.
name
The name of the state definition
policyName
Name of the policy.
principal
The principal which can be a certificate ARN or a Cognito ID.
region
Region to connect to.
key
Secret key to be used.
key... | salt/states/boto_iot.py | def policy_attached(name, policyName, principal,
region=None, key=None, keyid=None, profile=None):
'''
Ensure policy is attached to the given principal.
name
The name of the state definition
policyName
Name of the policy.
principal
The principal which can be a ... | def policy_attached(name, policyName, principal,
region=None, key=None, keyid=None, profile=None):
'''
Ensure policy is attached to the given principal.
name
The name of the state definition
policyName
Name of the policy.
principal
The principal which can be a ... | [
"Ensure",
"policy",
"is",
"attached",
"to",
"the",
"given",
"principal",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L490-L557 | [
"def",
"policy_attached",
"(",
"name",
",",
"policyName",
",",
"principal",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"policyName",
",",
"'re... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | topic_rule_present | Ensure topic rule exists.
name
The name of the state definition
ruleName
Name of the rule.
sql
The SQL statement used to query the topic.
actions
The actions associated with the rule.
description
The description of the rule.
ruleDisable
Speci... | salt/states/boto_iot.py | def topic_rule_present(name, ruleName, sql, actions, description='',
ruleDisabled=False,
region=None, key=None, keyid=None, profile=None):
'''
Ensure topic rule exists.
name
The name of the state definition
ruleName
Name of the rule.
sql
The SQL sta... | def topic_rule_present(name, ruleName, sql, actions, description='',
ruleDisabled=False,
region=None, key=None, keyid=None, profile=None):
'''
Ensure topic rule exists.
name
The name of the state definition
ruleName
Name of the rule.
sql
The SQL sta... | [
"Ensure",
"topic",
"rule",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L631-L746 | [
"def",
"topic_rule_present",
"(",
"name",
",",
"ruleName",
",",
"sql",
",",
"actions",
",",
"description",
"=",
"''",
",",
"ruleDisabled",
"=",
"False",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | topic_rule_absent | Ensure topic rule with passed properties is absent.
name
The name of the state definition.
ruleName
Name of the policy.
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and k... | salt/states/boto_iot.py | def topic_rule_absent(name, ruleName,
region=None, key=None, keyid=None, profile=None):
'''
Ensure topic rule with passed properties is absent.
name
The name of the state definition.
ruleName
Name of the policy.
region
Region to connect to.
key
... | def topic_rule_absent(name, ruleName,
region=None, key=None, keyid=None, profile=None):
'''
Ensure topic rule with passed properties is absent.
name
The name of the state definition.
ruleName
Name of the policy.
region
Region to connect to.
key
... | [
"Ensure",
"topic",
"rule",
"with",
"passed",
"properties",
"is",
"absent",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_iot.py#L749-L805 | [
"def",
"topic_rule_absent",
"(",
"name",
",",
"ruleName",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"ruleName",
",",
"'result'",
":",
"True",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _quote_username | Usernames can only contain ascii chars, so make sure we return a str type | salt/modules/useradd.py | def _quote_username(name):
'''
Usernames can only contain ascii chars, so make sure we return a str type
'''
if not isinstance(name, six.string_types):
return str(name) # future lint: disable=blacklisted-function
else:
return salt.utils.stringutils.to_str(name) | def _quote_username(name):
'''
Usernames can only contain ascii chars, so make sure we return a str type
'''
if not isinstance(name, six.string_types):
return str(name) # future lint: disable=blacklisted-function
else:
return salt.utils.stringutils.to_str(name) | [
"Usernames",
"can",
"only",
"contain",
"ascii",
"chars",
"so",
"make",
"sure",
"we",
"return",
"a",
"str",
"type"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L50-L57 | [
"def",
"_quote_username",
"(",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"six",
".",
"string_types",
")",
":",
"return",
"str",
"(",
"name",
")",
"# future lint: disable=blacklisted-function",
"else",
":",
"return",
"salt",
".",
"utils",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_gecos | Retrieve GECOS field info and return it in dictionary form | salt/modules/useradd.py | def _get_gecos(name, root=None):
'''
Retrieve GECOS field info and return it in dictionary form
'''
if root is not None and __grains__['kernel'] != 'AIX':
getpwnam = functools.partial(_getpwnam, root=root)
else:
getpwnam = functools.partial(pwd.getpwnam)
gecos_field = salt.utils.... | def _get_gecos(name, root=None):
'''
Retrieve GECOS field info and return it in dictionary form
'''
if root is not None and __grains__['kernel'] != 'AIX':
getpwnam = functools.partial(_getpwnam, root=root)
else:
getpwnam = functools.partial(pwd.getpwnam)
gecos_field = salt.utils.... | [
"Retrieve",
"GECOS",
"field",
"info",
"and",
"return",
"it",
"in",
"dictionary",
"form"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L60-L81 | [
"def",
"_get_gecos",
"(",
"name",
",",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"not",
"None",
"and",
"__grains__",
"[",
"'kernel'",
"]",
"!=",
"'AIX'",
":",
"getpwnam",
"=",
"functools",
".",
"partial",
"(",
"_getpwnam",
",",
"root",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _update_gecos | Common code to change a user's GECOS information | salt/modules/useradd.py | def _update_gecos(name, key, value, root=None):
'''
Common code to change a user's GECOS information
'''
if value is None:
value = ''
elif not isinstance(value, six.string_types):
value = six.text_type(value)
else:
value = salt.utils.stringutils.to_unicode(value)
pre_... | def _update_gecos(name, key, value, root=None):
'''
Common code to change a user's GECOS information
'''
if value is None:
value = ''
elif not isinstance(value, six.string_types):
value = six.text_type(value)
else:
value = salt.utils.stringutils.to_unicode(value)
pre_... | [
"Common",
"code",
"to",
"change",
"a",
"user",
"s",
"GECOS",
"information"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L96-L120 | [
"def",
"_update_gecos",
"(",
"name",
",",
"key",
",",
"value",
",",
"root",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"''",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"value",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add | Add a user to the minion
name
Username LOGIN to add
uid
User ID of the new account
gid
Name or ID of the primary group of the new account
groups
List of supplementary groups of the new account
home
Home directory of the new account
shell
Logi... | salt/modules/useradd.py | def add(name,
uid=None,
gid=None,
groups=None,
home=None,
shell=None,
unique=True,
system=False,
fullname='',
roomnumber='',
workphone='',
homephone='',
other='',
createhome=True,
loginclass=None,
nol... | def add(name,
uid=None,
gid=None,
groups=None,
home=None,
shell=None,
unique=True,
system=False,
fullname='',
roomnumber='',
workphone='',
homephone='',
other='',
createhome=True,
loginclass=None,
nol... | [
"Add",
"a",
"user",
"to",
"the",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L123-L313 | [
"def",
"add",
"(",
"name",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"home",
"=",
"None",
",",
"shell",
"=",
"None",
",",
"unique",
"=",
"True",
",",
"system",
"=",
"False",
",",
"fullname",
"=",
"''",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete | Remove a user from the minion
name
Username to delete
remove
Remove home directory and mail spool
force
Force some actions that would fail otherwise
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.delete name remove=Tru... | salt/modules/useradd.py | def delete(name, remove=False, force=False, root=None):
'''
Remove a user from the minion
name
Username to delete
remove
Remove home directory and mail spool
force
Force some actions that would fail otherwise
root
Directory to chroot into
CLI Example:
... | def delete(name, remove=False, force=False, root=None):
'''
Remove a user from the minion
name
Username to delete
remove
Remove home directory and mail spool
force
Force some actions that would fail otherwise
root
Directory to chroot into
CLI Example:
... | [
"Remove",
"a",
"user",
"from",
"the",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L316-L372 | [
"def",
"delete",
"(",
"name",
",",
"remove",
"=",
"False",
",",
"force",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'userdel'",
"]",
"if",
"remove",
":",
"cmd",
".",
"append",
"(",
"'-r'",
")",
"if",
"force",
"and",
"__gr... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | getent | Return the list of all info for all users
refresh
Force a refresh of user information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.getent | salt/modules/useradd.py | def getent(refresh=False, root=None):
'''
Return the list of all info for all users
refresh
Force a refresh of user information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.getent
'''
if 'user.getent' in __context__ and not re... | def getent(refresh=False, root=None):
'''
Return the list of all info for all users
refresh
Force a refresh of user information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.getent
'''
if 'user.getent' in __context__ and not re... | [
"Return",
"the",
"list",
"of",
"all",
"info",
"for",
"all",
"users"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L375-L403 | [
"def",
"getent",
"(",
"refresh",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"if",
"'user.getent'",
"in",
"__context__",
"and",
"not",
"refresh",
":",
"return",
"__context__",
"[",
"'user.getent'",
"]",
"ret",
"=",
"[",
"]",
"if",
"root",
"is",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _chattrib | Change an attribute for a named user | salt/modules/useradd.py | def _chattrib(name, key, value, param, persist=False, root=None):
'''
Change an attribute for a named user
'''
pre_info = info(name, root=root)
if not pre_info:
raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
if value == pre_info[key]:
return True
cm... | def _chattrib(name, key, value, param, persist=False, root=None):
'''
Change an attribute for a named user
'''
pre_info = info(name, root=root)
if not pre_info:
raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
if value == pre_info[key]:
return True
cm... | [
"Change",
"an",
"attribute",
"for",
"a",
"named",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L406-L428 | [
"def",
"_chattrib",
"(",
"name",
",",
"key",
",",
"value",
",",
"param",
",",
"persist",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"pre_info",
"=",
"info",
"(",
"name",
",",
"root",
"=",
"root",
")",
"if",
"not",
"pre_info",
":",
"raise",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | chhome | Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
name
User to modify
home
New home directory for the user account
presist
Move contents of the home directory to the new location
root
... | salt/modules/useradd.py | def chhome(name, home, persist=False, root=None):
'''
Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
name
User to modify
home
New home directory for the user account
presist
Move con... | def chhome(name, home, persist=False, root=None):
'''
Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
name
User to modify
home
New home directory for the user account
presist
Move con... | [
"Change",
"the",
"home",
"directory",
"of",
"the",
"user",
"pass",
"True",
"for",
"persist",
"to",
"move",
"files",
"to",
"the",
"new",
"home",
"directory",
"if",
"the",
"old",
"home",
"directory",
"exist",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L497-L520 | [
"def",
"chhome",
"(",
"name",
",",
"home",
",",
"persist",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"return",
"_chattrib",
"(",
"name",
",",
"'home'",
",",
"home",
",",
"'-d'",
",",
"persist",
"=",
"persist",
",",
"root",
"=",
"root",
")"
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | chgroups | Change the groups to which this user belongs
name
User to modify
groups
Groups to set for the user
append : False
If ``True``, append the specified group(s). Otherwise, this function
will replace the user's groups with the specified group(s).
root
Directory to... | salt/modules/useradd.py | def chgroups(name, groups, append=False, root=None):
'''
Change the groups to which this user belongs
name
User to modify
groups
Groups to set for the user
append : False
If ``True``, append the specified group(s). Otherwise, this function
will replace the user's g... | def chgroups(name, groups, append=False, root=None):
'''
Change the groups to which this user belongs
name
User to modify
groups
Groups to set for the user
append : False
If ``True``, append the specified group(s). Otherwise, this function
will replace the user's g... | [
"Change",
"the",
"groups",
"to",
"which",
"this",
"user",
"belongs"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L523-L583 | [
"def",
"chgroups",
"(",
"name",
",",
"groups",
",",
"append",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"groups",
",",
"six",
".",
"string_types",
")",
":",
"groups",
"=",
"groups",
".",
"split",
"(",
"','",
")",
"u... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | chloginclass | Change the default login class of the user
name
User to modify
loginclass
Login class for the new account
root
Directory to chroot into
.. note::
This function only applies to OpenBSD systems.
CLI Example:
.. code-block:: bash
salt '*' user.chloginc... | salt/modules/useradd.py | def chloginclass(name, loginclass, root=None):
'''
Change the default login class of the user
name
User to modify
loginclass
Login class for the new account
root
Directory to chroot into
.. note::
This function only applies to OpenBSD systems.
CLI Example... | def chloginclass(name, loginclass, root=None):
'''
Change the default login class of the user
name
User to modify
loginclass
Login class for the new account
root
Directory to chroot into
.. note::
This function only applies to OpenBSD systems.
CLI Example... | [
"Change",
"the",
"default",
"login",
"class",
"of",
"the",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L687-L721 | [
"def",
"chloginclass",
"(",
"name",
",",
"loginclass",
",",
"root",
"=",
"None",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"!=",
"'OpenBSD'",
":",
"return",
"False",
"if",
"loginclass",
"==",
"get_loginclass",
"(",
"name",
")",
":",
"return",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | info | Return user information
name
User to get the information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.info root | salt/modules/useradd.py | def info(name, root=None):
'''
Return user information
name
User to get the information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.info root
'''
# If root is provided, we use a less portable solution that
# depends on an... | def info(name, root=None):
'''
Return user information
name
User to get the information
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.info root
'''
# If root is provided, we use a less portable solution that
# depends on an... | [
"Return",
"user",
"information"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L724-L757 | [
"def",
"info",
"(",
"name",
",",
"root",
"=",
"None",
")",
":",
"# If root is provided, we use a less portable solution that",
"# depends on analyzing /etc/passwd manually. Of course we cannot",
"# find users from NIS nor LDAP, but in those cases do not makes",
"# sense to provide a root p... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_loginclass | Get the login class of the user
name
User to get the information
.. note::
This function only applies to OpenBSD systems.
CLI Example:
.. code-block:: bash
salt '*' user.get_loginclass foo | salt/modules/useradd.py | def get_loginclass(name):
'''
Get the login class of the user
name
User to get the information
.. note::
This function only applies to OpenBSD systems.
CLI Example:
.. code-block:: bash
salt '*' user.get_loginclass foo
'''
if __grains__['kernel'] != 'OpenBSD'... | def get_loginclass(name):
'''
Get the login class of the user
name
User to get the information
.. note::
This function only applies to OpenBSD systems.
CLI Example:
.. code-block:: bash
salt '*' user.get_loginclass foo
'''
if __grains__['kernel'] != 'OpenBSD'... | [
"Get",
"the",
"login",
"class",
"of",
"the",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L760-L790 | [
"def",
"get_loginclass",
"(",
"name",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"!=",
"'OpenBSD'",
":",
"return",
"False",
"userinfo",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"[",
"'userinfo'",
",",
"name",
"]",
",",
"python_shell",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _format_info | Return user information in a pretty way | salt/modules/useradd.py | def _format_info(data):
'''
Return user information in a pretty way
'''
# Put GECOS info into a list
gecos_field = salt.utils.stringutils.to_unicode(data.pw_gecos).split(',', 4)
# Make sure our list has at least five elements
while len(gecos_field) < 5:
gecos_field.append('')
re... | def _format_info(data):
'''
Return user information in a pretty way
'''
# Put GECOS info into a list
gecos_field = salt.utils.stringutils.to_unicode(data.pw_gecos).split(',', 4)
# Make sure our list has at least five elements
while len(gecos_field) < 5:
gecos_field.append('')
re... | [
"Return",
"user",
"information",
"in",
"a",
"pretty",
"way"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L793-L814 | [
"def",
"_format_info",
"(",
"data",
")",
":",
"# Put GECOS info into a list",
"gecos_field",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
"data",
".",
"pw_gecos",
")",
".",
"split",
"(",
"','",
",",
"4",
")",
"# Make sure our list has... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_users | Return a list of all users
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.list_users | salt/modules/useradd.py | def list_users(root=None):
'''
Return a list of all users
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.list_users
'''
if root is not None and __grains__['kernel'] != 'AIX':
getpwall = functools.partial(_getpwall, root=root)
els... | def list_users(root=None):
'''
Return a list of all users
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.list_users
'''
if root is not None and __grains__['kernel'] != 'AIX':
getpwall = functools.partial(_getpwall, root=root)
els... | [
"Return",
"a",
"list",
"of",
"all",
"users"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L852-L870 | [
"def",
"list_users",
"(",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"not",
"None",
"and",
"__grains__",
"[",
"'kernel'",
"]",
"!=",
"'AIX'",
":",
"getpwall",
"=",
"functools",
".",
"partial",
"(",
"_getpwall",
",",
"root",
"=",
"root",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | rename | Change the username for a named user
name
User to modify
new_name
New value of the login name
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.rename name new_name | salt/modules/useradd.py | def rename(name, new_name, root=None):
'''
Change the username for a named user
name
User to modify
new_name
New value of the login name
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.rename name new_name
'''
if inf... | def rename(name, new_name, root=None):
'''
Change the username for a named user
name
User to modify
new_name
New value of the login name
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' user.rename name new_name
'''
if inf... | [
"Change",
"the",
"username",
"for",
"a",
"named",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L873-L895 | [
"def",
"rename",
"(",
"name",
",",
"new_name",
",",
"root",
"=",
"None",
")",
":",
"if",
"info",
"(",
"new_name",
",",
"root",
"=",
"root",
")",
":",
"raise",
"CommandExecutionError",
"(",
"'User \\'{0}\\' already exists'",
".",
"format",
"(",
"new_name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _getpwnam | Alternative implementation for getpwnam, that use only /etc/passwd | salt/modules/useradd.py | def _getpwnam(name, root=None):
'''
Alternative implementation for getpwnam, that use only /etc/passwd
'''
root = '/' if not root else root
passwd = os.path.join(root, 'etc/passwd')
with salt.utils.files.fopen(passwd) as fp_:
for line in fp_:
line = salt.utils.stringutils.to_... | def _getpwnam(name, root=None):
'''
Alternative implementation for getpwnam, that use only /etc/passwd
'''
root = '/' if not root else root
passwd = os.path.join(root, 'etc/passwd')
with salt.utils.files.fopen(passwd) as fp_:
for line in fp_:
line = salt.utils.stringutils.to_... | [
"Alternative",
"implementation",
"for",
"getpwnam",
"that",
"use",
"only",
"/",
"etc",
"/",
"passwd"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L898-L912 | [
"def",
"_getpwnam",
"(",
"name",
",",
"root",
"=",
"None",
")",
":",
"root",
"=",
"'/'",
"if",
"not",
"root",
"else",
"root",
"passwd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"'etc/passwd'",
")",
"with",
"salt",
".",
"utils",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_subgids | Add a range of subordinate gids to the user
name
User to modify
first
Begin of the range
last
End of the range
CLI Examples:
.. code-block:: bash
salt '*' user.add_subgids foo
salt '*' user.add_subgids foo first=105000
salt '*' user.add_subgids f... | salt/modules/useradd.py | def add_subgids(name, first=100000, last=110000):
'''
Add a range of subordinate gids to the user
name
User to modify
first
Begin of the range
last
End of the range
CLI Examples:
.. code-block:: bash
salt '*' user.add_subgids foo
salt '*' user.ad... | def add_subgids(name, first=100000, last=110000):
'''
Add a range of subordinate gids to the user
name
User to modify
first
Begin of the range
last
End of the range
CLI Examples:
.. code-block:: bash
salt '*' user.add_subgids foo
salt '*' user.ad... | [
"Add",
"a",
"range",
"of",
"subordinate",
"gids",
"to",
"the",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L984-L1008 | [
"def",
"add_subgids",
"(",
"name",
",",
"first",
"=",
"100000",
",",
"last",
"=",
"110000",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"!=",
"'Linux'",
":",
"log",
".",
"warning",
"(",
"\"'subgids' are only supported on GNU/Linux hosts.\"",
")",
"retu... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | capability_installed | Install a DISM capability
Args:
name (str): The capability to install
source (str): The optional source of the capability
limit_access (bool): Prevent DISM from contacting Windows Update for
online images
image (Optional[str]): The path to the root directory of an offlin... | salt/states/win_dism.py | def capability_installed(name,
source=None,
limit_access=False,
image=None,
restart=False):
'''
Install a DISM capability
Args:
name (str): The capability to install
source (str): The optiona... | def capability_installed(name,
source=None,
limit_access=False,
image=None,
restart=False):
'''
Install a DISM capability
Args:
name (str): The capability to install
source (str): The optiona... | [
"Install",
"a",
"DISM",
"capability"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_dism.py#L40-L101 | [
"def",
"capability_installed",
"(",
"name",
",",
"source",
"=",
"None",
",",
"limit_access",
"=",
"False",
",",
"image",
"=",
"None",
",",
"restart",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | package_removed | Uninstall a package
Args:
name (str): The full path to the package. Can be either a .cab file or a
folder. Should point to the original source of the package, not to
where the file is installed. This can also be the name of a package as listed in
``dism.installed_package... | salt/states/win_dism.py | def package_removed(name, image=None, restart=False):
'''
Uninstall a package
Args:
name (str): The full path to the package. Can be either a .cab file or a
folder. Should point to the original source of the package, not to
where the file is installed. This can also be the n... | def package_removed(name, image=None, restart=False):
'''
Uninstall a package
Args:
name (str): The full path to the package. Can be either a .cab file or a
folder. Should point to the original source of the package, not to
where the file is installed. This can also be the n... | [
"Uninstall",
"a",
"package"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_dism.py#L368-L443 | [
"def",
"package_removed",
"(",
"name",
",",
"image",
"=",
"None",
",",
"restart",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"# Fa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ping | Performs an ICMP ping to a host
.. versionchanged:: 2015.8.0
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.ping archlinux.org
.. versionadded:: 2015.5.0
Return a True or False instead of ping output.
.. code-block:: bash
salt '*' netwo... | salt/modules/network.py | def ping(host, timeout=False, return_boolean=False):
'''
Performs an ICMP ping to a host
.. versionchanged:: 2015.8.0
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.ping archlinux.org
.. versionadded:: 2015.5.0
Return a True or False instead ... | def ping(host, timeout=False, return_boolean=False):
'''
Performs an ICMP ping to a host
.. versionchanged:: 2015.8.0
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.ping archlinux.org
.. versionadded:: 2015.5.0
Return a True or False instead ... | [
"Performs",
"an",
"ICMP",
"ping",
"to",
"a",
"host"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L63-L104 | [
"def",
"ping",
"(",
"host",
",",
"timeout",
"=",
"False",
",",
"return_boolean",
"=",
"False",
")",
":",
"if",
"timeout",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"cmd",
"=",
"'ping -c 4 {1} {0}'",
".",
"format",
"(",
"timeout... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_linux | Return netstat information for Linux distros | salt/modules/network.py | def _netstat_linux():
'''
Return netstat information for Linux distros
'''
ret = []
cmd = 'netstat -tulpnea'
out = __salt__['cmd.run'](cmd)
for line in out.splitlines():
comps = line.split()
if line.startswith('tcp'):
ret.append({
'proto': comps[0]... | def _netstat_linux():
'''
Return netstat information for Linux distros
'''
ret = []
cmd = 'netstat -tulpnea'
out = __salt__['cmd.run'](cmd)
for line in out.splitlines():
comps = line.split()
if line.startswith('tcp'):
ret.append({
'proto': comps[0]... | [
"Return",
"netstat",
"information",
"for",
"Linux",
"distros"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L109-L139 | [
"def",
"_netstat_linux",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'netstat -tulpnea'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
"for",
"line",
"in",
"out",
".",
"splitlines",
"(",
")",
":",
"comps",
"=",
"line",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _ss_linux | Return ss information for Linux distros
(netstat is deprecated and may not be available) | salt/modules/network.py | def _ss_linux():
'''
Return ss information for Linux distros
(netstat is deprecated and may not be available)
'''
ret = []
cmd = 'ss -tulpnea'
out = __salt__['cmd.run'](cmd)
for line in out.splitlines():
comps = line.split()
ss_user = 0
ss_inode = 0
ss_pro... | def _ss_linux():
'''
Return ss information for Linux distros
(netstat is deprecated and may not be available)
'''
ret = []
cmd = 'ss -tulpnea'
out = __salt__['cmd.run'](cmd)
for line in out.splitlines():
comps = line.split()
ss_user = 0
ss_inode = 0
ss_pro... | [
"Return",
"ss",
"information",
"for",
"Linux",
"distros",
"(",
"netstat",
"is",
"deprecated",
"and",
"may",
"not",
"be",
"available",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L142-L196 | [
"def",
"_ss_linux",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'ss -tulpnea'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
"for",
"line",
"in",
"out",
".",
"splitlines",
"(",
")",
":",
"comps",
"=",
"line",
".",
"split",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netinfo_openbsd | Get process information for network connections using fstat | salt/modules/network.py | def _netinfo_openbsd():
'''
Get process information for network connections using fstat
'''
ret = {}
_fstat_re = re.compile(
r'internet(6)? (?:stream tcp 0x\S+ (\S+)|dgram udp (\S+))'
r'(?: [<>=-]+ (\S+))?$'
)
out = __salt__['cmd.run']('fstat')
for line in out.splitlines(... | def _netinfo_openbsd():
'''
Get process information for network connections using fstat
'''
ret = {}
_fstat_re = re.compile(
r'internet(6)? (?:stream tcp 0x\S+ (\S+)|dgram udp (\S+))'
r'(?: [<>=-]+ (\S+))?$'
)
out = __salt__['cmd.run']('fstat')
for line in out.splitlines(... | [
"Get",
"process",
"information",
"for",
"network",
"connections",
"using",
"fstat"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L199-L243 | [
"def",
"_netinfo_openbsd",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"_fstat_re",
"=",
"re",
".",
"compile",
"(",
"r'internet(6)? (?:stream tcp 0x\\S+ (\\S+)|dgram udp (\\S+))'",
"r'(?: [<>=-]+ (\\S+))?$'",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'fstat... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netinfo_freebsd_netbsd | Get process information for network connections using sockstat | salt/modules/network.py | def _netinfo_freebsd_netbsd():
'''
Get process information for network connections using sockstat
'''
ret = {}
# NetBSD requires '-n' to disable port-to-service resolution
out = __salt__['cmd.run'](
'sockstat -46 {0} | tail -n+2'.format(
'-n' if __grains__['kernel'] == 'NetBS... | def _netinfo_freebsd_netbsd():
'''
Get process information for network connections using sockstat
'''
ret = {}
# NetBSD requires '-n' to disable port-to-service resolution
out = __salt__['cmd.run'](
'sockstat -46 {0} | tail -n+2'.format(
'-n' if __grains__['kernel'] == 'NetBS... | [
"Get",
"process",
"information",
"for",
"network",
"connections",
"using",
"sockstat"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L246-L267 | [
"def",
"_netinfo_freebsd_netbsd",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"# NetBSD requires '-n' to disable port-to-service resolution",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'sockstat -46 {0} | tail -n+2'",
".",
"format",
"(",
"'-n'",
"if",
"__grains__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _ppid | Return a dict of pid to ppid mappings | salt/modules/network.py | def _ppid():
'''
Return a dict of pid to ppid mappings
'''
ret = {}
if __grains__['kernel'] == 'SunOS':
cmd = 'ps -a -o pid,ppid | tail +2'
else:
cmd = 'ps -ax -o pid,ppid | tail -n+2'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
... | def _ppid():
'''
Return a dict of pid to ppid mappings
'''
ret = {}
if __grains__['kernel'] == 'SunOS':
cmd = 'ps -a -o pid,ppid | tail +2'
else:
cmd = 'ps -ax -o pid,ppid | tail -n+2'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
... | [
"Return",
"a",
"dict",
"of",
"pid",
"to",
"ppid",
"mappings"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L270-L283 | [
"def",
"_ppid",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"cmd",
"=",
"'ps -a -o pid,ppid | tail +2'",
"else",
":",
"cmd",
"=",
"'ps -ax -o pid,ppid | tail -n+2'",
"out",
"=",
"__salt__",
"[",
"'cmd.... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_bsd | Return netstat information for BSD flavors | salt/modules/network.py | def _netstat_bsd():
'''
Return netstat information for BSD flavors
'''
ret = []
if __grains__['kernel'] == 'NetBSD':
for addr_family in ('inet', 'inet6'):
cmd = 'netstat -f {0} -an | tail -n+3'.format(addr_family)
out = __salt__['cmd.run'](cmd, python_shell=True)
... | def _netstat_bsd():
'''
Return netstat information for BSD flavors
'''
ret = []
if __grains__['kernel'] == 'NetBSD':
for addr_family in ('inet', 'inet6'):
cmd = 'netstat -f {0} -an | tail -n+3'.format(addr_family)
out = __salt__['cmd.run'](cmd, python_shell=True)
... | [
"Return",
"netstat",
"information",
"for",
"BSD",
"flavors"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L286-L360 | [
"def",
"_netstat_bsd",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'NetBSD'",
":",
"for",
"addr_family",
"in",
"(",
"'inet'",
",",
"'inet6'",
")",
":",
"cmd",
"=",
"'netstat -f {0} -an | tail -n+3'",
".",
"format",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_sunos | Return netstat information for SunOS flavors | salt/modules/network.py | def _netstat_sunos():
'''
Return netstat information for SunOS flavors
'''
log.warning('User and program not (yet) supported on SunOS')
ret = []
for addr_family in ('inet', 'inet6'):
# Lookup TCP connections
cmd = 'netstat -f {0} -P tcp -an | tail +5'.format(addr_family)
... | def _netstat_sunos():
'''
Return netstat information for SunOS flavors
'''
log.warning('User and program not (yet) supported on SunOS')
ret = []
for addr_family in ('inet', 'inet6'):
# Lookup TCP connections
cmd = 'netstat -f {0} -P tcp -an | tail +5'.format(addr_family)
... | [
"Return",
"netstat",
"information",
"for",
"SunOS",
"flavors"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L363-L393 | [
"def",
"_netstat_sunos",
"(",
")",
":",
"log",
".",
"warning",
"(",
"'User and program not (yet) supported on SunOS'",
")",
"ret",
"=",
"[",
"]",
"for",
"addr_family",
"in",
"(",
"'inet'",
",",
"'inet6'",
")",
":",
"# Lookup TCP connections",
"cmd",
"=",
"'netst... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_aix | Return netstat information for SunOS flavors | salt/modules/network.py | def _netstat_aix():
'''
Return netstat information for SunOS flavors
'''
ret = []
## AIX 6.1 - 7.2, appears to ignore addr_family field contents
## for addr_family in ('inet', 'inet6'):
for addr_family in ('inet',):
# Lookup connections
cmd = 'netstat -n -a -f {0} | tail -n +... | def _netstat_aix():
'''
Return netstat information for SunOS flavors
'''
ret = []
## AIX 6.1 - 7.2, appears to ignore addr_family field contents
## for addr_family in ('inet', 'inet6'):
for addr_family in ('inet',):
# Lookup connections
cmd = 'netstat -n -a -f {0} | tail -n +... | [
"Return",
"netstat",
"information",
"for",
"SunOS",
"flavors"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L396-L440 | [
"def",
"_netstat_aix",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"## AIX 6.1 - 7.2, appears to ignore addr_family field contents",
"## for addr_family in ('inet', 'inet6'):",
"for",
"addr_family",
"in",
"(",
"'inet'",
",",
")",
":",
"# Lookup connections",
"cmd",
"=",
"'netsta... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _ip_route_linux | Return ip routing information for Linux distros
(netstat is deprecated and may not be available) | salt/modules/network.py | def _ip_route_linux():
'''
Return ip routing information for Linux distros
(netstat is deprecated and may not be available)
'''
# table main closest to old netstat inet output
ret = []
cmd = 'ip -4 route show table main'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in o... | def _ip_route_linux():
'''
Return ip routing information for Linux distros
(netstat is deprecated and may not be available)
'''
# table main closest to old netstat inet output
ret = []
cmd = 'ip -4 route show table main'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in o... | [
"Return",
"ip",
"routing",
"information",
"for",
"Linux",
"distros",
"(",
"netstat",
"is",
"deprecated",
"and",
"may",
"not",
"be",
"available",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L484-L577 | [
"def",
"_ip_route_linux",
"(",
")",
":",
"# table main closest to old netstat inet output",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'ip -4 route show table main'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"True",
")",
"for",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_route_freebsd | Return netstat routing information for FreeBSD and macOS | salt/modules/network.py | def _netstat_route_freebsd():
'''
Return netstat routing information for FreeBSD and macOS
'''
ret = []
cmd = 'netstat -f inet -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
if __grains__['os'] == 'FreeBSD... | def _netstat_route_freebsd():
'''
Return netstat routing information for FreeBSD and macOS
'''
ret = []
cmd = 'netstat -f inet -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
if __grains__['os'] == 'FreeBSD... | [
"Return",
"netstat",
"routing",
"information",
"for",
"FreeBSD",
"and",
"macOS"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L580-L616 | [
"def",
"_netstat_route_freebsd",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'netstat -f inet -rn | tail -n+5'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"True",
")",
"for",
"line",
"in",
"out",
".",
"split... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_route_netbsd | Return netstat routing information for NetBSD | salt/modules/network.py | def _netstat_route_netbsd():
'''
Return netstat routing information for NetBSD
'''
ret = []
cmd = 'netstat -f inet -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'in... | def _netstat_route_netbsd():
'''
Return netstat routing information for NetBSD
'''
ret = []
cmd = 'netstat -f inet -rn | tail -n+5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'in... | [
"Return",
"netstat",
"routing",
"information",
"for",
"NetBSD"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L619-L646 | [
"def",
"_netstat_route_netbsd",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'netstat -f inet -rn | tail -n+5'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"True",
")",
"for",
"line",
"in",
"out",
".",
"splitl... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _netstat_route_sunos | Return netstat routing information for SunOS | salt/modules/network.py | def _netstat_route_sunos():
'''
Return netstat routing information for SunOS
'''
ret = []
cmd = 'netstat -f inet -rn | tail +5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'inet',... | def _netstat_route_sunos():
'''
Return netstat routing information for SunOS
'''
ret = []
cmd = 'netstat -f inet -rn | tail +5'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
'addr_family': 'inet',... | [
"Return",
"netstat",
"routing",
"information",
"for",
"SunOS"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L679-L706 | [
"def",
"_netstat_route_sunos",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"'netstat -f inet -rn | tail +5'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"True",
")",
"for",
"line",
"in",
"out",
".",
"splitline... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | netstat | Return information on open ports and states
.. note::
On BSD minions, the output contains PID info (where available) for each
netstat entry, fetched from sockstat/fstat output.
.. versionchanged:: 2014.1.4
Added support for OpenBSD, FreeBSD, and NetBSD
.. versionchanged:: 2015.8.0... | salt/modules/network.py | def netstat():
'''
Return information on open ports and states
.. note::
On BSD minions, the output contains PID info (where available) for each
netstat entry, fetched from sockstat/fstat output.
.. versionchanged:: 2014.1.4
Added support for OpenBSD, FreeBSD, and NetBSD
.... | def netstat():
'''
Return information on open ports and states
.. note::
On BSD minions, the output contains PID info (where available) for each
netstat entry, fetched from sockstat/fstat output.
.. versionchanged:: 2014.1.4
Added support for OpenBSD, FreeBSD, and NetBSD
.... | [
"Return",
"information",
"on",
"open",
"ports",
"and",
"states"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L739-L773 | [
"def",
"netstat",
"(",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'Linux'",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'netstat'",
")",
":",
"return",
"_ss_linux",
"(",
")",
"else",
":",
"return",
"_netst... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | active_tcp | Return a dict containing information on all of the running TCP connections (currently linux and solaris only)
.. versionchanged:: 2015.8.4
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.active_tcp | salt/modules/network.py | def active_tcp():
'''
Return a dict containing information on all of the running TCP connections (currently linux and solaris only)
.. versionchanged:: 2015.8.4
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.active_tcp
'''
if __grains__['kerne... | def active_tcp():
'''
Return a dict containing information on all of the running TCP connections (currently linux and solaris only)
.. versionchanged:: 2015.8.4
Added support for SunOS
CLI Example:
.. code-block:: bash
salt '*' network.active_tcp
'''
if __grains__['kerne... | [
"Return",
"a",
"dict",
"containing",
"information",
"on",
"all",
"of",
"the",
"running",
"TCP",
"connections",
"(",
"currently",
"linux",
"and",
"solaris",
"only",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L776-L823 | [
"def",
"active_tcp",
"(",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'Linux'",
":",
"return",
"salt",
".",
"utils",
".",
"network",
".",
"active_tcp",
"(",
")",
"elif",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"# lets use... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | traceroute | Performs a traceroute to a 3rd party host
.. versionchanged:: 2015.8.0
Added support for SunOS
.. versionchanged:: 2016.11.4
Added support for AIX
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org | salt/modules/network.py | def traceroute(host):
'''
Performs a traceroute to a 3rd party host
.. versionchanged:: 2015.8.0
Added support for SunOS
.. versionchanged:: 2016.11.4
Added support for AIX
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org
'''
ret = ... | def traceroute(host):
'''
Performs a traceroute to a 3rd party host
.. versionchanged:: 2015.8.0
Added support for SunOS
.. versionchanged:: 2016.11.4
Added support for AIX
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org
'''
ret = ... | [
"Performs",
"a",
"traceroute",
"to",
"a",
"3rd",
"party",
"host"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L826-L956 | [
"def",
"traceroute",
"(",
"host",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'traceroute'",
")",
":",
"log",
".",
"info",
"(",
"'This minion does not have traceroute installed'",
")",
"return",
"ret"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | dig | Performs a DNS lookup with dig
CLI Example:
.. code-block:: bash
salt '*' network.dig archlinux.org | salt/modules/network.py | def dig(host):
'''
Performs a DNS lookup with dig
CLI Example:
.. code-block:: bash
salt '*' network.dig archlinux.org
'''
cmd = 'dig {0}'.format(salt.utils.network.sanitize_host(host))
return __salt__['cmd.run'](cmd) | def dig(host):
'''
Performs a DNS lookup with dig
CLI Example:
.. code-block:: bash
salt '*' network.dig archlinux.org
'''
cmd = 'dig {0}'.format(salt.utils.network.sanitize_host(host))
return __salt__['cmd.run'](cmd) | [
"Performs",
"a",
"DNS",
"lookup",
"with",
"dig"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L960-L971 | [
"def",
"dig",
"(",
"host",
")",
":",
"cmd",
"=",
"'dig {0}'",
".",
"format",
"(",
"salt",
".",
"utils",
".",
"network",
".",
"sanitize_host",
"(",
"host",
")",
")",
"return",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.