repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/lxc.py | state | python | def state(name, path=None):
'''
Returns the state of a container.
path
path to the container parent directory (default: /var/lib/lxc)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.state name
'''
# Don't use _ensure_exists() here, it wi... | Returns the state of a container.
path
path to the container parent directory (default: /var/lib/lxc)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.state name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2632-L2674 | [
"def exists(name, path=None):\n '''\n Returns whether the named container exists.\n\n path\n path to the container parent directory (default: /var/lib/lxc)\n\n .. versionadded:: 2015.8.0\n\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' lxc.exists name\n '''\n\n _exi... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | get_parameter | python | def get_parameter(name, parameter, path=None):
'''
Returns the value of a cgroup parameter for a container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.get_par... | Returns the value of a cgroup parameter for a container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.get_parameter container_name memory.limit_in_bytes | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2677-L2703 | [
"def _ensure_exists(name, path=None):\n '''\n Raise an exception if the container does not exist\n '''\n if not exists(name, path=path):\n raise CommandExecutionError(\n 'Container \\'{0}\\' does not exist'.format(name)\n )\n"
] | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | set_parameter | python | def set_parameter(name, parameter, value, path=None):
'''
Set the value of a cgroup parameter for a container.
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.set... | Set the value of a cgroup parameter for a container.
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.set_parameter name parameter value | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2706-L2733 | [
"def exists(name, path=None):\n '''\n Returns whether the named container exists.\n\n path\n path to the container parent directory (default: /var/lib/lxc)\n\n .. versionadded:: 2015.8.0\n\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' lxc.exists name\n '''\n\n _exi... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | info | python | def info(name, path=None):
'''
Returns information about a container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.info name
'''
cachekey = 'lxc.info.{0... | Returns information about a container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.info name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2736-L2879 | [
"def state(name, path=None):\n '''\n Returns the state of a container.\n\n path\n path to the container parent directory (default: /var/lib/lxc)\n\n .. versionadded:: 2015.8.0\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' lxc.state name\n '''\n # Don't use _ensure_... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | set_password | python | def set_password(name, users, password, encrypted=True, path=None):
'''
.. versionchanged:: 2015.5.0
Function renamed from ``set_pass`` to ``set_password``. Additionally,
this function now supports (and defaults to using) a password hash
instead of a plaintext password.
Set the pass... | .. versionchanged:: 2015.5.0
Function renamed from ``set_pass`` to ``set_password``. Additionally,
this function now supports (and defaults to using) a password hash
instead of a plaintext password.
Set the password of one or more system users inside containers
users
Comma-sep... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2882-L2945 | [
"def retcode(name,\n cmd,\n no_start=False,\n preserve_state=True,\n stdin=None,\n python_shell=True,\n output_loglevel='debug',\n use_vt=False,\n path=None,\n ignore_retcode=False,... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | update_lxc_conf | python | def update_lxc_conf(name, lxc_conf, lxc_conf_unset, path=None):
'''
Edit LXC configuration options
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt myminion lxc.update_lxc_c... | Edit LXC configuration options
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt myminion lxc.update_lxc_conf ubuntu \\
lxc_conf="[{'network.ipv4.ip':'10.0.3.5'}]" \\... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2951-L3051 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | set_dns | python | def set_dns(name, dnsservers=None, searchdomains=None, path=None):
'''
.. versionchanged:: 2015.5.0
The ``dnsservers`` and ``searchdomains`` parameters can now be passed
as a comma-separated list.
Update /etc/resolv.confo
path
path to the container parent
default: /var... | .. versionchanged:: 2015.5.0
The ``dnsservers`` and ``searchdomains`` parameters can now be passed
as a comma-separated list.
Update /etc/resolv.confo
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3054-L3147 | [
"def run_all(name,\n cmd,\n no_start=False,\n preserve_state=True,\n stdin=None,\n python_shell=True,\n output_loglevel='debug',\n use_vt=False,\n path=None,\n ignore_retcode=False,\n chroot_fallback=False,... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | running_systemd | python | def running_systemd(name, cache=True, path=None):
'''
Determine if systemD is running
path
path to the container parent
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.running_systemd ubuntu
'''
k = 'lxc.systemd.test.{0}{1}'.format(name... | Determine if systemD is running
path
path to the container parent
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt '*' lxc.running_systemd ubuntu | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3150-L3224 | [
"def run_all(name,\n cmd,\n no_start=False,\n preserve_state=True,\n stdin=None,\n python_shell=True,\n output_loglevel='debug',\n use_vt=False,\n path=None,\n ignore_retcode=False,\n chroot_fallback=False,... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | systemd_running_state | python | def systemd_running_state(name, path=None):
'''
Get the operational state of a systemd based container
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt myminion lxc.systemd_... | Get the operational state of a systemd based container
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt myminion lxc.systemd_running_state ubuntu | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3227-L3251 | [
"def run_all(name,\n cmd,\n no_start=False,\n preserve_state=True,\n stdin=None,\n python_shell=True,\n output_loglevel='debug',\n use_vt=False,\n path=None,\n ignore_retcode=False,\n chroot_fallback=False,... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | wait_started | python | def wait_started(name, path=None, timeout=300):
'''
Check that the system has fully inited
This is actually very important for systemD based containers
see https://github.com/saltstack/salt/issues/23847
path
path to the container parent
default: /var/lib/lxc (system default)
... | Check that the system has fully inited
This is actually very important for systemD based containers
see https://github.com/saltstack/salt/issues/23847
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. cod... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3311-L3359 | [
"def state(name, path=None):\n '''\n Returns the state of a container.\n\n path\n path to the container parent directory (default: /var/lib/lxc)\n\n .. versionadded:: 2015.8.0\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' lxc.state name\n '''\n # Don't use _ensure_... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | attachable | python | def attachable(name, path=None):
'''
Return True if the named container can be attached to via the lxc-attach
command
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt 'm... | Return True if the named container can be attached to via the lxc-attach
command
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt 'minion' lxc.attachable ubuntu | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3586-L3620 | [
"def _ensure_exists(name, path=None):\n '''\n Raise an exception if the container does not exist\n '''\n if not exists(name, path=path):\n raise CommandExecutionError(\n 'Container \\'{0}\\' does not exist'.format(name)\n )\n"
] | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | _run | python | def _run(name,
cmd,
output=None,
no_start=False,
preserve_state=True,
stdin=None,
python_shell=True,
output_loglevel='debug',
use_vt=False,
path=None,
ignore_retcode=False,
chroot_fallback=None,
keep_env='http_pr... | Common logic for lxc.run functions
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3623-L3691 | [
"def stop(name, kill=False, path=None, use_vt=None):\n '''\n Stop the named container\n\n path\n path to the container parent directory\n default: /var/lib/lxc (system)\n\n .. versionadded:: 2015.8.0\n\n kill: False\n Do not wait for the container to stop, kill all tasks in t... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | run | python | def run(name,
cmd,
no_start=False,
preserve_state=True,
stdin=None,
python_shell=True,
output_loglevel='debug',
use_vt=False,
path=None,
ignore_retcode=False,
chroot_fallback=False,
keep_env='http_proxy,https_proxy,no_proxy'):
'... | .. versionadded:: 2015.8.0
Run :mod:`cmd.run <salt.modules.cmdmod.run>` within a container
.. warning::
Many shell builtins do not work, failing with stderr similar to the
following:
.. code-block:: bash
lxc_container: No such file or directory - failed to exec 'command'... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3694-L3780 | [
"def _run(name,\n cmd,\n output=None,\n no_start=False,\n preserve_state=True,\n stdin=None,\n python_shell=True,\n output_loglevel='debug',\n use_vt=False,\n path=None,\n ignore_retcode=False,\n chroot_fallback=None,\n ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | _get_md5 | python | def _get_md5(name, path):
'''
Get the MD5 checksum of a file from a container
'''
output = run_stdout(name, 'md5sum "{0}"'.format(path),
chroot_fallback=True,
ignore_retcode=True)
try:
return output.split()[0]
except IndexError:
# D... | Get the MD5 checksum of a file from a container | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4141-L4152 | null | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | copy_to | python | def copy_to(name, source, dest, overwrite=False, makedirs=False, path=None):
'''
.. versionchanged:: 2015.8.0
Function renamed from ``lxc.cp`` to ``lxc.copy_to`` for consistency
with other container types. ``lxc.cp`` will continue to work, however.
For versions 2015.2.x and earlier, use ... | .. versionchanged:: 2015.8.0
Function renamed from ``lxc.cp`` to ``lxc.copy_to`` for consistency
with other container types. ``lxc.cp`` will continue to work, however.
For versions 2015.2.x and earlier, use ``lxc.cp``.
Copy a file or directory from the host into a container
name
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4155-L4212 | [
"def _ensure_running(name, no_start=False, path=None):\n '''\n If the container is not currently running, start it. This function returns\n the state that the container was in before changing\n\n path\n path to the container parent directory\n default: /var/lib/lxc (system)\n\n .. v... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | read_conf | python | def read_conf(conf_file, out_format='simple'):
'''
Read in an LXC configuration file. By default returns a simple, unsorted
dict, but can also return a more detailed structure including blank lines
and comments.
out_format:
set to 'simple' if you need the old and unsupported behavior.
... | Read in an LXC configuration file. By default returns a simple, unsorted
dict, but can also return a more detailed structure including blank lines
and comments.
out_format:
set to 'simple' if you need the old and unsupported behavior.
This won't support the multiple lxc values (eg: multiple... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4218-L4259 | [
"def decode(data, encoding=None, errors='strict', keep=False,\n normalize=False, preserve_dict_class=False, preserve_tuples=False,\n to_str=False):\n '''\n Generic function which will decode whichever type is passed, if necessary.\n Optionally use to_str=True to ensure strings are str t... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | write_conf | python | def write_conf(conf_file, conf):
'''
Write out an LXC configuration file
This is normally only used internally. The format of the data structure
must match that which is returned from ``lxc.read_conf()``, with
``out_format`` set to ``commented``.
An example might look like:
.. code-block:... | Write out an LXC configuration file
This is normally only used internally. The format of the data structure
must match that which is returned from ``lxc.read_conf()``, with
``out_format`` set to ``commented``.
An example might look like:
.. code-block:: python
[
{'lxc.utsname... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4262-L4323 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | edit_conf | python | def edit_conf(conf_file,
out_format='simple',
read_only=False,
lxc_config=None,
**kwargs):
'''
Edit an LXC configuration file. If a setting is already present inside the
file, its value will be replaced. If it does not exist, it will be appended
to... | Edit an LXC configuration file. If a setting is already present inside the
file, its value will be replaced. If it does not exist, it will be appended
to the end of the file. Comments and blank lines will be kept in-tact if
they already exist in the file.
out_format:
Set to simple if you need b... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4326-L4436 | [
"def _config_list(conf_tuples=None, only_net=False, **kwargs):\n '''\n Return a list of dicts from the salt level configurations\n\n conf_tuples\n _LXCConfig compatible list of entries which can contain\n\n - string line\n - tuple (lxc config param,value)\n - dict of... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | reboot | python | def reboot(name, path=None):
'''
Reboot a container.
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Examples:
.. code-block:: bash
salt 'minion' lxc.reboot myvm
'''
ret = {'result': True,
... | Reboot a container.
path
path to the container parent
default: /var/lib/lxc (system default)
.. versionadded:: 2015.8.0
CLI Examples:
.. code-block:: bash
salt 'minion' lxc.reboot myvm | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4439-L4476 | [
"def start(name, **kwargs):\n '''\n Start the named container\n\n path\n path to the container parent directory\n default: /var/lib/lxc (system)\n\n .. versionadded:: 2015.8.0\n\n lxc_config\n path to a lxc config file\n config file will be guessed from container name ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | reconfigure | python | def reconfigure(name,
cpu=None,
cpuset=None,
cpushare=None,
memory=None,
profile=None,
network_profile=None,
nic_opts=None,
bridge=None,
gateway=None,
autostart... | Reconfigure a container.
This only applies to a few property
name
Name of the container.
utsname
utsname of the container.
.. versionadded:: 2016.3.0
rootfs
rootfs of the container.
.. versionadded:: 2016.3.0
cpu
Select a random number of cpu cor... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4479-L4608 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def state(name, path=None):\n '''\n Returns the state of a container.\n\n path\n path to the container parent directory (default: /var/lib/lxc)\n\n .. versionadded:: 2015.8.0\n\n CLI Example:\n\n .. code-block:: bash\n\n ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | apply_network_profile | python | def apply_network_profile(name, network_profile, nic_opts=None, path=None):
'''
.. versionadded:: 2015.5.0
Apply a network profile to a container
network_profile
profile name or default values (dict)
nic_opts
values to override in defaults (dict)
indexed by nic card names
... | .. versionadded:: 2015.5.0
Apply a network profile to a container
network_profile
profile name or default values (dict)
nic_opts
values to override in defaults (dict)
indexed by nic card names
path
path to the container parent
.. versionadded:: 2015.8.0
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4611-L4678 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | get_pid | python | def get_pid(name, path=None):
'''
Returns a container pid.
Throw an exception if the container isn't running.
CLI Example:
.. code-block:: bash
salt '*' lxc.get_pid name
'''
if name not in list_(limit='running', path=path):
raise CommandExecutionError('Container {0} is not... | Returns a container pid.
Throw an exception if the container isn't running.
CLI Example:
.. code-block:: bash
salt '*' lxc.get_pid name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4681-L4696 | [
"def list_(extra=False, limit=None, path=None):\n '''\n List containers classified by state\n\n extra\n Also get per-container specific info. This will change the return data.\n Instead of returning a list of containers, a dictionary of containers\n and each container's output from :mo... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | add_veth | python | def add_veth(name, interface_name, bridge=None, path=None):
'''
Add a veth to a container.
Note : this function doesn't update the container config, just add the interface at runtime
name
Name of the container
interface_name
Name of the interface in the container
bridge
... | Add a veth to a container.
Note : this function doesn't update the container config, just add the interface at runtime
name
Name of the container
interface_name
Name of the interface in the container
bridge
Name of the bridge to attach the interface to (facultative)
CLI E... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4699-L4778 | [
"def get_pid(name, path=None):\n '''\n Returns a container pid.\n Throw an exception if the container isn't running.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' lxc.get_pid name\n '''\n if name not in list_(limit='running', path=path):\n raise CommandExecutionError('Con... | # -*- coding: utf-8 -*-
'''
Control Linux Containers via Salt
:depends: lxc package for distribution
lxc >= 1.0 (even beta alpha) is required
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import copy
import string
import textwrap
import difflib
imp... |
saltstack/salt | salt/modules/lxc.py | _LXCConfig._filter_data | python | def _filter_data(self, pattern):
'''
Removes parameters which match the pattern from the config data
'''
removed = []
filtered = []
for param in self.data:
if not param[0].startswith(pattern):
filtered.append(param)
else:
... | Removes parameters which match the pattern from the config data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L1055-L1067 | null | class _LXCConfig(object):
'''
LXC configuration data
'''
pattern = re.compile(r'^(\S+)(\s*)(=)(\s*)(.*)')
non_interpretable_pattern = re.compile(r'^((#.*)|(\s*))$')
def __init__(self, **kwargs):
kwargs = copy.deepcopy(kwargs)
self.name = kwargs.pop('name', None)
path = g... |
saltstack/salt | salt/engines/script.py | _get_serializer | python | def _get_serializer(output):
'''
Helper to return known serializer based on
pass output argument
'''
serializers = salt.loader.serializers(__opts__)
try:
return getattr(serializers, output)
except AttributeError:
raise CommandExecutionError(
"Unknown serializer '{... | Helper to return known serializer based on
pass output argument | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/script.py#L51-L62 | null | # -*- coding: utf-8 -*-
'''
Send events based on a script's stdout
.. versionadded:: Neon
Example Config
.. code-block:: yaml
engines:
- script:
cmd: /some/script.py -a 1 -b 2
output: json
interval: 5
Script engine configs:
cmd: Script or command to execute
output: ... |
saltstack/salt | salt/engines/script.py | start | python | def start(cmd, output='json', interval=1):
'''
Parse stdout of a command and generate an event
The script engine will scrap stdout of the
given script and generate an event based on the
presence of the 'tag' key and it's value.
If there is a data obj available, that will also
be fired alon... | Parse stdout of a command and generate an event
The script engine will scrap stdout of the
given script and generate an event based on the
presence of the 'tag' key and it's value.
If there is a data obj available, that will also
be fired along with the tag.
Example:
Given the follow... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/script.py#L65-L141 | [
"def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):\n '''\n Return an event object suitable for the named transport\n '''\n # TODO: AIO core is separate from transport\n if opts['transport'] in ('zeromq', 'tcp', 'detect'):\n return MasterEvent... | # -*- coding: utf-8 -*-
'''
Send events based on a script's stdout
.. versionadded:: Neon
Example Config
.. code-block:: yaml
engines:
- script:
cmd: /some/script.py -a 1 -b 2
output: json
interval: 5
Script engine configs:
cmd: Script or command to execute
output: ... |
saltstack/salt | salt/modules/bluez_bluetooth.py | version | python | def version():
'''
Return Bluez version from bluetoothd -v
CLI Example:
.. code-block:: bash
salt '*' bluetoothd.version
'''
cmd = 'bluetoothctl -v'
out = __salt__['cmd.run'](cmd).splitlines()
bluez_version = out[0]
pybluez_version = '<= 0.18 (Unknown, but installed)'
... | Return Bluez version from bluetoothd -v
CLI Example:
.. code-block:: bash
salt '*' bluetoothd.version | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L48-L66 | null | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | address_ | python | def address_():
'''
Get the many addresses of the Bluetooth adapter
CLI Example:
.. code-block:: bash
salt '*' bluetooth.address
'''
ret = {}
cmd = 'hciconfig'
out = __salt__['cmd.run'](cmd).splitlines()
dev = ''
for line in out:
if line.startswith('hci'):
... | Get the many addresses of the Bluetooth adapter
CLI Example:
.. code-block:: bash
salt '*' bluetooth.address | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L69-L98 | null | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | power | python | def power(dev, mode):
'''
Power a bluetooth device on or off
CLI Examples:
.. code-block:: bash
salt '*' bluetooth.power hci0 on
salt '*' bluetooth.power hci0 off
'''
if dev not in address_():
raise CommandExecutionError('Invalid dev passed to bluetooth.power')
if... | Power a bluetooth device on or off
CLI Examples:
.. code-block:: bash
salt '*' bluetooth.power hci0 on
salt '*' bluetooth.power hci0 off | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L101-L126 | [
"def address_():\n '''\n Get the many addresses of the Bluetooth adapter\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' bluetooth.address\n '''\n ret = {}\n cmd = 'hciconfig'\n out = __salt__['cmd.run'](cmd).splitlines()\n dev = ''\n for line in out:\n if line.sta... | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | discoverable | python | def discoverable(dev):
'''
Enable this bluetooth device to be discoverable.
CLI Example:
.. code-block:: bash
salt '*' bluetooth.discoverable hci0
'''
if dev not in address_():
raise CommandExecutionError(
'Invalid dev passed to bluetooth.discoverable'
)
... | Enable this bluetooth device to be discoverable.
CLI Example:
.. code-block:: bash
salt '*' bluetooth.discoverable hci0 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L129-L150 | [
"def address_():\n '''\n Get the many addresses of the Bluetooth adapter\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' bluetooth.address\n '''\n ret = {}\n cmd = 'hciconfig'\n out = __salt__['cmd.run'](cmd).splitlines()\n dev = ''\n for line in out:\n if line.sta... | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | scan | python | def scan():
'''
Scan for bluetooth devices in the area
CLI Example:
.. code-block:: bash
salt '*' bluetooth.scan
'''
ret = []
devices = bluetooth.discover_devices(lookup_names=True)
for device in devices:
ret.append({device[0]: device[1]})
return ret | Scan for bluetooth devices in the area
CLI Example:
.. code-block:: bash
salt '*' bluetooth.scan | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L175-L189 | null | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | block | python | def block(bdaddr):
'''
Block a specific bluetooth device by BD Address
CLI Example:
.. code-block:: bash
salt '*' bluetooth.block DE:AD:BE:EF:CA:FE
'''
if not salt.utils.validate.net.mac(bdaddr):
raise CommandExecutionError(
'Invalid BD address passed to bluetooth.... | Block a specific bluetooth device by BD Address
CLI Example:
.. code-block:: bash
salt '*' bluetooth.block DE:AD:BE:EF:CA:FE | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L192-L208 | [
"def mac(addr):\n '''\n Validates a mac address\n '''\n valid = re.compile(r'''\n (^([0-9A-F]{1,2}[-]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[:]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[.]){5}([0-9A-F]{1,2})$)\n ''',\n ... | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | pair | python | def pair(address, key):
'''
Pair the bluetooth adapter with a device
CLI Example:
.. code-block:: bash
salt '*' bluetooth.pair DE:AD:BE:EF:CA:FE 1234
Where DE:AD:BE:EF:CA:FE is the address of the device to pair with, and 1234
is the passphrase.
TODO: This function is currently b... | Pair the bluetooth adapter with a device
CLI Example:
.. code-block:: bash
salt '*' bluetooth.pair DE:AD:BE:EF:CA:FE 1234
Where DE:AD:BE:EF:CA:FE is the address of the device to pair with, and 1234
is the passphrase.
TODO: This function is currently broken, as the bluez-simple-agent pro... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L230-L263 | [
"def mac(addr):\n '''\n Validates a mac address\n '''\n valid = re.compile(r'''\n (^([0-9A-F]{1,2}[-]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[:]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[.]){5}([0-9A-F]{1,2})$)\n ''',\n ... | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/bluez_bluetooth.py | unpair | python | def unpair(address):
'''
Unpair the bluetooth adapter from a device
CLI Example:
.. code-block:: bash
salt '*' bluetooth.unpair DE:AD:BE:EF:CA:FE
Where DE:AD:BE:EF:CA:FE is the address of the device to unpair.
TODO: This function is currently broken, as the bluez-simple-agent progra... | Unpair the bluetooth adapter from a device
CLI Example:
.. code-block:: bash
salt '*' bluetooth.unpair DE:AD:BE:EF:CA:FE
Where DE:AD:BE:EF:CA:FE is the address of the device to unpair.
TODO: This function is currently broken, as the bluez-simple-agent program
no longer ships with BlueZ ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L266-L288 | [
"def mac(addr):\n '''\n Validates a mac address\n '''\n valid = re.compile(r'''\n (^([0-9A-F]{1,2}[-]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[:]){5}([0-9A-F]{1,2})$\n |^([0-9A-F]{1,2}[.]){5}([0-9A-F]{1,2})$)\n ''',\n ... | # -*- coding: utf-8 -*-
'''
Support for Bluetooth (using BlueZ in Linux).
The following packages are required packages for this module:
bluez >= 5.7
bluez-libs >= 5.7
bluez-utils >= 5.7
pybluez >= 0.18
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party lib... |
saltstack/salt | salt/modules/msteams.py | post_card | python | def post_card(message,
hook_url=None,
title=None,
theme_color=None):
'''
Send a message to an MS Teams channel.
:param message: The message to send to the MS Teams channel.
:param hook_url: The Teams webhook URL, if not specified in the configuration.
... | Send a message to an MS Teams channel.
:param message: The message to send to the MS Teams channel.
:param hook_url: The Teams webhook URL, if not specified in the configuration.
:param title: Optional title for the posted card
:param theme_color: Optional hex color highlight for the poste... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/msteams.py#L54-L96 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Module for sending messages to MS Teams
.. versionadded:: 2017.7.0
:configuration: This module can be used by either passing a hook_url
directly or by specifying it in a configuration profile in the salt
master/minion config. For example:
.. code-block:: yaml
msteams:
h... |
saltstack/salt | salt/beacons/ps.py | beacon | python | def beacon(config):
'''
Scan for processes and fire events
Example Config
.. code-block:: yaml
beacons:
ps:
- processes:
salt-master: running
mysql: stopped
The config above sets up beacons to check that
processes are running or s... | Scan for processes and fire events
Example Config
.. code-block:: yaml
beacons:
ps:
- processes:
salt-master: running
mysql: stopped
The config above sets up beacons to check that
processes are running or stopped. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/ps.py#L53-L94 | null | # -*- coding: utf-8 -*-
'''
Send events covering process status
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals
import logging
# Import third party libs
# pylint: disable=import-error
try:
import salt.utils.psutil_compat as psutil
HAS_PSUTIL = True
except ImportError:
HAS... |
saltstack/salt | salt/cloud/clouds/vagrant.py | list_nodes_full | python | def list_nodes_full(call=None):
'''
List the nodes, ask all 'vagrant' minions, return dict of grains (enhanced).
CLI Example:
.. code-block:: bash
salt-call -F
'''
ret = _list_nodes(call)
for key, grains in ret.items(): # clean up some hyperverbose grains -- everything is too mu... | List the nodes, ask all 'vagrant' minions, return dict of grains (enhanced).
CLI Example:
.. code-block:: bash
salt-call -F | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vagrant.py#L125-L148 | [
"def _list_nodes(call=None):\n '''\n List the nodes, ask all 'vagrant' minions, return dict of grains.\n '''\n local = salt.client.LocalClient()\n ret = local.cmd('salt-cloud:driver:vagrant', 'grains.items', '', tgt_type='grain')\n return ret\n",
"def _build_required_items(nodes):\n ret = {}\... | # -*- coding: utf-8 -*-
'''
Vagrant Cloud Driver
====================
The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.
Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagran... |
saltstack/salt | salt/cloud/clouds/vagrant.py | _list_nodes | python | def _list_nodes(call=None):
'''
List the nodes, ask all 'vagrant' minions, return dict of grains.
'''
local = salt.client.LocalClient()
ret = local.cmd('salt-cloud:driver:vagrant', 'grains.items', '', tgt_type='grain')
return ret | List the nodes, ask all 'vagrant' minions, return dict of grains. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vagrant.py#L151-L157 | [
"def cmd(self,\n tgt,\n fun,\n arg=(),\n timeout=None,\n tgt_type='glob',\n ret='',\n jid='',\n full_return=False,\n kwarg=None,\n **kwargs):\n '''\n Synchronously execute a command on targeted minions\n\n The cmd method will execute and... | # -*- coding: utf-8 -*-
'''
Vagrant Cloud Driver
====================
The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.
Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagran... |
saltstack/salt | salt/cloud/clouds/vagrant.py | create | python | def create(vm_):
'''
Provision a single machine
CLI Example:
.. code-block:: bash
salt-cloud -p my_profile new_node_1
'''
name = vm_['name']
machine = config.get_cloud_config_value(
'machine', vm_, __opts__, default='')
vm_['machine'] = machine
host = config.get_c... | Provision a single machine
CLI Example:
.. code-block:: bash
salt-cloud -p my_profile new_node_1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vagrant.py#L186-L248 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
Vagrant Cloud Driver
====================
The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.
Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagran... |
saltstack/salt | salt/cloud/clouds/vagrant.py | destroy | python | def destroy(name, call=None):
'''
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a, or --action.'
... | Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vagrant.py#L264-L316 | [
"def _get_my_info(name):\n local = salt.client.LocalClient()\n return local.cmd(name, 'grains.get', ['salt-cloud'])\n",
"def cmd(self,\n tgt,\n fun,\n arg=(),\n timeout=None,\n tgt_type='glob',\n ret='',\n jid='',\n full_return=False,\n kwarg=No... | # -*- coding: utf-8 -*-
'''
Vagrant Cloud Driver
====================
The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.
Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagran... |
saltstack/salt | salt/cloud/clouds/vagrant.py | reboot | python | def reboot(name, call=None):
'''
Reboot a vagrant minion.
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot vm_name
'''
if call != 'action':
raise SaltCloudException(
'The reboot action must be called with -a or ... | Reboot a vagrant minion.
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot vm_name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vagrant.py#L320-L342 | [
"def _get_my_info(name):\n local = salt.client.LocalClient()\n return local.cmd(name, 'grains.get', ['salt-cloud'])\n",
"def cmd(self,\n tgt,\n fun,\n arg=(),\n timeout=None,\n tgt_type='glob',\n ret='',\n jid='',\n full_return=False,\n kwarg=No... | # -*- coding: utf-8 -*-
'''
Vagrant Cloud Driver
====================
The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.
Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagran... |
saltstack/salt | salt/utils/pkg/__init__.py | clear_rtag | python | def clear_rtag(opts):
'''
Remove the rtag file
'''
try:
os.remove(rtag(opts))
except OSError as exc:
if exc.errno != errno.ENOENT:
# Using __str__() here to get the fully-formatted error message
# (error number, error message, path)
log.warning('En... | Remove the rtag file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pkg/__init__.py#L28-L38 | [
"def rtag(opts):\n '''\n Return the rtag file location. This file is used to ensure that we don't\n refresh more than once (unless explicitly configured to do so).\n '''\n return os.path.join(opts['cachedir'], 'pkg_refresh')\n"
] | # -*- coding: utf-8 -*-
'''
Common functions for managing package refreshes during states
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import os
import re
# Import Salt libs
import salt.utils.data
import salt.utils.files
import salt.utils... |
saltstack/salt | salt/utils/pkg/__init__.py | write_rtag | python | def write_rtag(opts):
'''
Write the rtag file
'''
rtag_file = rtag(opts)
if not os.path.exists(rtag_file):
try:
with salt.utils.files.fopen(rtag_file, 'w+'):
pass
except OSError as exc:
log.warning('Encountered error writing rtag: %s', exc.__st... | Write the rtag file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pkg/__init__.py#L41-L51 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Common functions for managing package refreshes during states
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import os
import re
# Import Salt libs
import salt.utils.data
import salt.utils.files
import salt.utils... |
saltstack/salt | salt/utils/pkg/__init__.py | check_refresh | python | def check_refresh(opts, refresh=None):
'''
Check whether or not a refresh is necessary
Returns:
- True if refresh evaluates as True
- False if refresh is False
- A boolean if refresh is not False and the rtag file exists
'''
return bool(
salt.utils.data.is_true(refresh) or
... | Check whether or not a refresh is necessary
Returns:
- True if refresh evaluates as True
- False if refresh is False
- A boolean if refresh is not False and the rtag file exists | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pkg/__init__.py#L54-L67 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Common functions for managing package refreshes during states
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import os
import re
# Import Salt libs
import salt.utils.data
import salt.utils.files
import salt.utils... |
saltstack/salt | salt/utils/pkg/__init__.py | match_version | python | def match_version(desired, available, cmp_func=None, ignore_epoch=False):
'''
Returns the first version of the list of available versions which matches
the desired version comparison expression, or None if no match is found.
'''
oper, version = split_comparison(desired)
if not oper:
oper... | Returns the first version of the list of available versions which matches
the desired version comparison expression, or None if no match is found. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pkg/__init__.py#L80-L95 | [
"def split_comparison(version):\n match = re.match(r'^(<=>|!=|>=|<=|>>|<<|<>|>|<|=)?\\s?([^<>=]+)$', version)\n if match:\n comparison = match.group(1) or ''\n version = match.group(2)\n else:\n comparison = ''\n return comparison, version\n",
"def compare(ver1='', oper='==', ver2... | # -*- coding: utf-8 -*-
'''
Common functions for managing package refreshes during states
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import os
import re
# Import Salt libs
import salt.utils.data
import salt.utils.files
import salt.utils... |
saltstack/salt | salt/modules/swift.py | _auth | python | def _auth(profile=None):
'''
Set up openstack credentials
'''
if profile:
credentials = __salt__['config.option'](profile)
user = credentials['keystone.user']
password = credentials.get('keystone.password', None)
tenant = credentials['keystone.tenant']
auth_url = ... | Set up openstack credentials | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L71-L104 | null | # -*- coding: utf-8 -*-
'''
Module for handling OpenStack Swift calls
Author: Anthony Stanton <anthony.stanton@gmail.com>
Inspired by the S3 and Nova modules
:depends: - swiftclient Python module
:configuration: This module is not usable until the user, tenant, auth URL, and password or auth_key
are specified e... |
saltstack/salt | salt/modules/swift.py | delete | python | def delete(cont, path=None, profile=None):
'''
Delete a container, or delete an object from a container.
CLI Example to delete a container::
salt myminion swift.delete mycontainer
CLI Example to delete an object from a container::
salt myminion swift.delete mycontainer remoteobject
... | Delete a container, or delete an object from a container.
CLI Example to delete a container::
salt myminion swift.delete mycontainer
CLI Example to delete an object from a container::
salt myminion swift.delete mycontainer remoteobject | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L107-L124 | [
"def _auth(profile=None):\n '''\n Set up openstack credentials\n '''\n if profile:\n credentials = __salt__['config.option'](profile)\n user = credentials['keystone.user']\n password = credentials.get('keystone.password', None)\n tenant = credentials['keystone.tenant']\n ... | # -*- coding: utf-8 -*-
'''
Module for handling OpenStack Swift calls
Author: Anthony Stanton <anthony.stanton@gmail.com>
Inspired by the S3 and Nova modules
:depends: - swiftclient Python module
:configuration: This module is not usable until the user, tenant, auth URL, and password or auth_key
are specified e... |
saltstack/salt | salt/modules/swift.py | get | python | def get(cont=None, path=None, local_file=None, return_bin=False, profile=None):
'''
List the contents of a container, or return an object from a container. Set
return_bin to True in order to retrieve an object wholesale. Otherwise,
Salt will attempt to parse an XML response.
CLI Example to list con... | List the contents of a container, or return an object from a container. Set
return_bin to True in order to retrieve an object wholesale. Otherwise,
Salt will attempt to parse an XML response.
CLI Example to list containers:
.. code-block:: bash
salt myminion swift.get
CLI Example to list... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L127-L172 | [
"def _auth(profile=None):\n '''\n Set up openstack credentials\n '''\n if profile:\n credentials = __salt__['config.option'](profile)\n user = credentials['keystone.user']\n password = credentials.get('keystone.password', None)\n tenant = credentials['keystone.tenant']\n ... | # -*- coding: utf-8 -*-
'''
Module for handling OpenStack Swift calls
Author: Anthony Stanton <anthony.stanton@gmail.com>
Inspired by the S3 and Nova modules
:depends: - swiftclient Python module
:configuration: This module is not usable until the user, tenant, auth URL, and password or auth_key
are specified e... |
saltstack/salt | salt/modules/swift.py | put | python | def put(cont, path=None, local_file=None, profile=None):
'''
Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
... | Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
salt myminion swift.put mycontainer remotepath local_file=/pa... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L179-L202 | [
"def _auth(profile=None):\n '''\n Set up openstack credentials\n '''\n if profile:\n credentials = __salt__['config.option'](profile)\n user = credentials['keystone.user']\n password = credentials.get('keystone.password', None)\n tenant = credentials['keystone.tenant']\n ... | # -*- coding: utf-8 -*-
'''
Module for handling OpenStack Swift calls
Author: Anthony Stanton <anthony.stanton@gmail.com>
Inspired by the S3 and Nova modules
:depends: - swiftclient Python module
:configuration: This module is not usable until the user, tenant, auth URL, and password or auth_key
are specified e... |
saltstack/salt | salt/modules/mac_shadow.py | _get_account_policy | python | def _get_account_policy(name):
'''
Get the entire accountPolicy and return it as a dictionary. For use by this
module only
:param str name: The user name
:return: a dictionary containing all values for the accountPolicy
:rtype: dict
:raises: CommandExecutionError on user not found or any ... | Get the entire accountPolicy and return it as a dictionary. For use by this
module only
:param str name: The user name
:return: a dictionary containing all values for the accountPolicy
:rtype: dict
:raises: CommandExecutionError on user not found or any other unknown error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L45-L75 | [
"def execute_return_result(cmd):\n '''\n Executes the passed command. Returns the standard out if successful\n\n :param str cmd: The command to run\n\n :return: The standard out of the command if successful, otherwise returns\n an error\n :rtype: str\n\n :raises: Error if command fails or is no... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | _set_account_policy | python | def _set_account_policy(name, policy):
'''
Set a value in the user accountPolicy. For use by this module only
:param str name: The user name
:param str policy: The policy to apply
:return: True if success, otherwise False
:rtype: bool
:raises: CommandExecutionError on user not found or an... | Set a value in the user accountPolicy. For use by this module only
:param str name: The user name
:param str policy: The policy to apply
:return: True if success, otherwise False
:rtype: bool
:raises: CommandExecutionError on user not found or any other unknown error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L78-L97 | [
"def execute_return_success(cmd):\n '''\n Executes the passed command. Returns True if successful\n\n :param str cmd: The command to run\n\n :return: True if successful, otherwise False\n :rtype: bool\n\n :raises: Error if command fails or is not supported\n '''\n\n ret = _run_all(cmd)\n\n ... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | _get_account_policy_data_value | python | def _get_account_policy_data_value(name, key):
'''
Return the value for a key in the accountPolicy section of the user's plist
file. For use by this module only
:param str name: The username
:param str key: The accountPolicy key
:return: The value contained within the key
:rtype: str
... | Return the value for a key in the accountPolicy section of the user's plist
file. For use by this module only
:param str name: The username
:param str key: The accountPolicy key
:return: The value contained within the key
:rtype: str
:raises: CommandExecutionError on user not found or any oth... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L100-L121 | [
"def execute_return_result(cmd):\n '''\n Executes the passed command. Returns the standard out if successful\n\n :param str cmd: The command to run\n\n :return: The standard out of the command if successful, otherwise returns\n an error\n :rtype: str\n\n :raises: Error if command fails or is no... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | _convert_to_datetime | python | def _convert_to_datetime(unix_timestamp):
'''
Converts a unix timestamp to a human readable date/time
:param float unix_timestamp: A unix timestamp
:return: A date/time in the format YYYY-mm-dd HH:MM:SS
:rtype: str
'''
try:
unix_timestamp = float(unix_timestamp)
return date... | Converts a unix timestamp to a human readable date/time
:param float unix_timestamp: A unix timestamp
:return: A date/time in the format YYYY-mm-dd HH:MM:SS
:rtype: str | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L124-L137 | null | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | info | python | def info(name):
'''
Return information for the specified user
:param str name: The username
:return: A dictionary containing the user's shadow information
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' shadow.info admin
'''
try:
data = pwd.getpwnam(name)... | Return information for the specified user
:param str name: The username
:return: A dictionary containing the user's shadow information
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' shadow.info admin | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L140-L183 | [
"def get_change(name):\n '''\n Gets the date on which the password expires\n\n :param str name: The name of the user account\n\n :return: The date the password will expire\n :rtype: str\n\n :raises: CommandExecutionError on user not found or any other unknown error\n\n CLI Example:\n\n .. co... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | get_account_created | python | def get_account_created(name):
'''
Get the date/time the account was created
:param str name: The username of the account
:return: The date/time the account was created (yyyy-mm-dd hh:mm:ss)
:rtype: str
:raises: CommandExecutionError on user not found or any other unknown error
CLI Examp... | Get the date/time the account was created
:param str name: The username of the account
:return: The date/time the account was created (yyyy-mm-dd hh:mm:ss)
:rtype: str
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
salt... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L186-L209 | [
"def parse_return(data):\n '''\n Returns the data portion of a string that is colon separated.\n\n :param str data: The string that contains the data to be parsed. Usually the\n standard out from a command\n\n For example:\n ``Time Zone: America/Denver``\n will return:\n ``America/Denver``\n... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | get_login_failed_count | python | def get_login_failed_count(name):
'''
Get the the number of failed login attempts
:param str name: The username of the account
:return: The number of failed login attempts
:rtype: int
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-bl... | Get the the number of failed login attempts
:param str name: The username of the account
:return: The number of failed login attempts
:rtype: int
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
salt '*' shadow.get_login_... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L238-L257 | [
"def parse_return(data):\n '''\n Returns the data portion of a string that is colon separated.\n\n :param str data: The string that contains the data to be parsed. Usually the\n standard out from a command\n\n For example:\n ``Time Zone: America/Denver``\n will return:\n ``America/Denver``\n... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | set_maxdays | python | def set_maxdays(name, days):
'''
Set the maximum age of the password in days
:param str name: The username of the account
:param int days: The maximum age of the account in days
:return: True if successful, False if not
:rtype: bool
:raises: CommandExecutionError on user not found or any... | Set the maximum age of the password in days
:param str name: The username of the account
:param int days: The maximum age of the account in days
:return: True if successful, False if not
:rtype: bool
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L287-L311 | [
"def _set_account_policy(name, policy):\n '''\n Set a value in the user accountPolicy. For use by this module only\n\n :param str name: The user name\n :param str policy: The policy to apply\n\n :return: True if success, otherwise False\n :rtype: bool\n\n :raises: CommandExecutionError on user ... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | get_maxdays | python | def get_maxdays(name):
'''
Get the maximum age of the password
:param str name: The username of the account
:return: The maximum age of the password in days
:rtype: int
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
... | Get the maximum age of the password
:param str name: The username of the account
:return: The maximum age of the password in days
:rtype: int
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
salt '*' shadow.get_maxdays ad... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L314-L337 | [
"def _get_account_policy(name):\n '''\n Get the entire accountPolicy and return it as a dictionary. For use by this\n module only\n\n :param str name: The user name\n\n :return: a dictionary containing all values for the accountPolicy\n :rtype: dict\n\n :raises: CommandExecutionError on user no... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | set_change | python | def set_change(name, date):
'''
Sets the date on which the password expires. The user will be required to
change their password. Format is mm/dd/yyyy
:param str name: The name of the user account
:param date date: The date the password will expire. Must be in mm/dd/yyyy
format.
:retur... | Sets the date on which the password expires. The user will be required to
change their password. Format is mm/dd/yyyy
:param str name: The name of the user account
:param date date: The date the password will expire. Must be in mm/dd/yyyy
format.
:return: True if successful, otherwise False
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L402-L426 | [
"def get_change(name):\n '''\n Gets the date on which the password expires\n\n :param str name: The name of the user account\n\n :return: The date the password will expire\n :rtype: str\n\n :raises: CommandExecutionError on user not found or any other unknown error\n\n CLI Example:\n\n .. co... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | set_expire | python | def set_expire(name, date):
'''
Sets the date on which the account expires. The user will not be able to
login after this date. Date format is mm/dd/yyyy
:param str name: The name of the user account
:param datetime date: The date the account will expire. Format must be
mm/dd/yyyy.
:r... | Sets the date on which the account expires. The user will not be able to
login after this date. Date format is mm/dd/yyyy
:param str name: The name of the user account
:param datetime date: The date the account will expire. Format must be
mm/dd/yyyy.
:return: True if successful, False if not
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L454-L478 | [
"def _set_account_policy(name, policy):\n '''\n Set a value in the user accountPolicy. For use by this module only\n\n :param str name: The user name\n :param str policy: The policy to apply\n\n :return: True if success, otherwise False\n :rtype: bool\n\n :raises: CommandExecutionError on user ... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | del_password | python | def del_password(name):
'''
Deletes the account password
:param str name: The user name of the account
:return: True if successful, otherwise False
:rtype: bool
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
sal... | Deletes the account password
:param str name: The user name of the account
:return: True if successful, otherwise False
:rtype: bool
:raises: CommandExecutionError on user not found or any other unknown error
CLI Example:
.. code-block:: bash
salt '*' shadow.del_password username | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L506-L536 | [
"def info(name):\n '''\n Return information for the specified user\n\n :param str name: The username\n\n :return: A dictionary containing the user's shadow information\n :rtype: dict\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' shadow.info admin\n '''\n try:\n data... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/modules/mac_shadow.py | set_password | python | def set_password(name, password):
'''
Set the password for a named user (insecure, the password will be in the
process list while the command is running)
:param str name: The name of the local user, which is assumed to be in the
local directory service
:param str password: The plaintext pa... | Set the password for a named user (insecure, the password will be in the
process list while the command is running)
:param str name: The name of the local user, which is assumed to be in the
local directory service
:param str password: The plaintext password to set
:return: True if successful... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_shadow.py#L539-L568 | [
"def execute_return_success(cmd):\n '''\n Executes the passed command. Returns True if successful\n\n :param str cmd: The command to run\n\n :return: True if successful, otherwise False\n :rtype: bool\n\n :raises: Error if command fails or is not supported\n '''\n\n ret = _run_all(cmd)\n\n ... | # -*- coding: utf-8 -*-
'''
Manage macOS local directory passwords and policies
.. versionadded:: 2016.3.0
Note that it is usually better to apply password policies through the creation
of a configuration profile.
'''
# Authentication concepts reference:
# https://developer.apple.com/library/mac/documentation/Network... |
saltstack/salt | salt/states/rabbitmq_policy.py | present | python | def present(name,
pattern,
definition,
priority=0,
vhost='/',
runas=None,
apply_to=None):
'''
Ensure the RabbitMQ policy exists.
Reference: http://www.rabbitmq.com/ha.html
name
Policy name
pattern
A regex of qu... | Ensure the RabbitMQ policy exists.
Reference: http://www.rabbitmq.com/ha.html
name
Policy name
pattern
A regex of queues to apply the policy to
definition
A json dict describing the policy
priority
Priority (defaults to 0)
vhost
Virtual host to apply to ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_policy.py#L37-L124 | null | # -*- coding: utf-8 -*-
'''
Manage RabbitMQ Policies
========================
:maintainer: Benn Eichhorn <benn@getlocalmeasure.com>
:maturity: new
:platform: all
Example:
.. code-block:: yaml
rabbit_policy:
rabbitmq_policy.present:
- name: HA
- pattern: '.*'
- definiti... |
saltstack/salt | salt/states/rabbitmq_policy.py | absent | python | def absent(name,
vhost='/',
runas=None):
'''
Ensure the named policy is absent
Reference: http://www.rabbitmq.com/ha.html
name
The name of the policy to remove
runas
Name of the user to run the command as
'''
ret = {'name': name, 'result': True, 'comme... | Ensure the named policy is absent
Reference: http://www.rabbitmq.com/ha.html
name
The name of the policy to remove
runas
Name of the user to run the command as | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_policy.py#L127-L165 | null | # -*- coding: utf-8 -*-
'''
Manage RabbitMQ Policies
========================
:maintainer: Benn Eichhorn <benn@getlocalmeasure.com>
:maturity: new
:platform: all
Example:
.. code-block:: yaml
rabbit_policy:
rabbitmq_policy.present:
- name: HA
- pattern: '.*'
- definiti... |
saltstack/salt | salt/cloud/clouds/openstack.py | get_configured_provider | python | def get_configured_provider():
'''
Return the first configured instance.
'''
return config.is_provider_configured(
__opts__, __active_provider_name__ or __virtualname__,
('auth', 'region_name'), log_message=False,
) or config.is_provider_configured(
__opts__, __active_provide... | Return the first configured instance. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L259-L269 | [
"def is_provider_configured(opts, provider, required_keys=(), log_message=True, aliases=()):\n '''\n Check and return the first matching and fully configured cloud provider\n configuration.\n '''\n if ':' in provider:\n alias, driver = provider.split(':')\n if alias not in opts['provide... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | preferred_ip | python | def preferred_ip(vm_, ips):
'''
Return the preferred Internet protocol. Either 'ipv4' (default) or 'ipv6'.
'''
proto = config.get_cloud_config_value(
'protocol', vm_, __opts__, default='ipv4', search_global=False
)
family = socket.AF_INET
if proto == 'ipv6':
family = socket.... | Return the preferred Internet protocol. Either 'ipv4' (default) or 'ipv6'. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L286-L303 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | get_conn | python | def get_conn():
'''
Return a conn object for the passed VM data
'''
if __active_provider_name__ in __context__:
return __context__[__active_provider_name__]
vm_ = get_configured_provider()
profile = vm_.pop('profile', None)
if profile is not None:
vm_ = __utils__['dictupdate.... | Return a conn object for the passed VM data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L314-L327 | [
"def get_configured_provider():\n '''\n Return the first configured instance.\n '''\n return config.is_provider_configured(\n __opts__, __active_provider_name__ or __virtualname__,\n ('auth', 'region_name'), log_message=False,\n ) or config.is_provider_configured(\n __opts__, __a... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_nodes | python | def list_nodes(conn=None, call=None):
'''
Return a list of VMs
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
r... | Return a list of VMs
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L330-L350 | [
"def list_nodes_full(conn=None, call=None):\n '''\n Return a list of VMs with all the information about them\n\n CLI Example\n\n .. code-block:: bash\n\n salt-cloud -f list_nodes_full myopenstack\n\n '''\n if call == 'action':\n raise SaltCloudSystemExit(\n 'The list_nodes... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_nodes_min | python | def list_nodes_min(conn=None, call=None):
'''
Return a list of VMs with minimal information
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_min myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_min function must be called wi... | Return a list of VMs with minimal information
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_min myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L353-L373 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_nodes_full | python | def list_nodes_full(conn=None, call=None):
'''
Return a list of VMs with all the information about them
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_full myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function mus... | Return a list of VMs with all the information about them
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_full myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L389-L418 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_nodes_select | python | def list_nodes_select(conn=None, call=None):
'''
Return a list of VMs with the fields from `query.selection`
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_full myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_select funct... | Return a list of VMs with the fields from `query.selection`
CLI Example
.. code-block:: bash
salt-cloud -f list_nodes_full myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L421-L438 | [
"def list_nodes(conn=None, call=None):\n '''\n Return a list of VMs\n\n CLI Example\n\n .. code-block:: bash\n\n salt-cloud -f list_nodes myopenstack\n\n '''\n if call == 'action':\n raise SaltCloudSystemExit(\n 'The list_nodes function must be called with -f or --function... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | show_instance | python | def show_instance(name, conn=None, call=None):
'''
Get VM on this OpenStack account
name
name of the instance
CLI Example
.. code-block:: bash
salt-cloud -a show_instance myserver
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance... | Get VM on this OpenStack account
name
name of the instance
CLI Example
.. code-block:: bash
salt-cloud -a show_instance myserver | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L441-L477 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | avail_images | python | def avail_images(conn=None, call=None):
'''
List available images for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f avail_images myopenstack
salt-cloud --list-images myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_imag... | List available images for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f avail_images myopenstack
salt-cloud --list-images myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L480-L499 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | avail_sizes | python | def avail_sizes(conn=None, call=None):
'''
List available sizes for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f avail_sizes myopenstack
salt-cloud --list-sizes myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes fu... | List available sizes for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f avail_sizes myopenstack
salt-cloud --list-sizes myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L502-L521 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_networks | python | def list_networks(conn=None, call=None):
'''
List networks for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f list_networks myopenstack
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_networks function must be called with '
'-f ... | List networks for OpenStack
CLI Example
.. code-block:: bash
salt-cloud -f list_networks myopenstack | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L524-L542 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | list_subnets | python | def list_subnets(conn=None, call=None, kwargs=None):
'''
List subnets in a virtual network
network
network to list subnets of
.. code-block:: bash
salt-cloud -f list_subnets myopenstack network=salt-net
'''
if call == 'action':
raise SaltCloudSystemExit(
'... | List subnets in a virtual network
network
network to list subnets of
.. code-block:: bash
salt-cloud -f list_subnets myopenstack network=salt-net | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L545-L568 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | _clean_create_kwargs | python | def _clean_create_kwargs(**kwargs):
'''
Sanatize kwargs to be sent to create_server
'''
VALID_OPTS = {
'name': six.string_types,
'image': six.string_types,
'flavor': six.string_types,
'auto_ip': bool,
'ips': list,
'ip_pool': six.string_types,
'root... | Sanatize kwargs to be sent to create_server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L571-L616 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | request_instance | python | def request_instance(vm_, conn=None, call=None):
'''
Request an instance to be built
'''
if call == 'function':
# Technically this function may be called other ways too, but it
# definitely cannot be called with --function.
raise SaltCloudSystemExit(
'The request_inst... | Request an instance to be built | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L619-L658 | [
"def destroy(name, conn=None, call=None):\n '''\n Delete a single VM\n '''\n if call == 'function':\n raise SaltCloudSystemExit(\n 'The destroy action must be called with -d, --destroy, '\n '-a or --action.'\n )\n\n __utils__['cloud.fire_event'](\n 'event',\... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | create | python | def create(vm_):
'''
Create a single VM from a data dict
'''
deploy = config.get_cloud_config_value('deploy', vm_, __opts__)
key_filename = config.get_cloud_config_value(
'ssh_key_file', vm_, __opts__, search_global=False, default=None
)
if key_filename is not None and not os.path.is... | Create a single VM from a data dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L661-L770 | [
"def destroy(name, conn=None, call=None):\n '''\n Delete a single VM\n '''\n if call == 'function':\n raise SaltCloudSystemExit(\n 'The destroy action must be called with -d, --destroy, '\n '-a or --action.'\n )\n\n __utils__['cloud.fire_event'](\n 'event',\... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | destroy | python | def destroy(name, conn=None, call=None):
'''
Delete a single VM
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)
__utils__['cloud.fire_event'](
'event',
'destroy... | Delete a single VM | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L773-L816 | [
"def show_instance(name, conn=None, call=None):\n '''\n Get VM on this OpenStack account\n\n name\n\n name of the instance\n\n CLI Example\n\n .. code-block:: bash\n\n salt-cloud -a show_instance myserver\n\n '''\n if call != 'action':\n raise SaltCloudSystemExit(\n ... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/cloud/clouds/openstack.py | call | python | def call(conn=None, call=None, kwargs=None):
'''
Call function from shade.
func
function to call from shade.openstackcloud library
CLI Example
.. code-block:: bash
salt-cloud -f call myopenstack func=list_images
t sujksalt-cloud -f call myopenstack func=create_network na... | Call function from shade.
func
function to call from shade.openstackcloud library
CLI Example
.. code-block:: bash
salt-cloud -f call myopenstack func=list_images
t sujksalt-cloud -f call myopenstack func=create_network name=mysubnet | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/openstack.py#L819-L858 | [
"def get_conn():\n '''\n Return a conn object for the passed VM data\n '''\n if __active_provider_name__ in __context__:\n return __context__[__active_provider_name__]\n vm_ = get_configured_provider()\n profile = vm_.pop('profile', None)\n if profile is not None:\n vm_ = __utils_... | # -*- coding: utf-8 -*-
'''
Openstack Cloud Driver
======================
:depends: `shade>=1.19.0 <https://pypi.python.org/pypi/shade>`_
OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python modu... |
saltstack/salt | salt/modules/slsutil.py | merge | python | def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):
'''
Merge a data structure into another by choosing a merge strategy
Strategies:
* aggregate
* list
* overwrite
* recurse
* smart
CLI Example:
.. code-block:: shell
salt '*' slsutil.merge ... | Merge a data structure into another by choosing a merge strategy
Strategies:
* aggregate
* list
* overwrite
* recurse
* smart
CLI Example:
.. code-block:: shell
salt '*' slsutil.merge '{foo: Foo}' '{bar: Bar}' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L37-L56 | [
"def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):\n if strategy == 'smart':\n if renderer.split('|')[-1] == 'yamlex' or renderer.startswith('yamlex_'):\n strategy = 'aggregate'\n else:\n strategy = 'recurse'\n\n if strategy == 'list':\n ... | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/modules/slsutil.py | merge_all | python | def merge_all(lst, strategy='smart', renderer='yaml', merge_lists=False):
'''
.. versionadded:: 2019.2.0
Merge a list of objects into each other in order
:type lst: Iterable
:param lst: List of objects to be merged.
:type strategy: String
:param strategy: Merge strategy. See utils.dictupd... | .. versionadded:: 2019.2.0
Merge a list of objects into each other in order
:type lst: Iterable
:param lst: List of objects to be merged.
:type strategy: String
:param strategy: Merge strategy. See utils.dictupdate.
:type renderer: String
:param renderer:
Renderer type. Used to d... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L59-L92 | [
"def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):\n if strategy == 'smart':\n if renderer.split('|')[-1] == 'yamlex' or renderer.startswith('yamlex_'):\n strategy = 'aggregate'\n else:\n strategy = 'recurse'\n\n if strategy == 'list':\n ... | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/modules/slsutil.py | renderer | python | def renderer(path=None, string=None, default_renderer='jinja|yaml', **kwargs):
'''
Parse a string or file through Salt's renderer system
.. versionchanged:: 2018.3.0
Add support for Salt fileserver URIs.
This is an open-ended function and can be used for a variety of tasks. It
makes use of ... | Parse a string or file through Salt's renderer system
.. versionchanged:: 2018.3.0
Add support for Salt fileserver URIs.
This is an open-ended function and can be used for a variety of tasks. It
makes use of Salt's "renderer pipes" system to run a string or file through
a pipe of any of the loa... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L95-L186 | [
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta... | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/modules/slsutil.py | serialize | python | def serialize(serializer, obj, **mod_kwargs):
'''
Serialize a Python object using a :py:mod:`serializer module
<salt.serializers>`
CLI Example:
.. code-block:: bash
salt '*' --no-parse=obj slsutil.serialize 'json' obj="{'foo': 'Foo!'}
Jinja Example:
.. code-block:: jinja
... | Serialize a Python object using a :py:mod:`serializer module
<salt.serializers>`
CLI Example:
.. code-block:: bash
salt '*' --no-parse=obj slsutil.serialize 'json' obj="{'foo': 'Foo!'}
Jinja Example:
.. code-block:: jinja
{% set json_string = salt.slsutil.serialize('json',
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L206-L225 | [
"def clean_kwargs(**kwargs):\n '''\n Return a dict without any of the __pub* keys (or any other keys starting\n with a dunder) from the kwargs dict passed into the execution module\n functions. These keys are useful for tracking what was used to invoke\n the function call, but they may not be desirab... | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/modules/slsutil.py | deserialize | python | def deserialize(serializer, stream_or_string, **mod_kwargs):
'''
Deserialize a Python object using a :py:mod:`serializer module
<salt.serializers>`
CLI Example:
.. code-block:: bash
salt '*' slsutil.deserialize 'json' '{"foo": "Foo!"}'
salt '*' --no-parse=stream_or_string slsutil.... | Deserialize a Python object using a :py:mod:`serializer module
<salt.serializers>`
CLI Example:
.. code-block:: bash
salt '*' slsutil.deserialize 'json' '{"foo": "Foo!"}'
salt '*' --no-parse=stream_or_string slsutil.deserialize 'json' \\
stream_or_string='{"foo": "Foo!"}'
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L228-L250 | [
"def clean_kwargs(**kwargs):\n '''\n Return a dict without any of the __pub* keys (or any other keys starting\n with a dunder) from the kwargs dict passed into the execution module\n functions. These keys are useful for tracking what was used to invoke\n the function call, but they may not be desirab... | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/modules/slsutil.py | banner | python | def banner(width=72, commentchar='#', borderchar='#', blockstart=None, blockend=None,
title=None, text=None, newline=False):
'''
Create a standardized comment block to include in a templated file.
A common technique in configuration management is to include a comment
block in managed files, ... | Create a standardized comment block to include in a templated file.
A common technique in configuration management is to include a comment
block in managed files, warning users not to modify the file. This
function simplifies and standardizes those comment blocks.
:param width: The width, in character... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/slsutil.py#L253-L339 | null | # -*- coding: utf-8 -*-
'''
Utility functions for use with or in SLS files
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import textwrap
import os
# Import Salt libs
import salt.exceptions
import salt.loader
import salt.template
import salt.utils.args
import salt.ut... |
saltstack/salt | salt/utils/msazure.py | get_storage_conn | python | def get_storage_conn(storage_account=None, storage_key=None, opts=None):
'''
.. versionadded:: 2015.8.0
Return a storage_conn object for the storage account
'''
if opts is None:
opts = {}
if not storage_account:
storage_account = opts.get('storage_account', None)
if not sto... | .. versionadded:: 2015.8.0
Return a storage_conn object for the storage account | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msazure.py#L26-L40 | null | # -*- coding: utf-8 -*-
'''
.. versionadded:: 2015.8.0
Utilities for accessing storage container blobs on Azure
'''
# Import python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import azure libs
HAS_LIBS = False
try:
import azure
HAS_LIBS = True
except ImportError:
pass
... |
saltstack/salt | salt/utils/msazure.py | list_blobs | python | def list_blobs(storage_conn=None, **kwargs):
'''
.. versionadded:: 2015.8.0
List blobs associated with the container
'''
if not storage_conn:
storage_conn = get_storage_conn(opts=kwargs)
if 'container' not in kwargs:
raise SaltSystemExit(
code=42,
msg='A... | .. versionadded:: 2015.8.0
List blobs associated with the container | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msazure.py#L43-L70 | [
"def get_storage_conn(storage_account=None, storage_key=None, opts=None):\n '''\n .. versionadded:: 2015.8.0\n\n Return a storage_conn object for the storage account\n '''\n if opts is None:\n opts = {}\n\n if not storage_account:\n storage_account = opts.get('storage_account', None)... | # -*- coding: utf-8 -*-
'''
.. versionadded:: 2015.8.0
Utilities for accessing storage container blobs on Azure
'''
# Import python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import azure libs
HAS_LIBS = False
try:
import azure
HAS_LIBS = True
except ImportError:
pass
... |
saltstack/salt | salt/utils/msazure.py | put_blob | python | def put_blob(storage_conn=None, **kwargs):
'''
.. versionadded:: 2015.8.0
Upload a blob
'''
if not storage_conn:
storage_conn = get_storage_conn(opts=kwargs)
if 'container' not in kwargs:
raise SaltSystemExit(code=42, msg='The blob container name must be specified as "container... | .. versionadded:: 2015.8.0
Upload a blob | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msazure.py#L73-L120 | [
"def get_storage_conn(storage_account=None, storage_key=None, opts=None):\n '''\n .. versionadded:: 2015.8.0\n\n Return a storage_conn object for the storage account\n '''\n if opts is None:\n opts = {}\n\n if not storage_account:\n storage_account = opts.get('storage_account', None)... | # -*- coding: utf-8 -*-
'''
.. versionadded:: 2015.8.0
Utilities for accessing storage container blobs on Azure
'''
# Import python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import azure libs
HAS_LIBS = False
try:
import azure
HAS_LIBS = True
except ImportError:
pass
... |
saltstack/salt | salt/utils/msazure.py | get_blob | python | def get_blob(storage_conn=None, **kwargs):
'''
.. versionadded:: 2015.8.0
Download a blob
'''
if not storage_conn:
storage_conn = get_storage_conn(opts=kwargs)
if 'container' not in kwargs:
raise SaltSystemExit(code=42, msg='The blob container name must be specified as "contain... | .. versionadded:: 2015.8.0
Download a blob | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msazure.py#L123-L167 | [
"def get_storage_conn(storage_account=None, storage_key=None, opts=None):\n '''\n .. versionadded:: 2015.8.0\n\n Return a storage_conn object for the storage account\n '''\n if opts is None:\n opts = {}\n\n if not storage_account:\n storage_account = opts.get('storage_account', None)... | # -*- coding: utf-8 -*-
'''
.. versionadded:: 2015.8.0
Utilities for accessing storage container blobs on Azure
'''
# Import python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import azure libs
HAS_LIBS = False
try:
import azure
HAS_LIBS = True
except ImportError:
pass
... |
saltstack/salt | salt/utils/msazure.py | object_to_dict | python | def object_to_dict(obj):
'''
.. versionadded:: 2015.8.0
Convert an object to a dictionary
'''
if isinstance(obj, list) or isinstance(obj, tuple):
ret = []
for item in obj:
ret.append(object_to_dict(item))
elif hasattr(obj, '__dict__'):
ret = {}
for it... | .. versionadded:: 2015.8.0
Convert an object to a dictionary | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msazure.py#L170-L188 | [
"def object_to_dict(obj):\n '''\n .. versionadded:: 2015.8.0\n\n Convert an object to a dictionary\n '''\n if isinstance(obj, list) or isinstance(obj, tuple):\n ret = []\n for item in obj:\n ret.append(object_to_dict(item))\n elif hasattr(obj, '__dict__'):\n ret = {... | # -*- coding: utf-8 -*-
'''
.. versionadded:: 2015.8.0
Utilities for accessing storage container blobs on Azure
'''
# Import python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import azure libs
HAS_LIBS = False
try:
import azure
HAS_LIBS = True
except ImportError:
pass
... |
saltstack/salt | salt/cloud/cli.py | SaltCloud.run | python | def run(self):
'''
Execute the salt-cloud command line
'''
# Parse shell arguments
self.parse_args()
salt_master_user = self.config.get('user')
if salt_master_user is None:
salt_master_user = salt.utils.user.get_user()
if not check_user(salt_... | Execute the salt-cloud command line | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/cli.py#L41-L397 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def verify_env(\n dirs,\n user,\n permissive=False,\n pki_dir='',\n skip_extra=False,\n root_dir=ROOT_DIR):\n '''\n Verify that the named directories are in place and that the environment\n can shake the... | class SaltCloud(salt.utils.parsers.SaltCloudParser):
def print_confirm(self, msg):
if self.options.assume_yes:
return True
print(msg)
res = input('Proceed? [N/y] ')
if not res.lower().startswith('y'):
return False
print('... proceeding')
retu... |
saltstack/salt | salt/states/webutil.py | user_exists | python | def user_exists(name, password=None, htpasswd_file=None, options='',
force=False, runas=None, update=False):
'''
Make sure the user is inside the specified htpasswd file
name
User name
password
User password
htpasswd_file
Path to the htpasswd file
opti... | Make sure the user is inside the specified htpasswd file
name
User name
password
User password
htpasswd_file
Path to the htpasswd file
options
See :mod:`salt.modules.htpasswd.useradd`
force
Touch the file even if user already created
runas
Th... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/webutil.py#L36-L104 | null | # -*- coding: utf-8 -*-
'''
Support for htpasswd module. Requires the apache2-utils package for Debian-based distros.
.. versionadded:: 2014.7.0
.. code-block:: yaml
username:
webutil.user_exists:
- password: secr3t
- htpasswd_file: /etc/nginx/htpasswd
- options: d
- force: ... |
saltstack/salt | salt/states/webutil.py | user_absent | python | def user_absent(name, htpasswd_file=None, runas=None):
'''
Make sure the user is not in the specified htpasswd file
name
User name
htpasswd_file
Path to the htpasswd file
runas
The system user to run htpasswd command with
'''
ret = {'name': name,
'chang... | Make sure the user is not in the specified htpasswd file
name
User name
htpasswd_file
Path to the htpasswd file
runas
The system user to run htpasswd command with | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/webutil.py#L107-L150 | null | # -*- coding: utf-8 -*-
'''
Support for htpasswd module. Requires the apache2-utils package for Debian-based distros.
.. versionadded:: 2014.7.0
.. code-block:: yaml
username:
webutil.user_exists:
- password: secr3t
- htpasswd_file: /etc/nginx/htpasswd
- options: d
- force: ... |
saltstack/salt | salt/modules/celery.py | run_task | python | def run_task(task_name, args=None, kwargs=None, broker=None, backend=None, wait_for_result=False, timeout=None,
propagate=True, interval=0.5, no_ack=True, raise_timeout=True, config=None):
'''
Execute celery tasks. For celery specific parameters see celery documentation.
CLI Example:
.. ... | Execute celery tasks. For celery specific parameters see celery documentation.
CLI Example:
.. code-block:: bash
salt '*' celery.run_task tasks.sleep args=[4] broker=redis://localhost \\
backend=redis://localhost wait_for_result=true
task_name
The task name, e.g. tasks.sleep
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/celery.py#L40-L110 | null | # -*- coding: utf-8 -*-
'''
Support for scheduling celery tasks. The worker is independent of salt and thus can run in a different
virtualenv or on a different python version, as long as broker, backend and serializer configurations match.
Also note that celery and packages required by the celery broker, e.g. redis mus... |
saltstack/salt | salt/client/api.py | APIClient.run | python | def run(self, cmd):
'''
Execute the salt command given by cmd dict.
cmd is a dictionary of the following form:
{
'mode': 'modestring',
'fun' : 'modulefunctionstring',
'kwarg': functionkeywordargdictionary,
'tgt' : 'targetpatternstring',
... | Execute the salt command given by cmd dict.
cmd is a dictionary of the following form:
{
'mode': 'modestring',
'fun' : 'modulefunctionstring',
'kwarg': functionkeywordargdictionary,
'tgt' : 'targetpatternstring',
'tgt_type' : 'targetpatternty... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L70-L137 | null | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/client/api.py | APIClient.signature | python | def signature(self, cmd):
'''
Convenience function that returns dict of function signature(s) specified by cmd.
cmd is dict of the form:
{
'module' : 'modulestring',
'tgt' : 'targetpatternstring',
'tgt_type' : 'targetpatterntype',
'token':... | Convenience function that returns dict of function signature(s) specified by cmd.
cmd is dict of the form:
{
'module' : 'modulestring',
'tgt' : 'targetpatternstring',
'tgt_type' : 'targetpatterntype',
'token': 'salttokenstring',
'username': 'u... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L177-L211 | [
"def _signature(self, cmd):\n '''\n Expects everything that signature does and also a client type string.\n client can either be master or minion.\n '''\n result = {}\n\n client = cmd.get('client', 'minion')\n if client == 'minion':\n cmd['fun'] = 'sys.argspec'\n cmd['kwarg'] = di... | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/client/api.py | APIClient._signature | python | def _signature(self, cmd):
'''
Expects everything that signature does and also a client type string.
client can either be master or minion.
'''
result = {}
client = cmd.get('client', 'minion')
if client == 'minion':
cmd['fun'] = 'sys.argspec'
... | Expects everything that signature does and also a client type string.
client can either be master or minion. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L213-L234 | null | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/client/api.py | APIClient.create_token | python | def create_token(self, creds):
'''
Create token with creds.
Token authorizes salt access if successful authentication
with the credentials in creds.
creds format is as follows:
{
'username': 'namestring',
'password': 'passwordstring',
... | Create token with creds.
Token authorizes salt access if successful authentication
with the credentials in creds.
creds format is as follows:
{
'username': 'namestring',
'password': 'passwordstring',
'eauth': 'eauthtypestring',
}
exam... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L236-L293 | null | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.