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/client/api.py | APIClient.verify_token | python | def verify_token(self, token):
'''
If token is valid Then returns user name associated with token
Else False.
'''
try:
result = self.resolver.get_token(token)
except Exception as ex:
raise EauthAuthenticationError(
"Token validation... | If token is valid Then returns user name associated with token
Else False. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L295-L306 | null | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/client/api.py | APIClient.get_event | python | def get_event(self, wait=0.25, tag='', full=False):
'''
Get a single salt event.
If no events are available, then block for up to ``wait`` seconds.
Return the event if it matches the tag (or ``tag`` is empty)
Otherwise return None
If wait is 0 then block forever or until... | Get a single salt event.
If no events are available, then block for up to ``wait`` seconds.
Return the event if it matches the tag (or ``tag`` is empty)
Otherwise return None
If wait is 0 then block forever or until next event becomes available. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L308-L317 | null | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/client/api.py | APIClient.fire_event | python | def fire_event(self, data, tag):
'''
fires event with data and tag
This only works if api is running with same user permissions as master
Need to convert this to a master call with appropriate authentication
'''
return self.event.fire_event(data, salt.utils.event.tagify(... | fires event with data and tag
This only works if api is running with same user permissions as master
Need to convert this to a master call with appropriate authentication | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L319-L326 | [
"def tagify(suffix='', prefix='', base=SALT):\n '''\n convenience function to build a namespaced event tag string\n from joining with the TABPART character the base, prefix and suffix\n\n If string prefix is a valid key in TAGS Then use the value of key prefix\n Else use prefix string\n\n If suffi... | class APIClient(object):
'''
Provide a uniform method of accessing the various client interfaces in Salt
in the form of low-data data structures. For example:
'''
def __init__(self, opts=None, listen=True):
if not opts:
opts = salt.config.client_config(
os.environ... |
saltstack/salt | salt/modules/win_timezone.py | get_zone | python | def get_zone():
'''
Get current timezone (i.e. America/Denver)
Returns:
str: Timezone in unix format
Raises:
CommandExecutionError: If timezone could not be gathered
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zone
'''
cmd = ['tzutil', '/g']
r... | Get current timezone (i.e. America/Denver)
Returns:
str: Timezone in unix format
Raises:
CommandExecutionError: If timezone could not be gathered
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zone | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L201-L223 | [
"def get_unix(self, key, default=None):\n return self.win_to_unix.get(key.lower(), default)\n"
] | # -*- coding: utf-8 -*-
'''
Module for managing timezone on Windows systems.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import logging
from datetime import datetime
# Import Salt libs
from salt.exceptions import CommandExecutionError
# Import 3rd party libs
try:... |
saltstack/salt | salt/modules/win_timezone.py | get_offset | python | def get_offset():
'''
Get current numeric timezone offset from UTC (i.e. -0700)
Returns:
str: Offset from UTC
CLI Example:
.. code-block:: bash
salt '*' timezone.get_offset
'''
# http://craigglennie.com/programming/python/2013/07/21/working-with-timezones-using-Python-and... | Get current numeric timezone offset from UTC (i.e. -0700)
Returns:
str: Offset from UTC
CLI Example:
.. code-block:: bash
salt '*' timezone.get_offset | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L226-L244 | [
"def get_zone():\n '''\n Get current timezone (i.e. America/Denver)\n\n Returns:\n str: Timezone in unix format\n\n Raises:\n CommandExecutionError: If timezone could not be gathered\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' timezone.get_zone\n '''\n cmd = [... | # -*- coding: utf-8 -*-
'''
Module for managing timezone on Windows systems.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import logging
from datetime import datetime
# Import Salt libs
from salt.exceptions import CommandExecutionError
# Import 3rd party libs
try:... |
saltstack/salt | salt/modules/win_timezone.py | get_zonecode | python | def get_zonecode():
'''
Get current timezone (i.e. PST, MDT, etc)
Returns:
str: An abbreviated timezone code
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zonecode
'''
tz_object = pytz.timezone(get_zone())
loc_time = tz_object.localize(datetime.utcnow())
... | Get current timezone (i.e. PST, MDT, etc)
Returns:
str: An abbreviated timezone code
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zonecode | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L247-L262 | [
"def get_zone():\n '''\n Get current timezone (i.e. America/Denver)\n\n Returns:\n str: Timezone in unix format\n\n Raises:\n CommandExecutionError: If timezone could not be gathered\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' timezone.get_zone\n '''\n cmd = [... | # -*- coding: utf-8 -*-
'''
Module for managing timezone on Windows systems.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import logging
from datetime import datetime
# Import Salt libs
from salt.exceptions import CommandExecutionError
# Import 3rd party libs
try:... |
saltstack/salt | salt/modules/win_timezone.py | set_zone | python | def set_zone(timezone):
'''
Sets the timezone using the tzutil.
Args:
timezone (str): A valid timezone
Returns:
bool: ``True`` if successful, otherwise ``False``
Raises:
CommandExecutionError: If invalid timezone is passed
CLI Example:
.. code-block:: bash
... | Sets the timezone using the tzutil.
Args:
timezone (str): A valid timezone
Returns:
bool: ``True`` if successful, otherwise ``False``
Raises:
CommandExecutionError: If invalid timezone is passed
CLI Example:
.. code-block:: bash
salt '*' timezone.set_zone 'Ameri... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L265-L303 | [
"def zone_compare(timezone):\n '''\n Compares the given timezone with the machine timezone. Mostly useful for\n running state checks.\n\n Args:\n timezone (str):\n The timezone to compare. This can be in Windows or Unix format. Can\n be any of the values returned by the ``ti... | # -*- coding: utf-8 -*-
'''
Module for managing timezone on Windows systems.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import logging
from datetime import datetime
# Import Salt libs
from salt.exceptions import CommandExecutionError
# Import 3rd party libs
try:... |
saltstack/salt | salt/modules/win_timezone.py | zone_compare | python | def zone_compare(timezone):
'''
Compares the given timezone with the machine timezone. Mostly useful for
running state checks.
Args:
timezone (str):
The timezone to compare. This can be in Windows or Unix format. Can
be any of the values returned by the ``timezone.list``... | Compares the given timezone with the machine timezone. Mostly useful for
running state checks.
Args:
timezone (str):
The timezone to compare. This can be in Windows or Unix format. Can
be any of the values returned by the ``timezone.list`` function
Returns:
bool: ``... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L306-L338 | [
"def get_zone():\n '''\n Get current timezone (i.e. America/Denver)\n\n Returns:\n str: Timezone in unix format\n\n Raises:\n CommandExecutionError: If timezone could not be gathered\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' timezone.get_zone\n '''\n cmd = [... | # -*- coding: utf-8 -*-
'''
Module for managing timezone on Windows systems.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import logging
from datetime import datetime
# Import Salt libs
from salt.exceptions import CommandExecutionError
# Import 3rd party libs
try:... |
saltstack/salt | salt/states/win_license.py | activate | python | def activate(name):
'''
Install and activate the given product key
name
The 5x5 product key given to you by Microsoft
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
product_key = name
license_info = __salt__['license.info']... | Install and activate the given product key
name
The 5x5 product key given to you by Microsoft | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_license.py#L33-L71 | null | # -*- coding: utf-8 -*-
'''
Installation and activation of windows licenses
===============================================
Install and activate windows licenses
.. code-block:: yaml
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX:
license.activate
'''
# Import Python libs
from __future__ import absolute_import, unicode_lit... |
saltstack/salt | salt/states/quota.py | mode | python | def mode(name, mode, quotatype):
'''
Set the quota for the system
name
The filesystem to set the quota mode on
mode
Whether the quota system is on or off
quotatype
Must be ``user`` or ``group``
'''
ret = {'name': name,
'changes': {},
'result':... | Set the quota for the system
name
The filesystem to set the quota mode on
mode
Whether the quota system is on or off
quotatype
Must be ``user`` or ``group`` | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/quota.py#L26-L62 | null | # -*- coding: utf-8 -*-
'''
Management of POSIX Quotas
==========================
The quota can be managed for the system:
.. code-block:: yaml
/:
quota.mode:
mode: off
quotatype: user
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
def __... |
saltstack/salt | salt/modules/quota.py | report | python | def report(mount):
'''
Report on quotas for a specific volume
CLI Example:
.. code-block:: bash
salt '*' quota.report /media/data
'''
ret = {mount: {}}
ret[mount]['User Quotas'] = _parse_quota(mount, '-u')
ret[mount]['Group Quotas'] = _parse_quota(mount, '-g')
return ret | Report on quotas for a specific volume
CLI Example:
.. code-block:: bash
salt '*' quota.report /media/data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L38-L51 | [
"def _parse_quota(mount, opts):\n '''\n Parse the output from repquota. Requires that -u -g are passed in\n '''\n cmd = 'repquota -vp {0} {1}'.format(opts, mount)\n out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()\n mode = 'header'\n\n if '-u' in opts:\n quotatype = 'Users... | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | _parse_quota | python | def _parse_quota(mount, opts):
'''
Parse the output from repquota. Requires that -u -g are passed in
'''
cmd = 'repquota -vp {0} {1}'.format(opts, mount)
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
mode = 'header'
if '-u' in opts:
quotatype = 'Users'
elif '-g... | Parse the output from repquota. Requires that -u -g are passed in | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L54-L94 | null | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | set_ | python | def set_(device, **kwargs):
'''
Calls out to setquota, for a specific user or group
CLI Example:
.. code-block:: bash
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
salt '*' quota.set /media/data group=painters file-hard-limit=1000
'''
empty = {'block-soft-... | Calls out to setquota, for a specific user or group
CLI Example:
.. code-block:: bash
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
salt '*' quota.set /media/data group=painters file-hard-limit=1000 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L97-L155 | [
"def _parse_quota(mount, opts):\n '''\n Parse the output from repquota. Requires that -u -g are passed in\n '''\n cmd = 'repquota -vp {0} {1}'.format(opts, mount)\n out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()\n mode = 'header'\n\n if '-u' in opts:\n quotatype = 'Users... | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | stats | python | def stats():
'''
Runs the quotastats command, and returns the parsed output
CLI Example:
.. code-block:: bash
salt '*' quota.stats
'''
ret = {}
out = __salt__['cmd.run']('quotastats').splitlines()
for line in out:
if not line:
continue
comps = line.... | Runs the quotastats command, and returns the parsed output
CLI Example:
.. code-block:: bash
salt '*' quota.stats | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L172-L190 | null | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | on | python | def on(device):
'''
Turns on the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.on
'''
cmd = 'quotaon {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | Turns on the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.on | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L193-L205 | null | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | off | python | def off(device):
'''
Turns off the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.off
'''
cmd = 'quotaoff {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | Turns off the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.off | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L208-L220 | null | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/modules/quota.py | get_mode | python | def get_mode(device):
'''
Report whether the quota system for this device is on or off
CLI Example:
.. code-block:: bash
salt '*' quota.get_mode
'''
ret = {}
cmd = 'quotaon -p {0}'.format(device)
out = __salt__['cmd.run'](cmd, python_shell=False)
for line in out.splitlines... | Report whether the quota system for this device is on or off
CLI Example:
.. code-block:: bash
salt '*' quota.get_mode | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L223-L251 | null | # -*- coding: utf-8 -*-
'''
Module for managing quotas on POSIX-like systems.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
# Import salt libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInv... |
saltstack/salt | salt/states/pagerduty_user.py | present | python | def present(profile='pagerduty', subdomain=None, api_key=None, **kwargs):
'''
Ensure pagerduty user exists.
Arguments match those supported by
https://developer.pagerduty.com/documentation/rest/users/create.
'''
return __salt__['pagerduty_util.resource_present']('users',
... | Ensure pagerduty user exists.
Arguments match those supported by
https://developer.pagerduty.com/documentation/rest/users/create. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pagerduty_user.py#L28-L40 | null | # -*- coding: utf-8 -*-
'''
Manage PagerDuty users.
Example:
.. code-block:: yaml
ensure bruce test user 1:
pagerduty.user_present:
- name: 'Bruce TestUser1'
- email: bruce+test1@lyft.com
- requester_id: P1GV5NT
'''
# Import Python libs
from __future__ import abs... |
saltstack/salt | salt/modules/rsync.py | _check | python | def _check(delete, force, update, passwordfile, exclude, excludefrom, dryrun, rsh):
'''
Generate rsync options
'''
options = ['-avz']
if delete:
options.append('--delete')
if force:
options.append('--force')
if update:
options.append('--update')
if rsh:
o... | Generate rsync options | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L38-L66 | null | # -*- coding: utf-8 -*-
'''
Wrapper for rsync
.. versionadded:: 2014.1.0
This data can also be passed into :ref:`pillar <pillar-walk-through>`.
Options passed into opts will overwrite options passed into pillar.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import ... |
saltstack/salt | salt/modules/rsync.py | rsync | python | def rsync(src,
dst,
delete=False,
force=False,
update=False,
passwordfile=None,
exclude=None,
excludefrom=None,
dryrun=False,
rsh=None,
additional_opts=None,
saltenv='base'):
'''
.. versionchanged:: 201... | .. versionchanged:: 2016.3.0
Return data now contains just the output of the rsync command, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Rsync files from src to dst
src
The source location where files will be rsynced from.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L69-L219 | [
"def mkstemp(*args, **kwargs):\n '''\n Helper function which does exactly what ``tempfile.mkstemp()`` does but\n accepts another argument, ``close_fd``, which, by default, is true and closes\n the fd before returning the file path. Something commonly done throughout\n Salt's code.\n '''\n if 'p... | # -*- coding: utf-8 -*-
'''
Wrapper for rsync
.. versionadded:: 2014.1.0
This data can also be passed into :ref:`pillar <pillar-walk-through>`.
Options passed into opts will overwrite options passed into pillar.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import ... |
saltstack/salt | salt/modules/rsync.py | version | python | def version():
'''
.. versionchanged:: 2016.3.0
Return data now contains just the version number as a string, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns rsync version
CLI Example:
.. code-block:: bash
sal... | .. versionchanged:: 2016.3.0
Return data now contains just the version number as a string, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns rsync version
CLI Example:
.. code-block:: bash
salt '*' rsync.version | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L222-L246 | null | # -*- coding: utf-8 -*-
'''
Wrapper for rsync
.. versionadded:: 2014.1.0
This data can also be passed into :ref:`pillar <pillar-walk-through>`.
Options passed into opts will overwrite options passed into pillar.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import ... |
saltstack/salt | salt/modules/rsync.py | config | python | def config(conf_path='/etc/rsyncd.conf'):
'''
.. versionchanged:: 2016.3.0
Return data now contains just the contents of the rsyncd.conf as a
string, instead of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns the contents of the rsync conf... | .. versionchanged:: 2016.3.0
Return data now contains just the contents of the rsyncd.conf as a
string, instead of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns the contents of the rsync config file
conf_path : /etc/rsyncd.conf
Path... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L249-L288 | [
"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 -*-
'''
Wrapper for rsync
.. versionadded:: 2014.1.0
This data can also be passed into :ref:`pillar <pillar-walk-through>`.
Options passed into opts will overwrite options passed into pillar.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import ... |
saltstack/salt | salt/states/keystone_role.py | present | python | def present(name, auth=None, **kwargs):
'''
Ensure an role exists
name
Name of the role
description
An arbitrary description of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
kwargs = __utils__['args.clean_k... | Ensure an role exists
name
Name of the role
description
An arbitrary description of the role | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_role.py#L40-L75 | null | # -*- coding: utf-8 -*-
'''
Management of OpenStack Keystone Roles
======================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create role:
keystone_role.present:
... |
saltstack/salt | salt/states/keystone_role.py | absent | python | def absent(name, auth=None, **kwargs):
'''
Ensure role does not exist
name
Name of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
__salt__['keystoneng.setup_clouds'](auth)
kwargs['name'] = name
role = __salt__['... | Ensure role does not exist
name
Name of the role | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_role.py#L78-L106 | null | # -*- coding: utf-8 -*-
'''
Management of OpenStack Keystone Roles
======================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create role:
keystone_role.present:
... |
saltstack/salt | salt/modules/mac_assistive.py | install | python | def install(app_id, enable=True):
'''
Install a bundle ID or command as being allowed to use
assistive access.
app_id
The bundle ID or command to install for assistive access.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
... | Install a bundle ID or command as being allowed to use
assistive access.
app_id
The bundle ID or command to install for assistive access.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' assistive.install /usr/bin/o... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L39-L78 | [
"def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e... | # -*- coding: utf-8 -*-
'''
This module allows you to manage assistive access on macOS minions with 10.9+
.. versionadded:: 2016.3.0
.. code-block:: bash
salt '*' assistive.install /usr/bin/osascript
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
impo... |
saltstack/salt | salt/modules/mac_assistive.py | enable | python | def enable(app_id, enabled=True):
'''
Enable or disable an existing assistive access application.
app_id
The bundle ID or command to set assistive access status.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' ... | Enable or disable an existing assistive access application.
app_id
The bundle ID or command to set assistive access status.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' assistive.enable /usr/bin/osascript
sa... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L103-L143 | [
"def _get_assistive_access():\n '''\n Get a list of all of the assistive access applications installed,\n returns as a ternary showing whether each app is enabled or not.\n '''\n cmd = 'sqlite3 \"/Library/Application Support/com.apple.TCC/TCC.db\" \"SELECT * FROM access\"'\n call = __salt__['cmd.r... | # -*- coding: utf-8 -*-
'''
This module allows you to manage assistive access on macOS minions with 10.9+
.. versionadded:: 2016.3.0
.. code-block:: bash
salt '*' assistive.install /usr/bin/osascript
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
impo... |
saltstack/salt | salt/modules/mac_assistive.py | remove | python | def remove(app_id):
'''
Remove a bundle ID or command as being allowed to use assistive access.
app_id
The bundle ID or command to remove from assistive access list.
CLI Example:
.. code-block:: bash
salt '*' assistive.remove /usr/bin/osascript
salt '*' assistive.remove c... | Remove a bundle ID or command as being allowed to use assistive access.
app_id
The bundle ID or command to remove from assistive access list.
CLI Example:
.. code-block:: bash
salt '*' assistive.remove /usr/bin/osascript
salt '*' assistive.remove com.smileonmymac.textexpander | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L168-L199 | null | # -*- coding: utf-8 -*-
'''
This module allows you to manage assistive access on macOS minions with 10.9+
.. versionadded:: 2016.3.0
.. code-block:: bash
salt '*' assistive.install /usr/bin/osascript
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
impo... |
saltstack/salt | salt/modules/mac_assistive.py | _get_assistive_access | python | def _get_assistive_access():
'''
Get a list of all of the assistive access applications installed,
returns as a ternary showing whether each app is enabled or not.
'''
cmd = 'sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT * FROM access"'
call = __salt__['cmd.run_all'](
... | Get a list of all of the assistive access applications installed,
returns as a ternary showing whether each app is enabled or not. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L210-L232 | null | # -*- coding: utf-8 -*-
'''
This module allows you to manage assistive access on macOS minions with 10.9+
.. versionadded:: 2016.3.0
.. code-block:: bash
salt '*' assistive.install /usr/bin/osascript
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
impo... |
saltstack/salt | salt/serializers/yaml.py | deserialize | python | def deserialize(stream_or_string, **options):
'''
Deserialize any string of stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower yaml module.
'''
options.setdefault('Loader', Loader)
try:
r... | Deserialize any string of stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower yaml module. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/yaml.py#L41-L64 | null | # -*- coding: utf-8 -*-
'''
salt.serializers.yaml
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Implements YAML serializer.
Underneath, it is based on pyyaml and use the safe dumper and loader.
It also use C bindings if they are available.
'''
from __future__ import absolute_import, print_function, unicode_literal... |
saltstack/salt | salt/serializers/yaml.py | serialize | python | def serialize(obj, **options):
'''
Serialize Python data to YAML.
:param obj: the data structure to serialize
:param options: options given to lower yaml module.
'''
options.setdefault('Dumper', Dumper)
try:
response = yaml.dump(obj, **options)
if response.endswith('\n...\n... | Serialize Python data to YAML.
:param obj: the data structure to serialize
:param options: options given to lower yaml module. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/yaml.py#L67-L85 | null | # -*- coding: utf-8 -*-
'''
salt.serializers.yaml
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Implements YAML serializer.
Underneath, it is based on pyyaml and use the safe dumper and loader.
It also use C bindings if they are available.
'''
from __future__ import absolute_import, print_function, unicode_literal... |
saltstack/salt | salt/modules/win_certutil.py | get_cert_serial | python | def get_cert_serial(cert_file):
'''
Get the serial number of a certificate file
cert_file
The certificate file to find the serial for
CLI Example:
.. code-block:: bash
salt '*' certutil.get_cert_serial <certificate name>
'''
cmd = "certutil.exe -silent -verify {0}".format... | Get the serial number of a certificate file
cert_file
The certificate file to find the serial for
CLI Example:
.. code-block:: bash
salt '*' certutil.get_cert_serial <certificate name> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L32-L52 | null | # -*- coding: utf-8 -*-
'''
This module allows you to install certificates into the windows certificate
manager.
.. code-block:: bash
salt '*' certutil.add_store salt://cert.cer "TrustedPublisher"
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
import l... |
saltstack/salt | salt/modules/win_certutil.py | get_stored_cert_serials | python | def get_stored_cert_serials(store):
'''
Get all of the certificate serials in the specified store
store
The store to get all the certificate serials from
CLI Example:
.. code-block:: bash
salt '*' certutil.get_stored_cert_serials <store>
'''
cmd = "certutil.exe -store {0}... | Get all of the certificate serials in the specified store
store
The store to get all the certificate serials from
CLI Example:
.. code-block:: bash
salt '*' certutil.get_stored_cert_serials <store> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L55-L72 | null | # -*- coding: utf-8 -*-
'''
This module allows you to install certificates into the windows certificate
manager.
.. code-block:: bash
salt '*' certutil.add_store salt://cert.cer "TrustedPublisher"
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
import l... |
saltstack/salt | salt/modules/win_certutil.py | add_store | python | def add_store(source, store, saltenv='base'):
'''
Add the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to add the certificate to
saltenv
The salt environment t... | Add the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to add the certificate to
saltenv
The salt environment to use this is ignored if the path
is local
CL... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L75-L98 | null | # -*- coding: utf-8 -*-
'''
This module allows you to install certificates into the windows certificate
manager.
.. code-block:: bash
salt '*' certutil.add_store salt://cert.cer "TrustedPublisher"
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
import l... |
saltstack/salt | salt/modules/win_certutil.py | del_store | python | def del_store(source, store, saltenv='base'):
'''
Delete the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to delete the certificate from
saltenv
The salt envir... | Delete the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to delete the certificate from
saltenv
The salt environment to use this is ignored if the path
is local... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L101-L125 | [
"def get_cert_serial(cert_file):\n '''\n Get the serial number of a certificate file\n\n cert_file\n The certificate file to find the serial for\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' certutil.get_cert_serial <certificate name>\n '''\n cmd = \"certutil.exe -silent ... | # -*- coding: utf-8 -*-
'''
This module allows you to install certificates into the windows certificate
manager.
.. code-block:: bash
salt '*' certutil.add_store salt://cert.cer "TrustedPublisher"
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import re
import l... |
saltstack/salt | salt/states/ddns.py | present | python | def present(name, zone, ttl, data, rdtype='A', **kwargs):
'''
Ensures that the named DNS record is present with the given ttl.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so... | Ensures that the named DNS record is present with the given ttl.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arg... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ddns.py#L35-L91 | null | # -*- coding: utf-8 -*-
'''
Dynamic DNS updates
===================
Ensure a DNS record is present or absent utilizing RFC 2136
type dynamic updates.
:depends: - `dnspython <http://www.dnspython.org/>`_
.. note::
The ``dnspython`` module is required when managing DDNS using a TSIG key.
If you are not using a... |
saltstack/salt | salt/states/ddns.py | absent | python | def absent(name, zone, data=None, rdtype=None, **kwargs):
'''
Ensures that the named DNS record is absent.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that info... | Ensures that the named DNS record is absent.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arguments.
zone
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ddns.py#L94-L145 | null | # -*- coding: utf-8 -*-
'''
Dynamic DNS updates
===================
Ensure a DNS record is present or absent utilizing RFC 2136
type dynamic updates.
:depends: - `dnspython <http://www.dnspython.org/>`_
.. note::
The ``dnspython`` module is required when managing DDNS using a TSIG key.
If you are not using a... |
saltstack/salt | salt/renderers/json.py | render | python | def render(json_data, saltenv='base', sls='', **kws):
'''
Accepts JSON as a string or as a file object and runs it through the JSON
parser.
:rtype: A Python data structure
'''
if not isinstance(json_data, six.string_types):
json_data = json_data.read()
if json_data.startswith('#!')... | Accepts JSON as a string or as a file object and runs it through the JSON
parser.
:rtype: A Python data structure | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/json.py#L16-L30 | null | # -*- coding: utf-8 -*-
'''
JSON Renderer for Salt
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import salt.utils.json
json = salt.utils.json.import_json()
# Import salt libs
from salt.ext import six
|
saltstack/salt | salt/modules/at.py | _cmd | python | def _cmd(binary, *args):
'''
Wrapper to run at(1) or return None.
'''
binary = salt.utils.path.which(binary)
if not binary:
raise CommandNotFoundError('{0}: command not found'.format(binary))
cmd = [binary] + list(args)
return __salt__['cmd.run_stdout']([binary] + list(args),
... | Wrapper to run at(1) or return None. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L51-L60 | null | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/modules/at.py | atq | python | def atq(tag=None):
'''
List all queued and running jobs or only those with
an optional 'tag'.
CLI Example:
.. code-block:: bash
salt '*' at.atq
salt '*' at.atq [tag]
salt '*' at.atq [job number]
'''
jobs = []
# Shim to produce output similar to what __virtual_... | List all queued and running jobs or only those with
an optional 'tag'.
CLI Example:
.. code-block:: bash
salt '*' at.atq
salt '*' at.atq [tag]
salt '*' at.atq [job number] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L63-L163 | [
"def _cmd(binary, *args):\n '''\n Wrapper to run at(1) or return None.\n '''\n binary = salt.utils.path.which(binary)\n if not binary:\n raise CommandNotFoundError('{0}: command not found'.format(binary))\n cmd = [binary] + list(args)\n return __salt__['cmd.run_stdout']([binary] + list(a... | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/modules/at.py | atrm | python | def atrm(*args):
'''
Remove jobs from the queue.
CLI Example:
.. code-block:: bash
salt '*' at.atrm <jobid> <jobid> .. <jobid>
salt '*' at.atrm all
salt '*' at.atrm all [tag]
'''
# Need to do this here also since we use atq()
if not salt.utils.path.which('at'):
... | Remove jobs from the queue.
CLI Example:
.. code-block:: bash
salt '*' at.atrm <jobid> <jobid> .. <jobid>
salt '*' at.atrm all
salt '*' at.atrm all [tag] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L166-L207 | [
"def _cmd(binary, *args):\n '''\n Wrapper to run at(1) or return None.\n '''\n binary = salt.utils.path.which(binary)\n if not binary:\n raise CommandNotFoundError('{0}: command not found'.format(binary))\n cmd = [binary] + list(args)\n return __salt__['cmd.run_stdout']([binary] + list(a... | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/modules/at.py | at | python | def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' ... | Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscri... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L210-L263 | [
"def atq(tag=None):\n '''\n List all queued and running jobs or only those with\n an optional 'tag'.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' at.atq\n salt '*' at.atq [tag]\n salt '*' at.atq [job number]\n '''\n jobs = []\n\n # Shim to produce output simila... | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/modules/at.py | atc | python | def atc(jobid):
'''
Print the at(1) script that will run for the passed job
id. This is mostly for debugging so the output will
just be text.
CLI Example:
.. code-block:: bash
salt '*' at.atc <jobid>
'''
# Shim to produce output similar to what __virtual__() should do
# bu... | Print the at(1) script that will run for the passed job
id. This is mostly for debugging so the output will
just be text.
CLI Example:
.. code-block:: bash
salt '*' at.atc <jobid> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L266-L287 | [
"def _cmd(binary, *args):\n '''\n Wrapper to run at(1) or return None.\n '''\n binary = salt.utils.path.which(binary)\n if not binary:\n raise CommandNotFoundError('{0}: command not found'.format(binary))\n cmd = [binary] + list(args)\n return __salt__['cmd.run_stdout']([binary] + list(a... | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/modules/at.py | _atq | python | def _atq(**kwargs):
'''
Return match jobs list
'''
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get... | Return match jobs list | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L290-L368 | [
"def atq(tag=None):\n '''\n List all queued and running jobs or only those with\n an optional 'tag'.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' at.atq\n salt '*' at.atq [tag]\n salt '*' at.atq [job number]\n '''\n jobs = []\n\n # Shim to produce output simila... | # -*- coding: utf-8 -*-
'''
Wrapper module for at(1)
Also, a 'tag' feature has been added to more
easily tag jobs.
:platform: linux,openbsd,freebsd
.. versionchanged:: 2017.7.0
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import re
import time
import datetim... |
saltstack/salt | salt/cli/support/__init__.py | _render_profile | python | def _render_profile(path, caller, runner):
'''
Render profile as Jinja2.
:param path:
:return:
'''
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)
return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner).strip() | Render profile as Jinja2.
:param path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L15-L22 | null | # coding=utf-8
'''
Get default scenario of the support.
'''
from __future__ import print_function, unicode_literals, absolute_import
import yaml
import os
import salt.exceptions
import jinja2
import logging
log = logging.getLogger(__name__)
def get_profile(profile, caller, runner):
'''
Get profile.
:pa... |
saltstack/salt | salt/cli/support/__init__.py | get_profile | python | def get_profile(profile, caller, runner):
'''
Get profile.
:param profile:
:return:
'''
profiles = profile.split(',')
data = {}
for profile in profiles:
if os.path.basename(profile) == profile:
profile = profile.split('.')[0] # Trim extension if someone added it
... | Get profile.
:param profile:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L25-L52 | [
"def _render_profile(path, caller, runner):\n '''\n Render profile as Jinja2.\n :param path:\n :return:\n '''\n env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)\n return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner... | # coding=utf-8
'''
Get default scenario of the support.
'''
from __future__ import print_function, unicode_literals, absolute_import
import yaml
import os
import salt.exceptions
import jinja2
import logging
log = logging.getLogger(__name__)
def _render_profile(path, caller, runner):
'''
Render profile as Jin... |
saltstack/salt | salt/cli/support/__init__.py | get_profiles | python | def get_profiles(config):
'''
Get available profiles.
:return:
'''
profiles = []
for profile_name in os.listdir(os.path.join(os.path.dirname(__file__), 'profiles')):
if profile_name.endswith('.yml'):
profiles.append(profile_name.split('.')[0])
return sorted(profiles) | Get available profiles.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L55-L66 | null | # coding=utf-8
'''
Get default scenario of the support.
'''
from __future__ import print_function, unicode_literals, absolute_import
import yaml
import os
import salt.exceptions
import jinja2
import logging
log = logging.getLogger(__name__)
def _render_profile(path, caller, runner):
'''
Render profile as Jin... |
saltstack/salt | salt/utils/user.py | get_user | python | def get_user():
'''
Get the current user
'''
if HAS_PWD:
ret = pwd.getpwuid(os.geteuid()).pw_name
elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:
ret = salt.utils.win_functions.get_current_user()
else:
raise CommandExecutionError(
'Required exte... | Get the current user | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L54-L65 | [
"def to_unicode(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str or unicode, return unicode (str for python 3)\n '''\n def _normalize(s):\n return unicodedata.normalize('NFC', s) if normalize else s\n\n if encoding is None:\n # Try utf-8 first, and fall back to det... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_uid | python | def get_uid(user=None):
'''
Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned.
'''
if not HAS_PWD:
return None
elif user i... | Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L69-L86 | null | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | _win_user_token_is_admin | python | def _win_user_token_is_admin(user_token):
'''
Using the win32 api, determine if the user with token 'user_token' has
administrator rights.
See MSDN entry here:
http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx
'''
class SID_IDENTIFIER_AUTHORITY(ctypes.Structure):
_fie... | Using the win32 api, determine if the user with token 'user_token' has
administrator rights.
See MSDN entry here:
http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L89-L131 | null | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_specific_user | python | def get_specific_user():
'''
Get a user name for publishing. If you find the user is "root" attempt to be
more specific
'''
user = get_user()
if salt.utils.platform.is_windows():
if _win_current_user_is_admin():
return 'sudo_{0}'.format(user)
else:
env_vars = ('SU... | Get a user name for publishing. If you find the user is "root" attempt to be
more specific | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L142-L157 | [
"def get_user():\n '''\n Get the current user\n '''\n if HAS_PWD:\n ret = pwd.getpwuid(os.geteuid()).pw_name\n elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:\n ret = salt.utils.win_functions.get_current_user()\n else:\n raise CommandExecutionError(\n ... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | chugid | python | def chugid(runas, group=None):
'''
Change the current process to belong to the specified user (and the groups
to which it belongs)
'''
uinfo = pwd.getpwnam(runas)
supgroups = []
supgroups_seen = set()
if group:
try:
target_pw_gid = grp.getgrnam(group).gr_gid
... | Change the current process to belong to the specified user (and the groups
to which it belongs) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L160-L229 | [
"def get_group_dict(user=None, include_default=True):\n '''\n Returns a dict of all of the system groups as keys, and group ids\n as values, of which the user is a member.\n E.g.: {'staff': 501, 'sudo': 27}\n '''\n if HAS_GRP is False or HAS_PWD is False:\n return {}\n group_dict = {}\n ... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | chugid_and_umask | python | def chugid_and_umask(runas, umask, group=None):
'''
Helper method for for subprocess.Popen to initialise uid/gid and umask
for the new process.
'''
set_runas = False
set_grp = False
current_user = getpass.getuser()
if runas and runas != current_user:
set_runas = True
run... | Helper method for for subprocess.Popen to initialise uid/gid and umask
for the new process. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L232-L257 | [
"def chugid(runas, group=None):\n '''\n Change the current process to belong to the specified user (and the groups\n to which it belongs)\n '''\n uinfo = pwd.getpwnam(runas)\n supgroups = []\n supgroups_seen = set()\n\n if group:\n try:\n target_pw_gid = grp.getgrnam(group)... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_default_group | python | def get_default_group(user):
'''
Returns the specified user's default group. If the user doesn't exist, a
KeyError will be raised.
'''
return grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name \
if HAS_GRP and HAS_PWD \
else None | Returns the specified user's default group. If the user doesn't exist, a
KeyError will be raised. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L260-L267 | null | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_group_list | python | def get_group_list(user, include_default=True):
'''
Returns a list of all of the system group names of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
group_names = None
ugroups = set()
if hasattr(os, 'getgrouplist'):
# Try os.getgroupli... | Returns a list of all of the system group names of which the user
is a member. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L270-L326 | [
"def get_default_group(user):\n '''\n Returns the specified user's default group. If the user doesn't exist, a\n KeyError will be raised.\n '''\n return grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name \\\n if HAS_GRP and HAS_PWD \\\n else None\n"
] | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_group_dict | python | def get_group_dict(user=None, include_default=True):
'''
Returns a dict of all of the system groups as keys, and group ids
as values, of which the user is a member.
E.g.: {'staff': 501, 'sudo': 27}
'''
if HAS_GRP is False or HAS_PWD is False:
return {}
group_dict = {}
group_names... | Returns a dict of all of the system groups as keys, and group ids
as values, of which the user is a member.
E.g.: {'staff': 501, 'sudo': 27} | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L329-L341 | [
"def get_group_list(user, include_default=True):\n '''\n Returns a list of all of the system group names of which the user\n is a member.\n '''\n if HAS_GRP is False or HAS_PWD is False:\n return []\n group_names = None\n ugroups = set()\n if hasattr(os, 'getgrouplist'):\n # Tr... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_gid_list | python | def get_gid_list(user, include_default=True):
'''
Returns a list of all of the system group IDs of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
gid_list = list(
six.itervalues(
get_group_dict(user, include_default=include_default)... | Returns a list of all of the system group IDs of which the user
is a member. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L344-L356 | [
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def get_group_dict(user=None, include_default=True):\n '''\n Returns a dict of all of the system groups as keys, and group ids\n as values, of which the user is a member.\n E.g.: {'staff': 501, 'sudo': 27}\n '''\n if HAS_GRP is False ... | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/utils/user.py | get_gid | python | def get_gid(group=None):
'''
Get the gid for a given group name. If no group given, the current egid
will be returned. If the group does not exist, None will be returned. On
systems which do not support grp or os.getegid it will return None.
'''
if not HAS_GRP:
return None
if group i... | Get the gid for a given group name. If no group given, the current egid
will be returned. If the group does not exist, None will be returned. On
systems which do not support grp or os.getegid it will return None. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L359-L376 | null | # -*- coding: utf-8 -*-
'''
Functions for querying and modifying a user account and the groups to which it
belongs.
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
import ctypes
import getpass
import logging
import os
import sys
# Import Salt libs
import salt.utils.p... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | html_override_tool | python | def html_override_tool():
'''
Bypass the normal handler and serve HTML for all URLs
The ``app_path`` setting must be non-empty and the request must ask for
``text/html`` in the ``Accept`` header.
'''
apiopts = cherrypy.config['apiopts']
request = cherrypy.request
url_blacklist = (
... | Bypass the normal handler and serve HTML for all URLs
The ``app_path`` setting must be non-empty and the request must ask for
``text/html`` in the ``Accept`` header. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L649-L681 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_token_tool | python | def salt_token_tool():
'''
If the custom authentication header is supplied, put it in the cookie dict
so the rest of the session-based auth works as intended
'''
x_auth = cherrypy.request.headers.get('X-Auth-Token', None)
# X-Auth-Token header trumps session cookie
if x_auth:
cherry... | If the custom authentication header is supplied, put it in the cookie dict
so the rest of the session-based auth works as intended | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L684-L693 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_api_acl_tool | python | def salt_api_acl_tool(username, request):
'''
..versionadded:: 2016.3.0
Verifies user requests against the API whitelist. (User/IP pair)
in order to provide whitelisting for the API similar to the
master, but over the API.
..code-block:: yaml
rest_cherrypy:
api_acl:
... | ..versionadded:: 2016.3.0
Verifies user requests against the API whitelist. (User/IP pair)
in order to provide whitelisting for the API similar to the
master, but over the API.
..code-block:: yaml
rest_cherrypy:
api_acl:
users:
'*':
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L696-L762 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_ip_verify_tool | python | def salt_ip_verify_tool():
'''
If there is a list of restricted IPs, verify current
client is coming from one of those IPs.
'''
# This is overly cumbersome and crude,
# But, it's also safe... ish...
salt_config = cherrypy.config.get('saltopts', None)
if salt_config:
cherrypy_conf... | If there is a list of restricted IPs, verify current
client is coming from one of those IPs. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L765-L783 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | cors_tool | python | def cors_tool():
'''
Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight
request swap out the default handler with a simple, single-purpose handler
that verifies the request and provides a valid CORS response.
'''
req_head = che... | Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight
request swap out the default handler with a simple, single-purpose handler
that verifies the request and provides a valid CORS response. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L798-L840 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_handler | python | def hypermedia_handler(*args, **kwargs):
'''
Determine the best output format based on the Accept header, execute the
regular handler, and transform the output to the request content type (even
if it's an error).
:param args: Pass args through to the main handler
:param kwargs: Pass kwargs thro... | Determine the best output format based on the Accept header, execute the
regular handler, and transform the output to the request content type (even
if it's an error).
:param args: Pass args through to the main handler
:param kwargs: Pass kwargs through to the main handler | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L853-L918 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_out | python | def hypermedia_out():
'''
Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the
requested content type
'''
request = cherrypy.serving.request
request._hypermedia_inner_handler = request.handler
# If handler... | Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the
requested content type | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L921-L933 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | process_request_body | python | def process_request_body(fn):
'''
A decorator to skip a processor function if process_request_body is False
'''
@functools.wraps(fn)
def wrapped(*args, **kwargs): # pylint: disable=C0111
if cherrypy.request.process_request_body is not False:
fn(*args, **kwargs)
return wrappe... | A decorator to skip a processor function if process_request_body is False | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L936-L944 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | urlencoded_processor | python | def urlencoded_processor(entity):
'''
Accept x-www-form-urlencoded data (run through CherryPy's formatter)
and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with
key-value pairs, any more complicated requirements (e.g. compound
commands... | Accept x-www-form-urlencoded data (run through CherryPy's formatter)
and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with
key-value pairs, any more complicated requirements (e.g. compound
commands) must instead be delivered via JSON or YAML.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L947-L969 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | json_processor | python | def json_processor(entity):
'''
Unserialize raw POST data in JSON format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | Unserialize raw POST data in JSON format to a Python data structure.
:param entity: raw POST data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L973-L993 | [
"def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_... | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | yaml_processor | python | def yaml_processor(entity):
'''
Unserialize raw POST data in YAML format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | Unserialize raw POST data in YAML format to a Python data structure.
:param entity: raw POST data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L997-L1016 | [
"def safe_load(stream, Loader=SaltYamlSafeLoader):\n '''\n .. versionadded:: 2018.3.0\n\n Helper function which automagically uses our custom loader.\n '''\n return yaml.load(stream, Loader=Loader)\n"
] | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_in | python | def hypermedia_in():
'''
Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data
and will place that data structure into the request object.
:raises HTTPError: if the request contains a Content-Type that we do not
hav... | Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data
and will place that data structure into the request object.
:raises HTTPError: if the request contains a Content-Type that we do not
have a processor for | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1045-L1074 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | lowdata_fmt | python | def lowdata_fmt():
'''
Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run.
'''
if cherrypy.request.method.upper() != 'POST':
return
data = cherrypy.request.unserialized_data
# if the data was sen... | Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1077-L1100 | null | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | get_app | python | def get_app(opts):
'''
Returns a WSGI app and a configuration dictionary
'''
apiopts = opts.get(__name__.rsplit('.', 2)[-2], {}) # rest_cherrypy opts
# Add Salt and salt-api config options to the main CherryPy config dict
cherrypy.config['saltopts'] = opts
cherrypy.config['apiopts'] = apio... | Returns a WSGI app and a configuration dictionary | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2927-L2940 | [
"def get_conf(self):\n '''\n Combine the CherryPy configuration with the rest_cherrypy config values\n pulled from the master config and return the CherryPy configuration\n '''\n conf = {\n 'global': {\n 'server.socket_host': self.apiopts.get('host', '0.0.0.0'),\n 'server... | # encoding: utf-8
'''
A REST API for Salt
===================
.. py:currentmodule:: salt.netapi.rest_cherrypy.app
.. note::
This module is Experimental on Windows platforms, and supports limited
configurations:
- doesn't support PAM authentication (i.e. external_auth: auto)
- doesn't support SSL (i.... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | LowDataAdapter.exec_lowstate | python | def exec_lowstate(self, client=None, token=None):
'''
Pull a Low State data structure from request and execute the low-data
chunks through Salt. The low-data chunks will be updated to include the
authorization token for the current session.
'''
lowstate = cherrypy.request... | Pull a Low State data structure from request and execute the low-data
chunks through Salt. The low-data chunks will be updated to include the
authorization token for the current session. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1155-L1208 | null | class LowDataAdapter(object):
'''
The primary entry point to Salt's REST API
'''
exposed = True
_cp_config = {
'tools.salt_token.on': True,
'tools.sessions.on': True,
'tools.sessions.timeout': 60 * 10, # 10 hours
# 'tools.autovary.on': True,
'tools.hyperm... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | LowDataAdapter.POST | python | def POST(self, **kwargs):
'''
Send one or more Salt commands in the request body
.. http:post:: /
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
... | Send one or more Salt commands in the request body
.. http:post:: /
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
:status 200: |200|
:status 400:... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1251-L1310 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class LowDataAdapter(object):
'''
The primary entry point to Salt's REST API
'''
exposed = True
_cp_config = {
'tools.salt_token.on': True,
'tools.sessions.on': True,
'tools.sessions.timeout': 60 * 10, # 10 hours
# 'tools.autovary.on': True,
'tools.hyperm... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Minions.GET | python | def GET(self, mid=None):
'''
A convenience URL for getting lists of minions or getting minion
details
.. http:get:: /minions/(mid)
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|... | A convenience URL for getting lists of minions or getting minion
details
.. http:get:: /minions/(mid)
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|
:status 406: |406|
**Ex... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1321-L1366 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Minions(LowDataAdapter):
'''
Convenience URLs for working with minions
'''
_cp_config = dict(LowDataAdapter._cp_config, **{
'tools.salt_auth.on': True,
})
def POST(self, **kwargs):
'''
Start an execution command and immediately return the job id
.. http:p... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Minions.POST | python | def POST(self, **kwargs):
'''
Start an execution command and immediately return the job id
.. http:post:: /minions
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |r... | Start an execution command and immediately return the job id
.. http:post:: /minions
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
:status 200: |200|
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1368-L1432 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Minions(LowDataAdapter):
'''
Convenience URLs for working with minions
'''
_cp_config = dict(LowDataAdapter._cp_config, **{
'tools.salt_auth.on': True,
})
def GET(self, mid=None):
'''
A convenience URL for getting lists of minions or getting minion
details
... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Jobs.GET | python | def GET(self, jid=None, timeout=''):
'''
A convenience URL for getting lists of previously run jobs or getting
the return from a single job
.. http:get:: /jobs/(jid)
List jobs or show a single job from the job cache.
:reqheader X-Auth-Token: |req_token|
... | A convenience URL for getting lists of previously run jobs or getting
the return from a single job
.. http:get:: /jobs/(jid)
List jobs or show a single job from the job cache.
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1440-L1548 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Jobs(LowDataAdapter):
_cp_config = dict(LowDataAdapter._cp_config, **{
'tools.salt_auth.on': True,
})
|
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Keys.GET | python | def GET(self, mid=None):
'''
Show the list of minion keys or detail on a specific key
.. versionadded:: 2014.7.0
.. http:get:: /keys/(mid)
List all keys or show a specific key
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
... | Show the list of minion keys or detail on a specific key
.. versionadded:: 2014.7.0
.. http:get:: /keys/(mid)
List all keys or show a specific key
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:sta... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1561-L1646 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Keys(LowDataAdapter):
'''
Convenience URLs for working with minion keys
.. versionadded:: 2014.7.0
These URLs wrap the functionality provided by the :py:mod:`key wheel
module <salt.wheel.key>` functions.
'''
@cherrypy.config(**{'tools.hypermedia_out.on': False, 'tools.sessions.on':... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Keys.POST | python | def POST(self, **kwargs):
r'''
Easily generate keys for a minion and auto-accept the new key
Accepts all the same parameters as the :py:func:`key.gen_accept
<salt.wheel.key.gen_accept>`.
.. note:: A note about ``curl``
Avoid using the ``-i`` flag or HTTP headers will... | r'''
Easily generate keys for a minion and auto-accept the new key
Accepts all the same parameters as the :py:func:`key.gen_accept
<salt.wheel.key.gen_accept>`.
.. note:: A note about ``curl``
Avoid using the ``-i`` flag or HTTP headers will be written and
produce... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1649-L1752 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Keys(LowDataAdapter):
'''
Convenience URLs for working with minion keys
.. versionadded:: 2014.7.0
These URLs wrap the functionality provided by the :py:mod:`key wheel
module <salt.wheel.key>` functions.
'''
def GET(self, mid=None):
'''
Show the list of minion keys o... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Login.POST | python | def POST(self, **kwargs):
'''
:ref:`Authenticate <rest_cherrypy-auth>` against Salt's eauth system
.. http:post:: /login
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:form eauth: the eau... | :ref:`Authenticate <rest_cherrypy-auth>` against Salt's eauth system
.. http:post:: /login
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:form eauth: the eauth backend configured for the user
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1805-L1932 | [
"def salt_api_acl_tool(username, request):\n '''\n ..versionadded:: 2016.3.0\n\n Verifies user requests against the API whitelist. (User/IP pair)\n in order to provide whitelisting for the API similar to the\n master, but over the API.\n\n ..code-block:: yaml\n\n rest_cherrypy:\n ... | class Login(LowDataAdapter):
'''
Log in to receive a session token
:ref:`Authentication information <rest_cherrypy-auth>`.
'''
def __init__(self, *args, **kwargs):
super(Login, self).__init__(*args, **kwargs)
self.auth = salt.auth.Resolver(self.opts)
def GET(self):
''... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Token.POST | python | def POST(self, **kwargs):
r'''
.. http:post:: /token
Generate a Salt eauth token
:status 200: |200|
:status 400: |400|
:status 401: |401|
**Example request:**
.. code-block:: bash
curl -sSk https://localhost:8000/token \
... | r'''
.. http:post:: /token
Generate a Salt eauth token
:status 200: |200|
:status 400: |400|
:status 401: |401|
**Example request:**
.. code-block:: bash
curl -sSk https://localhost:8000/token \
-H 'Content-type: ap... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1964-L2016 | [
"def exec_lowstate(self, client=None, token=None):\n '''\n Pull a Low State data structure from request and execute the low-data\n chunks through Salt. The low-data chunks will be updated to include the\n authorization token for the current session.\n '''\n lowstate = cherrypy.request.lowstate\n\n... | class Token(LowDataAdapter):
'''
Generate a Salt token from eauth credentials
Wraps functionality in the :py:mod:`auth Runner <salt.runners.auth>`.
.. versionadded:: 2017.7.0
'''
@cherrypy.config(**{'tools.sessions.on': False})
|
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Events._is_valid_token | python | def _is_valid_token(self, auth_token):
'''
Check if this is a valid salt-api token or valid Salt token
salt-api tokens are regular session tokens that tie back to a real Salt
token. Salt tokens are tokens generated by Salt's eauth system.
:return bool: True if valid, False if n... | Check if this is a valid salt-api token or valid Salt token
salt-api tokens are regular session tokens that tie back to a real Salt
token. Salt tokens are tokens generated by Salt's eauth system.
:return bool: True if valid, False if not valid. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2191-L2219 | null | class Events(object):
'''
Expose the Salt event bus
The event bus on the Salt master exposes a large variety of things, notably
when executions are started on the master and also when minions ultimately
return their results. This URL provides a real-time window into a running
Salt infrastructur... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Events.GET | python | def GET(self, token=None, salt_token=None):
r'''
An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each
event is formatted as JSON.
.. http:get:: /events
:status 200: |200|
:status 401: |401|
... | r'''
An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each
event is formatted as JSON.
.. http:get:: /events
:status 200: |200|
:status 401: |401|
:status 406: |406|
:query token... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2221-L2380 | [
"def _is_valid_token(self, auth_token):\n '''\n Check if this is a valid salt-api token or valid Salt token\n\n salt-api tokens are regular session tokens that tie back to a real Salt\n token. Salt tokens are tokens generated by Salt's eauth system.\n\n :return bool: True if valid, False if not valid... | class Events(object):
'''
Expose the Salt event bus
The event bus on the Salt master exposes a large variety of things, notably
when executions are started on the master and also when minions ultimately
return their results. This URL provides a real-time window into a running
Salt infrastructur... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | WebsocketEndpoint.GET | python | def GET(self, token=None, **kwargs):
'''
Return a websocket connection of Salt's event stream
.. http:get:: /ws/(token)
:query format_events: The event stream will undergo server-side
formatting if the ``format_events`` URL parameter is included
in the request. ... | Return a websocket connection of Salt's event stream
.. http:get:: /ws/(token)
:query format_events: The event stream will undergo server-side
formatting if the ``format_events`` URL parameter is included
in the request. This can be useful to avoid formatting on the
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2413-L2573 | null | class WebsocketEndpoint(object):
'''
Open a WebSocket connection to Salt's event bus
The event bus on the Salt master exposes a large variety of things, notably
when executions are started on the master and also when minions ultimately
return their results. This URL provides a real-time window into... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Webhook.POST | python | def POST(self, *args, **kwargs):
'''
Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
... | Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
.. code-block:: bash
curl -sS localhos... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2643-L2739 | null | class Webhook(object):
'''
A generic web hook entry point that fires an event on Salt's event bus
External services can POST data to this URL to trigger an event in Salt.
For example, Amazon SNS, Jenkins-CI or Travis-CI, or GitHub web hooks.
.. note:: Be mindful of security
Salt's Reactor... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | App.GET | python | def GET(self, *args):
'''
Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5
history API.
.. http::get:: /app
:reqheader X-Auth-Token: |req_token|
:status 200: |200|
... | Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5
history API.
.. http::get:: /app
:reqheader X-Auth-Token: |req_token|
:status 200: |200|
:status 401: |401| | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2783-L2803 | null | class App(object):
'''
Class to serve HTML5 apps
'''
exposed = True
|
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API._setattr_url_map | python | def _setattr_url_map(self):
'''
Set an attribute on the local instance for each key/val in url_map
CherryPy uses class attributes to resolve URLs.
'''
if self.apiopts.get('enable_sessions', True) is False:
url_blacklist = ['login', 'logout', 'minions', 'jobs']
... | Set an attribute on the local instance for each key/val in url_map
CherryPy uses class attributes to resolve URLs. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2823-L2838 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | class API(object):
'''
Collect configuration and URL map for building the CherryPy app
'''
url_map = {
'index': LowDataAdapter,
'login': Login,
'logout': Logout,
'token': Token,
'minions': Minions,
'run': Run,
'jobs': Jobs,
'keys': Keys,
... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API._update_url_map | python | def _update_url_map(self):
'''
Assemble any dynamic or configurable URLs
'''
if HAS_WEBSOCKETS:
self.url_map.update({
'ws': WebsocketEndpoint,
})
# Allow the Webhook URL to be overridden from the conf.
self.url_map.update({
... | Assemble any dynamic or configurable URLs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2840-L2857 | null | class API(object):
'''
Collect configuration and URL map for building the CherryPy app
'''
url_map = {
'index': LowDataAdapter,
'login': Login,
'logout': Logout,
'token': Token,
'minions': Minions,
'run': Run,
'jobs': Jobs,
'keys': Keys,
... |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API.get_conf | python | def get_conf(self):
'''
Combine the CherryPy configuration with the rest_cherrypy config values
pulled from the master config and return the CherryPy configuration
'''
conf = {
'global': {
'server.socket_host': self.apiopts.get('host', '0.0.0.0'),
... | Combine the CherryPy configuration with the rest_cherrypy config values
pulled from the master config and return the CherryPy configuration | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2866-L2924 | [
"def version_cmp(pkg1, pkg2, ignore_epoch=False):\n '''\n Compares two version strings using salt.utils.versions.LooseVersion. This\n is a fallback for providers which don't have a version comparison utility\n built into them. Return -1 if version1 < version2, 0 if version1 ==\n version2, and 1 if v... | class API(object):
'''
Collect configuration and URL map for building the CherryPy app
'''
url_map = {
'index': LowDataAdapter,
'login': Login,
'logout': Logout,
'token': Token,
'minions': Minions,
'run': Run,
'jobs': Jobs,
'keys': Keys,
... |
saltstack/salt | salt/modules/gentoo_service.py | get_disabled | python | def get_disabled():
'''
Return a set of services that are installed but disabled
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=False,
... | Return a set of services that are installed but disabled
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L107-L119 | [
"def _get_service_list(include_enabled=True, include_disabled=False):\n enabled_services = dict()\n disabled_services = set()\n lines = _list_services()\n for line in lines:\n if '|' not in line:\n continue\n service = [l.strip() for l in line.split('|')]\n # enabled serv... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | available | python | def available(name):
'''
Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
... | Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L122-L135 | [
"def _get_service_list(include_enabled=True, include_disabled=False):\n enabled_services = dict()\n disabled_services = set()\n lines = _list_services()\n for line in lines:\n if '|' not in line:\n continue\n service = [l.strip() for l in line.split('|')]\n # enabled serv... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | get_all | python | def get_all():
'''
Return all available boot services
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
include_disabled=True)
... | Return all available boot services
CLI Example:
.. code-block:: bash
salt '*' service.get_all | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L153-L166 | [
"def _get_service_list(include_enabled=True, include_disabled=False):\n enabled_services = dict()\n disabled_services = set()\n lines = _list_services()\n for line in lines:\n if '|' not in line:\n continue\n service = [l.strip() for l in line.split('|')]\n # enabled serv... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | status | python | def status(name, sig=None):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the servi... | Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the service to check
sig (str): Signature... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L239-L276 | [
"def get_all():\n '''\n Return all available boot services\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' service.get_all\n '''\n (enabled_services, disabled_services) = _get_service_list(include_enabled=True,\n include_di... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | enable | python | def enable(name, **kwargs):
'''
Enable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.enable <service name> <runlevels=single-runlevel>
salt '*' service.enable <service name> <runlevels=[runlevel1,runlevel2]>
'''
if 'runlevels' in kwargs:... | Enable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.enable <service name> <runlevels=single-runlevel>
salt '*' service.enable <service name> <runlevels=[runlevel1,runlevel2]> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L279-L306 | [
"def _ret_code(cmd, ignore_retcode=False):\n log.debug('executing [%s]', cmd)\n sts = __salt__['cmd.retcode'](cmd, python_shell=False, ignore_retcode=ignore_retcode)\n return sts\n",
"def _enable_delta(name, requested_runlevels):\n all_enabled = get_enabled()\n current_levels = set(all_enabled[name... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | disable | python | def disable(name, **kwargs):
'''
Disable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.disable <service name> <runlevels=single-runlevel>
salt '*' service.disable <service name> <runlevels=[runlevel1,runlevel2]>
'''
levels = []
if 'r... | Disable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.disable <service name> <runlevels=single-runlevel>
salt '*' service.disable <service name> <runlevels=[runlevel1,runlevel2]> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L309-L328 | [
"def _ret_code(cmd, ignore_retcode=False):\n log.debug('executing [%s]', cmd)\n sts = __salt__['cmd.retcode'](cmd, python_shell=False, ignore_retcode=ignore_retcode)\n return sts\n",
"def _disable_delta(name, requested_runlevels):\n all_enabled = get_enabled()\n current_levels = set(all_enabled[nam... | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/modules/gentoo_service.py | enabled | python | def enabled(name, **kwargs):
'''
Return True if the named service is enabled, false otherwise
CLI Example:
.. code-block:: bash
salt '*' service.enabled <service name> <runlevels=single-runlevel>
salt '*' service.enabled <service name> <runlevels=[runlevel1,runlevel2]>
'''
ena... | Return True if the named service is enabled, false otherwise
CLI Example:
.. code-block:: bash
salt '*' service.enabled <service name> <runlevels=single-runlevel>
salt '*' service.enabled <service name> <runlevels=[runlevel1,runlevel2]> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L331-L349 | [
"def get_enabled():\n '''\n Return a list of service that are enabled on boot\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' service.get_enabled\n '''\n (enabled_services, disabled_services) = _get_service_list()\n return odict.OrderedDict(enabled_services)\n"
] | # -*- coding: utf-8 -*-
'''
Top level package command wrapper, used to translate the os detected by grains
to the correct service manager
.. important::
If you feel that Salt should be using this module to manage services on a
minion, and it is using a different module (or gives an error similar to
*'servi... |
saltstack/salt | salt/states/virtualenv_mod.py | managed | python | def managed(name,
venv_bin=None,
requirements=None,
system_site_packages=False,
distribute=False,
use_wheel=False,
clear=False,
python=None,
extra_search_dir=None,
never_download=None,
prompt=None,
... | Create a virtualenv and optionally manage it with pip
name
Path to the virtualenv.
venv_bin: virtualenv
The name (and optionally path) of the virtualenv command. This can also
be set globally in the minion config file as ``virtualenv.venv_bin``.
requirements: None
Path to ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virtualenv_mod.py#L33-L337 | [
"def compare(ver1='', oper='==', ver2='', cmp_func=None, ignore_epoch=False):\n '''\n Compares two version numbers. Accepts a custom function to perform the\n cmp-style version comparison, otherwise uses version_cmp().\n '''\n cmp_map = {'<': (-1,), '<=': (-1, 0), '==': (0,),\n '>=': (0... | # -*- coding: utf-8 -*-
'''
Setup of Python virtualenv sandboxes.
.. versionadded:: 0.17.0
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
import os
# Import Salt libs
import salt.version
import salt.utils.functools
import salt.utils.platform
import sa... |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_bond_1 | python | def _parse_settings_bond_1(opts, iface, bond_def):
'''
Filters given options and outputs valid settings for bond1.
If an option has a value that is not expected, this
function will log what the Interface, Setting and what it was
expecting.
'''
bond = {'mode': '1'}
for binding in ['miim... | Filters given options and outputs valid settings for bond1.
If an option has a value that is not expected, this
function will log what the Interface, Setting and what it was
expecting. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L320-L356 | null | # -*- coding: utf-8 -*-
'''
The networking module for RHEL/Fedora based distros
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import logging
import os.path
import os
# Import third party libs
import jinja2
import jinja2.exceptions
# Import salt libs
import salt.uti... |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_vlan | python | def _parse_settings_vlan(opts, iface):
'''
Filters given options and outputs valid settings for a vlan
'''
vlan = {}
if 'reorder_hdr' in opts:
if opts['reorder_hdr'] in _CONFIG_TRUE + _CONFIG_FALSE:
vlan.update({'reorder_hdr': opts['reorder_hdr']})
else:
vali... | Filters given options and outputs valid settings for a vlan | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L571-L596 | null | # -*- coding: utf-8 -*-
'''
The networking module for RHEL/Fedora based distros
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import logging
import os.path
import os
# Import third party libs
import jinja2
import jinja2.exceptions
# Import salt libs
import salt.uti... |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_eth | python | def _parse_settings_eth(opts, iface_type, enabled, iface):
'''
Filters given options and outputs valid settings for a
network interface.
'''
result = {'name': iface}
if 'proto' in opts:
valid = ['none', 'bootp', 'dhcp']
if opts['proto'] in valid:
result['proto'] = opt... | Filters given options and outputs valid settings for a
network interface. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L599-L816 | null | # -*- coding: utf-8 -*-
'''
The networking module for RHEL/Fedora based distros
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import logging
import os.path
import os
# Import third party libs
import jinja2
import jinja2.exceptions
# Import salt libs
import salt.uti... |
saltstack/salt | salt/modules/rh_ip.py | _parse_network_settings | python | def _parse_network_settings(opts, current):
'''
Filters given options and outputs valid settings for
the global network settings file.
'''
# Normalize keys
opts = dict((k.lower(), v) for (k, v) in six.iteritems(opts))
current = dict((k.lower(), v) for (k, v) in six.iteritems(current))
#... | Filters given options and outputs valid settings for
the global network settings file. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L836-L903 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _log_default_network(opt, value):\n log.info('Using existing setting -- Setting: %s Value: %s',\n opt, value)\n",
"def _raise_error_network(option, expected):\n '''\n Log and raise an error with a logical formatted message.\n ... | # -*- coding: utf-8 -*-
'''
The networking module for RHEL/Fedora based distros
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import logging
import os.path
import os
# Import third party libs
import jinja2
import jinja2.exceptions
# Import salt libs
import salt.uti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.