repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/snapper.py | diff_jid | python | def diff_jid(jid, config='root'):
'''
Returns the changes applied by a `jid`
jid
The job id to lookup
config
Configuration name.
CLI Example:
.. code-block:: bash
salt '*' snapper.diff_jid jid=20160607130930720112
'''
pre_snapshot, post_snapshot = _get_jid_sn... | Returns the changes applied by a `jid`
jid
The job id to lookup
config
Configuration name.
CLI Example:
.. code-block:: bash
salt '*' snapper.diff_jid jid=20160607130930720112 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/snapper.py#L855-L872 | [
"def diff(config='root', filename=None, num_pre=None, num_post=None):\n '''\n Returns the differences between two snapshots\n\n config\n Configuration name.\n\n filename\n if not provided the showing differences between snapshots for\n all \"text\" files\n\n num_pre\n firs... | # -*- coding: utf-8 -*-
'''
Module to manage filesystem snapshots with snapper
.. versionadded:: 2016.11.0
:codeauthor: Duncan Mac-Vicar P. <dmacvicar@suse.de>
:codeauthor: Pablo Suárez Hernández <psuarezhernandez@suse.de>
:depends: ``dbus`` Python module.
:depends: ``snapper`` http://snapper.io, a... |
saltstack/salt | salt/modules/snapper.py | create_baseline | python | def create_baseline(tag="baseline", config='root'):
'''
Creates a snapshot marked as baseline
tag
Tag name for the baseline
config
Configuration name.
CLI Example:
.. code-block:: bash
salt '*' snapper.create_baseline
salt '*' snapper.create_baseline my_custo... | Creates a snapshot marked as baseline
tag
Tag name for the baseline
config
Configuration name.
CLI Example:
.. code-block:: bash
salt '*' snapper.create_baseline
salt '*' snapper.create_baseline my_custom_baseline | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/snapper.py#L875-L896 | null | # -*- coding: utf-8 -*-
'''
Module to manage filesystem snapshots with snapper
.. versionadded:: 2016.11.0
:codeauthor: Duncan Mac-Vicar P. <dmacvicar@suse.de>
:codeauthor: Pablo Suárez Hernández <psuarezhernandez@suse.de>
:depends: ``dbus`` Python module.
:depends: ``snapper`` http://snapper.io, a... |
saltstack/salt | salt/states/environ.py | setenv | python | def setenv(name,
value,
false_unsets=False,
clear_all=False,
update_minion=False,
permanent=False):
'''
Set the salt process environment variables.
name
The environment key to set. Must be a string.
value
Either a string or dict. W... | Set the salt process environment variables.
name
The environment key to set. Must be a string.
value
Either a string or dict. When string, it will be the value
set for the environment key of 'name' above.
When a dict, each key/value pair represents an environment
variab... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/environ.py#L34-L184 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _norm_key(key):\n '''\n Normalize windows environment keys\n '''\n if salt.utils.platform.is_windows():\n return key.upper()\n return key\n",
"def key_exists():\n if salt.utils.platform.is_windows():\n permanent_hive... | # -*- coding: utf-8 -*-
'''
Support for getting and setting the environment variables
of the current salt process.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
# Import Salt libs
import salt.utils.platform
# Import 3rd-party libs
from salt.ext import six... |
saltstack/salt | salt/modules/znc.py | _makepass | python | def _makepass(password, hasher='sha256'):
'''
Create a znc compatible hashed password
'''
# Setup the hasher
if hasher == 'sha256':
h = hashlib.sha256(password)
elif hasher == 'md5':
h = hashlib.md5(password)
else:
return NotImplemented
c = "abcdefghijklmnopqrstu... | Create a znc compatible hashed password | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/znc.py#L34-L58 | null | # -*- coding: utf-8 -*-
'''
znc - An advanced IRC bouncer
.. versionadded:: 2014.7.0
Provides an interface to basic ZNC functionality
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import hashlib
import logging
import os.path
import random
import signal
# Import sa... |
saltstack/salt | salt/modules/znc.py | buildmod | python | def buildmod(*modules):
'''
Build module using znc-buildmod
CLI Example:
.. code-block:: bash
salt '*' znc.buildmod module.cpp [...]
'''
# Check if module files are missing
missing = [module for module in modules if not os.path.exists(module)]
if missing:
return 'Error... | Build module using znc-buildmod
CLI Example:
.. code-block:: bash
salt '*' znc.buildmod module.cpp [...] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/znc.py#L61-L79 | null | # -*- coding: utf-8 -*-
'''
znc - An advanced IRC bouncer
.. versionadded:: 2014.7.0
Provides an interface to basic ZNC functionality
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import hashlib
import logging
import os.path
import random
import signal
# Import sa... |
saltstack/salt | salt/modules/znc.py | version | python | def version():
'''
Return server version from znc --version
CLI Example:
.. code-block:: bash
salt '*' znc.version
'''
cmd = ['znc', '--version']
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
ret = out[0].split(' - ')
return ret[0] | Return server version from znc --version
CLI Example:
.. code-block:: bash
salt '*' znc.version | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/znc.py#L108-L121 | null | # -*- coding: utf-8 -*-
'''
znc - An advanced IRC bouncer
.. versionadded:: 2014.7.0
Provides an interface to basic ZNC functionality
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import hashlib
import logging
import os.path
import random
import signal
# Import sa... |
saltstack/salt | salt/returners/odbc.py | _get_conn | python | def _get_conn(ret=None):
'''
Return a MSSQL connection.
'''
_options = _get_options(ret)
dsn = _options.get('dsn')
user = _options.get('user')
passwd = _options.get('passwd')
return pyodbc.connect('DSN={0};UID={1};PWD={2}'.format(
dsn,
user,
passwd)) | Return a MSSQL connection. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/odbc.py#L169-L181 | [
"def _get_options(ret=None):\n '''\n Get the odbc options from salt.\n '''\n attrs = {'dsn': 'dsn',\n 'user': 'user',\n 'passwd': 'passwd'}\n\n _options = salt.returners.get_returner_options('returner.{0}'.format(__virtualname__),\n ... | # -*- coding: utf-8 -*-
'''
Return data to an ODBC compliant server. This driver was
developed with Microsoft SQL Server in mind, but theoretically
could be used to return data to any compliant ODBC database
as long as there is a working ODBC driver for it on your
minion platform.
:maintainer: C. R. Oldham (cr@sal... |
saltstack/salt | salt/returners/odbc.py | returner | python | def returner(ret):
'''
Return data to an odbc server
'''
conn = _get_conn(ret)
cur = conn.cursor()
sql = '''INSERT INTO salt_returns
(fun, jid, retval, id, success, full_ret)
VALUES (?, ?, ?, ?, ?, ?)'''
cur.execute(
sql, (
ret['fun'],
... | Return data to an odbc server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/odbc.py#L192-L211 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Return data to an ODBC compliant server. This driver was
developed with Microsoft SQL Server in mind, but theoretically
could be used to return data to any compliant ODBC database
as long as there is a working ODBC driver for it on your
minion platform.
:maintainer: C. R. Oldham (cr@sal... |
saltstack/salt | salt/returners/odbc.py | get_jid | python | def get_jid(jid):
'''
Return the information returned when the specified job id was executed
'''
conn = _get_conn(ret=None)
cur = conn.cursor()
sql = '''SELECT id, full_ret FROM salt_returns WHERE jid = ?'''
cur.execute(sql, (jid,))
data = cur.fetchall()
ret = {}
if data:
... | Return the information returned when the specified job id was executed | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/odbc.py#L249-L264 | [
"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 -*-
'''
Return data to an ODBC compliant server. This driver was
developed with Microsoft SQL Server in mind, but theoretically
could be used to return data to any compliant ODBC database
as long as there is a working ODBC driver for it on your
minion platform.
:maintainer: C. R. Oldham (cr@sal... |
saltstack/salt | salt/returners/odbc.py | get_fun | python | def get_fun(fun):
'''
Return a dict of the last function called for all minions
'''
conn = _get_conn(ret=None)
cur = conn.cursor()
sql = '''SELECT s.id,s.jid, s.full_ret
FROM salt_returns s
JOIN ( SELECT MAX(jid) AS jid FROM salt_returns GROUP BY fun, id) max
... | Return a dict of the last function called for all minions | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/odbc.py#L267-L288 | [
"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 -*-
'''
Return data to an ODBC compliant server. This driver was
developed with Microsoft SQL Server in mind, but theoretically
could be used to return data to any compliant ODBC database
as long as there is a working ODBC driver for it on your
minion platform.
:maintainer: C. R. Oldham (cr@sal... |
saltstack/salt | salt/returners/odbc.py | get_jids | python | def get_jids():
'''
Return a list of all job ids
'''
conn = _get_conn(ret=None)
cur = conn.cursor()
sql = '''SELECT distinct jid, load FROM jids'''
cur.execute(sql)
data = cur.fetchall()
ret = {}
for jid, load in data:
ret[jid] = salt.utils.jid.format_jid_instance(jid, s... | Return a list of all job ids | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/odbc.py#L291-L305 | [
"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 -*-
'''
Return data to an ODBC compliant server. This driver was
developed with Microsoft SQL Server in mind, but theoretically
could be used to return data to any compliant ODBC database
as long as there is a working ODBC driver for it on your
minion platform.
:maintainer: C. R. Oldham (cr@sal... |
saltstack/salt | salt/states/smartos.py | _load_config | python | def _load_config():
'''
Loads and parses /usbkey/config
'''
config = {}
if os.path.isfile('/usbkey/config'):
with salt.utils.files.fopen('/usbkey/config', 'r') as config_file:
for optval in config_file:
optval = salt.utils.stringutils.to_unicode(optval)
... | Loads and parses /usbkey/config | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L185-L202 | [
"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 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | _write_config | python | def _write_config(config):
'''
writes /usbkey/config
'''
try:
with salt.utils.atomicfile.atomic_open('/usbkey/config', 'w') as config_file:
config_file.write("#\n# This file was generated by salt\n#\n")
for prop in salt.utils.odict.OrderedDict(sorted(config.items())):
... | writes /usbkey/config | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L205-L225 | [
"def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | _parse_vmconfig | python | def _parse_vmconfig(config, instances):
'''
Parse vm_present vm config
'''
vmconfig = None
if isinstance(config, (salt.utils.odict.OrderedDict)):
vmconfig = salt.utils.odict.OrderedDict()
for prop in config:
if prop not in instances:
vmconfig[prop] = conf... | Parse vm_present vm config | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L228-L253 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | _get_instance_changes | python | def _get_instance_changes(current, state):
'''
get modified properties
'''
# get keys
current_keys = set(current.keys())
state_keys = set(state.keys())
# compare configs
changed = salt.utils.data.compare_dicts(current, state)
for change in salt.utils.data.compare_dicts(current, stat... | get modified properties | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L256-L272 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | config_present | python | def config_present(name, value):
'''
Ensure configuration property is set to value in /usbkey/config
name : string
name of property
value : string
value of property
'''
name = name.lower()
ret = {'name': name,
'changes': {},
'result': None,
... | Ensure configuration property is set to value in /usbkey/config
name : string
name of property
value : string
value of property | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L329-L376 | [
"def _load_config():\n '''\n Loads and parses /usbkey/config\n '''\n config = {}\n\n if os.path.isfile('/usbkey/config'):\n with salt.utils.files.fopen('/usbkey/config', 'r') as config_file:\n for optval in config_file:\n optval = salt.utils.stringutils.to_unicode(opt... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | config_absent | python | def config_absent(name):
'''
Ensure configuration property is absent in /usbkey/config
name : string
name of property
'''
name = name.lower()
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
# load configuration
config = _load... | Ensure configuration property is absent in /usbkey/config
name : string
name of property | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L379-L411 | [
"def _load_config():\n '''\n Loads and parses /usbkey/config\n '''\n config = {}\n\n if os.path.isfile('/usbkey/config'):\n with salt.utils.files.fopen('/usbkey/config', 'r') as config_file:\n for optval in config_file:\n optval = salt.utils.stringutils.to_unicode(opt... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | source_present | python | def source_present(name, source_type='imgapi'):
'''
Ensure an image source is present on the computenode
name : string
source url
source_type : string
source type (imgapi or docker)
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment... | Ensure an image source is present on the computenode
name : string
source url
source_type : string
source type (imgapi or docker) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L414-L449 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | source_absent | python | def source_absent(name):
'''
Ensure an image source is absent on the computenode
name : string
source url
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if name not in __salt__['imgadm.sources']():
# source is absent
... | Ensure an image source is absent on the computenode
name : string
source url | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L452-L485 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | image_present | python | def image_present(name):
'''
Ensure image is present on the computenode
name : string
uuid of image
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if _is_docker_uuid(name) and __salt__['imgadm.docker_to_uuid'](name):
# do... | Ensure image is present on the computenode
name : string
uuid of image | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L488-L542 | [
"def _is_uuid(uuid):\n '''\n Check if uuid is a valid smartos uuid\n\n Example: e69a0918-055d-11e5-8912-e3ceb6df4cf8\n '''\n if uuid and list((len(x) for x in uuid.split('-'))) == [8, 4, 4, 4, 12]:\n return True\n return False\n",
"def _is_docker_uuid(uuid):\n '''\n Check if uuid is... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | image_absent | python | def image_absent(name):
'''
Ensure image is absent on the computenode
name : string
uuid of image
.. note::
computenode.image_absent will only remove the image if it is not used
by a vm.
'''
ret = {'name': name,
'changes': {},
'result': None,
... | Ensure image is absent on the computenode
name : string
uuid of image
.. note::
computenode.image_absent will only remove the image if it is not used
by a vm. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L545-L604 | [
"def _is_uuid(uuid):\n '''\n Check if uuid is a valid smartos uuid\n\n Example: e69a0918-055d-11e5-8912-e3ceb6df4cf8\n '''\n if uuid and list((len(x) for x in uuid.split('-'))) == [8, 4, 4, 4, 12]:\n return True\n return False\n",
"def _is_docker_uuid(uuid):\n '''\n Check if uuid is... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | image_vacuum | python | def image_vacuum(name):
'''
Delete images not in use or installed via image_present
.. warning::
Only image_present states that are included via the
top file will be detected.
'''
name = name.lower()
ret = {'name': name,
'changes': {},
'result': None,
... | Delete images not in use or installed via image_present
.. warning::
Only image_present states that are included via the
top file will be detected. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L607-L685 | [
"def _is_uuid(uuid):\n '''\n Check if uuid is a valid smartos uuid\n\n Example: e69a0918-055d-11e5-8912-e3ceb6df4cf8\n '''\n if uuid and list((len(x) for x in uuid.split('-'))) == [8, 4, 4, 4, 12]:\n return True\n return False\n",
"def _is_docker_uuid(uuid):\n '''\n Check if uuid is... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | vm_present | python | def vm_present(name, vmconfig, config=None):
'''
Ensure vm is present on the computenode
name : string
hostname of vm
vmconfig : dict
options to set for the vm
config : dict
fine grain control over vm_present
.. note::
The following configuration properties can... | Ensure vm is present on the computenode
name : string
hostname of vm
vmconfig : dict
options to set for the vm
config : dict
fine grain control over vm_present
.. note::
The following configuration properties can be toggled in the config parameter.
- kvm_rebo... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L688-L1120 | [
"def _parse_vmconfig(config, instances):\n '''\n Parse vm_present vm config\n '''\n vmconfig = None\n\n if isinstance(config, (salt.utils.odict.OrderedDict)):\n vmconfig = salt.utils.odict.OrderedDict()\n for prop in config:\n if prop not in instances:\n vmconf... | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | vm_absent | python | def vm_absent(name, archive=False):
'''
Ensure vm is absent on the computenode
name : string
hostname of vm
archive : boolean
toggle archiving of vm on removal
.. note::
State ID is used as hostname. Hostnames must be unique.
'''
name = name.lower()
ret = {'na... | Ensure vm is absent on the computenode
name : string
hostname of vm
archive : boolean
toggle archiving of vm on removal
.. note::
State ID is used as hostname. Hostnames must be unique. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L1123-L1165 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/smartos.py | vm_running | python | def vm_running(name):
'''
Ensure vm is in the running state on the computenode
name : string
hostname of vm
.. note::
State ID is used as hostname. Hostnames must be unique.
'''
name = name.lower()
ret = {'name': name,
'changes': {},
'result': None,
... | Ensure vm is in the running state on the computenode
name : string
hostname of vm
.. note::
State ID is used as hostname. Hostnames must be unique. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L1168-L1200 | null | # -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: vmadm, imgadm
:platform: smartos
.. versionadded:: 2016.3.0
.. code-block:: yaml
vmtest.example.org:
smartos.vm_present:
- config... |
saltstack/salt | salt/states/ports.py | _repack_options | python | def _repack_options(options):
'''
Repack the options data
'''
return dict(
[
(six.text_type(x), _normalize(y))
for x, y in six.iteritems(salt.utils.data.repack_dictlist(options))
]
) | Repack the options data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ports.py#L42-L51 | null | # -*- coding: utf-8 -*-
'''
Manage software from FreeBSD ports
.. versionadded:: 2014.1.0
.. note::
It may be helpful to use a higher timeout when running a
:mod:`ports.installed <salt.states.ports>` state, since compiling the port
may exceed Salt's timeout.
.. code-block:: bash
salt -t 120... |
saltstack/salt | salt/states/ports.py | _get_option_list | python | def _get_option_list(options):
'''
Returns the key/value pairs in the passed dict in a commaspace-delimited
list in the format "key=value".
'''
return ', '.join(['{0}={1}'.format(x, y) for x, y in six.iteritems(options)]) | Returns the key/value pairs in the passed dict in a commaspace-delimited
list in the format "key=value". | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ports.py#L54-L59 | null | # -*- coding: utf-8 -*-
'''
Manage software from FreeBSD ports
.. versionadded:: 2014.1.0
.. note::
It may be helpful to use a higher timeout when running a
:mod:`ports.installed <salt.states.ports>` state, since compiling the port
may exceed Salt's timeout.
.. code-block:: bash
salt -t 120... |
saltstack/salt | salt/states/ports.py | installed | python | def installed(name, options=None):
'''
Verify that the desired port is installed, and that it was compiled with
the desired options.
options
Make sure that the desired non-default options are set
.. warning::
Any build options not passed here assume the default values for ... | Verify that the desired port is installed, and that it was compiled with
the desired options.
options
Make sure that the desired non-default options are set
.. warning::
Any build options not passed here assume the default values for the
port, and are not just differen... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ports.py#L73-L186 | [
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def _options_file_exists(name):\n '''\n Returns True/False based on whether or not the options file for the\n specified port exists.\n '''\n return os.path.isfile(os.path.join(_options_dir(name), 'options'))\n",
"def _repack_options(op... | # -*- coding: utf-8 -*-
'''
Manage software from FreeBSD ports
.. versionadded:: 2014.1.0
.. note::
It may be helpful to use a higher timeout when running a
:mod:`ports.installed <salt.states.ports>` state, since compiling the port
may exceed Salt's timeout.
.. code-block:: bash
salt -t 120... |
saltstack/salt | salt/states/win_network.py | _validate | python | def _validate(dns_proto, dns_servers, ip_proto, ip_addrs, gateway):
'''
Ensure that the configuration passed is formatted correctly and contains
valid IP addresses, etc.
'''
errors = []
# Validate DNS configuration
if dns_proto == 'dhcp':
if dns_servers is not None:
error... | Ensure that the configuration passed is formatted correctly and contains
valid IP addresses, etc. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_network.py#L94-L154 | null | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces on Windows hosts
====================================================
.. versionadded:: 2014.1.0
This module provides the ``network`` state(s) on Windows hosts. DNS servers, IP
addresses and default gateways can currently be managed.
Below is an example... |
saltstack/salt | salt/states/win_network.py | _changes | python | def _changes(cur, dns_proto, dns_servers, ip_proto, ip_addrs, gateway):
'''
Compares the current interface against the desired configuration and
returns a dictionary describing the changes that need to be made.
'''
changes = {}
cur_dns_proto = (
'static' if 'Statically Configured DNS Ser... | Compares the current interface against the desired configuration and
returns a dictionary describing the changes that need to be made. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_network.py#L168-L206 | null | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces on Windows hosts
====================================================
.. versionadded:: 2014.1.0
This module provides the ``network`` state(s) on Windows hosts. DNS servers, IP
addresses and default gateways can currently be managed.
Below is an example... |
saltstack/salt | salt/states/win_network.py | managed | python | def managed(name,
dns_proto=None,
dns_servers=None,
ip_proto=None,
ip_addrs=None,
gateway=None,
enabled=True,
**kwargs):
'''
Ensure that the named interface is configured properly.
Args:
name (str):
The... | Ensure that the named interface is configured properly.
Args:
name (str):
The name of the interface to manage
dns_proto (str): None
Set to ``static`` and use the ``dns_servers`` parameter to provide a
list of DNS nameservers. set to ``dhcp`` to use DHCP to get ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_network.py#L209-L442 | [
"def _changes(cur, dns_proto, dns_servers, ip_proto, ip_addrs, gateway):\n '''\n Compares the current interface against the desired configuration and\n returns a dictionary describing the changes that need to be made.\n '''\n changes = {}\n cur_dns_proto = (\n 'static' if 'Statically Config... | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces on Windows hosts
====================================================
.. versionadded:: 2014.1.0
This module provides the ``network`` state(s) on Windows hosts. DNS servers, IP
addresses and default gateways can currently be managed.
Below is an example... |
saltstack/salt | salt/utils/rsax931.py | _load_libcrypto | python | def _load_libcrypto():
'''
Load OpenSSL libcrypto
'''
if sys.platform.startswith('win'):
# cdll.LoadLibrary on windows requires an 'str' argument
return cdll.LoadLibrary(str('libeay32')) # future lint: disable=blacklisted-function
elif getattr(sys, 'frozen', False) and salt.utils.pl... | Load OpenSSL libcrypto | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/rsax931.py#L26-L53 | null | # -*- coding: utf-8 -*-
'''
Create and verify ANSI X9.31 RSA signatures using OpenSSL libcrypto
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import glob
import sys
import os
# Import Salt libs
import salt.utils.platform
import salt.utils.stringutils
# Import 3rd-p... |
saltstack/salt | salt/utils/rsax931.py | _init_libcrypto | python | def _init_libcrypto():
'''
Set up libcrypto argtypes and initialize the library
'''
libcrypto = _load_libcrypto()
try:
libcrypto.OPENSSL_init_crypto()
except AttributeError:
# Support for OpenSSL < 1.1 (OPENSSL_API_COMPAT < 0x10100000L)
libcrypto.OPENSSL_no_config()
... | Set up libcrypto argtypes and initialize the library | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/rsax931.py#L56-L83 | [
"def _load_libcrypto():\n '''\n Load OpenSSL libcrypto\n '''\n if sys.platform.startswith('win'):\n # cdll.LoadLibrary on windows requires an 'str' argument\n return cdll.LoadLibrary(str('libeay32')) # future lint: disable=blacklisted-function\n elif getattr(sys, 'frozen', False) and s... | # -*- coding: utf-8 -*-
'''
Create and verify ANSI X9.31 RSA signatures using OpenSSL libcrypto
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import glob
import sys
import os
# Import Salt libs
import salt.utils.platform
import salt.utils.stringutils
# Import 3rd-p... |
saltstack/salt | salt/utils/rsax931.py | RSAX931Signer.sign | python | def sign(self, msg):
'''
Sign a message (digest) using the private key
:param str msg: The message (digest) to sign
:rtype: str
:return: The signature, or an empty string if the encryption failed
'''
# Allocate a buffer large enough for the signature. Freed by ct... | Sign a message (digest) using the private key
:param str msg: The message (digest) to sign
:rtype: str
:return: The signature, or an empty string if the encryption failed | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/rsax931.py#L112-L126 | null | class RSAX931Signer(object):
'''
Create ANSI X9.31 RSA signatures using OpenSSL libcrypto
'''
def __init__(self, keydata):
'''
Init an RSAX931Signer instance
:param str keydata: The RSA private key in PEM format
'''
keydata = salt.utils.stringutils.to_bytes(keyda... |
saltstack/salt | salt/utils/rsax931.py | RSAX931Verifier.verify | python | def verify(self, signed):
'''
Recover the message (digest) from the signature using the public key
:param str signed: The signature created with the private key
:rtype: str
:return: The message (digest) recovered from the signature, or an empty
string if the decrypti... | Recover the message (digest) from the signature using the public key
:param str signed: The signature created with the private key
:rtype: str
:return: The message (digest) recovered from the signature, or an empty
string if the decryption failed | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/rsax931.py#L150-L165 | null | class RSAX931Verifier(object):
'''
Verify ANSI X9.31 RSA signatures using OpenSSL libcrypto
'''
def __init__(self, pubdata):
'''
Init an RSAX931Verifier instance
:param str pubdata: The RSA public key in PEM format
'''
pubdata = salt.utils.stringutils.to_bytes(pu... |
saltstack/salt | salt/modules/cabal.py | install | python | def install(pkg=None,
pkgs=None,
user=None,
install_global=False,
env=None):
'''
Install a cabal package.
pkg
A package name in format accepted by cabal-install. See:
https://wiki.haskell.org/Cabal-Install
pkgs
A list of packages ... | Install a cabal package.
pkg
A package name in format accepted by cabal-install. See:
https://wiki.haskell.org/Cabal-Install
pkgs
A list of packages names in same format as ``pkg``
user
The user to run cabal install with
install_global
Install package globally... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cabal.py#L54-L103 | null | # -*- coding: utf-8 -*-
'''
Manage and query Cabal packages
===============================
.. versionadded:: 2015.8.0
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import salt.utils.path
from salt.exceptions import CommandExecutionError
logger = logging.getLogger(__na... |
saltstack/salt | salt/modules/cabal.py | list_ | python | def list_(
pkg=None,
user=None,
installed=False,
env=None):
'''
List packages matching a search string.
pkg
Search string for matching package names
user
The user to run cabal list with
installed
If True, only return installed packages.
en... | List packages matching a search string.
pkg
Search string for matching package names
user
The user to run cabal list with
installed
If True, only return installed packages.
env
Environment variables to set when invoking cabal. Uses the
same ``env`` format as the ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cabal.py#L106-L149 | null | # -*- coding: utf-8 -*-
'''
Manage and query Cabal packages
===============================
.. versionadded:: 2015.8.0
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import salt.utils.path
from salt.exceptions import CommandExecutionError
logger = logging.getLogger(__na... |
saltstack/salt | salt/modules/cabal.py | uninstall | python | def uninstall(pkg,
user=None,
env=None):
'''
Uninstall a cabal package.
pkg
The package to uninstall
user
The user to run ghc-pkg unregister with
env
Environment variables to set when invoking cabal. Uses the
same ``env`` format as the :py... | Uninstall a cabal package.
pkg
The package to uninstall
user
The user to run ghc-pkg unregister with
env
Environment variables to set when invoking cabal. Uses the
same ``env`` format as the :py:func:`cmd.run
<salt.modules.cmdmod.run>` execution function
CLI Exa... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cabal.py#L152-L182 | null | # -*- coding: utf-8 -*-
'''
Manage and query Cabal packages
===============================
.. versionadded:: 2015.8.0
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import salt.utils.path
from salt.exceptions import CommandExecutionError
logger = logging.getLogger(__na... |
saltstack/salt | salt/renderers/yamlex.py | render | python | def render(sls_data, saltenv='base', sls='', **kws):
'''
Accepts YAML_EX as a string or as a file object and runs it through the YAML_EX
parser.
:rtype: A Python data structure
'''
with warnings.catch_warnings(record=True) as warn_list:
data = deserialize(sls_data) or {}
for it... | Accepts YAML_EX as a string or as a file object and runs it through the YAML_EX
parser.
:rtype: A Python data structure | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/yamlex.py#L15-L33 | [
"def create(path, saltenv=None):\n '''\n join `path` and `saltenv` into a 'salt://' URL.\n '''\n if salt.utils.platform.is_windows():\n path = salt.utils.path.sanitize_win_path(path)\n path = salt.utils.data.decode(path)\n\n query = 'saltenv={0}'.format(saltenv) if saltenv else ''\n url ... | # -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import warnings
# Import salt libs
import salt.utils.url
from salt.serializers.yamlex import deserialize
log = logging.getLogger(__name__)
|
saltstack/salt | salt/returners/django_return.py | returner | python | def returner(ret):
'''
Signal a Django server that a return is available
'''
signaled = dispatch.Signal(providing_args=['ret']).send(sender='returner', ret=ret)
for signal in signaled:
log.debug(
'Django returner function \'returner\' signaled %s '
'which responded w... | Signal a Django server that a return is available | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/django_return.py#L57-L67 | null | # -*- coding: utf-8 -*-
'''
A returner that will inform a Django system that
returns are available using Django's signal system.
https://docs.djangoproject.com/en/dev/topics/signals/
It is up to the Django developer to register necessary
handlers with the signals provided by this returner
and process returns as neces... |
saltstack/salt | salt/returners/django_return.py | save_load | python | def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
signaled = dispatch.Signal(
providing_args=['jid', 'load']).send(
sender='save_load', jid=jid, load=load)
for signal in signaled:
log.debug(
'Django returner function \'save_lo... | Save the load to the specified jid | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/django_return.py#L70-L82 | null | # -*- coding: utf-8 -*-
'''
A returner that will inform a Django system that
returns are available using Django's signal system.
https://docs.djangoproject.com/en/dev/topics/signals/
It is up to the Django developer to register necessary
handlers with the signals provided by this returner
and process returns as neces... |
saltstack/salt | salt/returners/django_return.py | prep_jid | python | def prep_jid(nocache=False, passed_jid=None):
'''
Do any work necessary to prepare a JID, including sending a custom ID
'''
return passed_jid if passed_jid is not None else salt.utils.jid.gen_jid(__opts__) | Do any work necessary to prepare a JID, including sending a custom ID | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/django_return.py#L85-L89 | [
"def gen_jid(opts=None):\n '''\n Generate a jid\n '''\n if opts is None:\n salt.utils.versions.warn_until(\n 'Sodium',\n 'The `opts` argument was not passed into salt.utils.jid.gen_jid(). '\n 'This will be required starting in {version}.'\n )\n opts ... | # -*- coding: utf-8 -*-
'''
A returner that will inform a Django system that
returns are available using Django's signal system.
https://docs.djangoproject.com/en/dev/topics/signals/
It is up to the Django developer to register necessary
handlers with the signals provided by this returner
and process returns as neces... |
saltstack/salt | salt/client/netapi.py | NetapiClient.run | python | def run(self):
'''
Load and start all available api modules
'''
if not len(self.netapi):
log.error("Did not find any netapi configurations, nothing to start")
kwargs = {}
if salt.utils.platform.is_windows():
kwargs['log_queue'] = salt.log.setup.ge... | Load and start all available api modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/netapi.py#L61-L92 | null | class NetapiClient(object):
'''
Start each netapi module that is configured to run
'''
def __init__(self, opts):
self.opts = opts
self.process_manager = salt.utils.process.ProcessManager(name='NetAPIProcessManager')
self.netapi = salt.loader.netapi(self.opts)
def _handle_si... |
saltstack/salt | salt/tops/varstack_top.py | top | python | def top(**kwargs):
'''
Query |varstack| for the top data (states of the minions).
'''
conf = __opts__['master_tops']['varstack']
__grains__ = kwargs['grains']
vs_ = varstack.Varstack(config_filename=conf)
ret = vs_.evaluate(__grains__)
return {'base': ret['states']} | Query |varstack| for the top data (states of the minions). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/tops/varstack_top.py#L61-L71 | null | # -*- coding: utf-8 -*-
'''
Use `Varstack <https://github.com/conversis/varstack>`_ to provide tops data
.. |varstack| replace:: **varstack**
This :ref:`master_tops <master-tops-system>` plugin provides access to
the |varstack| hierarchical yaml files, so you can user |varstack| as a full
:mod:`external node classifi... |
saltstack/salt | salt/auth/keystone.py | auth | python | def auth(username, password):
'''
Try and authenticate
'''
try:
keystone = client.Client(username=username, password=password,
auth_url=get_auth_url())
return keystone.authenticate()
except (AuthorizationFailure, Unauthorized):
return False | Try and authenticate | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/auth/keystone.py#L26-L35 | [
"def get_auth_url():\n '''\n Try and get the URL from the config, else return localhost\n '''\n try:\n return __opts__['keystone.auth_url']\n except KeyError:\n return 'http://localhost:35357/v2.0'\n"
] | # -*- coding: utf-8 -*-
'''
Provide authentication using OpenStack Keystone
:depends: - keystoneclient Python module
'''
from __future__ import absolute_import, print_function, unicode_literals
try:
from keystoneclient.v2_0 import client
from keystoneclient.exceptions import AuthorizationFailure, Unauthoriz... |
saltstack/salt | salt/modules/xml.py | get_value | python | def get_value(file, element):
'''
Returns the value of the matched xpath element
CLI Example:
.. code-block:: bash
salt '*' xml.get_value /tmp/test.xml ".//element"
'''
try:
root = ET.parse(file)
element = root.find(element)
return element.text
except Attri... | Returns the value of the matched xpath element
CLI Example:
.. code-block:: bash
salt '*' xml.get_value /tmp/test.xml ".//element" | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xml.py#L26-L42 | null | # -*- coding: utf-8 -*-
'''
XML file mangler
.. versionadded:: Neon
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import xml.etree.ElementTree as ET
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'xml'
def __virtual__():
''... |
saltstack/salt | salt/modules/xml.py | set_value | python | def set_value(file, element, value):
'''
Sets the value of the matched xpath element
CLI Example:
.. code-block:: bash
salt '*' xml.set_value /tmp/test.xml ".//element" "new value"
'''
try:
root = ET.parse(file)
relement = root.find(element)
except AttributeError:
... | Sets the value of the matched xpath element
CLI Example:
.. code-block:: bash
salt '*' xml.set_value /tmp/test.xml ".//element" "new value" | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xml.py#L45-L63 | null | # -*- coding: utf-8 -*-
'''
XML file mangler
.. versionadded:: Neon
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import xml.etree.ElementTree as ET
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'xml'
def __virtual__():
''... |
saltstack/salt | salt/modules/xml.py | get_attribute | python | def get_attribute(file, element):
'''
Return the attributes of the matched xpath element.
CLI Example:
.. code-block:: bash
salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']"
'''
try:
root = ET.parse(file)
element = root.find(element)
return element... | Return the attributes of the matched xpath element.
CLI Example:
.. code-block:: bash
salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']" | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xml.py#L66-L82 | null | # -*- coding: utf-8 -*-
'''
XML file mangler
.. versionadded:: Neon
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import xml.etree.ElementTree as ET
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'xml'
def __virtual__():
''... |
saltstack/salt | salt/modules/xml.py | set_attribute | python | def set_attribute(file, element, key, value):
'''
Set the requested attribute key and value for matched xpath element.
CLI Example:
.. code-block:: bash
salt '*' xml.set_attribute /tmp/test.xml ".//element[@id='3']" editedby "gal"
'''
try:
root = ET.parse(file)
element... | Set the requested attribute key and value for matched xpath element.
CLI Example:
.. code-block:: bash
salt '*' xml.set_attribute /tmp/test.xml ".//element[@id='3']" editedby "gal" | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xml.py#L85-L103 | null | # -*- coding: utf-8 -*-
'''
XML file mangler
.. versionadded:: Neon
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
import xml.etree.ElementTree as ET
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'xml'
def __virtual__():
''... |
saltstack/salt | salt/utils/openstack/swift.py | SaltSwift.get_account | python | def get_account(self):
'''
List Swift containers
'''
try:
listing = self.conn.get_account()
return listing
except Exception as exc:
log.error('There was an error::')
if hasattr(exc, 'code') and hasattr(exc, 'msg'):
l... | List Swift containers | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/swift.py#L97-L109 | null | class SaltSwift(object):
'''
Class for all swiftclient functions
'''
def __init__(
self,
user,
tenant_name,
auth_url,
password=None,
auth_version=2,
**kwargs
):
'''
Set up openstack credentials
... |
saltstack/salt | salt/utils/openstack/swift.py | SaltSwift.get_object | python | def get_object(self, cont, obj, local_file=None, return_bin=False):
'''
Retrieve a file from Swift
'''
try:
if local_file is None and return_bin is False:
return False
headers, body = self.conn.get_object(cont, obj, resp_chunk_size=65536)
... | Retrieve a file from Swift | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/swift.py#L165-L197 | [
"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 SaltSwift(object):
'''
Class for all swiftclient functions
'''
def __init__(
self,
user,
tenant_name,
auth_url,
password=None,
auth_version=2,
**kwargs
):
'''
Set up openstack credentials
... |
saltstack/salt | salt/utils/openstack/swift.py | SaltSwift.put_object | python | def put_object(self, cont, obj, local_file):
'''
Upload a file to Swift
'''
try:
with salt.utils.files.fopen(local_file, 'rb') as fp_:
self.conn.put_object(cont, obj, fp_)
return True
except Exception as exc:
log.error('There wa... | Upload a file to Swift | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/swift.py#L199-L212 | [
"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 SaltSwift(object):
'''
Class for all swiftclient functions
'''
def __init__(
self,
user,
tenant_name,
auth_url,
password=None,
auth_version=2,
**kwargs
):
'''
Set up openstack credentials
... |
saltstack/salt | salt/utils/openstack/swift.py | SaltSwift.delete_object | python | def delete_object(self, cont, obj):
'''
Delete a file from Swift
'''
try:
self.conn.delete_object(cont, obj)
return True
except Exception as exc:
log.error('There was an error::')
if hasattr(exc, 'code') and hasattr(exc, 'msg'):
... | Delete a file from Swift | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/swift.py#L214-L226 | null | class SaltSwift(object):
'''
Class for all swiftclient functions
'''
def __init__(
self,
user,
tenant_name,
auth_url,
password=None,
auth_version=2,
**kwargs
):
'''
Set up openstack credentials
... |
saltstack/salt | salt/modules/xfs.py | _xfs_info_get_kv | python | def _xfs_info_get_kv(serialized):
'''
Parse one line of the XFS info output.
'''
# No need to know sub-elements here
if serialized.startswith("="):
serialized = serialized[1:].strip()
serialized = serialized.replace(" = ", "=*** ").replace(" =", "=")
# Keywords has no spaces, value... | Parse one line of the XFS info output. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L71-L90 | null | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _parse_xfs_info | python | def _parse_xfs_info(data):
'''
Parse output from "xfs_info" or "xfs_growfs -n".
'''
ret = {}
spr = re.compile(r'\s+')
entry = None
for line in [spr.sub(" ", l).strip().replace(", ", " ") for l in data.split("\n")]:
if not line:
continue
nfo = _xfs_info_get_kv(line... | Parse output from "xfs_info" or "xfs_growfs -n". | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L93-L109 | [
"def _xfs_info_get_kv(serialized):\n '''\n Parse one line of the XFS info output.\n '''\n # No need to know sub-elements here\n if serialized.startswith(\"=\"):\n serialized = serialized[1:].strip()\n\n serialized = serialized.replace(\" = \", \"=*** \").replace(\" =\", \"=\")\n\n # Keyw... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | info | python | def info(device):
'''
Get filesystem geometry information.
CLI Example:
.. code-block:: bash
salt '*' xfs.info /dev/sda1
'''
out = __salt__['cmd.run_all']("xfs_info {0}".format(device))
if out.get('stderr'):
raise CommandExecutionError(out['stderr'].replace("xfs_info:", ""... | Get filesystem geometry information.
CLI Example:
.. code-block:: bash
salt '*' xfs.info /dev/sda1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L112-L125 | [
"def _parse_xfs_info(data):\n '''\n Parse output from \"xfs_info\" or \"xfs_growfs -n\".\n '''\n ret = {}\n spr = re.compile(r'\\s+')\n entry = None\n for line in [spr.sub(\" \", l).strip().replace(\", \", \" \") for l in data.split(\"\\n\")]:\n if not line:\n continue\n ... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _xfsdump_output | python | def _xfsdump_output(data):
'''
Parse CLI output of the xfsdump utility.
'''
out = {}
summary = []
summary_block = False
for line in [l.strip() for l in data.split("\n") if l.strip()]:
line = re.sub("^xfsdump: ", "", line)
if line.startswith("session id:"):
out['S... | Parse CLI output of the xfsdump utility. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L128-L160 | null | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | dump | python | def dump(device, destination, level=0, label=None, noerase=None):
'''
Dump filesystem device to the media (file, tape etc).
Required parameters:
* **device**: XFS device, content of which to be dumped.
* **destination**: Specifies a dump destination.
Valid options are:
* **label**: Label... | Dump filesystem device to the media (file, tape etc).
Required parameters:
* **device**: XFS device, content of which to be dumped.
* **destination**: Specifies a dump destination.
Valid options are:
* **label**: Label of the dump. Otherwise automatically generated label is used.
* **level**... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L163-L208 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _xr_to_keyset | python | def _xr_to_keyset(line):
'''
Parse xfsrestore output keyset elements.
'''
tkns = [elm for elm in line.strip().split(":", 1) if elm]
if len(tkns) == 1:
return "'{0}': ".format(tkns[0])
else:
key, val = tkns
return "'{0}': '{1}',".format(key.strip(), val.strip()) | Parse xfsrestore output keyset elements. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L211-L220 | null | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _xfs_inventory_output | python | def _xfs_inventory_output(out):
'''
Transform xfsrestore inventory data output to a Python dict source and evaluate it.
'''
data = []
out = [line for line in out.split("\n") if line.strip()]
# No inventory yet
if len(out) == 1 and 'restore status' in out[0].lower():
return {'restore... | Transform xfsrestore inventory data output to a Python dict source and evaluate it. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L223-L256 | [
"def _xr_to_keyset(line):\n '''\n Parse xfsrestore output keyset elements.\n '''\n tkns = [elm for elm in line.strip().split(\":\", 1) if elm]\n if len(tkns) == 1:\n return \"'{0}': \".format(tkns[0])\n else:\n key, val = tkns\n return \"'{0}': '{1}',\".format(key.strip(), val... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _xfs_prune_output | python | def _xfs_prune_output(out, uuid):
'''
Parse prune output.
'''
data = {}
cnt = []
cutpoint = False
for line in [l.strip() for l in out.split("\n") if l]:
if line.startswith("-"):
if cutpoint:
break
else:
cutpoint = True
... | Parse prune output. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L275-L297 | null | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | prune_dump | python | def prune_dump(sessionid):
'''
Prunes the dump session identified by the given session id.
CLI Example:
.. code-block:: bash
salt '*' xfs.prune_dump b74a3586-e52e-4a4a-8775-c3334fa8ea2c
'''
out = __salt__['cmd.run_all']("xfsinvutil -s {0} -F".format(sessionid))
_verify_run(out)
... | Prunes the dump session identified by the given session id.
CLI Example:
.. code-block:: bash
salt '*' xfs.prune_dump b74a3586-e52e-4a4a-8775-c3334fa8ea2c | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L300-L318 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _xfs_estimate_output | python | def _xfs_estimate_output(out):
'''
Parse xfs_estimate output.
'''
spc = re.compile(r"\s+")
data = {}
for line in [l for l in out.split("\n") if l.strip()][1:]:
directory, bsize, blocks, megabytes, logsize = spc.sub(" ", line).split(" ")
data[directory] = {
'block _siz... | Parse xfs_estimate output. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L360-L375 | null | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | estimate | python | def estimate(path):
'''
Estimate the space that an XFS filesystem will take.
For each directory estimate the space that directory would take
if it were copied to an XFS filesystem.
Estimation does not cross mount points.
CLI Example:
.. code-block:: bash
salt '*' xfs.estimate /pat... | Estimate the space that an XFS filesystem will take.
For each directory estimate the space that directory would take
if it were copied to an XFS filesystem.
Estimation does not cross mount points.
CLI Example:
.. code-block:: bash
salt '*' xfs.estimate /path/to/file
salt '*' xfs.e... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L378-L398 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | mkfs | python | def mkfs(device, label=None, ssize=None, noforce=None,
bso=None, gmo=None, ino=None, lso=None, rso=None, nmo=None, dso=None):
'''
Create a file system on the specified device. By default wipes out with force.
General options:
* **label**: Specify volume label.
* **ssize**: Specify the fun... | Create a file system on the specified device. By default wipes out with force.
General options:
* **label**: Specify volume label.
* **ssize**: Specify the fundamental sector size of the filesystem.
* **noforce**: Do not force create filesystem, if disk is already formatted.
Filesystem geometry o... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L401-L462 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | modify | python | def modify(device, label=None, lazy_counting=None, uuid=None):
'''
Modify parameters of an XFS filesystem.
CLI Example:
.. code-block:: bash
salt '*' xfs.modify /dev/sda1 label='My backup' lazy_counting=False
salt '*' xfs.modify /dev/sda1 uuid=False
salt '*' xfs.modify /dev/sd... | Modify parameters of an XFS filesystem.
CLI Example:
.. code-block:: bash
salt '*' xfs.modify /dev/sda1 label='My backup' lazy_counting=False
salt '*' xfs.modify /dev/sda1 uuid=False
salt '*' xfs.modify /dev/sda1 uuid=True | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L465-L506 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | _get_mounts | python | def _get_mounts():
'''
List mounted filesystems.
'''
mounts = {}
with salt.utils.files.fopen("/proc/mounts") as fhr:
for line in salt.utils.data.decode(fhr.readlines()):
device, mntpnt, fstype, options, fs_freq, fs_passno = line.strip().split(" ")
if fstype != 'xfs':
... | List mounted filesystems. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L509-L524 | [
"def decode(data, encoding=None, errors='strict', keep=False,\n normalize=False, preserve_dict_class=False, preserve_tuples=False,\n to_str=False):\n '''\n Generic function which will decode whichever type is passed, if necessary.\n Optionally use to_str=True to ensure strings are str t... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/xfs.py | defragment | python | def defragment(device):
'''
Defragment mounted XFS filesystem.
In order to mount a filesystem, device should be properly mounted and writable.
CLI Example:
.. code-block:: bash
salt '*' xfs.defragment /dev/sda1
'''
if device == '/':
raise CommandExecutionError("Root is not... | Defragment mounted XFS filesystem.
In order to mount a filesystem, device should be properly mounted and writable.
CLI Example:
.. code-block:: bash
salt '*' xfs.defragment /dev/sda1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L527-L549 | [
"def _verify_run(out, cmd=None):\n '''\n Crash to the log if command execution was not successful.\n '''\n if out.get(\"retcode\", 0) and out['stderr']:\n if cmd:\n log.debug('Command: \"%s\"', cmd)\n\n log.debug('Return code: %s', out.get('retcode'))\n log.debug('Error o... | # -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (C) 2014 SUSE LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# right... |
saltstack/salt | salt/modules/hashutil.py | digest | python | def digest(instr, checksum='md5'):
'''
Return a checksum digest for a string
instr
A string
checksum : ``md5``
The hashing algorithm to use to generate checksums. Valid options: md5,
sha256, sha512.
CLI Example:
.. code-block:: bash
salt '*' hashutil.digest 'g... | Return a checksum digest for a string
instr
A string
checksum : ``md5``
The hashing algorithm to use to generate checksums. Valid options: md5,
sha256, sha512.
CLI Example:
.. code-block:: bash
salt '*' hashutil.digest 'get salted' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L26-L53 | null | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/modules/hashutil.py | digest_file | python | def digest_file(infile, checksum='md5'):
'''
Return a checksum digest for a file
infile
A file path
checksum : ``md5``
The hashing algorithm to use to generate checksums. Wraps the
:py:func:`hashutil.digest <salt.modules.hashutil.digest>` execution
function.
CLI Exa... | Return a checksum digest for a file
infile
A file path
checksum : ``md5``
The hashing algorithm to use to generate checksums. Wraps the
:py:func:`hashutil.digest <salt.modules.hashutil.digest>` execution
function.
CLI Example:
.. code-block:: bash
salt '*' has... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L56-L80 | [
"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 ... | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/modules/hashutil.py | base64_encodefile | python | def base64_encodefile(fname):
'''
Read a file from the file system and return as a base64 encoded string
.. versionadded:: 2016.3.0
Pillar example:
.. code-block:: yaml
path:
to:
data: |
{{ salt.hashutil.base64_encodefile('/path/to/binary_file') | inde... | Read a file from the file system and return as a base64 encoded string
.. versionadded:: 2016.3.0
Pillar example:
.. code-block:: yaml
path:
to:
data: |
{{ salt.hashutil.base64_encodefile('/path/to/binary_file') | indent(6) }}
The :py:func:`file.decode <s... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L135-L165 | [
"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 ... | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/modules/hashutil.py | base64_decodefile | python | def base64_decodefile(instr, outfile):
r'''
Decode a base64-encoded string and write the result to a file
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' hashutil.base64_decodefile instr='Z2V0IHNhbHRlZAo=' outfile='/path/to/binary_file'
'''
encoded_f = Strin... | r'''
Decode a base64-encoded string and write the result to a file
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' hashutil.base64_decodefile instr='Z2V0IHNhbHRlZAo=' outfile='/path/to/binary_file' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L184-L201 | [
"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 ... | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/modules/hashutil.py | hmac_signature | python | def hmac_signature(string, shared_secret, challenge_hmac):
'''
Verify a challenging hmac signature against a string / shared-secret
.. versionadded:: 2014.7.0
Returns a boolean if the verification succeeded or failed.
CLI Example:
.. code-block:: bash
salt '*' hashutil.hmac_signatur... | Verify a challenging hmac signature against a string / shared-secret
.. versionadded:: 2014.7.0
Returns a boolean if the verification succeeded or failed.
CLI Example:
.. code-block:: bash
salt '*' hashutil.hmac_signature 'get salted' 'shared secret' 'eBWf9bstXg+NiP5AOwppB5HMvZiYMPzEM9W5YMm... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L249-L263 | null | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/modules/hashutil.py | github_signature | python | def github_signature(string, shared_secret, challenge_hmac):
'''
Verify a challenging hmac signature against a string / shared-secret for
github webhooks.
.. versionadded:: 2017.7.0
Returns a boolean if the verification succeeded or failed.
CLI Example:
.. code-block:: bash
salt... | Verify a challenging hmac signature against a string / shared-secret for
github webhooks.
.. versionadded:: 2017.7.0
Returns a boolean if the verification succeeded or failed.
CLI Example:
.. code-block:: bash
salt '*' hashutil.github_signature '{"ref":....} ' 'shared secret' 'sha1=bc65... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hashutil.py#L266-L288 | null | # encoding: utf-8
'''
A collection of hashing and encoding functions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import hmac
# Import Salt libs
import salt.exceptions
from salt.ext import six
import salt.utils.files
import salt.utils.h... |
saltstack/salt | salt/thorium/wheel.py | cmd | python | def cmd(
name,
fun=None,
arg=(),
**kwargs):
'''
Execute a runner asynchronous:
USAGE:
.. code-block:: yaml
run_cloud:
wheel.cmd:
- fun: key.delete
- match: minion_id
'''
ret = {'name': name,
'changes': {},
... | Execute a runner asynchronous:
USAGE:
.. code-block:: yaml
run_cloud:
wheel.cmd:
- fun: key.delete
- match: minion_id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/wheel.py#L11-L39 | [
"def cmd_async(self, low):\n '''\n Execute a function asynchronously; eauth is respected\n\n This function requires that :conf_master:`external_auth` is configured\n and the user is authorized\n\n .. code-block:: python\n\n >>> wheel.cmd_async({\n 'fun': 'key.finger',\n '... | # -*- coding: utf-8 -*-
'''
React by calling asynchronous runners
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
# import salt libs
import salt.wheel
|
saltstack/salt | salt/modules/inspector.py | _ | python | def _(module):
'''
Get inspectlib module for the lazy loader.
:param module:
:return:
'''
mod = None
# pylint: disable=E0598
try:
# importlib is in Python 2.7+ and 3+
import importlib
mod = importlib.import_module("salt.modules.inspectlib.{0}".format(module))
... | Get inspectlib module for the lazy loader.
:param module:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L45-L68 | null | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | inspect | python | def inspect(mode='all', priority=19, **kwargs):
'''
Start node inspection and save the data to the database for further query.
Parameters:
* **mode**: Clarify inspection mode: configuration, payload, all (default)
payload
* **filter**: Comma-separated directories to track payload.
... | Start node inspection and save the data to the database for further query.
Parameters:
* **mode**: Clarify inspection mode: configuration, payload, all (default)
payload
* **filter**: Comma-separated directories to track payload.
* **priority**: (advanced) Set priority of the inspection. D... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L71-L103 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | query | python | def query(*args, **kwargs):
'''
Query the node for specific information.
Parameters:
* **scope**: Specify scope of the query.
* **System**: Return system data.
* **Software**: Return software information.
* **Services**: Return known services.
* **Identity**: Return use... | Query the node for specific information.
Parameters:
* **scope**: Specify scope of the query.
* **System**: Return system data.
* **Software**: Return software information.
* **Services**: Return known services.
* **Identity**: Return user accounts information for this system.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L106-L168 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | build | python | def build(format='qcow2', path='/tmp/'):
'''
Build an image from a current system description.
The image is a system image can be output in bootable ISO or QCOW2 formats.
Node uses the image building library Kiwi to perform the actual build.
Parameters:
* **format**: Specifies output format: ... | Build an image from a current system description.
The image is a system image can be output in bootable ISO or QCOW2 formats.
Node uses the image building library Kiwi to perform the actual build.
Parameters:
* **format**: Specifies output format: "qcow2" or "iso. Default: `qcow2`.
* **path**: Sp... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L171-L198 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | export | python | def export(local=False, path="/tmp", format='qcow2'):
'''
Export an image description for Kiwi.
Parameters:
* **local**: Specifies True or False if the export has to be in the local file. Default: False.
* **path**: If `local=True`, then specifies the path where file with the Kiwi description is w... | Export an image description for Kiwi.
Parameters:
* **local**: Specifies True or False if the export has to be in the local file. Default: False.
* **path**: If `local=True`, then specifies the path where file with the Kiwi description is written.
Default: `/tmp`.
CLI Example:
..... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L201-L227 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | snapshots | python | def snapshots():
'''
List current description snapshots.
CLI Example:
.. code-block:: bash
salt myminion inspector.snapshots
'''
try:
return _("collector").Inspector(cachedir=__opts__['cachedir'],
piddir=os.path.dirname(__opts__['pidfile... | List current description snapshots.
CLI Example:
.. code-block:: bash
salt myminion inspector.snapshots | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L230-L247 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/modules/inspector.py | delete | python | def delete(all=False, *databases):
'''
Remove description snapshots from the system.
::parameter: all. Default: False. Remove all snapshots, if set to True.
CLI example:
.. code-block:: bash
salt myminion inspector.delete <ID> <ID1> <ID2>..
salt myminion inspector.delete all=True... | Remove description snapshots from the system.
::parameter: all. Default: False. Remove all snapshots, if set to True.
CLI example:
.. code-block:: bash
salt myminion inspector.delete <ID> <ID1> <ID2>..
salt myminion inspector.delete all=True | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspector.py#L250-L277 | [
"def _(module):\n '''\n Get inspectlib module for the lazy loader.\n\n :param module:\n :return:\n '''\n\n mod = None\n # pylint: disable=E0598\n try:\n # importlib is in Python 2.7+ and 3+\n import importlib\n mod = importlib.import_module(\"salt.modules.inspectlib.{0}\... | # -*- coding: utf-8 -*-
#
# Copyright 2015 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
saltstack/salt | salt/engines/napalm_syslog.py | start | python | def start(transport='zmq',
address='0.0.0.0',
port=49017,
auth_address='0.0.0.0',
auth_port=49018,
disable_security=False,
certificate=None,
os_whitelist=None,
os_blacklist=None,
error_whitelist=None,
error_blacklist=Non... | Listen to napalm-logs and publish events into the Salt event bus.
transport: ``zmq``
Choose the desired transport.
.. note::
Currently ``zmq`` is the only valid option.
address: ``0.0.0.0``
The address of the publisher, as configured on napalm-logs.
port: ``49017``
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/napalm_syslog.py#L248-L378 | [
"def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):\n '''\n Return an event object suitable for the named transport\n '''\n # TODO: AIO core is separate from transport\n if opts['transport'] in ('zeromq', 'tcp', 'detect'):\n return MasterEvent... | # -*- coding: utf-8 -*-
'''
NAPALM syslog engine
====================
.. versionadded:: 2017.7.0
An engine that takes syslog messages structured in
OpenConfig_ or IETF format
and fires Salt events.
.. _OpenConfig: http://www.openconfig.net/
As there can be many messages pushed into the event bus,
the user is able t... |
saltstack/salt | salt/states/salt_proxy.py | configure_proxy | python | def configure_proxy(name, proxyname='p8000', start=True):
'''
Create the salt proxy file and start the proxy process
if required
Parameters:
name:
The name of this state
proxyname:
Name to be used for this proxy (should match entries in pillar)
start:
... | Create the salt proxy file and start the proxy process
if required
Parameters:
name:
The name of this state
proxyname:
Name to be used for this proxy (should match entries in pillar)
start:
Boolean indicating if the process should be started
Exam... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/salt_proxy.py#L33-L62 | null | # -*- coding: utf-8 -*-
'''
Salt proxy state
.. versionadded:: 2015.8.2
State to deploy and run salt-proxy processes
on a minion.
Set up pillar data for your proxies per the documentation.
Run the state as below
..code-block:: yaml
salt-proxy-configure:
salt_proxy.c... |
saltstack/salt | salt/modules/hadoop.py | _hadoop_cmd | python | def _hadoop_cmd(module, command, *args):
'''
Hadoop/hdfs command wrapper
As Hadoop command has been deprecated this module will default
to use hdfs command and fall back to hadoop if it is not found
In order to prevent random execution the module name is checked
Follows hadoop ... | Hadoop/hdfs command wrapper
As Hadoop command has been deprecated this module will default
to use hdfs command and fall back to hadoop if it is not found
In order to prevent random execution the module name is checked
Follows hadoop command template:
hadoop module -command args
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hadoop.py#L30-L57 | null | # -*- coding: utf-8 -*-
'''
Support for hadoop
:maintainer: Yann Jouanin <yann.jouanin@intelunix.fr>
:maturity: new
:depends:
:platform: linux
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import salt libs
import salt.utils.path
__authorized_modules__ = ['versi... |
saltstack/salt | salt/modules/hadoop.py | dfs_present | python | def dfs_present(path):
'''
Check if a file or directory is present on the distributed FS.
CLI Example:
.. code-block:: bash
salt '*' hadoop.dfs_present /some_random_file
Returns True if the file is present
'''
cmd_return = _hadoop_cmd('dfs', 'stat', path)
match = 'No such fil... | Check if a file or directory is present on the distributed FS.
CLI Example:
.. code-block:: bash
salt '*' hadoop.dfs_present /some_random_file
Returns True if the file is present | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hadoop.py#L115-L129 | [
"def _hadoop_cmd(module, command, *args):\n '''\n Hadoop/hdfs command wrapper\n\n As Hadoop command has been deprecated this module will default\n to use hdfs command and fall back to hadoop if it is not found\n\n In order to prevent random execution the module name is checked\n\n F... | # -*- coding: utf-8 -*-
'''
Support for hadoop
:maintainer: Yann Jouanin <yann.jouanin@intelunix.fr>
:maturity: new
:depends:
:platform: linux
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import salt libs
import salt.utils.path
__authorized_modules__ = ['versi... |
saltstack/salt | salt/modules/hadoop.py | dfs_absent | python | def dfs_absent(path):
'''
Check if a file or directory is absent on the distributed FS.
CLI Example:
.. code-block:: bash
salt '*' hadoop.dfs_absent /some_random_file
Returns True if the file is absent
'''
cmd_return = _hadoop_cmd('dfs', 'stat', path)
match = 'No such file or... | Check if a file or directory is absent on the distributed FS.
CLI Example:
.. code-block:: bash
salt '*' hadoop.dfs_absent /some_random_file
Returns True if the file is absent | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hadoop.py#L132-L146 | [
"def _hadoop_cmd(module, command, *args):\n '''\n Hadoop/hdfs command wrapper\n\n As Hadoop command has been deprecated this module will default\n to use hdfs command and fall back to hadoop if it is not found\n\n In order to prevent random execution the module name is checked\n\n F... | # -*- coding: utf-8 -*-
'''
Support for hadoop
:maintainer: Yann Jouanin <yann.jouanin@intelunix.fr>
:maturity: new
:depends:
:platform: linux
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import salt libs
import salt.utils.path
__authorized_modules__ = ['versi... |
saltstack/salt | salt/utils/timed_subprocess.py | TimedProc.run | python | def run(self):
'''
wait for subprocess to terminate and return subprocess' return code.
If timeout is reached, throw TimedProcTimeoutError
'''
def receive():
if self.with_communicate:
self.stdout, self.stderr = self.process.communicate(input=self.stdin... | wait for subprocess to terminate and return subprocess' return code.
If timeout is reached, throw TimedProcTimeoutError | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/timed_subprocess.py#L82-L113 | [
"def receive():\n if self.with_communicate:\n self.stdout, self.stderr = self.process.communicate(input=self.stdin)\n elif self.wait:\n self.process.wait()\n"
] | class TimedProc(object):
'''
Create a TimedProc object, calls subprocess.Popen with passed args and **kwargs
'''
def __init__(self, args, **kwargs):
self.wait = not kwargs.pop('bg', False)
self.stdin = kwargs.pop('stdin', None)
self.with_communicate = kwargs.pop('with_communicat... |
saltstack/salt | salt/modules/boto_kinesis.py | _get_full_stream | python | def _get_full_stream(stream_name, region=None, key=None, keyid=None, profile=None):
'''
Get complete stream info from AWS, via describe_stream, including all shards.
CLI example::
salt myminion boto_kinesis._get_full_stream my_stream region=us-east-1
'''
conn = _get_conn(region=region, key... | Get complete stream info from AWS, via describe_stream, including all shards.
CLI example::
salt myminion boto_kinesis._get_full_stream my_stream region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L98-L121 | [
"def _get_basic_stream(stream_name, conn):\n '''\n Stream info from AWS, via describe_stream\n Only returns the first \"page\" of shards (up to 100); use _get_full_stream() for all shards.\n\n CLI example::\n\n salt myminion boto_kinesis._get_basic_stream my_stream existing_conn\n '''\n ret... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | get_stream_when_active | python | def get_stream_when_active(stream_name, region=None, key=None, keyid=None, profile=None):
'''
Get complete stream info from AWS, returning only when the stream is in the ACTIVE state.
Continues to retry when stream is updating or creating.
If the stream is deleted during retries, the loop will catch the... | Get complete stream info from AWS, returning only when the stream is in the ACTIVE state.
Continues to retry when stream is updating or creating.
If the stream is deleted during retries, the loop will catch the error and break.
CLI example::
salt myminion boto_kinesis.get_stream_when_active my_str... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L124-L153 | [
"def _get_basic_stream(stream_name, conn):\n '''\n Stream info from AWS, via describe_stream\n Only returns the first \"page\" of shards (up to 100); use _get_full_stream() for all shards.\n\n CLI example::\n\n salt myminion boto_kinesis._get_basic_stream my_stream existing_conn\n '''\n ret... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | exists | python | def exists(stream_name, region=None, key=None, keyid=None, profile=None):
'''
Check if the stream exists. Returns False and the error if it does not.
CLI example::
salt myminion boto_kinesis.exists my_stream region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile... | Check if the stream exists. Returns False and the error if it does not.
CLI example::
salt myminion boto_kinesis.exists my_stream region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L156-L174 | [
"def _get_basic_stream(stream_name, conn):\n '''\n Stream info from AWS, via describe_stream\n Only returns the first \"page\" of shards (up to 100); use _get_full_stream() for all shards.\n\n CLI example::\n\n salt myminion boto_kinesis._get_basic_stream my_stream existing_conn\n '''\n ret... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | create_stream | python | def create_stream(stream_name, num_shards, region=None, key=None, keyid=None, profile=None):
'''
Create a stream with name stream_name and initial number of shards num_shards.
CLI example::
salt myminion boto_kinesis.create_stream my_stream N region=us-east-1
'''
conn = _get_conn(region=re... | Create a stream with name stream_name and initial number of shards num_shards.
CLI example::
salt myminion boto_kinesis.create_stream my_stream N region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L177-L192 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | delete_stream | python | def delete_stream(stream_name, region=None, key=None, keyid=None, profile=None):
'''
Delete the stream with name stream_name. This cannot be undone! All data will be lost!!
CLI example::
salt myminion boto_kinesis.delete_stream my_stream region=us-east-1
'''
conn = _get_conn(region=region,... | Delete the stream with name stream_name. This cannot be undone! All data will be lost!!
CLI example::
salt myminion boto_kinesis.delete_stream my_stream region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L195-L209 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | increase_stream_retention_period | python | def increase_stream_retention_period(stream_name, retention_hours,
region=None, key=None, keyid=None, profile=None):
'''
Increase stream retention period to retention_hours
CLI example::
salt myminion boto_kinesis.increase_stream_retention_period my_stream N re... | Increase stream retention period to retention_hours
CLI example::
salt myminion boto_kinesis.increase_stream_retention_period my_stream N region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L212-L228 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | enable_enhanced_monitoring | python | def enable_enhanced_monitoring(stream_name, metrics,
region=None, key=None, keyid=None, profile=None):
'''
Enable enhanced monitoring for the specified shard-level metrics on stream stream_name
CLI example::
salt myminion boto_kinesis.enable_enhanced_monitoring my_st... | Enable enhanced monitoring for the specified shard-level metrics on stream stream_name
CLI example::
salt myminion boto_kinesis.enable_enhanced_monitoring my_stream ["metrics", "to", "enable"] region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L250-L267 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | get_info_for_reshard | python | def get_info_for_reshard(stream_details):
min_hash_key = 0
max_hash_key = 0
stream_details["OpenShards"] = []
for shard in stream_details["Shards"]:
shard_id = shard["ShardId"]
if "EndingSequenceNumber" in shard["SequenceNumberRange"]:
# EndingSequenceNumber is null for open ... | Collect some data: number of open shards, key range, etc.
Modifies stream_details to add a sorted list of OpenShards.
Returns (min_hash_key, max_hash_key, stream_details)
CLI example::
salt myminion boto_kinesis.get_info_for_reshard existing_stream_details | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L290-L320 | [
"def long_int(hash_key):\n \"\"\"\n The hash key is a 128-bit int, sent as a string.\n It's necessary to convert to int/long for comparison operations.\n This helper method handles python 2/3 incompatibility\n\n CLI example::\n\n salt myminion boto_kinesis.long_int some_MD5_hash_as_string\n\n ... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | reshard | python | def reshard(stream_name, desired_size, force=False,
region=None, key=None, keyid=None, profile=None):
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
r = {}
stream_response = get_stream_when_active(stream_name, region, key, keyid, profile)
if 'error' in stream_respons... | Reshard a kinesis stream. Each call to this function will wait until the stream is ACTIVE,
then make a single split or merge operation. This function decides where to split or merge
with the assumption that the ultimate goal is a balanced partition space.
For safety, user must past in force=True; otherwis... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L341-L449 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | list_streams | python | def list_streams(region=None, key=None, keyid=None, profile=None):
'''
Return a list of all streams visible to the current account
CLI example:
.. code-block:: bash
salt myminion boto_kinesis.list_streams
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
s... | Return a list of all streams visible to the current account
CLI example:
.. code-block:: bash
salt myminion boto_kinesis.list_streams | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L452-L473 | [
"def _execute_with_retries(conn, function, **kwargs):\n '''\n Retry if we're rate limited by AWS or blocked by another call.\n Give up and return error message if resource not found or argument is invalid.\n\n conn\n The connection established by the calling method via _get_conn()\n\n function... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | _get_next_open_shard | python | def _get_next_open_shard(stream_details, shard_id):
'''
Return the next open shard after shard_id
CLI example::
salt myminion boto_kinesis._get_next_open_shard existing_stream_details shard_id
'''
found = False
for shard in stream_details["OpenShards"]:
current_shard_id = shard... | Return the next open shard after shard_id
CLI example::
salt myminion boto_kinesis._get_next_open_shard existing_stream_details shard_id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L476-L491 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
saltstack/salt | salt/modules/boto_kinesis.py | _execute_with_retries | python | def _execute_with_retries(conn, function, **kwargs):
'''
Retry if we're rate limited by AWS or blocked by another call.
Give up and return error message if resource not found or argument is invalid.
conn
The connection established by the calling method via _get_conn()
function
The ... | Retry if we're rate limited by AWS or blocked by another call.
Give up and return error message if resource not found or argument is invalid.
conn
The connection established by the calling method via _get_conn()
function
The function to call on conn. i.e. create_stream
**kwargs
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kinesis.py#L494-L543 | [
"def _jittered_backoff(attempt, max_retry_delay):\n '''\n Basic exponential backoff\n\n CLI example::\n\n salt myminion boto_kinesis._jittered_backoff current_attempt_number max_delay_in_seconds\n '''\n return min(random.random() * (2 ** attempt), max_retry_delay)\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Kinesis
.. versionadded:: 2017.7.0
:configuration: This module accepts explicit Kinesis credentials but can also
utilize IAM roles assigned to the instance trough Instance Profiles.
Dynamic credentials are then automatically obtained from AWS API and no... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.