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/utils/decorators/path.py | which_bin | python | def which_bin(exes):
'''
Decorator wrapper for salt.utils.path.which_bin
'''
def wrapper(function):
def wrapped(*args, **kwargs):
if salt.utils.path.which_bin(exes) is None:
raise CommandNotFoundError(
'None of provided binaries({0}) was not found ... | Decorator wrapper for salt.utils.path.which_bin | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/decorators/path.py#L28-L43 | null | # -*- coding: utf-8 -*-
'''
Decorators for salt.utils.path
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
import salt.utils.path
from salt.exceptions import CommandNotFoundError
from salt.utils.decorators.signature import identical_signature_wrapper
def which(exe):
... |
saltstack/salt | salt/runners/doc.py | runner | python | def runner():
'''
Return all inline documentation for runner modules
CLI Example:
.. code-block:: bash
salt-run doc.runner
'''
client = salt.runner.RunnerClient(__opts__)
ret = client.get_docs()
return ret | Return all inline documentation for runner modules
CLI Example:
.. code-block:: bash
salt-run doc.runner | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/doc.py#L27-L39 | [
"def get_docs(self, arg=None):\n '''\n Return a dictionary of functions and the inline documentation for each\n '''\n if arg:\n if '*' in arg:\n target_mod = arg\n _use_fnmatch = True\n else:\n target_mod = arg + '.' if not arg.endswith('.') else arg\n ... | # -*- coding: utf-8 -*-
'''
A runner module to collect and display the inline documentation from the
various module types
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import itertools
# Import salt libs
import salt.client
import salt.runner
import salt.wheel
# Impo... |
saltstack/salt | salt/runners/doc.py | wheel | python | def wheel():
'''
Return all inline documentation for wheel modules
CLI Example:
.. code-block:: bash
salt-run doc.wheel
'''
client = salt.wheel.Wheel(__opts__)
ret = client.get_docs()
return ret | Return all inline documentation for wheel modules
CLI Example:
.. code-block:: bash
salt-run doc.wheel | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/doc.py#L42-L54 | [
"def get_docs(self, arg=None):\n '''\n Return a dictionary of functions and the inline documentation for each\n '''\n if arg:\n if '*' in arg:\n target_mod = arg\n _use_fnmatch = True\n else:\n target_mod = arg + '.' if not arg.endswith('.') else arg\n ... | # -*- coding: utf-8 -*-
'''
A runner module to collect and display the inline documentation from the
various module types
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import itertools
# Import salt libs
import salt.client
import salt.runner
import salt.wheel
# Impo... |
saltstack/salt | salt/runners/doc.py | execution | python | def execution():
'''
Collect all the sys.doc output from each minion and return the aggregate
CLI Example:
.. code-block:: bash
salt-run doc.execution
'''
client = salt.client.get_local_client(__opts__['conf_file'])
docs = {}
try:
for ret in client.cmd_iter('*', 'sys.... | Collect all the sys.doc output from each minion and return the aggregate
CLI Example:
.. code-block:: bash
salt-run doc.execution | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/doc.py#L57-L81 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def get_local_client(\n c_path=os.path.join(syspaths.CONFIG_DIR, 'master'),\n mopts=None,\n skip_perm_errors=False,\n io_loop=None,\n auto_reconnect=False):... | # -*- coding: utf-8 -*-
'''
A runner module to collect and display the inline documentation from the
various module types
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import itertools
# Import salt libs
import salt.client
import salt.runner
import salt.wheel
# Impo... |
saltstack/salt | salt/modules/temp.py | file | python | def file(suffix='', prefix='tmp', parent=None):
'''
Create a temporary file
CLI Example:
.. code-block:: bash
salt '*' temp.file
salt '*' temp.file prefix='mytemp-' parent='/var/run/'
'''
fh_, tmp_ = tempfile.mkstemp(suffix, prefix, parent)
os.close(fh_)
return tmp_ | Create a temporary file
CLI Example:
.. code-block:: bash
salt '*' temp.file
salt '*' temp.file prefix='mytemp-' parent='/var/run/' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/temp.py#L33-L46 | null | # -*- coding: utf-8 -*-
'''
Simple module for creating temporary directories and files
This is a thin wrapper around Pythons tempfile module
.. versionadded:: 2015.8.0
'''
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
import tempfile
log = logging.getLogger(__nam... |
saltstack/salt | salt/runner.py | RunnerClient._reformat_low | python | def _reformat_low(self, low):
'''
Format the low data for RunnerClient()'s master_call() function
This also normalizes the following low data formats to a single, common
low data structure.
Old-style low: ``{'fun': 'jobs.lookup_jid', 'jid': '1234'}``
New-style: ``{'fun'... | Format the low data for RunnerClient()'s master_call() function
This also normalizes the following low data formats to a single, common
low data structure.
Old-style low: ``{'fun': 'jobs.lookup_jid', 'jid': '1234'}``
New-style: ``{'fun': 'jobs.lookup_jid', 'kwarg': {'jid': '1234'}}``
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L66-L107 | [
"def parse_input(args, kwargs=None, condition=True, no_parse=None):\n '''\n Parse out the args and kwargs from a list of input values. Optionally,\n return the args and kwargs without passing them to condition_input().\n\n Don't pull args with key=val apart if it has a newline in it.\n '''\n if no... | class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'''
The interface used by the :command:`salt-run` CLI tool on the Salt Master
It executes :ref:`runner modules <all-salt.runners>` which run on the Salt
Master.
Importing and using ``RunnerClient`` must be done on the sam... |
saltstack/salt | salt/runner.py | RunnerClient.cmd_async | python | def cmd_async(self, low):
'''
Execute a runner function asynchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:: python
runner.ea... | Execute a runner function asynchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:: python
runner.eauth_async({
'fun': 'jobs.list_... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L109-L127 | [
"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 '... | class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'''
The interface used by the :command:`salt-run` CLI tool on the Salt Master
It executes :ref:`runner modules <all-salt.runners>` which run on the Salt
Master.
Importing and using ``RunnerClient`` must be done on the sam... |
saltstack/salt | salt/runner.py | RunnerClient.cmd_sync | python | def cmd_sync(self, low, timeout=None, full_return=False):
'''
Execute a runner function synchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:... | Execute a runner function synchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:: python
runner.eauth_sync({
'fun': 'jobs.list_jo... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L129-L146 | [
"def cmd_sync(self, low, timeout=None, full_return=False):\n '''\n Execute a runner function synchronously; eauth is respected\n\n This function requires that :conf_master:`external_auth` is configured\n and the user is authorized to execute runner functions: (``@runner``).\n\n .. code-block:: python... | class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'''
The interface used by the :command:`salt-run` CLI tool on the Salt Master
It executes :ref:`runner modules <all-salt.runners>` which run on the Salt
Master.
Importing and using ``RunnerClient`` must be done on the sam... |
saltstack/salt | salt/runner.py | Runner.print_docs | python | def print_docs(self):
'''
Print out the documentation!
'''
arg = self.opts.get('fun', None)
docs = super(Runner, self).get_docs(arg)
for fun in sorted(docs):
display_output('{0}:'.format(fun), 'text', self.opts)
print(docs[fun]) | Print out the documentation! | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L169-L177 | [
"def display_output(data, out=None, opts=None, **kwargs):\n '''\n Print the passed data using the desired output\n '''\n if opts is None:\n opts = {}\n display_data = try_printout(data, out, opts, **kwargs)\n\n output_filename = opts.get('output_file', None)\n log.trace('data = %s', data... | class Runner(RunnerClient):
'''
Execute the salt runner interface
'''
def __init__(self, opts):
super(Runner, self).__init__(opts)
self.returners = salt.loader.returners(opts, self.functions)
self.outputters = salt.loader.outputters(opts)
# TODO: move to mixin whenever we w... |
saltstack/salt | salt/runner.py | Runner.run | python | def run(self):
'''
Execute the runner sequence
'''
# Print documentation only
if self.opts.get('doc', False):
self.print_docs()
else:
return self._run_runner() | Execute the runner sequence | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L180-L188 | null | class Runner(RunnerClient):
'''
Execute the salt runner interface
'''
def __init__(self, opts):
super(Runner, self).__init__(opts)
self.returners = salt.loader.returners(opts, self.functions)
self.outputters = salt.loader.outputters(opts)
def print_docs(self):
'''
... |
saltstack/salt | salt/runner.py | Runner._run_runner | python | def _run_runner(self):
'''
Actually execute specific runner
:return:
'''
import salt.minion
ret = {}
low = {'fun': self.opts['fun']}
try:
# Allocate a jid
async_pub = self._gen_async_pub()
self.jid = async_pub['jid']
... | Actually execute specific runner
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runner.py#L190-L312 | null | class Runner(RunnerClient):
'''
Execute the salt runner interface
'''
def __init__(self, opts):
super(Runner, self).__init__(opts)
self.returners = salt.loader.returners(opts, self.functions)
self.outputters = salt.loader.outputters(opts)
def print_docs(self):
'''
... |
saltstack/salt | salt/thorium/status.py | reg | python | def reg(name):
'''
Activate this register to turn on a minion status tracking register, this
register keeps the current status beacon data and the time that each beacon
was last checked in.
'''
ret = {'name': name,
'changes': {},
'comment': '',
'result': True}
... | Activate this register to turn on a minion status tracking register, this
register keeps the current status beacon data and the time that each beacon
was last checked in. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/status.py#L14-L38 | null | # -*- coding: utf-8 -*-
'''
This thorium state is used to track the status beacon events and keep track of
the active status of minions
.. versionadded:: 2016.11.0
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import time
import fnmatch
|
saltstack/salt | salt/tops/reclass_adapter.py | top | python | def top(**kwargs):
'''
Query |reclass| for the top data (states of the minions).
'''
# If reclass is installed, __virtual__ put it onto the search path, so we
# don't need to protect against ImportError:
# pylint: disable=3rd-party-module-not-gated
from reclass.adapters.salt import top as r... | Query |reclass| for the top data (states of the minions). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/tops/reclass_adapter.py#L82-L146 | [
"def filter_out_source_path_option(opts):\n if 'reclass_source_path' in opts:\n del opts['reclass_source_path']\n",
"def set_inventory_base_uri_default(config, opts):\n if 'inventory_base_uri' in opts:\n return\n\n base_roots = config.get('file_roots', {}).get('base', [])\n if base_roots... | # -*- coding: utf-8 -*-
'''
Read tops data from a reclass database
.. |reclass| replace:: **reclass**
This :ref:`master_tops <master-tops-system>` plugin provides access to
the |reclass| database, such that state information (top data) are retrieved
from |reclass|.
You can find more information about |reclass| at
ht... |
saltstack/salt | salt/modules/boto_datapipeline.py | create_pipeline | python | def create_pipeline(name, unique_id, description='', region=None, key=None, keyid=None,
profile=None):
'''
Create a new, empty pipeline. This function is idempotent.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.create_pipeline my_name my_unique_id
... | Create a new, empty pipeline. This function is idempotent.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.create_pipeline my_name my_unique_id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L57-L79 | [
"def _get_client(region, key, keyid, profile):\n '''\n Get a boto connection to Data Pipeline.\n '''\n session = _get_session(region, key, keyid, profile)\n if not session:\n log.error(\"Failed to get datapipeline client.\")\n return None\n\n return session.client('datapipeline')\n"
... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | delete_pipeline | python | def delete_pipeline(pipeline_id, region=None, key=None, keyid=None, profile=None):
'''
Delete a pipeline, its pipeline definition, and its run history. This function is idempotent.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.delete_pipeline my_pipeline_id
'''
cli... | Delete a pipeline, its pipeline definition, and its run history. This function is idempotent.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.delete_pipeline my_pipeline_id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L82-L99 | [
"def _get_client(region, key, keyid, profile):\n '''\n Get a boto connection to Data Pipeline.\n '''\n session = _get_session(region, key, keyid, profile)\n if not session:\n log.error(\"Failed to get datapipeline client.\")\n return None\n\n return session.client('datapipeline')\n"
... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | describe_pipelines | python | def describe_pipelines(pipeline_ids, region=None, key=None, keyid=None, profile=None):
'''
Retrieve metadata about one or more pipelines.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.describe_pipelines ['my_pipeline_id']
'''
client = _get_client(region, key, keyid... | Retrieve metadata about one or more pipelines.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.describe_pipelines ['my_pipeline_id'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L102-L118 | [
"def _get_client(region, key, keyid, profile):\n '''\n Get a boto connection to Data Pipeline.\n '''\n session = _get_session(region, key, keyid, profile)\n if not session:\n log.error(\"Failed to get datapipeline client.\")\n return None\n\n return session.client('datapipeline')\n"
... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | list_pipelines | python | def list_pipelines(region=None, key=None, keyid=None, profile=None):
'''
Get a list of pipeline ids and names for all pipelines.
CLI Example:
.. code-block:: bash
salt myminion boto_datapipeline.list_pipelines profile=myprofile
'''
client = _get_client(region, key, keyid, profile)
... | Get a list of pipeline ids and names for all pipelines.
CLI Example:
.. code-block:: bash
salt myminion boto_datapipeline.list_pipelines profile=myprofile | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L144-L164 | [
"def _get_client(region, key, keyid, profile):\n '''\n Get a boto connection to Data Pipeline.\n '''\n session = _get_session(region, key, keyid, profile)\n if not session:\n log.error(\"Failed to get datapipeline client.\")\n return None\n\n return session.client('datapipeline')\n"
... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | pipeline_id_from_name | python | def pipeline_id_from_name(name, region=None, key=None, keyid=None, profile=None):
'''
Get the pipeline id, if it exists, for the given name.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.pipeline_id_from_name my_pipeline_name
'''
r = {}
result_pipelines = list_... | Get the pipeline id, if it exists, for the given name.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.pipeline_id_from_name my_pipeline_name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L167-L187 | [
"def list_pipelines(region=None, key=None, keyid=None, profile=None):\n '''\n Get a list of pipeline ids and names for all pipelines.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt myminion boto_datapipeline.list_pipelines profile=myprofile\n '''\n client = _get_client(region, key, keyi... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | put_pipeline_definition | python | def put_pipeline_definition(pipeline_id, pipeline_objects, parameter_objects=None,
parameter_values=None, region=None, key=None, keyid=None, profile=None):
'''
Add tasks, schedules, and preconditions to the specified pipeline. This function is
idempotent and will replace an exist... | Add tasks, schedules, and preconditions to the specified pipeline. This function is
idempotent and will replace an existing definition.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.put_pipeline_definition my_pipeline_id my_pipeline_objects | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L190-L219 | [
"def _get_client(region, key, keyid, profile):\n '''\n Get a boto connection to Data Pipeline.\n '''\n session = _get_session(region, key, keyid, profile)\n if not session:\n log.error(\"Failed to get datapipeline client.\")\n return None\n\n return session.client('datapipeline')\n"
... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | _get_client | python | def _get_client(region, key, keyid, profile):
'''
Get a boto connection to Data Pipeline.
'''
session = _get_session(region, key, keyid, profile)
if not session:
log.error("Failed to get datapipeline client.")
return None
return session.client('datapipeline') | Get a boto connection to Data Pipeline. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L222-L231 | [
"def _get_session(region, key, keyid, profile):\n '''\n Get a boto3 session\n '''\n if profile:\n if isinstance(profile, six.string_types):\n _profile = __salt__['config.option'](profile)\n elif isinstance(profile, dict):\n _profile = profile\n key = _profile.g... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/boto_datapipeline.py | _get_session | python | def _get_session(region, key, keyid, profile):
'''
Get a boto3 session
'''
if profile:
if isinstance(profile, six.string_types):
_profile = __salt__['config.option'](profile)
elif isinstance(profile, dict):
_profile = profile
key = _profile.get('key', None... | Get a boto3 session | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L234-L257 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Data Pipeline
.. versionadded:: 2016.3.0
:depends: boto3
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
# Import Salt libs
from salt.ext import six
import salt.utils.versions
log = logging.get... |
saltstack/salt | salt/modules/qemu_img.py | make_image | python | def make_image(location, size, fmt):
'''
Create a blank virtual machine image file of the specified size in
megabytes. The image can be created in any format supported by qemu
CLI Example:
.. code-block:: bash
salt '*' qemu_img.make_image /tmp/image.qcow 2048 qcow2
salt '*' qemu_i... | Create a blank virtual machine image file of the specified size in
megabytes. The image can be created in any format supported by qemu
CLI Example:
.. code-block:: bash
salt '*' qemu_img.make_image /tmp/image.qcow 2048 qcow2
salt '*' qemu_img.make_image /tmp/image.raw 10240 raw | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/qemu_img.py#L28-L51 | null | # -*- coding: utf-8 -*-
'''
Qemu-img Command Wrapper
========================
The qemu img command is wrapped for specific functions
:depends: qemu-img
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
# Import salt libs
import salt.utils.path
def __virtua... |
saltstack/salt | salt/modules/qemu_img.py | convert | python | def convert(orig, dest, fmt):
'''
Convert an existing disk image to another format using qemu-img
CLI Example:
.. code-block:: bash
salt '*' qemu_img.convert /path/to/original.img /path/to/new.img qcow2
'''
cmd = ('qemu-img', 'convert', '-O', fmt, orig, dest)
ret = __salt__['cmd.r... | Convert an existing disk image to another format using qemu-img
CLI Example:
.. code-block:: bash
salt '*' qemu_img.convert /path/to/original.img /path/to/new.img qcow2 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/qemu_img.py#L54-L69 | null | # -*- coding: utf-8 -*-
'''
Qemu-img Command Wrapper
========================
The qemu img command is wrapped for specific functions
:depends: qemu-img
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
# Import salt libs
import salt.utils.path
def __virtua... |
saltstack/salt | salt/modules/win_network.py | ping | python | def ping(host, timeout=False, return_boolean=False):
'''
Performs a ping to a host
CLI Example:
.. code-block:: bash
salt '*' network.ping archlinux.org
.. versionadded:: 2016.11.0
Return a True or False instead of ping output.
.. code-block:: bash
salt '*' network.pin... | Performs a ping to a host
CLI Example:
.. code-block:: bash
salt '*' network.ping archlinux.org
.. versionadded:: 2016.11.0
Return a True or False instead of ping output.
.. code-block:: bash
salt '*' network.ping archlinux.org return_boolean=True
Set the time to wait for... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L69-L107 | [
"def sanitize_host(host):\n '''\n Sanitize host string.\n https://tools.ietf.org/html/rfc1123#section-2.1\n '''\n RFC952_characters = ascii_letters + digits + \".-\"\n return \"\".join([c for c in host[0:255] if c in RFC952_characters])\n"
] | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | netstat | python | def netstat():
'''
Return information on open ports and states
CLI Example:
.. code-block:: bash
salt '*' network.netstat
'''
ret = []
cmd = ['netstat', '-nao']
lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
for line in lines:
comps = line.split(... | Return information on open ports and states
CLI Example:
.. code-block:: bash
salt '*' network.netstat | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L110-L139 | null | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | traceroute | python | def traceroute(host):
'''
Performs a traceroute to a 3rd party host
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org
'''
ret = []
cmd = ['tracert', salt.utils.network.sanitize_host(host)]
lines = __salt__['cmd.run'](cmd, python_shell=False).splitline... | Performs a traceroute to a 3rd party host
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L142-L193 | [
"def sanitize_host(host):\n '''\n Sanitize host string.\n https://tools.ietf.org/html/rfc1123#section-2.1\n '''\n RFC952_characters = ascii_letters + digits + \".-\"\n return \"\".join([c for c in host[0:255] if c in RFC952_characters])\n"
] | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | nslookup | python | def nslookup(host):
'''
Query DNS for information about a domain or ip address
CLI Example:
.. code-block:: bash
salt '*' network.nslookup archlinux.org
'''
ret = []
addresses = []
cmd = ['nslookup', salt.utils.network.sanitize_host(host)]
lines = __salt__['cmd.run'](cmd, ... | Query DNS for information about a domain or ip address
CLI Example:
.. code-block:: bash
salt '*' network.nslookup archlinux.org | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L196-L226 | [
"def sanitize_host(host):\n '''\n Sanitize host string.\n https://tools.ietf.org/html/rfc1123#section-2.1\n '''\n RFC952_characters = ascii_letters + digits + \".-\"\n return \"\".join([c for c in host[0:255] if c in RFC952_characters])\n"
] | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | get_route | python | def get_route(ip):
'''
Return routing information for given destination ip
.. versionadded:: 2016.11.5
CLI Example::
salt '*' network.get_route 10.10.10.10
'''
cmd = 'Find-NetRoute -RemoteIPAddress {0}'.format(ip)
out = __salt__['cmd.run'](cmd, shell='powershell', python_shell=Tru... | Return routing information for given destination ip
.. versionadded:: 2016.11.5
CLI Example::
salt '*' network.get_route 10.10.10.10 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L229-L255 | null | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | dig | python | def dig(host):
'''
Performs a DNS lookup with dig
Note: dig must be installed on the Windows minion
CLI Example:
.. code-block:: bash
salt '*' network.dig archlinux.org
'''
cmd = ['dig', salt.utils.network.sanitize_host(host)]
return __salt__['cmd.run'](cmd, python_shell=Fals... | Performs a DNS lookup with dig
Note: dig must be installed on the Windows minion
CLI Example:
.. code-block:: bash
salt '*' network.dig archlinux.org | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L258-L271 | [
"def sanitize_host(host):\n '''\n Sanitize host string.\n https://tools.ietf.org/html/rfc1123#section-2.1\n '''\n RFC952_characters = ascii_letters + digits + \".-\"\n return \"\".join([c for c in host[0:255] if c in RFC952_characters])\n"
] | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | interfaces_names | python | def interfaces_names():
'''
Return a list of all the interfaces names
CLI Example:
.. code-block:: bash
salt '*' network.interfaces_names
'''
ret = []
with salt.utils.winapi.Com():
c = wmi.WMI()
for iface in c.Win32_NetworkAdapter(NetEnabled=True):
ret... | Return a list of all the interfaces names
CLI Example:
.. code-block:: bash
salt '*' network.interfaces_names | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L274-L290 | null | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | ip_addrs | python | def ip_addrs(interface=None, include_loopback=False, cidr=None, type=None):
'''
Returns a list of IPv4 addresses assigned to the host.
interface
Only IP addresses from that interface will be returned.
include_loopback : False
Include loopback 127.0.0.1 IPv4 address.
cidr
D... | Returns a list of IPv4 addresses assigned to the host.
interface
Only IP addresses from that interface will be returned.
include_loopback : False
Include loopback 127.0.0.1 IPv4 address.
cidr
Describes subnet using CIDR notation and only IPv4 addresses that belong
to this ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L349-L389 | [
"def ip_addrs(interface=None, include_loopback=False, interface_data=None):\n '''\n Returns a list of IPv4 addresses assigned to the host. 127.0.0.1 is\n ignored, unless 'include_loopback=True' is indicated. If 'interface' is\n provided, then only IP addresses from that interface will be returned.\n ... | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | ip_addrs6 | python | def ip_addrs6(interface=None, include_loopback=False, cidr=None):
'''
Returns a list of IPv6 addresses assigned to the host.
interface
Only IP addresses from that interface will be returned.
include_loopback : False
Include loopback ::1 IPv6 address.
cidr
Describes subnet ... | Returns a list of IPv6 addresses assigned to the host.
interface
Only IP addresses from that interface will be returned.
include_loopback : False
Include loopback ::1 IPv6 address.
cidr
Describes subnet using CIDR notation and only IPv6 addresses that belong
to this subnet... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L395-L423 | [
"def ip_addrs6(interface=None, include_loopback=False, interface_data=None):\n '''\n Returns a list of IPv6 addresses assigned to the host. ::1 is ignored,\n unless 'include_loopback=True' is indicated. If 'interface' is provided,\n then only IP addresses from that interface will be returned.\n '''\n... | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/modules/win_network.py | connect | python | def connect(host, port=None, **kwargs):
'''
Test connectivity to a host using a particular
port from the minion.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' network.connect archlinux.org 80
salt '*' network.connect archlinux.org 80 timeout=3
... | Test connectivity to a host using a particular
port from the minion.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' network.connect archlinux.org 80
salt '*' network.connect archlinux.org 80 timeout=3
salt '*' network.connect archlinux.org 80 timeout=... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L429-L518 | [
"def ipv4_addr(addr):\n '''\n Returns True if the IPv4 address (and optional subnet) are valid, otherwise\n returns False.\n '''\n return __ip_addr(addr, socket.AF_INET)\n"
] | # -*- coding: utf-8 -*-
'''
Module for gathering and managing network information
'''
from __future__ import absolute_import, unicode_literals, print_function
# Import Python libs
import re
import hashlib
import datetime
import socket
# Import Salt libs
import salt.utils.network
import salt.utils.platform
import salt... |
saltstack/salt | salt/returners/pushover_returner.py | _post_message | python | def _post_message(user,
device,
message,
title,
priority,
expire,
retry,
sound,
api_version=1,
token=None):
'''
Send a message to a Pushover user or g... | Send a message to a Pushover user or group.
:param user: The user or group to send to, must be key of user or group not email address.
:param message: The message to send to the PushOver user or group.
:param title: Specify who the message is from.
:param priority The priority of th... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/pushover_returner.py#L151-L198 | [
"def query(function,\n token=None,\n api_version='1',\n method='POST',\n header_dict=None,\n data=None,\n query_params=None,\n opts=None):\n '''\n PushOver object method function to construct and execute on the API URL.\n\n :param token: ... | # -*- coding: utf-8 -*-
'''
Return salt data via pushover (http://www.pushover.net)
.. versionadded:: 2016.3.0
The following fields can be set in the minion conf file::
pushover.user (required)
pushover.token (required)
pushover.title (optional)
pushover.device (optional)
pushover.priority (optio... |
saltstack/salt | salt/returners/pushover_returner.py | returner | python | def returner(ret):
'''
Send an PushOver message with the data
'''
_options = _get_options(ret)
user = _options.get('user')
device = _options.get('device')
token = _options.get('token')
title = _options.get('title')
priority = _options.get('priority')
expire = _options.get('expi... | Send an PushOver message with the data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/pushover_returner.py#L201-L251 | [
"def _get_options(ret=None):\n '''\n Get the pushover options from salt.\n '''\n\n defaults = {'priority': '0'}\n\n attrs = {'pushover_profile': 'profile',\n 'user': 'user',\n 'device': 'device',\n 'token': 'token',\n 'priority': 'priority',\n ... | # -*- coding: utf-8 -*-
'''
Return salt data via pushover (http://www.pushover.net)
.. versionadded:: 2016.3.0
The following fields can be set in the minion conf file::
pushover.user (required)
pushover.token (required)
pushover.title (optional)
pushover.device (optional)
pushover.priority (optio... |
saltstack/salt | salt/loader.py | _format_entrypoint_target | python | def _format_entrypoint_target(ep):
'''
Makes a string describing the target of an EntryPoint object.
Base strongly on EntryPoint.__str__().
'''
s = ep.module_name
if ep.attrs:
s += ':' + '.'.join(ep.attrs)
return s | Makes a string describing the target of an EntryPoint object.
Base strongly on EntryPoint.__str__(). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L147-L156 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | minion_mods | python | def minion_mods(
opts,
context=None,
utils=None,
whitelist=None,
initial_load=False,
loaded_base_name=None,
notify=False,
static_modules=None,
proxy=None):
'''
Load execution modules
Returns a dictionary of execution modules appropriat... | Load execution modules
Returns a dictionary of execution modules appropriate for the current
system by evaluating the __virtual__() function in each module.
:param dict opts: The Salt options dictionary
:param dict context: A Salt context that should be made present inside
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L205-L287 | [
"def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ... | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | raw_mod | python | def raw_mod(opts, name, functions, mod='modules'):
'''
Returns a single module loaded raw and bypassing the __virtual__ function
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
testmod = salt.loader.raw_... | Returns a single module loaded raw and bypassing the __virtual__ function
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
testmod = salt.loader.raw_mod(__opts__, 'test', None)
testmod['test.ping']() | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L290-L315 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | engines | python | def engines(opts, functions, runners, utils, proxy=None):
'''
Return the master services plugins
'''
pack = {'__salt__': functions,
'__runners__': runners,
'__proxy__': proxy,
'__utils__': utils}
return LazyLoader(
_module_dirs(opts, 'engines'),
op... | Return the master services plugins | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L341-L354 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | proxy | python | def proxy(opts, functions=None, returners=None, whitelist=None, utils=None):
'''
Returns the proxy module for this salt-proxy-minion
'''
ret = LazyLoader(
_module_dirs(opts, 'proxy'),
opts,
tag='proxy',
pack={'__salt__': functions, '__ret__': returners, '__utils__': utils... | Returns the proxy module for this salt-proxy-minion | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L357-L370 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | returners | python | def returners(opts, functions, whitelist=None, context=None, proxy=None):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'returners', 'returner'),
opts,
tag='returner',
whitelist=whitelist,
pack={'__salt__': functions, '__context__': co... | Returns the returner modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L373-L383 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | utils | python | def utils(opts, whitelist=None, context=None, proxy=proxy):
'''
Returns the utility modules
'''
return LazyLoader(
_module_dirs(opts, 'utils', ext_type_dirs='utils_dirs'),
opts,
tag='utils',
whitelist=whitelist,
pack={'__context__': context, '__proxy__': proxy or ... | Returns the utility modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L386-L396 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | pillars | python | def pillars(opts, functions, context=None):
'''
Returns the pillars modules
'''
ret = LazyLoader(_module_dirs(opts, 'pillar'),
opts,
tag='pillar',
pack={'__salt__': functions,
'__context__': context,
... | Returns the pillars modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L399-L410 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | tops | python | def tops(opts):
'''
Returns the tops modules
'''
if 'master_tops' not in opts:
return {}
whitelist = list(opts['master_tops'].keys())
ret = LazyLoader(
_module_dirs(opts, 'tops', 'top'),
opts,
tag='top',
whitelist=whitelist,
)
return FilterDictWrap... | Returns the tops modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L413-L426 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | wheels | python | def wheels(opts, whitelist=None, context=None):
'''
Returns the wheels modules
'''
if context is None:
context = {}
return LazyLoader(
_module_dirs(opts, 'wheel'),
opts,
tag='wheel',
whitelist=whitelist,
pack={'__context__': context},
) | Returns the wheels modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L429-L441 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | outputters | python | def outputters(opts):
'''
Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace
'''
ret = LazyLoader(
_module_dirs(opts, 'output', ext_type_dirs='outputter_dirs'),
opts,
ta... | Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L444-L459 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | auth | python | def auth(opts, whitelist=None):
'''
Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader
'''
return LazyLoader(
_module_dirs(opts, 'auth'),
opts,
tag='auth',
whitelist=whitelist,
pack={'__salt__': minion_mods(opts)},... | Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L488-L501 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | fileserver | python | def fileserver(opts, backends):
'''
Returns the file server modules
'''
return LazyLoader(_module_dirs(opts, 'fileserver'),
opts,
tag='fileserver',
whitelist=backends,
pack={'__utils__': utils(opts)}) | Returns the file server modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L504-L512 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | roster | python | def roster(opts, runner=None, utils=None, whitelist=None):
'''
Returns the roster modules
'''
return LazyLoader(
_module_dirs(opts, 'roster'),
opts,
tag='roster',
whitelist=whitelist,
pack={
'__runner__': runner,
'__utils__': utils,
... | Returns the roster modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L515-L528 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | thorium | python | def thorium(opts, functions, runners):
'''
Load the thorium runtime modules
'''
pack = {'__salt__': functions, '__runner__': runners, '__context__': {}}
ret = LazyLoader(_module_dirs(opts, 'thorium'),
opts,
tag='thorium',
pack=pack)
ret.pack['__thorium__'] = r... | Load the thorium runtime modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L531-L541 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | states | python | def states(opts, functions, utils, serializers, whitelist=None, proxy=None, context=None):
'''
Returns the state modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
.... | Returns the state modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.c... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L544-L574 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | beacons | python | def beacons(opts, functions, context=None, proxy=None):
'''
Load the beacon modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
'''
return LazyLoader(
_mod... | Load the beacon modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L577-L591 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | log_handlers | python | def log_handlers(opts):
'''
Returns the custom logging handler modules
:param dict opts: The Salt options dictionary
'''
ret = LazyLoader(
_module_dirs(
opts,
'log_handlers',
int_type='handlers',
base_path=os.path.join(SALT_BASE_PATH, 'log'),
... | Returns the custom logging handler modules
:param dict opts: The Salt options dictionary | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L594-L610 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | ssh_wrapper | python | def ssh_wrapper(opts, functions=None, context=None):
'''
Returns the custom logging handler modules
'''
return LazyLoader(
_module_dirs(
opts,
'wrapper',
base_path=os.path.join(SALT_BASE_PATH, os.path.join('client', 'ssh')),
),
opts,
ta... | Returns the custom logging handler modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L613-L631 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | render | python | def render(opts, functions, states=None, proxy=None, context=None):
'''
Returns the render modules
'''
if context is None:
context = {}
pack = {'__salt__': functions,
'__grains__': opts.get('grains', {}),
'__context__': context}
if states:
pack['__states... | Returns the render modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L634-L666 | [
"def check_render_pipe_str(pipestr, renderers, blacklist, whitelist):\n '''\n Check that all renderers specified in the pipe string are available.\n If so, return the list of render functions in the pipe as\n (render_func, arg_str) tuples; otherwise return [].\n '''\n if pipestr is None:\n ... | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | grain_funcs | python | def grain_funcs(opts, proxy=None):
'''
Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__)
'''
ret = LazyLoader(
... | Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L669-L692 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | _load_cached_grains | python | def _load_cached_grains(opts, cfn):
'''
Returns the grains cached in cfn, or None if the cache is too old or is
corrupted.
'''
if not os.path.isfile(cfn):
log.debug('Grains cache file does not exist.')
return None
grains_cache_age = int(time.time() - os.path.getmtime(cfn))
i... | Returns the grains cached in cfn, or None if the cache is too old or is
corrupted. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L695-L729 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | grains | python | def grains(opts, force_refresh=False, proxy=None):
'''
Return the functions for the dynamic grains and the values for the static
grains.
Since grains are computed early in the startup process, grains functions
do not have __salt__ or __proxy__ available. At proxy-minion startup,
this function ... | Return the functions for the dynamic grains and the values for the static
grains.
Since grains are computed early in the startup process, grains functions
do not have __salt__ or __proxy__ available. At proxy-minion startup,
this function is called with the proxymodule LazyLoader object so grains
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L732-L909 | [
"def include_config(include, orig_path, verbose, exit_on_config_errors=False):\n '''\n Parses extra configuration file(s) specified in an include list in the\n main config file.\n '''\n # Protect against empty option\n if not include:\n return {}\n\n if orig_path is None:\n # When... | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | call | python | def call(fun, **kwargs):
'''
Directly call a function inside a loader directory
'''
args = kwargs.get('args', [])
dirs = kwargs.get('dirs', [])
funcs = LazyLoader(
[os.path.join(SALT_BASE_PATH, 'modules')] + dirs,
None,
tag='modules',
virtual_enable=False,
)
... | Directly call a function inside a loader directory | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L913-L926 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | runner | python | def runner(opts, utils=None, context=None, whitelist=None):
'''
Directly call a function inside a loader directory
'''
if utils is None:
utils = {}
if context is None:
context = {}
ret = LazyLoader(
_module_dirs(opts, 'runners', 'runner', ext_type_dirs='runner_dirs'),
... | Directly call a function inside a loader directory | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L929-L946 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | sdb | python | def sdb(opts, functions=None, whitelist=None, utils=None):
'''
Make a very small database call
'''
if utils is None:
utils = {}
return LazyLoader(
_module_dirs(opts, 'sdb'),
opts,
tag='sdb',
pack={
'__sdb__': functions,
'__opts__': opt... | Make a very small database call | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L960-L978 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | pkgdb | python | def pkgdb(opts):
'''
Return modules for SPM's package database
.. versionadded:: 2015.8.0
'''
return LazyLoader(
_module_dirs(
opts,
'pkgdb',
base_path=os.path.join(SALT_BASE_PATH, 'spm')
),
opts,
tag='pkgdb'
) | Return modules for SPM's package database
.. versionadded:: 2015.8.0 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L981-L995 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | clouds | python | def clouds(opts):
'''
Return the cloud functions
'''
# Let's bring __active_provider_name__, defaulting to None, to all cloud
# drivers. This will get temporarily updated/overridden with a context
# manager when needed.
functions = LazyLoader(
_module_dirs(opts,
... | Return the cloud functions | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1015-L1039 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | executors | python | def executors(opts, functions=None, context=None, proxy=None):
'''
Returns the executor modules
'''
executors = LazyLoader(
_module_dirs(opts, 'executors', 'executor'),
opts,
tag='executor',
pack={'__salt__': functions, '__context__': context or {}, '__proxy__': proxy or ... | Returns the executor modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1053-L1064 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | cache | python | def cache(opts, serial):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'cache', 'cache'),
opts,
tag='cache',
pack={'__opts__': opts, '__context__': {'serial': serial}},
) | Returns the returner modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1067-L1076 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | _inject_into_mod | python | def _inject_into_mod(mod, name, value, force_lock=False):
'''
Inject a variable into a module. This is used to inject "globals" like
``__salt__``, ``__pillar``, or ``grains``.
Instead of injecting the value directly, a ``ThreadLocalProxy`` is created.
If such a proxy is already present under the sp... | Inject a variable into a module. This is used to inject "globals" like
``__salt__``, ``__pillar``, or ``grains``.
Instead of injecting the value directly, a ``ThreadLocalProxy`` is created.
If such a proxy is already present under the specified name, it is updated
with the new value. This update only a... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1096-L1155 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | global_injector_decorator | python | def global_injector_decorator(inject_globals):
'''
Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject
'''
def inner_decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
... | Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L2044-L2058 | null | # -*- coding: utf-8 -*-
'''
The Salt loader is the core to Salt's plugin system, the loader scans
directories for python loadable code and organizes the code into the
plugin interfaces used by Salt.
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
im... |
saltstack/salt | salt/loader.py | LazyLoader.missing_fun_string | python | def missing_fun_string(self, function_name):
'''
Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False
'''
mod_name = function_name.split('.')[0]
if mod_name in self.loaded_modules:
return '\'{0}\'... | Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1348-L1366 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._refresh_file_mapping | python | def _refresh_file_mapping(self):
'''
refresh the mapping of the FS on disk
'''
# map of suffix to description for imp
if self.opts.get('cython_enable', True) is True:
try:
global pyximport
pyximport = __import__('pyximport') # pylint: ... | refresh the mapping of the FS on disk | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1368-L1520 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader.clear | python | def clear(self):
'''
Clear the dict
'''
with self._lock:
super(LazyLoader, self).clear() # clear the lazy loader
self.loaded_files = set()
self.missing_modules = {}
self.loaded_modules = {}
# if we have been loaded before, lets... | Clear the dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1522-L1535 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader.__prep_mod_opts | python | def __prep_mod_opts(self, opts):
'''
Strip out of the opts any logger instance
'''
if '__grains__' not in self.pack:
grains = opts.get('grains', {})
if isinstance(grains, ThreadLocalProxy):
grains = ThreadLocalProxy.unproxy(grains)
se... | Strip out of the opts any logger instance | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1537-L1564 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._iter_files | python | def _iter_files(self, mod_name):
'''
Iterate over all file_mapping files in order of closeness to mod_name
'''
# do we have an exact match?
if mod_name in self.file_mapping:
yield mod_name
# do we have a partial match?
for k in self.file_mapping:
... | Iterate over all file_mapping files in order of closeness to mod_name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1566-L1582 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._load | python | def _load(self, key):
'''
Load a single item if you have it
'''
# if the key doesn't have a '.' then it isn't valid for this mod dict
if not isinstance(key, six.string_types):
raise KeyError('The key must be a string.')
if '.' not in key:
raise Key... | Load a single item if you have it | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1851-L1902 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._load_all | python | def _load_all(self):
'''
Load all of them
'''
with self._lock:
for name in self.file_mapping:
if name in self.loaded_files or name in self.missing_modules:
continue
self._load_module(name)
self.loaded = True | Load all of them | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1904-L1914 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._apply_outputter | python | def _apply_outputter(self, func, mod):
'''
Apply the __outputter__ variable to the functions
'''
if hasattr(mod, '__outputter__'):
outp = mod.__outputter__
if func.__name__ in outp:
func.__outputter__ = outp[func.__name__] | Apply the __outputter__ variable to the functions | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1921-L1928 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/loader.py | LazyLoader._process_virtual | python | def _process_virtual(self, mod, module_name, virtual_func='__virtual__'):
'''
Given a loaded module and its default name determine its virtual name
This function returns a tuple. The first value will be either True or
False and will indicate if the module should be loaded or not (i.e. i... | Given a loaded module and its default name determine its virtual name
This function returns a tuple. The first value will be either True or
False and will indicate if the module should be loaded or not (i.e. if
it threw and exception while processing its __virtual__ function). The
secon... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1930-L2041 | null | class LazyLoader(salt.utils.lazy.LazyDict):
'''
A pseduo-dictionary which has a set of keys which are the
name of the module and function, delimited by a dot. When
the value of the key is accessed, the function is then loaded
from disk and into memory.
.. note::
Iterating over keys wil... |
saltstack/salt | salt/modules/smbios.py | get | python | def get(string, clean=True):
'''
Get an individual DMI string from SMBIOS info
string
The string to fetch. DMIdecode supports:
- ``bios-vendor``
- ``bios-version``
- ``bios-release-date``
- ``system-manufacturer``
- ``system-product-name``
... | Get an individual DMI string from SMBIOS info
string
The string to fetch. DMIdecode supports:
- ``bios-vendor``
- ``bios-version``
- ``bios-release-date``
- ``system-manufacturer``
- ``system-product-name``
- ``system-version``
- ``syste... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L41-L89 | [
"def _dmidecoder(args=None):\n '''\n Call DMIdecode\n '''\n dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios'])\n\n if not args:\n out = salt.modules.cmdmod._run_quiet(dmidecoder)\n else:\n out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args))\n\n re... | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/modules/smbios.py | records | python | def records(rec_type=None, fields=None, clean=True):
'''
Return DMI records from SMBIOS
type
Return only records of type(s)
The SMBIOS specification defines the following DMI types:
==== ======================================
Type Information
==== ===============... | Return DMI records from SMBIOS
type
Return only records of type(s)
The SMBIOS specification defines the following DMI types:
==== ======================================
Type Information
==== ======================================
0 BIOS
1 System
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L92-L167 | [
"def _dmidecoder(args=None):\n '''\n Call DMIdecode\n '''\n dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios'])\n\n if not args:\n out = salt.modules.cmdmod._run_quiet(dmidecoder)\n else:\n out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args))\n\n re... | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/modules/smbios.py | _dmi_parse | python | def _dmi_parse(data, clean=True, fields=None):
'''
Structurize DMI records into a nice list
Optionally trash bogus entries and filter output
'''
dmi = []
# Detect & split Handle records
dmi_split = re.compile('(handle [0-9]x[0-9a-f]+[^\n]+)\n', re.MULTILINE+re.IGNORECASE)
dmi_raw = iter... | Structurize DMI records into a nice list
Optionally trash bogus entries and filter output | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L170-L207 | [
"def _dmi_data(dmi_raw, clean, fields):\n '''\n Parse the raw DMIdecode output of a single handle\n into a nice dict\n '''\n dmi_data = {}\n\n key = None\n key_data = [None, []]\n for line in dmi_raw:\n if re.match(r'\\t[^\\s]+', line):\n # Finish previous key\n ... | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/modules/smbios.py | _dmi_data | python | def _dmi_data(dmi_raw, clean, fields):
'''
Parse the raw DMIdecode output of a single handle
into a nice dict
'''
dmi_data = {}
key = None
key_data = [None, []]
for line in dmi_raw:
if re.match(r'\t[^\s]+', line):
# Finish previous key
if key is not None:... | Parse the raw DMIdecode output of a single handle
into a nice dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L210-L259 | null | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/modules/smbios.py | _dmi_cast | python | def _dmi_cast(key, val, clean=True):
'''
Simple caster thingy for trying to fish out at least ints & lists from strings
'''
if clean and not _dmi_isclean(key, val):
return
elif not re.match(r'serial|part|asset|product', key, flags=re.IGNORECASE):
if ',' in val:
val = [el.... | Simple caster thingy for trying to fish out at least ints & lists from strings | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L262-L277 | null | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/modules/smbios.py | _dmidecoder | python | def _dmidecoder(args=None):
'''
Call DMIdecode
'''
dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios'])
if not args:
out = salt.modules.cmdmod._run_quiet(dmidecoder)
else:
out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args))
return out | Call DMIdecode | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L316-L327 | [
"def which_bin(exes):\n '''\n Scan over some possible executables and return the first one that is found\n '''\n if not isinstance(exes, Iterable):\n return None\n for exe in exes:\n path = which(exe)\n if not path:\n continue\n return path\n return None\n",
... | # -*- coding: utf-8 -*-
'''
Interface to SMBIOS/DMI
(Parsing through dmidecode)
External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_
'''
... |
saltstack/salt | salt/utils/yamlloader.py | SaltYamlSafeLoader.construct_mapping | python | def construct_mapping(self, node, deep=False):
'''
Build the mapping for YAML
'''
if not isinstance(node, MappingNode):
raise ConstructorError(
None,
None,
'expected a mapping node, but found {0}'.format(node.id),
... | Build the mapping for YAML | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L72-L105 | null | class SaltYamlSafeLoader(yaml.SafeLoader):
'''
Create a custom YAML loader that uses the custom constructor. This allows
for the YAML loading defaults to be manipulated based on needs within salt
to make things like sls file more intuitive.
'''
def __init__(self, stream, dictclass=dict):
... |
saltstack/salt | salt/utils/yamlloader.py | SaltYamlSafeLoader.construct_scalar | python | def construct_scalar(self, node):
'''
Verify integers and pass them in correctly is they are declared
as octal
'''
if node.tag == 'tag:yaml.org,2002:int':
if node.value == '0':
pass
elif node.value.startswith('0') and not node.value.startsw... | Verify integers and pass them in correctly is they are declared
as octal | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L107-L121 | null | class SaltYamlSafeLoader(yaml.SafeLoader):
'''
Create a custom YAML loader that uses the custom constructor. This allows
for the YAML loading defaults to be manipulated based on needs within salt
to make things like sls file more intuitive.
'''
def __init__(self, stream, dictclass=dict):
... |
saltstack/salt | salt/ext/ipaddress.py | ip_address | python | def ip_address(address):
try:
return IPv4Address(address)
except (AddressValueError, NetmaskValueError):
pass
try:
return IPv6Address(address)
except (AddressValueError, NetmaskValueError):
pass
raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
... | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Address or IPv6Address obje... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L93-L120 | null | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | ip_network | python | def ip_network(address, strict=True):
try:
return IPv4Network(address, strict)
except (AddressValueError, NetmaskValueError):
pass
try:
return IPv6Network(address, strict)
except (AddressValueError, NetmaskValueError):
pass
raise ValueError('%r does not appear to be... | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP network. Either IPv4 or
IPv6 networks may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Network or IPv6Network objec... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L123-L150 | null | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | _split_optional_netmask | python | def _split_optional_netmask(address):
addr = str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | Helper to split the netmask and raise AddressValueError if needed | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L224-L229 | null | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | _count_righthand_zero_bits | python | def _count_righthand_zero_bits(number, bits):
if number == 0:
return bits
for i in range(bits):
if (number >> i) & 1:
return i
# All bits of interest were zero, even if there are more in the number
return bits | Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L251-L268 | null | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | _collapse_addresses_recursive | python | def _collapse_addresses_recursive(addresses):
while True:
last_addr = None
ret_array = []
optimized = False
for cur_addr in addresses:
if not ret_array:
last_addr = cur_addr
ret_array.append(cur_addr)
elif (cur_addr.network_add... | Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collapse_addresses_recursive([ip1, ip2, ip3, ip4]) ->
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L327-L372 | null | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | collapse_addresses | python | def collapse_addresses(addresses):
i = 0
addrs = []
ips = []
nets = []
# split IP addresses and networks
for ip in addresses:
if isinstance(ip, _BaseAddress):
if ips and ips[-1]._version != ip._version:
raise TypeError("%s and %s are not of the same version" ... | Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network or IPv6Network objects.
Returns:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L375-L429 | [
"def isinstance(val, types):\n if types is int:\n types = (int, long)\n elif type(types) is tuple and int in types:\n types += (long,)\n return _builtin_isinstance(val, types)\n",
"def _find_address_range(addresses):\n \"\"\"Find a sequence of IPv#Address.\n\n Args:\n addresses... | '''
Python 2.[67] port of Python 3.4's ipaddress module
Almost verbatim copy of the core lib, with compatibility changes
Source: https://bitbucket.org/kwi/py2-ipaddress/
'''
# pylint: skip-file
# List of compatibility changes:
# Python 3 uses only new-style classes.
# s/class \(\w\+\):/class \1(object):/
# Use iter... |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_ip_int | python | def _prefix_from_ip_int(self, ip_int):
trailing_zeroes = _count_righthand_zero_bits(ip_int,
self._max_prefixlen)
prefixlen = self._max_prefixlen - trailing_zeroes
leading_ones = ip_int >> trailing_zeroes
all_ones = (1 << prefixlen) - 1... | Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & ones | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L548-L570 | null | class _IPAddressBase(_TotalOrderingMixin):
"""The mother class."""
@property
def exploded(self):
"""Return the longhand version of the IP address as a string."""
return self._explode_shorthand_ip_string()
@property
def compressed(self):
"""Return the shorthand version of t... |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_prefix_string | python | def _prefix_from_prefix_string(self, prefixlen_str):
# int allows a leading +/- as well as surrounding whitespace,
# so we ensure that isn't the case
if not _BaseV4._DECIMAL_DIGITS.issuperset(prefixlen_str):
self._report_invalid_netmask(prefixlen_str)
try:
prefixl... | Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L576-L598 | null | class _IPAddressBase(_TotalOrderingMixin):
"""The mother class."""
@property
def exploded(self):
"""Return the longhand version of the IP address as a string."""
return self._explode_shorthand_ip_string()
@property
def compressed(self):
"""Return the shorthand version of t... |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_ip_string | python | def _prefix_from_ip_string(self, ip_str):
# Parse the netmask/hostmask like an IP address.
try:
ip_int = self._ip_int_from_string(ip_str)
except AddressValueError:
self._report_invalid_netmask(ip_str)
# Try matching a netmask (this would be /1*0*/ as a bitwise re... | Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask/hostmask | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L600-L631 | null | class _IPAddressBase(_TotalOrderingMixin):
"""The mother class."""
@property
def exploded(self):
"""Return the longhand version of the IP address as a string."""
return self._explode_shorthand_ip_string()
@property
def compressed(self):
"""Return the shorthand version of t... |
saltstack/salt | salt/ext/ipaddress.py | _BaseNetwork.subnets | python | def subnets(self, prefixlen_diff=1, new_prefix=None):
if self._prefixlen == self._max_prefixlen:
yield self
return
if new_prefix is not None:
if new_prefix < self._prefixlen:
raise ValueError('new prefix must be longer')
if prefixlen_diff ... | The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
prefixlen_diff: An integer, the amount the prefix length
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L967-L1027 | null | class _BaseNetwork(_IPAddressBase):
"""A generic IP network object.
This IP class contains the version independent methods which are
used by networks.
"""
def __init__(self, address):
self._cache = {}
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, str(self))
... |
saltstack/salt | salt/ext/ipaddress.py | _BaseNetwork.supernet | python | def supernet(self, prefixlen_diff=1, new_prefix=None):
if self._prefixlen == 0:
return self
if new_prefix is not None:
if new_prefix > self._prefixlen:
raise ValueError('new prefix must be shorter')
if prefixlen_diff != 1:
raise ValueE... | The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of 3, a supernet with a
/21 netmask is returned.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1029-L1068 | null | class _BaseNetwork(_IPAddressBase):
"""A generic IP network object.
This IP class contains the version independent methods which are
used by networks.
"""
def __init__(self, address):
self._cache = {}
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, str(self))
... |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._ip_int_from_string | python | def _ip_int_from_string(self, ip_str):
if not ip_str:
raise AddressValueError('Address cannot be empty')
octets = ip_str.split('.')
if len(octets) != 4:
raise AddressValueError("Expected 4 octets in %r" % ip_str)
try:
return _int_from_bytes(map(self.... | Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1176-L1199 | null | class _BaseV4(object):
"""Base IPv4 object.
The following methods are used by IPv4 objects in both single IP
addresses and networks.
"""
# Equivalent to 255.255.255.255 or 32 bits of 1's.
_ALL_ONES = (2**IPV4LENGTH) - 1
_DECIMAL_DIGITS = frozenset('0123456789')
# the valid octets fo... |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._parse_octet | python | def _parse_octet(self, octet_str):
if not octet_str:
raise ValueError("Empty octet not permitted")
# Whitelist the characters, since int() allows a lot of bizarre stuff.
if not self._DECIMAL_DIGITS.issuperset(octet_str):
msg = "Only decimal digits permitted in %r"
... | Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255]. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1201-L1235 | null | class _BaseV4(object):
"""Base IPv4 object.
The following methods are used by IPv4 objects in both single IP
addresses and networks.
"""
# Equivalent to 255.255.255.255 or 32 bits of 1's.
_ALL_ONES = (2**IPV4LENGTH) - 1
_DECIMAL_DIGITS = frozenset('0123456789')
# the valid octets fo... |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._is_valid_netmask | python | def _is_valid_netmask(self, netmask):
mask = netmask.split('.')
if len(mask) == 4:
try:
for x in mask:
if int(x) not in self._valid_mask_octets:
return False
except ValueError:
# Found something that isn'... | Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1249-L1278 | null | class _BaseV4(object):
"""Base IPv4 object.
The following methods are used by IPv4 objects in both single IP
addresses and networks.
"""
# Equivalent to 255.255.255.255 or 32 bits of 1's.
_ALL_ONES = (2**IPV4LENGTH) - 1
_DECIMAL_DIGITS = frozenset('0123456789')
# the valid octets fo... |
saltstack/salt | salt/ext/ipaddress.py | IPv4Address.is_private | python | def is_private(self):
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8') or
self in IPv4Network('127.0.0.0/8') or
self in IPv4Network('169.254.0.0/16') or
self in IPv4Network('172.16.0.0/12') or
self in IP... | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1377-L1398 | null | class IPv4Address(_BaseV4, _BaseAddress):
"""Represent and manipulate single IPv4 Addresses."""
def __init__(self, address):
"""
Args:
address: A string or integer representing the IP
Additionally, an integer can be passed, so
IPv4Address('192.0.2.1') ... |
saltstack/salt | salt/ext/ipaddress.py | _BaseV6._explode_shorthand_ip_string | python | def _explode_shorthand_ip_string(self):
if isinstance(self, IPv6Network):
ip_str = str(self.network_address)
elif isinstance(self, IPv6Interface):
ip_str = str(self.ip)
else:
ip_str = str(self)
ip_int = self._ip_int_from_string(ip_str)
hex_str... | Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1847-L1869 | null | class _BaseV6(object):
"""Base IPv6 object.
The following methods are used by IPv6 objects in both single IP
addresses and networks.
"""
_ALL_ONES = (2**IPV6LENGTH) - 1
_HEXTET_COUNT = 8
_HEX_DIGITS = frozenset('0123456789ABCDEFabcdef')
def __init__(self, address):
self._ver... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.