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/kmod.py
mod_list
python
def mod_list(only_persist=False): ''' Return a list of the loaded module names only_persist Only return the list of loaded persistent modules CLI Example: .. code-block:: bash salt '*' kmod.mod_list ''' mods = set() if only_persist: conf = _get_modules_conf() ...
Return a list of the loaded module names only_persist Only return the list of loaded persistent modules CLI Example: .. code-block:: bash salt '*' kmod.mod_list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L196-L225
[ "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 -*- ''' Module to manage Linux kernel modules ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import re import logging # Import salt libs import salt.utils.files import salt.utils.path log = logging.getLogger(__name__) def __virtual__(...
saltstack/salt
salt/modules/kmod.py
load
python
def load(mod, persist=False): ''' Load the specified kernel module mod Name of module to add persist Write module to /etc/modules to make it load on system reboot CLI Example: .. code-block:: bash salt '*' kmod.load kvm ''' pre_mods = lsmod() res = __salt...
Load the specified kernel module mod Name of module to add persist Write module to /etc/modules to make it load on system reboot CLI Example: .. code-block:: bash salt '*' kmod.load kvm
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L228-L254
[ "def _new_mods(pre_mods, post_mods):\n '''\n Return a list of the new modules, pass an lsmod dict before running\n modprobe and one after modprobe has run\n '''\n pre = set()\n post = set()\n for mod in pre_mods:\n pre.add(mod['module'])\n for mod in post_mods:\n post.add(mod['...
# -*- coding: utf-8 -*- ''' Module to manage Linux kernel modules ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import re import logging # Import salt libs import salt.utils.files import salt.utils.path log = logging.getLogger(__name__) def __virtual__(...
saltstack/salt
salt/proxy/onyx.py
init
python
def init(opts=None): ''' Required. Can be used to initialize the server connection. ''' if opts is None: opts = __opts__ try: DETAILS[_worker_name()] = SSHConnection( host=opts['proxy']['host'], username=opts['proxy']['username'], password=opts...
Required. Can be used to initialize the server connection.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L87-L107
[ "def _worker_name():\n return multiprocessing.current_process().name\n" ]
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
ping
python
def ping(): ''' Ping the device on the other end of the connection .. code-block: bash salt '*' onyx.cmd ping ''' if _worker_name() not in DETAILS: init() try: return DETAILS[_worker_name()].conn.isalive() except TerminalException as e: log.error(e) ...
Ping the device on the other end of the connection .. code-block: bash salt '*' onyx.cmd ping
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L117-L131
[ "def init(opts=None):\n '''\n Required.\n Can be used to initialize the server connection.\n '''\n if opts is None:\n opts = __opts__\n try:\n DETAILS[_worker_name()] = SSHConnection(\n host=opts['proxy']['host'],\n username=opts['proxy']['username'],\n ...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
sendline
python
def sendline(command): ''' Run command through switch's cli .. code-block: bash salt '*' onyx.cmd sendline 'show run | include "username admin password 7"' ''' if ping() is False: init() out, _ = DETAILS[_worker_name()].sendline(command) return out
Run command through switch's cli .. code-block: bash salt '*' onyx.cmd sendline 'show run | include "username admin password 7"'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L141-L153
[ "def init(opts=None):\n '''\n Required.\n Can be used to initialize the server connection.\n '''\n if opts is None:\n opts = __opts__\n try:\n DETAILS[_worker_name()] = SSHConnection(\n host=opts['proxy']['host'],\n username=opts['proxy']['username'],\n ...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
grains
python
def grains(): ''' Get grains for proxy minion .. code-block: bash salt '*' onyx.cmd grains ''' if not DETAILS['grains_cache']: ret = system_info() log.debug(ret) DETAILS['grains_cache'].update(ret) return {'onyx': DETAILS['grains_cache']}
Get grains for proxy minion .. code-block: bash salt '*' onyx.cmd grains
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L221-L233
[ "def system_info():\n '''\n Return system information for grains of the NX OS proxy minion\n\n .. code-block:: bash\n\n salt '*' onyx.system_info\n '''\n # data = show_ver()\n info = {\n 'software': 'Test',\n 'hardware': '',\n 'plugins': ''\n }\n return info\n" ]
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
get_user
python
def get_user(username): ''' Get username line from switch .. code-block: bash salt '*' onyx.cmd get_user username=admin ''' try: enable() configure_terminal() cmd_out = sendline('show running-config | include "username {0} password 7"'.format(username)) cmd_...
Get username line from switch .. code-block: bash salt '*' onyx.cmd get_user username=admin
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L248-L267
[ "def disable():\n '''\n Shortcut to run `disable` on switch\n\n .. code-block:: bash\n\n salt '*' onyx.cmd disable\n '''\n try:\n ret = sendline('disable')\n except TerminalException as e:\n log.error(e)\n return 'Failed to \"configure terminal\"'\n r...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
get_roles
python
def get_roles(username): ''' Get roles that the username is assigned from switch .. code-block: bash salt '*' onyx.cmd get_roles username=admin ''' info = sendline('show user-account {0}'.format(username)) roles = re.search(r'^\s*roles:(.*)$', info, re.MULTILINE) if roles: ...
Get roles that the username is assigned from switch .. code-block: bash salt '*' onyx.cmd get_roles username=admin
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L270-L284
[ "def sendline(command):\n '''\n Run command through switch's cli\n\n .. code-block: bash\n\n salt '*' onyx.cmd sendline 'show run | include\n \"username admin password 7\"'\n '''\n if ping() is False:\n init()\n out, _ = DETAILS[_worker_name()].sendline(command)\n return ou...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
remove_user
python
def remove_user(username): ''' Remove user from switch .. code-block:: bash salt '*' onyx.cmd remove_user username=daniel ''' try: sendline('config terminal') user_line = 'no username {0}'.format(username) ret = sendline(user_line) sendline('end') se...
Remove user from switch .. code-block:: bash salt '*' onyx.cmd remove_user username=daniel
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L298-L315
[ "def sendline(command):\n '''\n Run command through switch's cli\n\n .. code-block: bash\n\n salt '*' onyx.cmd sendline 'show run | include\n \"username admin password 7\"'\n '''\n if ping() is False:\n init()\n out, _ = DETAILS[_worker_name()].sendline(command)\n return ou...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
set_role
python
def set_role(username, role): ''' Assign role to username .. code-block:: bash salt '*' onyx.cmd set_role username=daniel role=vdc-admin ''' try: sendline('config terminal') role_line = 'username {0} role {1}'.format(username, role) ret = sendline(role_line) ...
Assign role to username .. code-block:: bash salt '*' onyx.cmd set_role username=daniel role=vdc-admin
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L318-L335
[ "def sendline(command):\n '''\n Run command through switch's cli\n\n .. code-block: bash\n\n salt '*' onyx.cmd sendline 'show run | include\n \"username admin password 7\"'\n '''\n if ping() is False:\n init()\n out, _ = DETAILS[_worker_name()].sendline(command)\n return ou...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
show_run
python
def show_run(): ''' Shortcut to run `show run` on switch .. code-block:: bash salt '*' onyx.cmd show_run ''' try: enable() configure_terminal() ret = sendline('show running-config') configure_terminal_exit() disable() except TerminalException as ...
Shortcut to run `show run` on switch .. code-block:: bash salt '*' onyx.cmd show_run
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L358-L375
[ "def disable():\n '''\n Shortcut to run `disable` on switch\n\n .. code-block:: bash\n\n salt '*' onyx.cmd disable\n '''\n try:\n ret = sendline('disable')\n except TerminalException as e:\n log.error(e)\n return 'Failed to \"configure terminal\"'\n r...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
add_config
python
def add_config(lines): ''' Add one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw' .. note:: For more than one config added per command, lines should be a list. ''' if not isinstance(...
Add one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw' .. note:: For more than one config added per command, lines should be a list.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L394-L418
[ "def disable():\n '''\n Shortcut to run `disable` on switch\n\n .. code-block:: bash\n\n salt '*' onyx.cmd disable\n '''\n try:\n ret = sendline('disable')\n except TerminalException as e:\n log.error(e)\n return 'Failed to \"configure terminal\"'\n r...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
delete_config
python
def delete_config(lines): ''' Delete one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator' .. note:: For more than one config deleted per command, lines should be a list....
Delete one or more config lines to the switch running config .. code-block:: bash salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator' .. note:: For more than one config deleted per command, lines should be a list.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L421-L444
[ "def sendline(command):\n '''\n Run command through switch's cli\n\n .. code-block: bash\n\n salt '*' onyx.cmd sendline 'show run | include\n \"username admin password 7\"'\n '''\n if ping() is False:\n init()\n out, _ = DETAILS[_worker_name()].sendline(command)\n return ou...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
find
python
def find(pattern): ''' Find all instances where the pattern is in the running command .. code-block:: bash salt '*' onyx.cmd find '^snmp-server.*$' .. note:: This uses the `re.MULTILINE` regex format for python, and runs the regex against the whole show_run output. ''' ...
Find all instances where the pattern is in the running command .. code-block:: bash salt '*' onyx.cmd find '^snmp-server.*$' .. note:: This uses the `re.MULTILINE` regex format for python, and runs the regex against the whole show_run output.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L447-L460
[ "def show_run():\n '''\n Shortcut to run `show run` on switch\n\n .. code-block:: bash\n\n salt '*' onyx.cmd show_run\n '''\n try:\n enable()\n configure_terminal()\n ret = sendline('show running-config')\n configure_terminal_exit()\n disable()\n except Te...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/proxy/onyx.py
replace
python
def replace(old_value, new_value, full_match=False): ''' Replace string or full line matches in switch's running config If full_match is set to True, then the whole line will need to be matched as part of the old value. .. code-block:: bash salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWT...
Replace string or full line matches in switch's running config If full_match is set to True, then the whole line will need to be matched as part of the old value. .. code-block:: bash salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWTESTSTRINGHERE'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L463-L489
[ "def show_run():\n '''\n Shortcut to run `show run` on switch\n\n .. code-block:: bash\n\n salt '*' onyx.cmd show_run\n '''\n try:\n enable()\n configure_terminal()\n ret = sendline('show running-config')\n configure_terminal_exit()\n disable()\n except Te...
# -*- coding: utf-8 -*- ''' Proxy Minion for Onyx OS Switches .. versionadded: Neon The Onyx OS Proxy Minion uses the built in SSHConnection module in :mod:`salt.utils.vt_helper <salt.utils.vt_helper>` To configure the proxy minion: .. code-block:: yaml proxy: proxytype: onyx host: 192.168.187.100 ...
saltstack/salt
salt/states/postgres_group.py
present
python
def present(name, createdb=None, createroles=None, encrypted=None, superuser=None, inherit=None, login=None, replication=None, password=None, refresh_password=None, groups=None, user=None,...
Ensure that the named group is present with the specified privileges Please note that the user/group notion in postgresql is just abstract, we have roles, where users can be seen as roles with the ``LOGIN`` privilege and groups the others. name The name of the group to manage createdb ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_group.py#L36-L213
[ "def _maybe_encrypt_password(role,\n password,\n encrypted=_DEFAULT_PASSWORDS_ENCRYPTION):\n '''\n pgsql passwords are md5 hashes of the string: 'md5{password}{rolename}'\n '''\n if password is not None:\n password = six.text_type(password)\n ...
# -*- coding: utf-8 -*- ''' Management of PostgreSQL groups (roles) ======================================= The postgres_group module is used to create and manage Postgres groups. .. code-block:: yaml frank: postgres_group.present ''' from __future__ import absolute_import, unicode_literals, print_function...
saltstack/salt
salt/states/postgres_group.py
absent
python
def absent(name, user=None, maintenance_db=None, db_password=None, db_host=None, db_port=None, db_user=None): ''' Ensure that the named group is absent name The groupname of the group to remove user System user all opera...
Ensure that the named group is absent name The groupname of the group to remove user System user all operations should be performed on behalf of .. versionadded:: 0.17.0 db_user database username if different from config or defaul db_password user password if...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_group.py#L216-L273
null
# -*- coding: utf-8 -*- ''' Management of PostgreSQL groups (roles) ======================================= The postgres_group module is used to create and manage Postgres groups. .. code-block:: yaml frank: postgres_group.present ''' from __future__ import absolute_import, unicode_literals, print_function...
saltstack/salt
salt/utils/docker/translate/helpers.py
get_port_def
python
def get_port_def(port_num, proto='tcp'): ''' Given a port number and protocol, returns the port definition expected by docker-py. For TCP ports this is simply an integer, for UDP ports this is (port_num, 'udp'). port_num can also be a string in the format 'port_num/udp'. If so, the "proto" argu...
Given a port number and protocol, returns the port definition expected by docker-py. For TCP ports this is simply an integer, for UDP ports this is (port_num, 'udp'). port_num can also be a string in the format 'port_num/udp'. If so, the "proto" argument will be ignored. The reason we need to be able t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L26-L59
null
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
get_port_range
python
def get_port_range(port_def): ''' Given a port number or range, return a start and end to that range. Port ranges are defined as a string containing two numbers separated by a dash (e.g. '4505-4506'). A ValueError will be raised if bad input is provided. ''' if isinstance(port_def, six.inte...
Given a port number or range, return a start and end to that range. Port ranges are defined as a string containing two numbers separated by a dash (e.g. '4505-4506'). A ValueError will be raised if bad input is provided.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L62-L93
[ "def split(item, sep=',', maxsplit=-1):\n return [x.strip() for x in item.split(sep, maxsplit)]\n" ]
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
map_vals
python
def map_vals(val, *names, **extra_opts): ''' Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function provides common code to handle these instances. ''' fill = extra_opts.pop('fill', NOTSET) expected_num_elements...
Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function provides common code to handle these instances.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L96-L127
[ "def translate_stringlist(val):\n '''\n On the CLI, these are passed as multiple instances of a given CLI option.\n In Salt, we accept these as a comma-delimited list but the API expects a\n Python list. This function accepts input and returns it back as a Python\n list of strings. If the input is a ...
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_command
python
def translate_command(val): ''' Input should either be a single string, or a list of strings. This is used for the two args that deal with commands ("command" and "entrypoint"). ''' if isinstance(val, six.string_types): return val elif isinstance(val, list): for idx in range(len(...
Input should either be a single string, or a list of strings. This is used for the two args that deal with commands ("command" and "entrypoint").
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L176-L190
null
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_bytes
python
def translate_bytes(val): ''' These values can be expressed as an integer number of bytes, or a string expression (i.e. 100mb, 1gb, etc.). ''' try: val = int(val) except (TypeError, ValueError): if not isinstance(val, six.string_types): val = six.text_type(val) re...
These values can be expressed as an integer number of bytes, or a string expression (i.e. 100mb, 1gb, etc.).
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L193-L203
null
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_stringlist
python
def translate_stringlist(val): ''' On the CLI, these are passed as multiple instances of a given CLI option. In Salt, we accept these as a comma-delimited list but the API expects a Python list. This function accepts input and returns it back as a Python list of strings. If the input is a string whi...
On the CLI, these are passed as multiple instances of a given CLI option. In Salt, we accept these as a comma-delimited list but the API expects a Python list. This function accepts input and returns it back as a Python list of strings. If the input is a string which is a comma-separated list of items, ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L206-L222
[ "def split(item, sep=',', maxsplit=-1):\n return [x.strip() for x in item.split(sep, maxsplit)]\n" ]
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_device_rates
python
def translate_device_rates(val, numeric_rate=True): ''' CLI input is a list of PATH:RATE pairs, but the API expects a list of dictionaries in the format [{'Path': path, 'Rate': rate}] ''' val = map_vals(val, 'Path', 'Rate') for idx in range(len(val)): try: is_abs = os.path.is...
CLI input is a list of PATH:RATE pairs, but the API expects a list of dictionaries in the format [{'Path': path, 'Rate': rate}]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L225-L257
[ "def map_vals(val, *names, **extra_opts):\n '''\n Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list\n of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function\n provides common code to handle these instances.\n '''\n fill = extra_opts.pop('fill', NOTSET)\n expected_...
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_key_val
python
def translate_key_val(val, delimiter='='): ''' CLI input is a list of key/val pairs, but the API expects a dictionary in the format {key: val} ''' if isinstance(val, dict): return val val = translate_stringlist(val) new_val = {} for item in val: try: lvalue, r...
CLI input is a list of key/val pairs, but the API expects a dictionary in the format {key: val}
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L260-L277
[ "def split(item, sep=',', maxsplit=-1):\n return [x.strip() for x in item.split(sep, maxsplit)]\n", "def translate_stringlist(val):\n '''\n On the CLI, these are passed as multiple instances of a given CLI option.\n In Salt, we accept these as a comma-delimited list but the API expects a\n Python l...
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/utils/docker/translate/helpers.py
translate_labels
python
def translate_labels(val): ''' Can either be a list of label names, or a list of name=value pairs. The API can accept either a list of label names or a dictionary mapping names to values, so the value we translate will be different depending on the input. ''' if not isinstance(val, dict): ...
Can either be a list of label names, or a list of name=value pairs. The API can accept either a list of label names or a dictionary mapping names to values, so the value we translate will be different depending on the input.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L280-L308
[ "def split(item, sep=',', maxsplit=-1):\n return [x.strip() for x in item.split(sep, maxsplit)]\n" ]
# -*- coding: utf-8 -*- ''' Functions to translate input in the docker CLI format to the format desired by by the API. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os # Import Salt libs import salt.utils.data import salt.utils.network from salt.exceptions imp...
saltstack/salt
salt/states/firewall.py
check
python
def check(name, port=None, **kwargs): ''' Checks if there is an open connection from the minion to the defined host on a specific port. name host name or ip address to test connection to port The port to test the connection on kwargs Additional parameters, parameters allowe...
Checks if there is an open connection from the minion to the defined host on a specific port. name host name or ip address to test connection to port The port to test the connection on kwargs Additional parameters, parameters allowed are: proto (tcp or udp) family (i...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/firewall.py#L19-L67
null
# -*- coding: utf-8 -*- ''' State to check firewall configurations .. versionadded:: 2016.3.0 ''' from __future__ import absolute_import, print_function, unicode_literals def __virtual__(): ''' Load only if network is loaded ''' return 'firewall' if 'network.connect' in __salt__ else False
saltstack/salt
salt/states/selinux.py
_refine_mode
python
def _refine_mode(mode): ''' Return a mode value that is predictable ''' mode = six.text_type(mode).lower() if any([mode.startswith('e'), mode == '1', mode == 'on']): return 'Enforcing' if any([mode.startswith('p'), mode == '0', mode == 'off...
Return a mode value that is predictable
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L41-L56
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
mode
python
def mode(name): ''' Verifies the mode SELinux is running in, can be set to enforcing, permissive, or disabled .. note:: A change to or from disabled mode requires a system reboot. You will need to perform this yourself. name The mode to run SELinux in, permissive, enforcing...
Verifies the mode SELinux is running in, can be set to enforcing, permissive, or disabled .. note:: A change to or from disabled mode requires a system reboot. You will need to perform this yourself. name The mode to run SELinux in, permissive, enforcing, or disabled.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L84-L133
[ "def _refine_mode(mode):\n '''\n Return a mode value that is predictable\n '''\n mode = six.text_type(mode).lower()\n if any([mode.startswith('e'),\n mode == '1',\n mode == 'on']):\n return 'Enforcing'\n if any([mode.startswith('p'),\n mode == '0',\n ...
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
boolean
python
def boolean(name, value, persist=False): ''' Set up an SELinux boolean name The name of the boolean to set value The value to set on the boolean persist Defaults to False, set persist to true to make the boolean apply on a reboot ''' ret = {'name': name, ...
Set up an SELinux boolean name The name of the boolean to set value The value to set on the boolean persist Defaults to False, set persist to true to make the boolean apply on a reboot
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L136-L191
[ "def _refine_value(value):\n '''\n Return a yes/no value, or None if the input is invalid\n '''\n value = six.text_type(value).lower()\n if value in ('1', 'on', 'yes', 'true'):\n return 'on'\n if value in ('0', 'off', 'no', 'false'):\n return 'off'\n return None\n" ]
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
module
python
def module(name, module_state='Enabled', version='any', **opts): ''' Enable/Disable and optionally force a specific version for an SELinux module name The name of the module to control module_state Should the module be enabled or disabled? version Defaults to no preference...
Enable/Disable and optionally force a specific version for an SELinux module name The name of the module to control module_state Should the module be enabled or disabled? version Defaults to no preference, set to a specified value if required. Currently can only alert if t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L194-L268
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
module_install
python
def module_install(name): ''' Installs custom SELinux module from given file name Path to file with module to install .. versionadded:: 2016.11.6 ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} if __salt__['selinux.install_sem...
Installs custom SELinux module from given file name Path to file with module to install .. versionadded:: 2016.11.6
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L271-L289
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
module_remove
python
def module_remove(name): ''' Removes SELinux module name The name of the module to remove .. versionadded:: 2016.11.6 ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} modules = __salt__['selinux.list_semod']() if name not i...
Removes SELinux module name The name of the module to remove .. versionadded:: 2016.11.6
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L292-L315
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
fcontext_policy_present
python
def fcontext_policy_present(name, sel_type, filetype='a', sel_user=None, sel_level=None): ''' .. versionadded:: 2017.7.0 Makes sure a SELinux policy for a given filespec (name), filetype and SELinux context type is present. name filespec of the file or directory. Regex syntax is allowed. ...
.. versionadded:: 2017.7.0 Makes sure a SELinux policy for a given filespec (name), filetype and SELinux context type is present. name filespec of the file or directory. Regex syntax is allowed. sel_type SELinux context type. There are many. filetype The SELinux filetype ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L318-L396
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
fcontext_policy_absent
python
def fcontext_policy_absent(name, filetype='a', sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2017.7.0 Makes sure an SELinux file context policy for a given filespec (name), filetype and SELinux context type is absent. name filespec of the file or directory. Regex syn...
.. versionadded:: 2017.7.0 Makes sure an SELinux file context policy for a given filespec (name), filetype and SELinux context type is absent. name filespec of the file or directory. Regex syntax is allowed. filetype The SELinux filetype specification. Use one of [a, f, d, c, b, ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L399-L455
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
fcontext_policy_applied
python
def fcontext_policy_applied(name, recursive=False): ''' .. versionadded:: 2017.7.0 Checks and makes sure the SELinux policies for a given filespec are applied. ''' ret = {'name': name, 'result': False, 'changes': {}, 'comment': ''} changes_text = __salt__['selinux.fcontext_policy_is_applie...
.. versionadded:: 2017.7.0 Checks and makes sure the SELinux policies for a given filespec are applied.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L458-L481
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
port_policy_present
python
def port_policy_present(name, sel_type, protocol=None, port=None, sel_range=None): ''' .. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is present. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)...
.. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is present. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. protocol The protocol for the port, ``...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L484-L536
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/selinux.py
port_policy_absent
python
def port_policy_absent(name, sel_type=None, protocol=None, port=None): ''' .. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is absent. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_...
.. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is absent. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. Optional; can be used in determining if policy is pr...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L539-L587
null
# -*- coding: utf-8 -*- ''' Management of SELinux rules =========================== If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True ...
saltstack/salt
salt/states/openstack_config.py
present
python
def present(name, filename, section, value, parameter=None): ''' Ensure a value is set in an OpenStack configuration file. filename The full path to the configuration file section The section in which the parameter will be set parameter (optional) The parameter to change. ...
Ensure a value is set in an OpenStack configuration file. filename The full path to the configuration file section The section in which the parameter will be set parameter (optional) The parameter to change. If the parameter is not supplied, the name will be used as the parameter...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/openstack_config.py#L33-L90
null
# -*- coding: utf-8 -*- ''' Manage OpenStack configuration file settings. :maintainer: Jeffrey C. Ollie <jeff@ocjtech.us> :maturity: new :depends: :platform: linux ''' # Import Python Libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt Libs from salt.ext import six from salt....
saltstack/salt
salt/states/azurearm_compute.py
availability_set_present
python
def availability_set_present(name, resource_group, tags=None, platform_update_domain_count=None, platform_fault_domain_count=None, virtual_machines=None, sku=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure an availabilit...
.. versionadded:: 2019.2.0 Ensure an availability set exists. :param name: Name of the availability set. :param resource_group: The resource group assigned to the availability set. :param tags: A dictionary of strings can be passed as tag metadata to the availability set obje...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_compute.py#L104-L263
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Compute State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_compute.py
availability_set_absent
python
def availability_set_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure an availability set does not exist in a resource group. :param name: Name of the availability set. :param resource_group: Name of the resource group containing the availa...
.. versionadded:: 2019.2.0 Ensure an availability set does not exist in a resource group. :param name: Name of the availability set. :param resource_group: Name of the resource group containing the availability set. :param connection_auth: A dict with subscription and authent...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_compute.py#L266-L326
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Compute State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/grains/fibre_channel.py
_linux_wwns
python
def _linux_wwns(): ''' Return Fibre Channel port WWNs from a Linux host. ''' ret = [] for fc_file in glob.glob('/sys/class/fc_host/*/port_name'): with salt.utils.files.fopen(fc_file, 'r') as _wwn: content = _wwn.read() for line in content.splitlines(): ...
Return Fibre Channel port WWNs from a Linux host.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/fibre_channel.py#L38-L48
[ "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 -*- ''' Grains for Fibre Channel WWN's. On Windows this runs a PowerShell command that queries WMI to get the Fibre Channel WWN's available. .. versionadded:: 2018.3.0 To enable these grains set ``fibre_channel_grains: True``. .. code-block:: yaml fibre_channel_grains: True ''' # Import Pyth...
saltstack/salt
salt/grains/fibre_channel.py
_windows_wwns
python
def _windows_wwns(): ''' Return Fibre Channel port WWNs from a Windows host. ''' ps_cmd = r'Get-WmiObject -ErrorAction Stop ' \ r'-class MSFC_FibrePortHBAAttributes ' \ r'-namespace "root\WMI" | ' \ r'Select -Expandproperty Attributes | ' \ r'%{($_.Por...
Return Fibre Channel port WWNs from a Windows host.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/fibre_channel.py#L51-L64
[ "def powershell(cmd,\n cwd=None,\n stdin=None,\n runas=None,\n shell=DEFAULT_SHELL,\n env=None,\n clean_env=False,\n template=None,\n rstrip=True,\n umask=None,\n output_encodi...
# -*- coding: utf-8 -*- ''' Grains for Fibre Channel WWN's. On Windows this runs a PowerShell command that queries WMI to get the Fibre Channel WWN's available. .. versionadded:: 2018.3.0 To enable these grains set ``fibre_channel_grains: True``. .. code-block:: yaml fibre_channel_grains: True ''' # Import Pyth...
saltstack/salt
salt/grains/fibre_channel.py
fibre_channel_wwns
python
def fibre_channel_wwns(): ''' Return list of fiber channel HBA WWNs ''' grains = {'fc_wwn': False} if salt.utils.platform.is_linux(): grains['fc_wwn'] = _linux_wwns() elif salt.utils.platform.is_windows(): grains['fc_wwn'] = _windows_wwns() return grains
Return list of fiber channel HBA WWNs
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/fibre_channel.py#L67-L76
[ "def _linux_wwns():\n '''\n Return Fibre Channel port WWNs from a Linux host.\n '''\n ret = []\n for fc_file in glob.glob('/sys/class/fc_host/*/port_name'):\n with salt.utils.files.fopen(fc_file, 'r') as _wwn:\n content = _wwn.read()\n for line in content.splitlines():\n ...
# -*- coding: utf-8 -*- ''' Grains for Fibre Channel WWN's. On Windows this runs a PowerShell command that queries WMI to get the Fibre Channel WWN's available. .. versionadded:: 2018.3.0 To enable these grains set ``fibre_channel_grains: True``. .. code-block:: yaml fibre_channel_grains: True ''' # Import Pyth...
saltstack/salt
salt/utils/vsan.py
vsan_supported
python
def vsan_supported(service_instance): ''' Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher service_instance Service instance to the host or vCenter ''' try: api_version = service_instance.content.about.apiVersion except vim.fault.NoPe...
Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher service_instance Service instance to the host or vCenter
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L85-L107
null
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
get_vsan_cluster_config_system
python
def get_vsan_cluster_config_system(service_instance): ''' Returns a vim.cluster.VsanVcClusterConfigSystem object service_instance Service instance to the host or vCenter ''' #TODO Replace when better connection mechanism is available #For python 2.7.9 and later, the defaul SSL conext ...
Returns a vim.cluster.VsanVcClusterConfigSystem object service_instance Service instance to the host or vCenter
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L110-L131
[ "def GetVsanVcMos(vcStub, context=None):\n vsanStub = GetVsanVcStub(vcStub, context)\n vcMos = {\n 'vsan-disk-management-system' : vim.cluster.VsanVcDiskManagementSystem(\n 'vsan-disk-management-system',\n vsanStub\n ...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
get_host_vsan_system
python
def get_host_vsan_system(service_instance, host_ref, hostname=None): ''' Returns a host's vsan system service_instance Service instance to the host or vCenter host_ref Refernce to ESXi host hostname Name of ESXi host. Default value is None. ''' if not hostname: ...
Returns a host's vsan system service_instance Service instance to the host or vCenter host_ref Refernce to ESXi host hostname Name of ESXi host. Default value is None.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L158-L184
[ "def get_mors_with_properties(service_instance, object_type, property_list=None,\n container_ref=None, traversal_spec=None,\n local_properties=False):\n '''\n Returns a list containing properties and managed object references for the managed object.\n\n ...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
create_diskgroup
python
def create_diskgroup(service_instance, vsan_disk_mgmt_system, host_ref, cache_disk, capacity_disks): ''' Creates a disk group service_instance Service instance to the host or vCenter vsan_disk_mgmt_system vim.VimClusterVsanVcDiskManagemenetSystem representing the v...
Creates a disk group service_instance Service instance to the host or vCenter vsan_disk_mgmt_system vim.VimClusterVsanVcDiskManagemenetSystem representing the vSan disk management system retrieved from the vsan endpoint. host_ref vim.HostSystem object representing the targ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L187-L242
[ "def get_managed_object_name(mo_ref):\n '''\n Returns the name of a managed object.\n If the name wasn't found, it returns None.\n\n mo_ref\n The managed object reference.\n '''\n props = get_properties_of_managed_object(mo_ref, ['name'])\n return props.get('name')\n", "def _wait_for_t...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
remove_capacity_from_diskgroup
python
def remove_capacity_from_diskgroup(service_instance, host_ref, diskgroup, capacity_disks, data_evacuation=True, hostname=None, host_vsan_system=None): ''' Removes capacity disk(s) from a disk group. ser...
Removes capacity disk(s) from a disk group. service_instance Service instance to the host or vCenter host_vsan_system ESXi host's VSAN system host_ref Reference to the ESXi host diskgroup The vsan.HostDiskMapping object representing the host's diskgroup from w...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L308-L379
[ "def wait_for_task(task, instance_name, task_type, sleep_seconds=1, log_level='debug'):\n '''\n Waits for a task to be completed.\n\n task\n The task to wait for.\n\n instance_name\n The name of the ESXi host, vCenter Server, or Virtual Machine that\n the task is being run on.\n\n ...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
remove_diskgroup
python
def remove_diskgroup(service_instance, host_ref, diskgroup, hostname=None, host_vsan_system=None, erase_disk_partitions=False, data_accessibility=True): ''' Removes a disk group. service_instance Service instance to the host or vCenter host_ref ...
Removes a disk group. service_instance Service instance to the host or vCenter host_ref Reference to the ESXi host diskgroup The vsan.HostDiskMapping object representing the host's diskgroup from where the capacity needs to be removed hostname Name of ESXi hos...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L382-L440
[ "def wait_for_task(task, instance_name, task_type, sleep_seconds=1, log_level='debug'):\n '''\n Waits for a task to be completed.\n\n task\n The task to wait for.\n\n instance_name\n The name of the ESXi host, vCenter Server, or Virtual Machine that\n the task is being run on.\n\n ...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
get_cluster_vsan_info
python
def get_cluster_vsan_info(cluster_ref): ''' Returns the extended cluster vsan configuration object (vim.VsanConfigInfoEx). cluster_ref Reference to the cluster ''' cluster_name = salt.utils.vmware.get_managed_object_name(cluster_ref) log.trace('Retrieving cluster vsan info of clust...
Returns the extended cluster vsan configuration object (vim.VsanConfigInfoEx). cluster_ref Reference to the cluster
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L443-L468
[ "def get_managed_object_name(mo_ref):\n '''\n Returns the name of a managed object.\n If the name wasn't found, it returns None.\n\n mo_ref\n The managed object reference.\n '''\n props = get_properties_of_managed_object(mo_ref, ['name'])\n return props.get('name')\n", "def get_service...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
reconfigure_cluster_vsan
python
def reconfigure_cluster_vsan(cluster_ref, cluster_vsan_spec): ''' Reconfigures the VSAN system of a cluster. cluster_ref Reference to the cluster cluster_vsan_spec Cluster VSAN reconfigure spec (vim.vsan.ReconfigSpec). ''' cluster_name = salt.utils.vmware.get_managed_object_nam...
Reconfigures the VSAN system of a cluster. cluster_ref Reference to the cluster cluster_vsan_spec Cluster VSAN reconfigure spec (vim.vsan.ReconfigSpec).
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L471-L500
[ "def get_managed_object_name(mo_ref):\n '''\n Returns the name of a managed object.\n If the name wasn't found, it returns None.\n\n mo_ref\n The managed object reference.\n '''\n props = get_properties_of_managed_object(mo_ref, ['name'])\n return props.get('name')\n", "def get_service...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/vsan.py
_wait_for_tasks
python
def _wait_for_tasks(tasks, service_instance): ''' Wait for tasks created via the VSAN API ''' log.trace('Waiting for vsan tasks: {0}', ', '.join([six.text_type(t) for t in tasks])) try: vsanapiutils.WaitForTasks(tasks, service_instance) except vim.fault.NoPermission as exc:...
Wait for tasks created via the VSAN API
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L503-L522
[ "def WaitForTasks(tasks, si):\n \"\"\"\n Given the service instance si and tasks, it returns after all the\n tasks are complete\n \"\"\"\n\n pc = si.content.propertyCollector\n\n taskList = [str(task) for task in tasks]\n\n # Create filter\n objSpecs = [vmodl.query.PropertyCollector.ObjectSpec(obj=t...
# -*- coding: utf-8 -*- ''' Connection library for VMware vSAN endpoint This library used the vSAN extension of the VMware SDK used to manage vSAN related objects :codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com> Dependencies ~~~~~~~~~~~~ - pyVmomi Python Module pyVmomi ------- PyVmomi can be inst...
saltstack/salt
salt/utils/crypt.py
decrypt
python
def decrypt(data, rend, translate_newlines=False, renderers=None, opts=None, valid_rend=None): ''' .. versionadded:: 2017.7.0 Decrypt a data structure using the specified renderer. Written originally as a common codebase to handle decryption o...
.. versionadded:: 2017.7.0 Decrypt a data structure using the specified renderer. Written originally as a common codebase to handle decryption of encrypted elements within Pillar data, but should be flexible enough for other uses as well. Returns the decrypted result, but any decryption renderer shoul...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/crypt.py#L27-L100
null
# -*- coding: utf-8 -*- ''' Functions dealing with encryption ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import hashlib import logging import os log = logging.getLogger(__name__) # Import Salt libs import salt.loader import salt.utils.files from salt.exceptions...
saltstack/salt
salt/utils/crypt.py
pem_finger
python
def pem_finger(path=None, key=None, sum_type='sha256'): ''' Pass in either a raw pem string, or the path on disk to the location of a pem file, and the type of cryptographic hash to use. The default is SHA256. The fingerprint of the pem will be returned. If neither a key nor a path are passed in, a...
Pass in either a raw pem string, or the path on disk to the location of a pem file, and the type of cryptographic hash to use. The default is SHA256. The fingerprint of the pem will be returned. If neither a key nor a path are passed in, a blank string will be returned.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/crypt.py#L117-L140
[ "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 -*- ''' Functions dealing with encryption ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import hashlib import logging import os log = logging.getLogger(__name__) # Import Salt libs import salt.loader import salt.utils.files from salt.exceptions...
saltstack/salt
salt/utils/schema.py
SchemaItem._get_argname_value
python
def _get_argname_value(self, argname): ''' Return the argname value looking up on all possible attributes ''' # Let's see if there's a private function to get the value argvalue = getattr(self, '__get_{0}__'.format(argname), None) if argvalue is not None and callable(argv...
Return the argname value looking up on all possible attributes
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schema.py#L731-L748
null
class SchemaItem(six.with_metaclass(BaseSchemaItemMeta, object)): ''' Base configuration items class. All configurations must subclass it ''' # Define some class level attributes to make PyLint happier __type__ = None __format__ = None _attributes = None __flatten__ = False __...
saltstack/salt
salt/utils/schema.py
BaseSchemaItem.serialize
python
def serialize(self): ''' Return a serializable form of the config instance ''' serialized = {'type': self.__type__} for argname in self._attributes: if argname == 'required': # This is handled elsewhere continue argvalue = s...
Return a serializable form of the config instance
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schema.py#L827-L845
[ "def _get_argname_value(self, argname):\n '''\n Return the argname value looking up on all possible attributes\n '''\n # Let's see if there's a private function to get the value\n argvalue = getattr(self, '__get_{0}__'.format(argname), None)\n if argvalue is not None and callable(argvalue):\n ...
class BaseSchemaItem(SchemaItem): ''' Base configuration items class. All configurations must subclass it ''' # Let's define description as a class attribute, this will allow a custom configuration # item to do something like: # class MyCustomConfig(StringItem): # ''' # ...
saltstack/salt
salt/utils/schema.py
ComplexSchemaItem._add_missing_schema_attributes
python
def _add_missing_schema_attributes(self): ''' Adds any missed schema attributes to the _attributes list The attributes can be class attributes and they won't be included in the _attributes list automatically ''' for attr in [attr for attr in dir(self) if not attr.startsw...
Adds any missed schema attributes to the _attributes list The attributes can be class attributes and they won't be included in the _attributes list automatically
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schema.py#L1481-L1493
null
class ComplexSchemaItem(BaseSchemaItem): ''' .. versionadded:: 2016.11.0 Complex Schema Item ''' # This attribute is populated by the metaclass, but pylint fails to see it # and assumes it's not an iterable _attributes = [] _definition_name = None def __init__(self, definition_nam...
saltstack/salt
salt/utils/schema.py
ComplexSchemaItem.get_definition
python
def get_definition(self): '''Returns the definition of the complex item''' serialized = super(ComplexSchemaItem, self).serialize() # Adjust entries in the serialization del serialized['definition_name'] serialized['title'] = self.definition_name properties = {} ...
Returns the definition of the complex item
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schema.py#L1506-L1533
[ "def serialize(self):\n '''\n Return a serializable form of the config instance\n '''\n serialized = {'type': self.__type__}\n for argname in self._attributes:\n if argname == 'required':\n # This is handled elsewhere\n continue\n argvalue = self._get_argname_value...
class ComplexSchemaItem(BaseSchemaItem): ''' .. versionadded:: 2016.11.0 Complex Schema Item ''' # This attribute is populated by the metaclass, but pylint fails to see it # and assumes it's not an iterable _attributes = [] _definition_name = None def __init__(self, definition_nam...
saltstack/salt
salt/utils/schema.py
ComplexSchemaItem.get_complex_attrs
python
def get_complex_attrs(self): '''Returns a dictionary of the complex attributes''' return [getattr(self, attr_name) for attr_name in self._attributes if isinstance(getattr(self, attr_name), ComplexSchemaItem)]
Returns a dictionary of the complex attributes
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schema.py#L1535-L1538
null
class ComplexSchemaItem(BaseSchemaItem): ''' .. versionadded:: 2016.11.0 Complex Schema Item ''' # This attribute is populated by the metaclass, but pylint fails to see it # and assumes it's not an iterable _attributes = [] _definition_name = None def __init__(self, definition_nam...
saltstack/salt
salt/modules/boto_rds.py
exists
python
def exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS exists. CLI example:: salt myminion boto_rds.exists myrds region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: rds = conn.descri...
Check to see if an RDS exists. CLI example:: salt myminion boto_rds.exists myrds region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L141-L155
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
option_group_exists
python
def option_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS option group exists. CLI example:: salt myminion boto_rds.option_group_exists myoptiongr region=us-east-1 ''' conn = _get_conn(region=region, key=ke...
Check to see if an RDS option group exists. CLI example:: salt myminion boto_rds.option_group_exists myoptiongr region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L158-L173
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
parameter_group_exists
python
def parameter_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1 ''' co...
Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L176-L196
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
subnet_group_exists
python
def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS subnet group exists. CLI example:: salt myminion boto_rds.subnet_group_exists my-param-group \ region=us-east-1 ''' try: con...
Check to see if an RDS subnet group exists. CLI example:: salt myminion boto_rds.subnet_group_exists my-param-group \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L199-L220
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
create
python
def create(name, allocated_storage, db_instance_class, engine, master_username, master_user_password, db_name=None, db_security_groups=None, vpc_security_group_ids=None, vpc_security_groups=None, availability_zone=None, db_subnet_group_name=None, preferred_maintenance_window=...
Create an RDS Instance CLI example to create an RDS Instance:: salt myminion boto_rds.create myrds 10 db.t2.micro MySQL sqlusr sqlpassw
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L223-L319
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def describe_db_instances(name=None, filters=None, jmespath='DBInstances',\n region=None, key=None, keyid=None, profile=None):\n '''\n Return a detailed listing of some, or all, DB Instances visible in the\n current scop...
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
create_read_replica
python
def create_read_replica(name, source_name, db_instance_class=None, availability_zone=None, port=None, auto_minor_version_upgrade=None, iops=None, option_group_name=None, publicly_accessible=None, tags=None, db_subnet_group_n...
Create an RDS read replica CLI example to create an RDS read replica:: salt myminion boto_rds.create_read_replica replicaname source_name
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L322-L377
[ "def _tag_doc(tags):\n taglist = []\n if tags is not None:\n for k, v in six.iteritems(tags):\n if six.text_type(k).startswith('__'):\n continue\n taglist.append({'Key': six.text_type(k), 'Value': six.text_type(v)})\n return taglist\n" ]
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
create_option_group
python
def create_option_group(name, engine_name, major_engine_version, option_group_description, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS option group CLI example to create an RDS option group:: salt myminion boto_rds....
Create an RDS option group CLI example to create an RDS option group:: salt myminion boto_rds.create_option_group my-opt-group mysql 5.6 \ "group description"
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L380-L410
[ "def _tag_doc(tags):\n taglist = []\n if tags is not None:\n for k, v in six.iteritems(tags):\n if six.text_type(k).startswith('__'):\n continue\n taglist.append({'Key': six.text_type(k), 'Value': six.text_type(v)})\n return taglist\n" ]
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
create_parameter_group
python
def create_parameter_group(name, db_parameter_group_family, description, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS parameter group CLI example to create an RDS parameter group:: salt myminion boto_rds.create...
Create an RDS parameter group CLI example to create an RDS parameter group:: salt myminion boto_rds.create_parameter_group my-param-group mysql5.6 \ "group description"
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L413-L446
[ "def _tag_doc(tags):\n taglist = []\n if tags is not None:\n for k, v in six.iteritems(tags):\n if six.text_type(k).startswith('__'):\n continue\n taglist.append({'Key': six.text_type(k), 'Value': six.text_type(v)})\n return taglist\n" ]
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
create_subnet_group
python
def create_subnet_group(name, description, subnet_ids, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS subnet group CLI example to create an RDS subnet group:: salt myminion boto_rds.create_subnet_group my-subnet-group \ "group des...
Create an RDS subnet group CLI example to create an RDS subnet group:: salt myminion boto_rds.create_subnet_group my-subnet-group \ "group description" '[subnet-12345678, subnet-87654321]' \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L449-L477
[ "def _tag_doc(tags):\n taglist = []\n if tags is not None:\n for k, v in six.iteritems(tags):\n if six.text_type(k).startswith('__'):\n continue\n taglist.append({'Key': six.text_type(k), 'Value': six.text_type(v)})\n return taglist\n" ]
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
update_parameter_group
python
def update_parameter_group(name, parameters, apply_method="pending-reboot", tags=None, region=None, key=None, keyid=None, profile=None): ''' Update an RDS parameter group. CLI example:: salt myminion boto_rds.update_parameter_group my-param-gro...
Update an RDS parameter group. CLI example:: salt myminion boto_rds.update_parameter_group my-param-group \ parameters='{"back_log":1, "binlog_cache_size":4096}' \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L480-L522
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def update(*args, **kwds): # pylint: disable=E0211\n '''od.update(E, **F) -> None. Update od from dict/iterable E and F.\n\n If E is a dict instance, does: for k in E: od[k] = E[k]\n If E has a .keys() method, does: for k in ...
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
describe
python
def describe(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return RDS instance details. CLI example:: salt myminion boto_rds.describe myrds ''' res = __salt__['boto_rds.exists'](name, tags, region, key, keyid, pro...
Return RDS instance details. CLI example:: salt myminion boto_rds.describe myrds
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L525-L572
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
describe_db_instances
python
def describe_db_instances(name=None, filters=None, jmespath='DBInstances', region=None, key=None, keyid=None, profile=None): ''' Return a detailed listing of some, or all, DB Instances visible in the current scope. Arbitrary subelements or subsections of the returned dataset c...
Return a detailed listing of some, or all, DB Instances visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well. CLI example:: salt myminion boto_rds.describe_db_instances jmespath='DBInstances[*].DBI...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L575-L600
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
describe_db_subnet_groups
python
def describe_db_subnet_groups(name=None, filters=None, jmespath='DBSubnetGroups', region=None, key=None, keyid=None, profile=None): ''' Return a detailed listing of some, or all, DB Subnet Groups visible in the current scope. Arbitrary subelements or subsections of the returne...
Return a detailed listing of some, or all, DB Subnet Groups visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well. CLI example:: salt myminion boto_rds.describe_db_subnet_groups
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L603-L622
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
get_endpoint
python
def get_endpoint(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return the endpoint of an RDS instance. CLI example:: salt myminion boto_rds.get_endpoint myrds ''' endpoint = False res = __salt__['boto_rds.exists'](name, tags, region, key, keyi...
Return the endpoint of an RDS instance. CLI example:: salt myminion boto_rds.get_endpoint myrds
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L625-L651
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
delete
python
def delete(name, skip_final_snapshot=None, final_db_snapshot_identifier=None, region=None, key=None, keyid=None, profile=None, tags=None, wait_for_deletion=True, timeout=180): ''' Delete an RDS instance. CLI example:: salt myminion boto_rds.delete myrds skip_final_snapshot=Tr...
Delete an RDS instance. CLI example:: salt myminion boto_rds.delete myrds skip_final_snapshot=True \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L654-L708
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
delete_option_group
python
def delete_option_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS option group. CLI example:: salt myminion boto_rds.delete_option_group my-opt-group \ region=us-east-1 ''' try: conn = _get_conn(region=region, key=key, keyid=keyid, pr...
Delete an RDS option group. CLI example:: salt myminion boto_rds.delete_option_group my-opt-group \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L711-L733
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
delete_parameter_group
python
def delete_parameter_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1 ''' try: conn = _get_conn(r...
Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L736-L755
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
delete_subnet_group
python
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS subnet group. CLI example:: salt myminion boto_rds.delete_subnet_group my-subnet-group \ region=us-east-1 ''' try: conn = _get_conn(region=regio...
Delete an RDS subnet group. CLI example:: salt myminion boto_rds.delete_subnet_group my-subnet-group \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L758-L777
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
describe_parameter_group
python
def describe_parameter_group(name, Filters=None, MaxRecords=None, Marker=None, region=None, key=None, keyid=None, profile=None): ''' Returns a list of `DBParameterGroup` descriptions. CLI example to description of parameter group:: salt myminion boto_rds.describe_parame...
Returns a list of `DBParameterGroup` descriptions. CLI example to description of parameter group:: salt myminion boto_rds.describe_parameter_group parametergroupname\ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L780-L819
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
describe_parameters
python
def describe_parameters(name, Source=None, MaxRecords=None, Marker=None, region=None, key=None, keyid=None, profile=None): ''' Returns a list of `DBParameterGroup` parameters. CLI example to description of parameters :: salt myminion boto_rds.describe_parameters parametergro...
Returns a list of `DBParameterGroup` parameters. CLI example to description of parameters :: salt myminion boto_rds.describe_parameters parametergroupname\ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L822-L875
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/modules/boto_rds.py
modify_db_instance
python
def modify_db_instance(name, allocated_storage=None, allow_major_version_upgrade=None, apply_immediately=None, auto_minor_version_upgrade=None, backup_retention_period=None, ca_certi...
Modify settings for a DB instance. CLI example to description of parameters :: salt myminion boto_rds.modify_db_instance db_instance_identifier region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L878-L952
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon RDS .. versionadded:: 2015.8.0 :configuration: This module accepts explicit rds credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no fu...
saltstack/salt
salt/beacons/sensehat.py
beacon
python
def beacon(config): ''' Monitor the temperature, humidity and pressure using the SenseHat sensors. You can either specify a threshold for each value and only emit a beacon if it is exceeded or define a range and emit a beacon when the value is out of range. Units: * humidity: ...
Monitor the temperature, humidity and pressure using the SenseHat sensors. You can either specify a threshold for each value and only emit a beacon if it is exceeded or define a range and emit a beacon when the value is out of range. Units: * humidity: percent * temperature...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/sensehat.py#L47-L109
null
# -*- coding: utf-8 -*- ''' Monitor temperature, humidity and pressure using the SenseHat of a Raspberry Pi =============================================================================== .. versionadded:: 2017.7.0 :maintainer: Benedikt Werner <1benediktwerner@gmail.com> :maturity: new :depends: sense_h...
saltstack/salt
salt/states/nova.py
flavor_present
python
def flavor_present(name, params=None, **kwargs): ''' Creates Nova flavor if it does not exist :param name: Flavor name :param params: Definition of the Flavor (see Compute API documentation) .. code-block:: yaml nova-flavor-present: nova.flavor_present: - name:...
Creates Nova flavor if it does not exist :param name: Flavor name :param params: Definition of the Flavor (see Compute API documentation) .. code-block:: yaml nova-flavor-present: nova.flavor_present: - name: myflavor - params: ram: ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nova.py#L27-L78
null
# -*- coding: utf-8 -*- ''' .. versionadded:: 2017.7 Module for handling OpenStack Nova calls :codeauthor: Jakub Sliva <jakub.sliva@ultimum.io> ''' from __future__ import absolute_import from __future__ import unicode_literals import logging from salt.ext import six log = logging.getLogger(__name__) def __virtual...
saltstack/salt
salt/states/nova.py
flavor_access_list
python
def flavor_access_list(name, projects, **kwargs): ''' Grants access of the flavor to a project. Flavor must be private. :param name: non-public flavor name :param projects: list of projects which should have the access to the flavor .. code-block:: yaml nova-flavor-share: nova...
Grants access of the flavor to a project. Flavor must be private. :param name: non-public flavor name :param projects: list of projects which should have the access to the flavor .. code-block:: yaml nova-flavor-share: nova.flavor_project_access: - name: myflavor ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nova.py#L81-L141
null
# -*- coding: utf-8 -*- ''' .. versionadded:: 2017.7 Module for handling OpenStack Nova calls :codeauthor: Jakub Sliva <jakub.sliva@ultimum.io> ''' from __future__ import absolute_import from __future__ import unicode_literals import logging from salt.ext import six log = logging.getLogger(__name__) def __virtual...
saltstack/salt
salt/states/nova.py
flavor_absent
python
def flavor_absent(name, **kwargs): ''' Makes flavor to be absent :param name: flavor name .. code-block:: yaml nova-flavor-absent: nova.flavor_absent: - name: flavor_name ''' dry_run = __opts__['test'] ret = {'name': name, 'result': False, 'comment': ''...
Makes flavor to be absent :param name: flavor name .. code-block:: yaml nova-flavor-absent: nova.flavor_absent: - name: flavor_name
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nova.py#L144-L183
null
# -*- coding: utf-8 -*- ''' .. versionadded:: 2017.7 Module for handling OpenStack Nova calls :codeauthor: Jakub Sliva <jakub.sliva@ultimum.io> ''' from __future__ import absolute_import from __future__ import unicode_literals import logging from salt.ext import six log = logging.getLogger(__name__) def __virtual...
saltstack/salt
salt/matchers/nodegroup_match.py
match
python
def match(tgt, nodegroups=None, opts=None): ''' This is a compatibility matcher and is NOT called when using nodegroups for remote execution, but is called when the nodegroups matcher is used in states ''' if not opts: opts = __opts__ if not nodegroups: log.debug('Nodegroup m...
This is a compatibility matcher and is NOT called when using nodegroups for remote execution, but is called when the nodegroups matcher is used in states
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/matchers/nodegroup_match.py#L14-L30
[ "def nodegroup_comp(nodegroup, nodegroups, skip=None, first_call=True):\n '''\n Recursively expand ``nodegroup`` from ``nodegroups``; ignore nodegroups in ``skip``\n\n If a top-level (non-recursive) call finds no nodegroups, return the original\n nodegroup definition (for backwards compatibility). Keep ...
# -*- coding: utf-8 -*- ''' This is the default nodegroup matcher. ''' from __future__ import absolute_import, print_function, unicode_literals import salt.utils.minions # pylint: disable=3rd-party-module-not-gated import salt.loader import logging log = logging.getLogger(__name__)
saltstack/salt
salt/states/ldap.py
managed
python
def managed(name, entries, connect_spec=None): '''Ensure the existence (or not) of LDAP entries and their attributes Example: .. code-block:: yaml ldapi:///: ldap.managed: - connect_spec: bind: method: sasl - entries: ...
Ensure the existence (or not) of LDAP entries and their attributes Example: .. code-block:: yaml ldapi:///: ldap.managed: - connect_spec: bind: method: sasl - entries: # make sure the entry doesn't exist ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ldap.py#L26-L368
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _process_entries(l, entries):\n '''Helper for managed() to process entries and return before/after views\n\n Collect the current database state and update it according to the\n data in :py:func:`managed`'s ``entries`` parameter. Return the\...
# -*- coding: utf-8 -*- ''' Manage entries in an LDAP database ================================== .. versionadded:: 2016.3.0 The ``states.ldap`` state module allows you to manage LDAP entries and their attributes. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals impor...
saltstack/salt
salt/states/ldap.py
_process_entries
python
def _process_entries(l, entries): '''Helper for managed() to process entries and return before/after views Collect the current database state and update it according to the data in :py:func:`managed`'s ``entries`` parameter. Return the current database state and what it will look like after modifi...
Helper for managed() to process entries and return before/after views Collect the current database state and update it according to the data in :py:func:`managed`'s ``entries`` parameter. Return the current database state and what it will look like after modification. :param l: the LDAP c...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ldap.py#L371-L455
null
# -*- coding: utf-8 -*- ''' Manage entries in an LDAP database ================================== .. versionadded:: 2016.3.0 The ``states.ldap`` state module allows you to manage LDAP entries and their attributes. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals impor...
saltstack/salt
salt/states/ldap.py
_update_entry
python
def _update_entry(entry, status, directives): '''Update an entry's attributes using the provided directives :param entry: A dict mapping each attribute name to a set of its values :param status: A dict holding cross-invocation status (whether delete_others is True or not, and the se...
Update an entry's attributes using the provided directives :param entry: A dict mapping each attribute name to a set of its values :param status: A dict holding cross-invocation status (whether delete_others is True or not, and the set of mentioned attributes) :param directives: ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ldap.py#L458-L494
null
# -*- coding: utf-8 -*- ''' Manage entries in an LDAP database ================================== .. versionadded:: 2016.3.0 The ``states.ldap`` state module allows you to manage LDAP entries and their attributes. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals impor...
saltstack/salt
salt/states/ldap.py
_toset
python
def _toset(thing): '''helper to convert various things to a set This enables flexibility in what users provide as the list of LDAP entry attribute values. Note that the LDAP spec prohibits duplicate values in an attribute. RFC 2251 states that: "The order of attribute values within the vals s...
helper to convert various things to a set This enables flexibility in what users provide as the list of LDAP entry attribute values. Note that the LDAP spec prohibits duplicate values in an attribute. RFC 2251 states that: "The order of attribute values within the vals set is undefined and i...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ldap.py#L497-L528
null
# -*- coding: utf-8 -*- ''' Manage entries in an LDAP database ================================== .. versionadded:: 2016.3.0 The ``states.ldap`` state module allows you to manage LDAP entries and their attributes. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals impor...
saltstack/salt
salt/modules/shadow.py
info
python
def info(name, root=None): ''' Return information for the specified user name User to get the information for root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.info root ''' if root is not None: getspnam = functools.parti...
Return information for the specified user name User to get the information for root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.info root
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L53-L95
null
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
_set_attrib
python
def _set_attrib(name, key, value, param, root=None, validate=True): ''' Set a parameter in /etc/shadow ''' pre_info = info(name, root=root) # If the user is not present or the attribute is already present, # we return early if not pre_info['name']: return False if value == pre_...
Set a parameter in /etc/shadow
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L98-L122
[ "def info(name, root=None):\n '''\n Return information for the specified user\n\n name\n User to get the information for\n\n root\n Directory to chroot into\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' shadow.info root\n '''\n if root is not None:\n gets...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
gen_password
python
def gen_password(password, crypt_salt=None, algorithm='sha512'): ''' .. versionadded:: 2014.7.0 Generate hashed password .. note:: When called this function is called directly via remote-execution, the password argument may be displayed in the system's process list. This may b...
.. versionadded:: 2014.7.0 Generate hashed password .. note:: When called this function is called directly via remote-execution, the password argument may be displayed in the system's process list. This may be a security risk on certain systems. password Plaintext passwor...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L193-L232
[ "def gen_hash(crypt_salt=None, password=None, algorithm='sha512'):\n '''\n Generate /etc/shadow hash\n '''\n if not HAS_CRYPT:\n raise SaltInvocationError('No crypt module for windows')\n\n hash_algorithms = dict(\n md5='$1$', blowfish='$2a$', sha256='$5$', sha512='$6$'\n )\n if a...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
del_password
python
def del_password(name, root=None): ''' .. versionadded:: 2014.7.0 Delete the password from name user name User to delete root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.del_password username ''' cmd = ['passwd'] if roo...
.. versionadded:: 2014.7.0 Delete the password from name user name User to delete root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.del_password username
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L235-L260
[ "def info(name, root=None):\n '''\n Return information for the specified user\n\n name\n User to get the information for\n\n root\n Directory to chroot into\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' shadow.info root\n '''\n if root is not None:\n gets...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
unlock_password
python
def unlock_password(name, root=None): ''' .. versionadded:: 2016.11.0 Unlock the password from name user name User to unlock root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.unlock_password username ''' pre_info = info(name...
.. versionadded:: 2016.11.0 Unlock the password from name user name User to unlock root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.unlock_password username
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L299-L332
[ "def info(name, root=None):\n '''\n Return information for the specified user\n\n name\n User to get the information for\n\n root\n Directory to chroot into\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' shadow.info root\n '''\n if root is not None:\n gets...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
set_password
python
def set_password(name, password, use_usermod=False, root=None): ''' Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command: ``python -c "import crypt; print crypt.crypt('password', '\\$6\\$SALTsalt')"`` ``SALTsalt``...
Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command: ``python -c "import crypt; print crypt.crypt('password', '\\$6\\$SALTsalt')"`` ``SALTsalt`` is the 8-character crpytographic salt. Valid characters in the salt are...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L335-L408
[ "def info(name, root=None):\n '''\n Return information for the specified user\n\n name\n User to get the information for\n\n root\n Directory to chroot into\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' shadow.info root\n '''\n if root is not None:\n gets...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
set_date
python
def set_date(name, date, root=None): ''' Sets the value for the date the password was last changed to days since the epoch (January 1, 1970). See man chage. name User to modify date Date the password was last changed root Directory to chroot into CLI Example: ...
Sets the value for the date the password was last changed to days since the epoch (January 1, 1970). See man chage. name User to modify date Date the password was last changed root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.se...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L434-L454
[ "def _set_attrib(name, key, value, param, root=None, validate=True):\n '''\n Set a parameter in /etc/shadow\n '''\n pre_info = info(name, root=root)\n\n # If the user is not present or the attribute is already present,\n # we return early\n if not pre_info['name']:\n return False\n\n ...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
set_expire
python
def set_expire(name, expire, root=None): ''' .. versionchanged:: 2014.7.0 Sets the value for the date the account expires as days since the epoch (January 1, 1970). Using a value of -1 will clear expiration. See man chage. name User to modify date Date the account expires ...
.. versionchanged:: 2014.7.0 Sets the value for the date the account expires as days since the epoch (January 1, 1970). Using a value of -1 will clear expiration. See man chage. name User to modify date Date the account expires root Directory to chroot into CLI E...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L457-L480
[ "def _set_attrib(name, key, value, param, root=None, validate=True):\n '''\n Set a parameter in /etc/shadow\n '''\n pre_info = info(name, root=root)\n\n # If the user is not present or the attribute is already present,\n # we return early\n if not pre_info['name']:\n return False\n\n ...
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
list_users
python
def list_users(root=None): ''' .. versionadded:: 2018.3.0 Return a list of all shadow users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.list_users ''' if root is not None: getspall = functools.partial(_getspall, root=root) ...
.. versionadded:: 2018.3.0 Return a list of all shadow users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.list_users
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L483-L504
null
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...
saltstack/salt
salt/modules/shadow.py
_getspnam
python
def _getspnam(name, root=None): ''' Alternative implementation for getspnam, that use only /etc/shadow ''' root = '/' if not root else root passwd = os.path.join(root, 'etc/shadow') with salt.utils.files.fopen(passwd) as fp_: for line in fp_: line = salt.utils.stringutils.to_...
Alternative implementation for getspnam, that use only /etc/shadow
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L507-L522
null
# -*- coding: utf-8 -*- ''' Manage the shadow file on Linux systems .. important:: If you feel that Salt should be using this module to manage passwords on a minion, and it is using a different module (or gives an error similar to *'shadow.info' is not available*), see :ref:`here <module-provider-overr...