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/cloud/clouds/aliyun.py | start | python | def start(name, call=None):
'''
Start a node
CLI Examples:
.. code-block:: bash
salt-cloud -a start myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
log.info('Starting node %s', name... | Start a node
CLI Examples:
.. code-block:: bash
salt-cloud -a start myinstance | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L495-L518 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | stop | python | def stop(name, force=False, call=None):
'''
Stop a node
CLI Examples:
.. code-block:: bash
salt-cloud -a stop myinstance
salt-cloud -a stop myinstance force=True
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or ... | Stop a node
CLI Examples:
.. code-block:: bash
salt-cloud -a stop myinstance
salt-cloud -a stop myinstance force=True | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L521-L548 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | reboot | python | def reboot(name, call=None):
'''
Reboot a node
CLI Examples:
.. code-block:: bash
salt-cloud -a reboot myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
log.info('Rebooting node %s', ... | Reboot a node
CLI Examples:
.. code-block:: bash
salt-cloud -a reboot myinstance | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L551-L574 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | create_node | python | def create_node(kwargs):
'''
Convenience function to make the rest api call for node creation.
'''
if not isinstance(kwargs, dict):
kwargs = {}
# Required parameters
params = {
'Action': 'CreateInstance',
'InstanceType': kwargs.get('size_id', ''),
'RegionId': kwa... | Convenience function to make the rest api call for node creation. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L577-L608 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | create | python | def create(vm_):
'''
Create a single VM from a data dict
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__,
__active_provider_name__ or 'ali... | Create a single VM from a data dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L611-L741 | [
"def destroy(name, call=None):\n '''\n Destroy a node.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud -a destroy myinstance\n salt-cloud -d myinstance\n '''\n if call == 'function':\n raise SaltCloudSystemExit(\n 'The destroy action must be called with -d,... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | _compute_signature | python | def _compute_signature(parameters, access_key_secret):
'''
Generate aliyun request signature
'''
def percent_encode(line):
if not isinstance(line, six.string_types):
return line
s = line
if sys.stdin.encoding is None:
s = line.decode().encode('utf8')
... | Generate aliyun request signature | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L744-L776 | null | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | query | python | def query(params=None):
'''
Make a web call to aliyun ECS REST API
'''
path = 'https://ecs-cn-hangzhou.aliyuncs.com'
access_key_id = config.get_cloud_config_value(
'id', get_configured_provider(), __opts__, search_global=False
)
access_key_secret = config.get_cloud_config_value(
... | Make a web call to aliyun ECS REST API | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L779-L832 | [
"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_... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | show_disk | python | def show_disk(name, call=None):
'''
Show the disk details of the instance
CLI Examples:
.. code-block:: bash
salt-cloud -a show_disk aliyun myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_disks action must be called with -a or --action.'
... | Show the disk details of the instance
CLI Examples:
.. code-block:: bash
salt-cloud -a show_disk aliyun myinstance | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L850-L877 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | list_monitor_data | python | def list_monitor_data(kwargs=None, call=None):
'''
Get monitor data of the instance. If instance name is
missing, will show all the instance monitor data on the region.
CLI Examples:
.. code-block:: bash
salt-cloud -f list_monitor_data aliyun
salt-cloud -f list_monitor_data aliyun... | Get monitor data of the instance. If instance name is
missing, will show all the instance monitor data on the region.
CLI Examples:
.. code-block:: bash
salt-cloud -f list_monitor_data aliyun
salt-cloud -f list_monitor_data aliyun name=AY14051311071990225bd | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L880-L917 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | show_image | python | def show_image(kwargs, call=None):
'''
Show the details from aliyun image
'''
if call != 'function':
raise SaltCloudSystemExit(
'The show_images function must be called with '
'-f or --function'
)
if not isinstance(kwargs, dict):
kwargs = {}
loca... | Show the details from aliyun image | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L950-L991 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/cloud/clouds/aliyun.py | destroy | python | def destroy(name, call=None):
'''
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud -a destroy myinstance
salt-cloud -d myinstance
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
... | Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud -a destroy myinstance
salt-cloud -d myinstance | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/aliyun.py#L994-L1045 | [
"def query(params=None):\n '''\n Make a web call to aliyun ECS REST API\n '''\n path = 'https://ecs-cn-hangzhou.aliyuncs.com'\n\n access_key_id = config.get_cloud_config_value(\n 'id', get_configured_provider(), __opts__, search_global=False\n )\n access_key_secret = config.get_cloud_con... | # -*- coding: utf-8 -*-
'''
AliYun ECS Cloud Module
=======================
.. versionadded:: 2014.7.0
The Aliyun cloud module is used to control access to the aliyun ECS.
http://www.aliyun.com/
Use of this module requires the ``id`` and ``key`` parameter to be set.
Set up the cloud configuration at ``/etc/salt/clou... |
saltstack/salt | salt/modules/solarispkg.py | _write_adminfile | python | def _write_adminfile(kwargs):
'''
Create a temporary adminfile based on the keyword arguments passed to
pkg.install.
'''
# Set the adminfile default variables
email = kwargs.get('email', '')
instance = kwargs.get('instance', 'quit')
partial = kwargs.get('partial', 'nocheck')
runlevel... | Create a temporary adminfile based on the keyword arguments passed to
pkg.install. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solarispkg.py#L42-L79 | null | # -*- coding: utf-8 -*-
'''
Package support for Solaris
.. important::
If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here
<module-provider-override>`.
'''
fr... |
saltstack/salt | salt/modules/solarispkg.py | list_pkgs | python | def list_pkgs(versions_as_list=False, **kwargs):
'''
List the packages currently installed as a dict:
.. code-block:: python
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(versions_a... | List the packages currently installed as a dict:
.. code-block:: python
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solarispkg.py#L82-L131 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Package support for Solaris
.. important::
If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here
<module-provider-override>`.
'''
fr... |
saltstack/salt | salt/modules/solarispkg.py | install | python | def install(name=None, sources=None, saltenv='base', **kwargs):
'''
Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package name... | Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package names and versions:
.. code-block:: python
{'<package>': {'old': '... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solarispkg.py#L201-L385 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Package support for Solaris
.. important::
If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here
<module-provider-override>`.
'''
fr... |
saltstack/salt | salt/modules/solarispkg.py | remove | python | def remove(name=None, pkgs=None, saltenv='base', **kwargs):
'''
Remove packages with pkgrm
name
The name of the package to be deleted
By default salt automatically provides an adminfile, to automate package
removal, with these options set::
email=
instance=quit
par... | Remove packages with pkgrm
name
The name of the package to be deleted
By default salt automatically provides an adminfile, to automate package
removal, with these options set::
email=
instance=quit
partial=nocheck
runlevel=nocheck
idepend=nocheck
rd... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solarispkg.py#L388-L488 | [
"def list_pkgs(versions_as_list=False, **kwargs):\n '''\n List the packages currently installed as a dict:\n\n .. code-block:: python\n\n {'<package_name>': '<version>'}\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' pkg.list_pkgs\n '''\n versions_as_list = salt.utils.data... | # -*- coding: utf-8 -*-
'''
Package support for Solaris
.. important::
If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here
<module-provider-override>`.
'''
fr... |
saltstack/salt | salt/states/boto_cloudtrail.py | present | python | def present(name, Name,
S3BucketName, S3KeyPrefix=None,
SnsTopicName=None,
IncludeGlobalServiceEvents=True,
IsMultiRegionTrail=None,
EnableLogFileValidation=False,
CloudWatchLogsLogGroupArn=None,
CloudWatchLogsRoleArn=None,
KmsKeyId... | Ensure trail exists.
name
The name of the state definition
Name
Name of the trail.
S3BucketName
Specifies the name of the Amazon S3 bucket designated for publishing log
files.
S3KeyPrefix
Specifies the Amazon S3 key prefix that comes after the name of the
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_cloudtrail.py#L75-L315 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Manage CloudTrail Objects
=========================
.. versionadded:: 2016.3.0
Create and destroy CloudTrail objects. Be aware that this interacts with Amazon's services,
and so may incur charges.
:depends:
- boto
- boto3
The dependencies listed above can be installed via package... |
saltstack/salt | salt/states/boto_cloudtrail.py | absent | python | def absent(name, Name,
region=None, key=None, keyid=None, profile=None):
'''
Ensure trail with passed properties is absent.
name
The name of the state definition.
Name
Name of the trail.
region
Region to connect to.
key
Secret key to be used.... | Ensure trail with passed properties is absent.
name
The name of the state definition.
Name
Name of the trail.
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and keyid, or a... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_cloudtrail.py#L318-L374 | null | # -*- coding: utf-8 -*-
'''
Manage CloudTrail Objects
=========================
.. versionadded:: 2016.3.0
Create and destroy CloudTrail objects. Be aware that this interacts with Amazon's services,
and so may incur charges.
:depends:
- boto
- boto3
The dependencies listed above can be installed via package... |
saltstack/salt | salt/transport/__init__.py | iter_transport_opts | python | def iter_transport_opts(opts):
'''
Yield transport, opts for all master configured transports
'''
transports = set()
for transport, opts_overrides in six.iteritems(opts.get('transport_opts', {})):
t_opts = dict(opts)
t_opts.update(opts_overrides)
t_opts['transport'] = transp... | Yield transport, opts for all master configured transports | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/__init__.py#L19-L33 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Encapsulate the different transports available to Salt.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
import salt.utils.versions
# Import third party libs
from salt.ext import six
from salt.ext.six.moves ... |
saltstack/salt | salt/thorium/check.py | gt | python | def gt(name, value):
'''
Only succeed if the value in the given register location is greater than
the given value
USAGE:
.. code-block:: yaml
foo:
check.gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... | Only succeed if the value in the given register location is greater than
the given value
USAGE:
.. code-block:: yaml
foo:
check.gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L17-L47 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | gte | python | def gte(name, value):
'''
Only succeed if the value in the given register location is greater or equal
than the given value
USAGE:
.. code-block:: yaml
foo:
check.gte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func:... | Only succeed if the value in the given register location is greater or equal
than the given value
USAGE:
.. code-block:: yaml
foo:
check.gte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L50-L80 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | lt | python | def lt(name, value):
'''
Only succeed if the value in the given register location is less than
the given value
USAGE:
.. code-block:: yaml
foo:
check.lt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... | Only succeed if the value in the given register location is less than
the given value
USAGE:
.. code-block:: yaml
foo:
check.lt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L83-L113 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | lte | python | def lte(name, value):
'''
Only succeed if the value in the given register location is less than
or equal the given value
USAGE:
.. code-block:: yaml
foo:
check.lte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: te... | Only succeed if the value in the given register location is less than
or equal the given value
USAGE:
.. code-block:: yaml
foo:
check.lte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L116-L146 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | eq | python | def eq(name, value):
'''
Only succeed if the value in the given register location is equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.eq:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... | Only succeed if the value in the given register location is equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.eq:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L149-L179 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | ne | python | def ne(name, value):
'''
Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... | Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L182-L212 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | contains | python | def contains(name,
value,
count_lt=None,
count_lte=None,
count_eq=None,
count_gte=None,
count_gt=None,
count_ne=None):
'''
Only succeed if the value in the given register location contains
the given value
USAGE:
... | Only succeed if the value in the given register location contains
the given value
USAGE:
.. code-block:: yaml
foo:
check.contains:
- value: itni
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L215-L274 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | event | python | def event(name):
'''
Chekcs for a specific event match and returns result True if the match
happens
USAGE:
.. code-block:: yaml
salt/foo/*/bar:
check.event
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | Chekcs for a specific event match and returns result True if the match
happens
USAGE:
.. code-block:: yaml
salt/foo/*/bar:
check.event
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
- check: salt/foo... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L277-L305 | [
"def expr_match(line, expr):\n '''\n Checks whether or not the passed value matches the specified expression.\n Tries to match expr first as a glob using fnmatch.fnmatch(), and then tries\n to match expr as a regular expression. Originally designed to match minion\n IDs for whitelists/blacklists.\n\n... | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/thorium/check.py | len_gt | python | def len_gt(name, value):
'''
Only succeed if length of the given register location is greater than
the given value.
USAGE:
.. code-block:: yaml
foo:
check.len_gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test... | Only succeed if length of the given register location is greater than
the given value.
USAGE:
.. code-block:: yaml
foo:
check.len_gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L308-L338 | null | # -*- coding: utf-8 -*-
'''
The check Thorium state is used to create gateways to commands, the checks
make it easy to make states that watch registers for changes and then just
succeed or fail based on the state of the register, this creates the pattern
of having a command execution get gated by a check state via a re... |
saltstack/salt | salt/modules/napalm_users.py | set_users | python | def set_users(users, test=False, commit=True, **kwargs): # pylint: disable=unused-argument
'''
Configures users on network devices.
:param users: Dictionary formatted as the output of the function config()
:param test: Dry run? If set as True, will apply the config, discard and
return the ch... | Configures users on network devices.
:param users: Dictionary formatted as the output of the function config()
:param test: Dry run? If set as True, will apply the config, discard and
return the changes. Default: False
:param commit: Commit? (default: True) Sometimes it is not needed to commit
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_users.py#L102-L141 | null | # -*- coding: utf-8 -*-
'''
NAPALM Users
============
Manages the configuration of the users on network devices.
:codeauthor: Mircea Ulinic <mircea@cloudflare.com>
:maturity: new
:depends: napalm
:platform: unix
Dependencies
------------
- :mod:`NAPALM proxy minion <salt.proxy.napalm>`
.. seealso::
:mod:... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | map_clonemode | python | def map_clonemode(vm_info):
mode_map = {
'state': 0,
'child': 1,
'all': 2
}
if not vm_info:
return DEFAULT_CLONE_MODE
if 'clonemode' not in vm_info:
return DEFAULT_CLONE_MODE
if vm_info['clonemode'] in mode_map:
return mode_map[vm_info['clonemode']]
... | Convert the virtualbox config file values for clone_mode into the integers the API requires | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L92-L113 | null | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | create | python | def create(vm_info):
'''
Creates a virtual machine from the given VM information
This is what is used to request a virtual machine to be created by the
cloud provider, wait for it to become available, and then (optionally) log
in and install Salt on it.
Events fired:
This function fires t... | Creates a virtual machine from the given VM information
This is what is used to request a virtual machine to be created by the
cloud provider, wait for it to become available, and then (optionally) log
in and install Salt on it.
Events fired:
This function fires the event ``salt/cloud/vm_name/cre... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L116-L228 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | list_nodes_full | python | def list_nodes_full(kwargs=None, call=None):
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called '
'with -f or --function.'
)
machines = {}
# TODO ask for the correct attributes e.g state and private_ips
for machine in vb... | All information available about all nodes should be returned in this function.
The fields in the list_nodes() function should also be returned,
even if they would not normally be provided by the cloud provider.
This is because some functions both within Salt and 3rd party will break if an expected field is... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L231-L268 | [
"def vb_list_machines(**kwargs):\n '''\n Which machines does the hypervisor have\n @param kwargs: Passed to vb_xpcom_to_attribute_dict to filter the attributes\n @type kwargs: dict\n @return: Untreated dicts of the machines known to the hypervisor\n @rtype: [{}]\n '''\n manager = vb_get_mana... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | list_nodes | python | def list_nodes(kwargs=None, call=None):
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called '
'with -f or --function.'
)
attributes = [
"id",
"image",
"size",
"state",
"private_ips",
"pub... | This function returns a list of nodes available on this cloud provider, using the following fields:
id (str)
image (str)
size (str)
state (str)
private_ips (list)
public_ips (list)
No other fields should be returned in this function, and all of these fields should be returned, even if empt... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L271-L315 | [
"def list_nodes_full(kwargs=None, call=None):\n \"\"\"\n All information available about all nodes should be returned in this function.\n The fields in the list_nodes() function should also be returned,\n even if they would not normally be provided by the cloud provider.\n\n This is because some func... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | destroy | python | def destroy(name, call=None):
log.info("Attempting to delete instance %s", name)
if not vb_machine_exists(name):
return "{0} doesn't exist and can't be deleted".format(name)
__utils__['cloud.fire_event'](
'event',
'destroying instance',
'salt/cloud/{0}/destroying'.format(nam... | This function irreversibly destroys a virtual machine on the cloud provider.
Before doing so, it should fire an event on the Salt event bus.
The tag for this event is `salt/cloud/<vm name>/destroying`.
Once the virtual machine has been destroyed, another event is fired.
The tag for that event is `salt/... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L327-L368 | [
"def vb_destroy_machine(name=None, timeout=10000):\n '''\n Attempts to get rid of a machine and all its files from the hypervisor\n @param name:\n @type name: str\n @param timeout int timeout in milliseconds\n '''\n vbox = vb_get_box()\n log.info('Destroying machine %s', name)\n machine =... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | start | python | def start(name, call=None):
'''
Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str
'''
if call != 'action':
raise SaltCloudSystemExit(
'The instance action must be called with -a or --action.'
)
lo... | Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L371-L388 | [
"def vb_start_vm(name=None, timeout=10000, **kwargs):\n '''\n Tells Virtualbox to start up a VM.\n Blocking function!\n\n @param name:\n @type name: str\n @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely\n @type timeout: int\n @return untreated dict of started ... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | stop | python | def stop(name, call=None):
if call != 'action':
raise SaltCloudSystemExit(
'The instance action must be called with -a or --action.'
)
log.info("Stopping machine: %s", name)
vb_stop_vm(name)
machine = vb_get_machine(name)
del machine["name"]
return treat_machine_dict... | Stop a running machine.
@param name: Machine to stop
@type name: str
@param call: Must be "action"
@type call: str | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L391-L408 | [
"def vb_stop_vm(name=None, timeout=10000, **kwargs):\n '''\n Tells Virtualbox to stop a VM.\n This is a blocking function!\n\n @param name:\n @type name: str\n @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely\n @type timeout: int\n @return untreated dict of sto... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/cloud/clouds/virtualbox.py | show_image | python | def show_image(kwargs, call=None):
if call != 'function':
raise SaltCloudSystemExit(
'The show_image action must be called with -f or --function.'
)
name = kwargs['image']
log.info("Showing image %s", name)
machine = vb_get_machine(name)
ret = {
machine["name"]:... | Show the details of an image | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L411-L428 | [
"def vb_get_machine(name, **kwargs):\n '''\n Attempts to fetch a machine from Virtualbox and convert it to a dict\n\n @param name: The unique name of the machine\n @type name:\n @param kwargs: To be passed to vb_xpcom_to_attribute_dict\n @type kwargs:\n @return:\n @rtype: dict\n '''\n ... | # -*- coding: utf-8 -*-
'''
A salt cloud provider that lets you use virtualbox on your machine
and act as a cloud.
:depends: vboxapi
For now this will only clone existing VMs. It's best to create a template
from which we will clone.
Followed
https://docs.saltstack.com/en/latest/topics/cloud/cloud.html#non-libcloud-b... |
saltstack/salt | salt/states/cryptdev.py | mapped | python | def mapped(name,
device,
keyfile=None,
opts=None,
config='/etc/crypttab',
persist=True,
immediate=False,
match_on='name'):
'''
Verify that a device is mapped
name
The name under which the device is to be mapped
device... | Verify that a device is mapped
name
The name under which the device is to be mapped
device
The device name, typically the device node, such as ``/dev/sdb1``
or ``UUID=066e0200-2867-4ebe-b9e6-f30026ca2314``.
keyfile
Either ``None`` if the password is to be entered manually ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cryptdev.py#L37-L134 | null | # -*- coding: utf-8 -*-
'''
Opening of Encrypted Devices
=======================
Ensure that an encrypted device is mapped with the `mapped` function:
.. code-block:: yaml
mappedname:
cryptdev.mapped:
- device: /dev/sdb1
- keyfile: /etc/keyfile.key
- opts:
- size=256
... |
saltstack/salt | salt/states/cryptdev.py | unmapped | python | def unmapped(name,
config='/etc/crypttab',
persist=True,
immediate=False):
'''
Ensure that a device is unmapped
name
The name to ensure is not mapped
config
Set an alternative location for the crypttab, if the map is persistent,
Default is... | Ensure that a device is unmapped
name
The name to ensure is not mapped
config
Set an alternative location for the crypttab, if the map is persistent,
Default is ``/etc/crypttab``
persist
Set if the map should be removed from the crypttab. Default is ``True``
immediate... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cryptdev.py#L137-L188 | null | # -*- coding: utf-8 -*-
'''
Opening of Encrypted Devices
=======================
Ensure that an encrypted device is mapped with the `mapped` function:
.. code-block:: yaml
mappedname:
cryptdev.mapped:
- device: /dev/sdb1
- keyfile: /etc/keyfile.key
- opts:
- size=256
... |
saltstack/salt | salt/runners/pillar.py | show_top | python | def show_top(minion=None, saltenv='base'):
'''
Returns the compiled top data for pillar for a specific minion. If no
minion is specified, we use the first minion we find.
CLI Example:
.. code-block:: bash
salt-run pillar.show_top
'''
id_, grains, _ = salt.utils.minions.get_minion... | Returns the compiled top data for pillar for a specific minion. If no
minion is specified, we use the first minion we find.
CLI Example:
.. code-block:: bash
salt-run pillar.show_top | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/pillar.py#L13-L43 | [
"def get_minion_data(minion, opts):\n '''\n Get the grains/pillar for a specific minion. If minion is None, it\n will return the grains/pillar for the first minion it finds.\n\n Return value is a tuple of the minion ID, grains, and pillar\n '''\n grains = None\n pillar = None\n if opts.get(... | # -*- coding: utf-8 -*-
'''
Functions to interact with the pillar compiler on the master
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import salt libs
import salt.pillar
import salt.loader
import salt.utils.minions
def show_pillar(minion='*', **kwargs):
'''
Returns the comp... |
saltstack/salt | salt/runners/pillar.py | show_pillar | python | def show_pillar(minion='*', **kwargs):
'''
Returns the compiled pillar either of a specific minion
or just the global available pillars. This function assumes
that no minion has the id ``*``.
Function also accepts pillarenv as attribute in order to limit to a specific pillar branch of git
CLI E... | Returns the compiled pillar either of a specific minion
or just the global available pillars. This function assumes
that no minion has the id ``*``.
Function also accepts pillarenv as attribute in order to limit to a specific pillar branch of git
CLI Example:
shows minion specific pillar:
.. ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/pillar.py#L46-L122 | [
"def get_minion_data(minion, opts):\n '''\n Get the grains/pillar for a specific minion. If minion is None, it\n will return the grains/pillar for the first minion it finds.\n\n Return value is a tuple of the minion ID, grains, and pillar\n '''\n grains = None\n pillar = None\n if opts.get(... | # -*- coding: utf-8 -*-
'''
Functions to interact with the pillar compiler on the master
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import salt libs
import salt.pillar
import salt.loader
import salt.utils.minions
def show_top(minion=None, saltenv='base'):
'''
Returns the c... |
saltstack/salt | salt/modules/rvm.py | install | python | def install(runas=None):
'''
Install RVM system-wide
runas
The user under which to run the rvm installer script. If not specified,
then it be run as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.install
'''
# RVM dependencies... | Install RVM system-wide
runas
The user under which to run the rvm installer script. If not specified,
then it be run as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.install | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L79-L108 | null | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | install_ruby | python | def install_ruby(ruby, runas=None, opts=None, env=None):
'''
Install a ruby implementation.
ruby
The version of ruby to install
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
env
Environment to... | Install a ruby implementation.
ruby
The version of ruby to install
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
env
Environment to set for the install command. Useful for exporting compilation
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L111-L146 | [
"def _rvm(command, runas=None, cwd=None, env=None):\n if runas is None:\n runas = __salt__['config.option']('rvm.runas')\n if not is_installed(runas):\n return False\n\n cmd = _get_rvm_location(runas) + command\n\n ret = __salt__['cmd.run_all'](cmd,\n runas... | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | reinstall_ruby | python | def reinstall_ruby(ruby, runas=None, env=None):
'''
Reinstall a ruby implementation
ruby
The version of ruby to reinstall
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:... | Reinstall a ruby implementation
ruby
The version of ruby to reinstall
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.reinstall_ruby 1.9.3-p385 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L149-L166 | [
"def _rvm(command, runas=None, cwd=None, env=None):\n if runas is None:\n runas = __salt__['config.option']('rvm.runas')\n if not is_installed(runas):\n return False\n\n cmd = _get_rvm_location(runas) + command\n\n ret = __salt__['cmd.run_all'](cmd,\n runas... | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | list_ | python | def list_(runas=None):
'''
List all rvm-installed rubies
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.list
'''
rubies = []
output = _rvm(['... | List all rvm-installed rubies
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.list | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L169-L193 | [
"def _rvm(command, runas=None, cwd=None, env=None):\n if runas is None:\n runas = __salt__['config.option']('rvm.runas')\n if not is_installed(runas):\n return False\n\n cmd = _get_rvm_location(runas) + command\n\n ret = __salt__['cmd.run_all'](cmd,\n runas... | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | wrapper | python | def wrapper(ruby_string, wrapper_prefix, runas=None, *binaries):
'''
Install RVM wrapper scripts
ruby_string
Ruby/gemset to install wrappers for
wrapper_prefix
What to prepend to the name of the generated wrapper binaries
runas
The user under which to run rvm. If not speci... | Install RVM wrapper scripts
ruby_string
Ruby/gemset to install wrappers for
wrapper_prefix
What to prepend to the name of the generated wrapper binaries
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L232-L259 | [
"def _rvm(command, runas=None, cwd=None, env=None):\n if runas is None:\n runas = __salt__['config.option']('rvm.runas')\n if not is_installed(runas):\n return False\n\n cmd = _get_rvm_location(runas) + command\n\n ret = __salt__['cmd.run_all'](cmd,\n runas... | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | gemset_list | python | def gemset_list(ruby='default', runas=None):
'''
List all gemsets for the given ruby.
ruby : default
The ruby version for which to list the gemsets
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Ex... | List all gemsets for the given ruby.
ruby : default
The ruby version for which to list the gemsets
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.ge... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L309-L334 | [
"def _rvm_do(ruby, command, runas=None, cwd=None, env=None):\n return _rvm([ruby or 'default', 'do'] + command, runas=runas, cwd=cwd, env=env)\n"
] | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | gemset_list_all | python | def gemset_list_all(runas=None):
'''
List all gemsets for all installed rubies.
Note that you must have set a default ruby before this can work.
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
... | List all gemsets for all installed rubies.
Note that you must have set a default ruby before this can work.
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.g... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L410-L440 | [
"def _rvm_do(ruby, command, runas=None, cwd=None, env=None):\n return _rvm([ruby or 'default', 'do'] + command, runas=runas, cwd=cwd, env=env)\n"
] | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | salt/modules/rvm.py | do | python | def do(ruby, command, runas=None, cwd=None, env=None): # pylint: disable=C0103
'''
Execute a command in an RVM controlled environment.
ruby
Which ruby to use
command
The rvm command to execute
runas
The user under which to run rvm. If not specified, then rvm will be run
... | Execute a command in an RVM controlled environment.
ruby
Which ruby to use
command
The rvm command to execute
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
cwd
The directory from which to... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rvm.py#L443-L471 | [
"def shlex_split(s, **kwargs):\n '''\n Only split if variable is a string\n '''\n if isinstance(s, six.string_types):\n # On PY2, shlex.split will fail with unicode types if there are\n # non-ascii characters in the string. So, we need to make sure we\n # invoke it with a str type, ... | # -*- coding: utf-8 -*-
'''
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import python libs
import re
import os
import logging
# Import salt libs
import salt.utils.args
from salt.exceptions import CommandExecut... |
saltstack/salt | doc/_ext/saltdomain.py | LiterateCoding.parse_file | python | def parse_file(self, fpath):
'''
Read a file on the file system (relative to salt's base project dir)
:returns: A file-like object.
:raises IOError: If the file cannot be found or read.
'''
sdir = os.path.abspath(os.path.join(os.path.dirname(salt.__file__),
... | Read a file on the file system (relative to salt's base project dir)
:returns: A file-like object.
:raises IOError: If the file cannot be found or read. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/_ext/saltdomain.py#L40-L50 | null | class LiterateCoding(Directive):
'''
Auto-doc SLS files using literate-style comment/code separation
'''
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = False
def parse_lit(self, lines):
'''
Parse a string line-by-line delin... |
saltstack/salt | doc/_ext/saltdomain.py | LiterateCoding.parse_lit | python | def parse_lit(self, lines):
'''
Parse a string line-by-line delineating comments and code
:returns: An tuple of boolean/list-of-string pairs. True designates a
comment; False designates code.
'''
comment_char = '#' # TODO: move this into a directive option
co... | Parse a string line-by-line delineating comments and code
:returns: An tuple of boolean/list-of-string pairs. True designates a
comment; False designates code. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/_ext/saltdomain.py#L52-L72 | null | class LiterateCoding(Directive):
'''
Auto-doc SLS files using literate-style comment/code separation
'''
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = False
def parse_file(self, fpath):
'''
Read a file on the file system (r... |
saltstack/salt | doc/_ext/saltdomain.py | LiterateFormula.parse_file | python | def parse_file(self, sls_path):
'''
Given a typical Salt SLS path (e.g.: apache.vhosts.standard), find the
file on the file system and parse it
'''
config = self.state.document.settings.env.config
formulas_dirs = config.formulas_dirs
fpath = sls_path.replace('.', ... | Given a typical Salt SLS path (e.g.: apache.vhosts.standard), find the
file on the file system and parse it | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/_ext/saltdomain.py#L134-L159 | null | class LiterateFormula(LiterateCoding):
'''
Customizations to handle finding and parsing SLS files
'''
|
saltstack/salt | salt/matchers/compound_pillar_exact_match.py | mmatch | python | def mmatch(expr, delimiter, greedy, opts=None):
'''
Return the minions found by looking via pillar
'''
if not opts:
opts = __opts__
ckminions = salt.utils.minions.CkMinions(opts)
return ckminions._check_compound_minions(expr, delimiter, greedy,
... | Return the minions found by looking via pillar | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/matchers/compound_pillar_exact_match.py#L17-L26 | [
"def _check_compound_minions(self,\n expr,\n delimiter,\n greedy,\n pillar_exact=False): # pylint: disable=unused-argument\n '''\n Return the minions found by looking via compound matcher\n '''\n ... | # -*- coding: utf-8 -*-
'''
This is the default pillar exact matcher for compound matches.
There is no minion-side equivalent for this, so consequently there is no ``match()``
function below, only an ``mmatch()``
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import salt.... |
saltstack/salt | salt/modules/sysfs.py | attr | python | def attr(key, value=None):
'''
Access/write a SysFS attribute.
If the attribute is a symlink, it's destination is returned
:return: value or bool
CLI example:
.. code-block:: bash
salt '*' sysfs.attr block/sda/queue/logical_block_size
'''
key = target(key)
if key is Fals... | Access/write a SysFS attribute.
If the attribute is a symlink, it's destination is returned
:return: value or bool
CLI example:
.. code-block:: bash
salt '*' sysfs.attr block/sda/queue/logical_block_size | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysfs.py#L32-L53 | [
"def target(key, full=True):\n '''\n Return the basename of a SysFS key path\n\n :param key: the location to resolve within SysFS\n :param full: full path instead of basename\n\n :return: fullpath or basename of path\n\n CLI example:\n .. code-block:: bash\n\n salt '*' sysfs.read class/... | # -*- coding: utf-8 -*-
'''
Module for interfacing with SysFS
.. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
.. versionadded:: 2016.3.0
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import stat
# Import Salt libs... |
saltstack/salt | salt/modules/sysfs.py | write | python | def write(key, value):
'''
Write a SysFS attribute/action
CLI example:
.. code-block:: bash
salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance'
'''
try:
key = target(key)
log.trace('Writing %s to %s', value, key)
with salt.utils.... | Write a SysFS attribute/action
CLI example:
.. code-block:: bash
salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysfs.py#L56-L74 | [
"def target(key, full=True):\n '''\n Return the basename of a SysFS key path\n\n :param key: the location to resolve within SysFS\n :param full: full path instead of basename\n\n :return: fullpath or basename of path\n\n CLI example:\n .. code-block:: bash\n\n salt '*' sysfs.read class/... | # -*- coding: utf-8 -*-
'''
Module for interfacing with SysFS
.. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
.. versionadded:: 2016.3.0
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import stat
# Import Salt libs... |
saltstack/salt | salt/modules/sysfs.py | read | python | def read(key, root=''):
'''
Read from SysFS
:param key: file or path in SysFS; if key is a list then root will be prefixed on each key
:return: the full (tree of) SysFS attributes under key
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/net/em1/statistics
'''
i... | Read from SysFS
:param key: file or path in SysFS; if key is a list then root will be prefixed on each key
:return: the full (tree of) SysFS attributes under key
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/net/em1/statistics | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysfs.py#L77-L139 | [
"def read(key, root=''):\n '''\n Read from SysFS\n\n :param key: file or path in SysFS; if key is a list then root will be prefixed on each key\n\n :return: the full (tree of) SysFS attributes under key\n\n CLI example:\n .. code-block:: bash\n\n salt '*' sysfs.read class/net/em1/statistic... | # -*- coding: utf-8 -*-
'''
Module for interfacing with SysFS
.. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
.. versionadded:: 2016.3.0
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import stat
# Import Salt libs... |
saltstack/salt | salt/modules/sysfs.py | target | python | def target(key, full=True):
'''
Return the basename of a SysFS key path
:param key: the location to resolve within SysFS
:param full: full path instead of basename
:return: fullpath or basename of path
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/ttyS0
'''
... | Return the basename of a SysFS key path
:param key: the location to resolve within SysFS
:param full: full path instead of basename
:return: fullpath or basename of path
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/ttyS0 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysfs.py#L142-L167 | null | # -*- coding: utf-8 -*-
'''
Module for interfacing with SysFS
.. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
.. versionadded:: 2016.3.0
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import stat
# Import Salt libs... |
saltstack/salt | salt/modules/sysfs.py | interfaces | python | def interfaces(root):
'''
Generate a dictionary with all available interfaces relative to root.
Symlinks are not followed.
CLI example:
.. code-block:: bash
salt '*' sysfs.interfaces block/bcache0/bcache
Output example:
.. code-block:: json
{
"r": [
... | Generate a dictionary with all available interfaces relative to root.
Symlinks are not followed.
CLI example:
.. code-block:: bash
salt '*' sysfs.interfaces block/bcache0/bcache
Output example:
.. code-block:: json
{
"r": [
"state",
"partial_str... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysfs.py#L170-L263 | [
"def target(key, full=True):\n '''\n Return the basename of a SysFS key path\n\n :param key: the location to resolve within SysFS\n :param full: full path instead of basename\n\n :return: fullpath or basename of path\n\n CLI example:\n .. code-block:: bash\n\n salt '*' sysfs.read class/... | # -*- coding: utf-8 -*-
'''
Module for interfacing with SysFS
.. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
.. versionadded:: 2016.3.0
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import stat
# Import Salt libs... |
saltstack/salt | salt/returners/librato_return.py | _get_librato | python | def _get_librato(ret=None):
'''
Return a Librato connection object.
'''
_options = _get_options(ret)
conn = librato.connect(
_options.get('email'),
_options.get('api_token'),
sanitizer=librato.sanitize_metric_name,
hostname=_options.get('api_url'))
log.info("Conn... | Return a Librato connection object. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/librato_return.py#L82-L94 | [
"def _get_options(ret=None):\n '''\n Get the Librato options from salt.\n '''\n attrs = {'email': 'email',\n 'api_token': 'api_token',\n 'api_url': 'api_url'\n }\n\n _options = salt.returners.get_returner_options(__virtualname__,\n ... | # -*- coding: utf-8 -*-
'''
Salt returner to return highstate stats to Librato
To enable this returner the minion will need the Librato
client importable on the Python path and the following
values configured in the minion or master config.
The Librato python client can be found at:
https://github.com/librato/python-... |
saltstack/salt | salt/returners/librato_return.py | returner | python | def returner(ret):
'''
Parse the return data and return metrics to Librato.
'''
librato_conn = _get_librato(ret)
q = librato_conn.new_queue()
if ret['fun'] == 'state.highstate':
log.debug('Found returned Highstate data.')
# Calculate the runtimes and number of failed states.
... | Parse the return data and return metrics to Librato. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/librato_return.py#L119-L161 | [
"def _calculate_runtimes(states):\n results = {\n 'runtime': 0.00,\n 'num_failed_states': 0,\n 'num_passed_states': 0\n }\n\n for state, resultset in states.items():\n if isinstance(resultset, dict) and 'duration' in resultset:\n # Count the pass vs failures\n ... | # -*- coding: utf-8 -*-
'''
Salt returner to return highstate stats to Librato
To enable this returner the minion will need the Librato
client importable on the Python path and the following
values configured in the minion or master config.
The Librato python client can be found at:
https://github.com/librato/python-... |
saltstack/salt | salt/states/keystone_endpoint.py | _common | python | def _common(ret, name, service_name, kwargs):
'''
Returns: tuple whose first element is a bool indicating success or failure
and the second element is either a ret dict for salt or an object
'''
if 'interface' not in kwargs and 'public_url' not in kwargs:
kwargs['interface'] = name
... | Returns: tuple whose first element is a bool indicating success or failure
and the second element is either a ret dict for salt or an object | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_endpoint.py#L51-L77 | null | # -*- coding: utf-8 -*-
'''
Management of OpenStack Keystone Endpoints
==========================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create endpoint:
keystone_endpoint.... |
saltstack/salt | salt/states/keystone_endpoint.py | present | python | def present(name, service_name, auth=None, **kwargs):
'''
Ensure an endpoint exists and is up-to-date
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
enabled
Boolean to cont... | Ensure an endpoint exists and is up-to-date
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
enabled
Boolean to control if endpoint is enabled | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_endpoint.py#L80-L143 | [
"def _common(ret, name, service_name, kwargs):\n '''\n Returns: tuple whose first element is a bool indicating success or failure\n and the second element is either a ret dict for salt or an object\n '''\n if 'interface' not in kwargs and 'public_url' not in kwargs:\n kwargs['interfac... | # -*- coding: utf-8 -*-
'''
Management of OpenStack Keystone Endpoints
==========================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create endpoint:
keystone_endpoint.... |
saltstack/salt | salt/states/keystone_endpoint.py | absent | python | def absent(name, service_name, auth=None, **kwargs):
'''
Ensure an endpoint does not exists
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
'''
ret = {'name': name,
'c... | Ensure an endpoint does not exists
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_endpoint.py#L146-L184 | [
"def _common(ret, name, service_name, kwargs):\n '''\n Returns: tuple whose first element is a bool indicating success or failure\n and the second element is either a ret dict for salt or an object\n '''\n if 'interface' not in kwargs and 'public_url' not in kwargs:\n kwargs['interfac... | # -*- coding: utf-8 -*-
'''
Management of OpenStack Keystone Endpoints
==========================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create endpoint:
keystone_endpoint.... |
saltstack/salt | salt/runners/bgp.py | _get_bgp_runner_opts | python | def _get_bgp_runner_opts():
'''
Return the bgp runner options.
'''
runner_opts = __opts__.get('runners', {}).get('bgp', {})
return {
'tgt': runner_opts.get('tgt', _DEFAULT_TARGET),
'tgt_type': runner_opts.get('tgt_type', _DEFAULT_EXPR_FORM),
'display': runner_opts.get('displa... | Return the bgp runner options. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/bgp.py#L167-L178 | null | # -*- coding: utf-8 -*-
'''
BGP Finder
==========
.. versionadded:: 2017.7.0
Runner to search BGP neighbors details.
Configuration
-------------
- Minion (proxy) config
The ``bgp.neighbors`` function must be appened in the list of ``mine_functions``:
.. code-block:: yaml
mine_functions:
... |
saltstack/salt | salt/runners/bgp.py | _compare_match | python | def _compare_match(dict1, dict2):
'''
Compare two dictionaries and return a boolean value if their values match.
'''
for karg, warg in six.iteritems(dict1):
if karg in dict2 and dict2[karg] != warg:
return False
return True | Compare two dictionaries and return a boolean value if their values match. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/bgp.py#L193-L200 | null | # -*- coding: utf-8 -*-
'''
BGP Finder
==========
.. versionadded:: 2017.7.0
Runner to search BGP neighbors details.
Configuration
-------------
- Minion (proxy) config
The ``bgp.neighbors`` function must be appened in the list of ``mine_functions``:
.. code-block:: yaml
mine_functions:
... |
saltstack/salt | salt/runners/bgp.py | _display_runner | python | def _display_runner(rows,
labels,
title,
display=_DEFAULT_DISPLAY,
outputter=_DEFAULT_OUTPUTTER):
'''
Display or return the rows.
'''
if display:
if outputter == 'table':
ret = salt.output.out_format({'ro... | Display or return the rows. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/bgp.py#L203-L225 | null | # -*- coding: utf-8 -*-
'''
BGP Finder
==========
.. versionadded:: 2017.7.0
Runner to search BGP neighbors details.
Configuration
-------------
- Minion (proxy) config
The ``bgp.neighbors`` function must be appened in the list of ``mine_functions``:
.. code-block:: yaml
mine_functions:
... |
saltstack/salt | salt/runners/bgp.py | neighbors | python | def neighbors(*asns, **kwargs):
'''
Search for BGP neighbors details in the mines of the ``bgp.neighbors`` function.
Arguments:
asns
A list of AS numbers to search for.
The runner will return only the neighbors of these AS numbers.
device
Filter by device name (minion ID).... | Search for BGP neighbors details in the mines of the ``bgp.neighbors`` function.
Arguments:
asns
A list of AS numbers to search for.
The runner will return only the neighbors of these AS numbers.
device
Filter by device name (minion ID).
ip
Search BGP neighbor using t... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/bgp.py#L232-L409 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _get_bgp_runner_opts():\n '''\n Return the bgp runner options.\n '''\n runner_opts = __opts__.get('runners', {}).get('bgp', {})\n return {\n 'tgt': runner_opts.get('tgt', _DEFAULT_TARGET),\n 'tgt_type': runner_opts.get('t... | # -*- coding: utf-8 -*-
'''
BGP Finder
==========
.. versionadded:: 2017.7.0
Runner to search BGP neighbors details.
Configuration
-------------
- Minion (proxy) config
The ``bgp.neighbors`` function must be appened in the list of ``mine_functions``:
.. code-block:: yaml
mine_functions:
... |
saltstack/salt | salt/returners/mongo_future_return.py | _get_conn | python | def _get_conn(ret):
'''
Return a mongodb connection object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
uri = _options.get('uri')
db_ = _options.get('db')
user = _options.get('user')
password = _options.get('password')
indexes = _o... | Return a mongodb connection object | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L158-L207 | [
"def _get_options(ret=None):\n '''\n Get the mongo options from salt.\n '''\n attrs = {'host': 'host',\n 'port': 'port',\n 'db': 'db',\n 'user': 'user',\n 'password': 'password',\n 'indexes': 'indexes',\n 'uri': 'uri'}\n\n _optio... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | returner | python | def returner(ret):
'''
Return data to a mongodb server
'''
conn, mdb = _get_conn(ret)
if isinstance(ret['return'], dict):
back = _remove_dots(ret['return'])
else:
back = ret['return']
if isinstance(ret, dict):
full_ret = _remove_dots(ret)
else:
full_ret ... | Return data to a mongodb server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L210-L241 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | _safe_copy | python | def _safe_copy(dat):
''' mongodb doesn't allow '.' in keys, but does allow unicode equivs.
Apparently the docs suggest using escaped unicode full-width
encodings. *sigh*
\\ --> \\\\
$ --> \\\\u0024
. --> \\\\u002e
Personally, I prefer URL encoding... | mongodb doesn't allow '.' in keys, but does allow unicode equivs.
Apparently the docs suggest using escaped unicode full-width
encodings. *sigh*
\\ --> \\\\
$ --> \\\\u0024
. --> \\\\u002e
Personally, I prefer URL encodings,
\\ --> %5c
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L244-L277 | [
"def _safe_copy(dat):\n ''' mongodb doesn't allow '.' in keys, but does allow unicode equivs.\n Apparently the docs suggest using escaped unicode full-width\n encodings. *sigh*\n\n \\\\ --> \\\\\\\\\n $ --> \\\\\\\\u0024\n . --> \\\\\\\\u002e\n\n Perso... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | save_load | python | def save_load(jid, load, minions=None):
'''
Save the load for a given job id
'''
conn, mdb = _get_conn(ret=None)
to_save = _safe_copy(load)
if PYMONGO_VERSION > _LooseVersion('2.3'):
#using .copy() to ensure original data for load is unchanged
mdb.jobs.insert_one(to_save)
el... | Save the load for a given job id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L280-L291 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | get_load | python | def get_load(jid):
'''
Return the load associated with a given job id
'''
conn, mdb = _get_conn(ret=None)
return mdb.jobs.find_one({'jid': jid}, {'_id': 0}) | Return the load associated with a given job id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L301-L306 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | get_minions | python | def get_minions():
'''
Return a list of minions
'''
conn, mdb = _get_conn(ret=None)
ret = []
name = mdb.saltReturns.distinct('minion')
ret.append(name)
return ret | Return a list of minions | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L336-L344 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | get_jids | python | def get_jids():
'''
Return a list of job ids
'''
conn, mdb = _get_conn(ret=None)
map = "function() { emit(this.jid, this); }"
reduce = "function (key, values) { return values[0]; }"
result = mdb.jobs.inline_map_reduce(map, reduce)
ret = {}
for r in result:
jid = r['_id']
... | Return a list of job ids | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L347-L359 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/returners/mongo_future_return.py | event_return | python | def event_return(events):
'''
Return events to Mongodb server
'''
conn, mdb = _get_conn(ret=None)
if isinstance(events, list):
events = events[0]
if isinstance(events, dict):
log.debug(events)
if PYMONGO_VERSION > _LooseVersion('2.3'):
mdb.events.insert_one... | Return events to Mongodb server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_future_return.py#L369-L384 | [
"def _get_conn(ret):\n '''\n Return a mongodb connection object\n '''\n _options = _get_options(ret)\n\n host = _options.get('host')\n port = _options.get('port')\n uri = _options.get('uri')\n db_ = _options.get('db')\n user = _options.get('user')\n password = _options.get('password')\... | # -*- coding: utf-8 -*-
'''
Return data to a mongodb server
Required python modules: pymongo
This returner will send data from the minions to a MongoDB server. MongoDB
server can be configured by using host, port, db, user and password settings
or by connection string URI (for pymongo > 2.3). To configure the settin... |
saltstack/salt | salt/client/ssh/__init__.py | lowstate_file_refs | python | def lowstate_file_refs(chunks):
'''
Create a list of file ref objects to reconcile
'''
refs = {}
for chunk in chunks:
saltenv = 'base'
crefs = []
for state in chunk:
if state == '__env__':
saltenv = chunk[state]
elif state == 'saltenv':... | Create a list of file ref objects to reconcile | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1535-L1555 | [
"def salt_refs(data):\n '''\n Pull salt file references out of the states\n '''\n proto = 'salt://'\n ret = []\n if isinstance(data, six.string_types):\n if data.startswith(proto):\n return [data]\n if isinstance(data, list):\n for comp in data:\n if isinstan... | # -*- coding: utf-8 -*-
'''
Create ssh executor system
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import copy
import getpass
import logging
import multiprocessing
import subprocess
import hashlib
import tarfile
import os
import re
import sys
import ti... |
saltstack/salt | salt/client/ssh/__init__.py | salt_refs | python | def salt_refs(data):
'''
Pull salt file references out of the states
'''
proto = 'salt://'
ret = []
if isinstance(data, six.string_types):
if data.startswith(proto):
return [data]
if isinstance(data, list):
for comp in data:
if isinstance(comp, six.str... | Pull salt file references out of the states | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1558-L1572 | null | # -*- coding: utf-8 -*-
'''
Create ssh executor system
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import copy
import getpass
import logging
import multiprocessing
import subprocess
import hashlib
import tarfile
import os
import re
import sys
import ti... |
saltstack/salt | salt/client/ssh/__init__.py | mod_data | python | def mod_data(fsclient):
'''
Generate the module arguments for the shim data
'''
# TODO, change out for a fileserver backend
sync_refs = [
'modules',
'states',
'grains',
'renderers',
'returners',
]
ret = {}
envs = fsclien... | Generate the module arguments for the shim data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1575-L1633 | [
"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 -*-
'''
Create ssh executor system
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import copy
import getpass
import logging
import multiprocessing
import subprocess
import hashlib
import tarfile
import os
import re
import sys
import ti... |
saltstack/salt | salt/client/ssh/__init__.py | ssh_version | python | def ssh_version():
'''
Returns the version of the installed ssh command
'''
# This function needs more granular checks and to be validated against
# older versions of ssh
ret = subprocess.Popen(
['ssh', '-V'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).co... | Returns the version of the installed ssh command | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1636-L1656 | null | # -*- coding: utf-8 -*-
'''
Create ssh executor system
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import copy
import getpass
import logging
import multiprocessing
import subprocess
import hashlib
import tarfile
import os
import re
import sys
import ti... |
saltstack/salt | salt/client/ssh/__init__.py | _convert_args | python | def _convert_args(args):
'''
Take a list of args, and convert any dicts inside the list to keyword
args in the form of `key=value`, ready to be passed to salt-ssh
'''
converted = []
for arg in args:
if isinstance(arg, dict):
for key in list(arg.keys()):
if key... | Take a list of args, and convert any dicts inside the list to keyword
args in the form of `key=value`, ready to be passed to salt-ssh | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1659-L1673 | null | # -*- coding: utf-8 -*-
'''
Create ssh executor system
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import copy
import getpass
import logging
import multiprocessing
import subprocess
import hashlib
import tarfile
import os
import re
import sys
import ti... |
saltstack/salt | salt/client/ssh/__init__.py | SSH._get_roster | python | def _get_roster(self):
'''
Read roster filename as a key to the data.
:return:
'''
roster_file = salt.roster.get_roster_file(self.opts)
if roster_file not in self.__parsed_rosters:
roster_data = compile_template(roster_file, salt.loader.render(self.opts, {}),
... | Read roster filename as a key to the data.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L330-L341 | null | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH._expand_target | python | def _expand_target(self):
'''
Figures out if the target is a reachable host without wildcards, expands if any.
:return:
'''
# TODO: Support -L
target = self.opts['tgt']
if isinstance(target, list):
return
hostname = self.opts['tgt'].split('@')... | Figures out if the target is a reachable host without wildcards, expands if any.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L343-L371 | [
"def is_reachable_host(entity_name):\n '''\n Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).\n :param hostname:\n :return:\n '''\n try:\n assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list\n ret = True\n except socket.gaierror:\n ... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH._update_roster | python | def _update_roster(self):
'''
Update default flat roster with the passed in information.
:return:
'''
roster_file = self._get_roster()
if os.access(roster_file, os.W_OK):
if self.__parsed_rosters[self.ROSTER_UPDATE_FLAG]:
with salt.utils.files.... | Update default flat roster with the passed in information.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L373-L392 | null | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH._update_targets | python | def _update_targets(self):
'''
Uptade targets in case hostname was directly passed without the roster.
:return:
'''
hostname = self.opts.get('tgt', '')
if '@' in hostname:
user, hostname = hostname.split('@', 1)
else:
user = self.opts.get(... | Uptade targets in case hostname was directly passed without the roster.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L394-L417 | [
"def is_reachable_host(entity_name):\n '''\n Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).\n :param hostname:\n :return:\n '''\n try:\n assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list\n ret = True\n except socket.gaierror:\n ... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.get_pubkey | python | def get_pubkey(self):
'''
Return the key string for the SSH public key
'''
if '__master_opts__' in self.opts and \
self.opts['__master_opts__'].get('ssh_use_home_key') and \
os.path.isfile(os.path.expanduser('~/.ssh/id_rsa')):
priv = os.path.ex... | Return the key string for the SSH public key | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L419-L438 | [
"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 ... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.key_deploy | python | def key_deploy(self, host, ret):
'''
Deploy the SSH key if the minions don't auth
'''
if not isinstance(ret[host], dict) or self.opts.get('ssh_key_deploy'):
target = self.targets[host]
if target.get('passwd', False) or self.opts['ssh_passwd']:
self... | Deploy the SSH key if the minions don't auth | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L440-L461 | [
"def _key_deploy_run(self, host, target, re_run=True):\n '''\n The ssh-copy-id routine\n '''\n argv = [\n 'ssh.set_auth_key',\n target.get('user', 'root'),\n self.get_pubkey(),\n ]\n\n single = Single(\n self.opts,\n argv,\n host,\n ... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH._key_deploy_run | python | def _key_deploy_run(self, host, target, re_run=True):
'''
The ssh-copy-id routine
'''
argv = [
'ssh.set_auth_key',
target.get('user', 'root'),
self.get_pubkey(),
]
single = Single(
self.opts,
argv,
... | The ssh-copy-id routine | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L463-L506 | [
"def find_json(raw):\n '''\n Pass in a raw string and load the json when it starts. This allows for a\n string to start with garbage and end with json but be cleanly loaded\n '''\n ret = {}\n lines = __split(raw)\n for ind, _ in enumerate(lines):\n try:\n working = '\\n'.join(... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.handle_routine | python | def handle_routine(self, que, opts, host, target, mine=False):
'''
Run the routine in a "Thread", put a dict on the queue
'''
opts = copy.deepcopy(opts)
single = Single(
opts,
opts['argv'],
host,
mods=self.mods,
... | Run the routine in a "Thread", put a dict on the queue | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L508-L541 | [
"def find_json(raw):\n '''\n Pass in a raw string and load the json when it starts. This allows for a\n string to start with garbage and end with json but be cleanly loaded\n '''\n ret = {}\n lines = __split(raw)\n for ind, _ in enumerate(lines):\n try:\n working = '\\n'.join(... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.handle_ssh | python | def handle_ssh(self, mine=False):
'''
Spin up the needed threads or processes and execute the subsequent
routines
'''
que = multiprocessing.Queue()
running = {}
target_iter = self.targets.__iter__()
returned = set()
rets = set()
init = Fals... | Spin up the needed threads or processes and execute the subsequent
routines | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L543-L637 | null | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.run_iter | python | def run_iter(self, mine=False, jid=None):
'''
Execute and yield returns as they come in, do not print to the display
mine
The Single objects will use mine_functions defined in the roster,
pillar, or master config (they will be checked in that order) and
will ... | Execute and yield returns as they come in, do not print to the display
mine
The Single objects will use mine_functions defined in the roster,
pillar, or master config (they will be checked in that order) and
will modify the argv with the arguments from mine_functions | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L639-L691 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"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... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.cache_job | python | def cache_job(self, jid, id_, ret, fun):
'''
Cache the job information
'''
self.returners['{0}.returner'.format(self.opts['master_job_cache'])]({'jid': jid,
'id': id_,
... | Cache the job information | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L693-L700 | null | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | SSH.run | python | def run(self, jid=None):
'''
Execute the overall routine, print results via outputters
'''
if self.opts.get('list_hosts'):
self._get_roster()
ret = {}
for roster_file in self.__parsed_rosters:
if roster_file.startswith('#'):
... | Execute the overall routine, print results via outputters | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L702-L812 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def display_output(data, out=None, opts=None, **kwargs):\n '''\n Print the passed data using the desired output\n '''\n if opts is None:\n opts = {}\n display_data = try_printout(data, out, opts, **kwargs)\n\n output_filename = opt... | class SSH(object):
'''
Create an SSH execution system
'''
ROSTER_UPDATE_FLAG = '#__needs_update'
def __init__(self, opts):
self.__parsed_rosters = {SSH.ROSTER_UPDATE_FLAG: True}
pull_sock = os.path.join(opts['sock_dir'], 'master_event_pull.ipc')
if os.path.exists(pull_sock) ... |
saltstack/salt | salt/client/ssh/__init__.py | Single.__arg_comps | python | def __arg_comps(self):
'''
Return the function name and the arg list
'''
fun = self.argv[0] if self.argv else ''
parsed = salt.utils.args.parse_input(
self.argv[1:],
condition=False,
no_parse=self.opts.get('no_parse', []))
args = parsed... | Return the function name and the arg list | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L932-L943 | [
"def parse_input(args, kwargs=None, condition=True, no_parse=None):\n '''\n Parse out the args and kwargs from a list of input values. Optionally,\n return the args and kwargs without passing them to condition_input().\n\n Don't pull args with key=val apart if it has a newline in it.\n '''\n if no... | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single._escape_arg | python | def _escape_arg(self, arg):
'''
Properly escape argument to protect special characters from shell
interpretation. This avoids having to do tricky argument quoting.
Effectively just escape all characters in the argument that are not
alphanumeric!
'''
if self.winr... | Properly escape argument to protect special characters from shell
interpretation. This avoids having to do tricky argument quoting.
Effectively just escape all characters in the argument that are not
alphanumeric! | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L945-L955 | null | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.deploy | python | def deploy(self):
'''
Deploy salt-thin
'''
self.shell.send(
self.thin,
os.path.join(self.thin_dir, 'salt-thin.tgz'),
)
self.deploy_ext()
return True | Deploy salt-thin | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L957-L966 | [
"def deploy_ext(self):\n '''\n Deploy the ext_mods tarball\n '''\n if self.mods.get('file'):\n self.shell.send(\n self.mods['file'],\n os.path.join(self.thin_dir, 'salt-ext_mods.tgz'),\n )\n return True\n"
] | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.deploy_ext | python | def deploy_ext(self):
'''
Deploy the ext_mods tarball
'''
if self.mods.get('file'):
self.shell.send(
self.mods['file'],
os.path.join(self.thin_dir, 'salt-ext_mods.tgz'),
)
return True | Deploy the ext_mods tarball | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L968-L977 | null | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.run | python | def run(self, deploy_attempted=False):
'''
Execute the routine, the routine can be either:
1. Execute a raw shell command
2. Execute a wrapper func
3. Execute a remote Salt command
If a (re)deploy is needed, then retry the operation after a deploy
attempt
... | Execute the routine, the routine can be either:
1. Execute a raw shell command
2. Execute a wrapper func
3. Execute a remote Salt command
If a (re)deploy is needed, then retry the operation after a deploy
attempt
Returns tuple of (stdout, stderr, retcode) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L979-L1003 | null | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.run_wfunc | python | def run_wfunc(self):
'''
Execute a wrapper function
Returns tuple of (json_data, '')
'''
# Ensure that opts/grains are up to date
# Execute routine
data_cache = False
data = None
cdir = os.path.join(self.opts['cachedir'], 'minions', self.id)
... | Execute a wrapper function
Returns tuple of (json_data, '') | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1005-L1195 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single._cmd_str | python | def _cmd_str(self):
'''
Prepare the command string
'''
sudo = 'sudo' if self.target['sudo'] else ''
sudo_user = self.target['sudo_user']
if '_caller_cachedir' in self.opts:
cachedir = self.opts['_caller_cachedir']
else:
cachedir = self.opts... | Prepare the command string | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1197-L1256 | null | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.shim_cmd | python | def shim_cmd(self, cmd_str, extension='py'):
'''
Run a shim command.
If tty is enabled, we must scp the shim to the target system and
execute it there
'''
if not self.tty and not self.winrm:
return self.shell.exec_cmd(cmd_str)
# Write the shim to a t... | Run a shim command.
If tty is enabled, we must scp the shim to the target system and
execute it there | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1258-L1304 | null | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
saltstack/salt | salt/client/ssh/__init__.py | Single.cmd_block | python | def cmd_block(self, is_retry=False):
'''
Prepare the pre-check command to send to the subsystem
1. execute SHIM + command
2. check if SHIM returns a master request or if it completed
3. handle any master request
4. re-execute SHIM + command
5. split SHIM results ... | Prepare the pre-check command to send to the subsystem
1. execute SHIM + command
2. check if SHIM returns a master request or if it completed
3. handle any master request
4. re-execute SHIM + command
5. split SHIM results from command results
6. return command results | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1306-L1408 | [
"def _convert_args(args):\n '''\n Take a list of args, and convert any dicts inside the list to keyword\n args in the form of `key=value`, ready to be passed to salt-ssh\n '''\n converted = []\n for arg in args:\n if isinstance(arg, dict):\n for key in list(arg.keys()):\n ... | class Single(object):
'''
Hold onto a single ssh execution
'''
# 1. Get command ready
# 2. Check if target has salt
# 3. deploy salt-thin
# 4. execute requested command via salt-thin
def __init__(
self,
opts,
argv,
id_,
host,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.