repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/thorium/status.py | reg | 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}
... | 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}
... | [
"def",
"reg",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
",",
"'result'",
":",
"True",
"}",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"'status'",
"not",
"i... | 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. | [
"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",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/status.py#L14-L38 | train |
saltstack/salt | salt/tops/reclass_adapter.py | top | 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... | 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... | [
"def",
"top",
"(",
"*",
"*",
"kwargs",
")",
":",
"# 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",
... | Query |reclass| for the top data (states of the minions). | [
"Query",
"|reclass|",
"for",
"the",
"top",
"data",
"(",
"states",
"of",
"the",
"minions",
")",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/tops/reclass_adapter.py#L82-L146 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | create_pipeline | 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
... | 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
... | [
"def",
"create_pipeline",
"(",
"name",
",",
"unique_id",
",",
"description",
"=",
"''",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"client",
"=",
"_get_client",
"(",
"region",
... | 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",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L57-L79 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | delete_pipeline | 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... | 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... | [
"def",
"delete_pipeline",
"(",
"pipeline_id",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"client",
"=",
"_get_client",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
... | 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 | [
"Delete",
"a",
"pipeline",
"its",
"pipeline",
"definition",
"and",
"its",
"run",
"history",
".",
"This",
"function",
"is",
"idempotent",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L82-L99 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | describe_pipelines | 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... | 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... | [
"def",
"describe_pipelines",
"(",
"pipeline_ids",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"client",
"=",
"_get_client",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profil... | Retrieve metadata about one or more pipelines.
CLI example:
.. code-block:: bash
salt myminion boto_datapipeline.describe_pipelines ['my_pipeline_id'] | [
"Retrieve",
"metadata",
"about",
"one",
"or",
"more",
"pipelines",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L102-L118 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | list_pipelines | 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)
... | 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)
... | [
"def",
"list_pipelines",
"(",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"client",
"=",
"_get_client",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
"r",
"=",
"{... | Get a list of pipeline ids and names for all pipelines.
CLI Example:
.. code-block:: bash
salt myminion boto_datapipeline.list_pipelines profile=myprofile | [
"Get",
"a",
"list",
"of",
"pipeline",
"ids",
"and",
"names",
"for",
"all",
"pipelines",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L144-L164 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | pipeline_id_from_name | 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_... | 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_... | [
"def",
"pipeline_id_from_name",
"(",
"name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"r",
"=",
"{",
"}",
"result_pipelines",
"=",
"list_pipelines",
"(",
")",
"if",
"'error'"... | 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 | [
"Get",
"the",
"pipeline",
"id",
"if",
"it",
"exists",
"for",
"the",
"given",
"name",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L167-L187 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | put_pipeline_definition | 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... | 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... | [
"def",
"put_pipeline_definition",
"(",
"pipeline_id",
",",
"pipeline_objects",
",",
"parameter_objects",
"=",
"None",
",",
"parameter_values",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"... | 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 | [
"Add",
"tasks",
"schedules",
"and",
"preconditions",
"to",
"the",
"specified",
"pipeline",
".",
"This",
"function",
"is",
"idempotent",
"and",
"will",
"replace",
"an",
"existing",
"definition",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L190-L219 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | _get_client | 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') | 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') | [
"def",
"_get_client",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"session",
"=",
"_get_session",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
"if",
"not",
"session",
":",
"log",
".",
"error",
"(",
"\"Failed to g... | Get a boto connection to Data Pipeline. | [
"Get",
"a",
"boto",
"connection",
"to",
"Data",
"Pipeline",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L222-L231 | train |
saltstack/salt | salt/modules/boto_datapipeline.py | _get_session | 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... | 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... | [
"def",
"_get_session",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"if",
"profile",
":",
"if",
"isinstance",
"(",
"profile",
",",
"six",
".",
"string_types",
")",
":",
"_profile",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
... | Get a boto3 session | [
"Get",
"a",
"boto3",
"session"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_datapipeline.py#L234-L257 | train |
saltstack/salt | salt/modules/qemu_img.py | make_image | 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... | 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... | [
"def",
"make_image",
"(",
"location",
",",
"size",
",",
"fmt",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"location",
")",
":",
"return",
"''",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"dirname"... | 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 | [
"Create",
"a",
"blank",
"virtual",
"machine",
"image",
"file",
"of",
"the",
"specified",
"size",
"in",
"megabytes",
".",
"The",
"image",
"can",
"be",
"created",
"in",
"any",
"format",
"supported",
"by",
"qemu"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/qemu_img.py#L28-L51 | train |
saltstack/salt | salt/modules/qemu_img.py | convert | 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... | 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... | [
"def",
"convert",
"(",
"orig",
",",
"dest",
",",
"fmt",
")",
":",
"cmd",
"=",
"(",
"'qemu-img'",
",",
"'convert'",
",",
"'-O'",
",",
"fmt",
",",
"orig",
",",
"dest",
")",
"ret",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"python_s... | 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 | [
"Convert",
"an",
"existing",
"disk",
"image",
"to",
"another",
"format",
"using",
"qemu",
"-",
"img"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/qemu_img.py#L54-L69 | train |
saltstack/salt | salt/modules/win_network.py | ping | 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... | 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... | [
"def",
"ping",
"(",
"host",
",",
"timeout",
"=",
"False",
",",
"return_boolean",
"=",
"False",
")",
":",
"if",
"timeout",
":",
"# Windows ping differs by having timeout be for individual echo requests.'",
"# Divide timeout by tries to mimic BSD behaviour.",
"timeout",
"=",
... | 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... | [
"Performs",
"a",
"ping",
"to",
"a",
"host"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L69-L107 | train |
saltstack/salt | salt/modules/win_network.py | netstat | 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(... | 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(... | [
"def",
"netstat",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"[",
"'netstat'",
",",
"'-nao'",
"]",
"lines",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
".",
"splitlines",
"(",
")",
"for",
"line"... | Return information on open ports and states
CLI Example:
.. code-block:: bash
salt '*' network.netstat | [
"Return",
"information",
"on",
"open",
"ports",
"and",
"states"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L110-L139 | train |
saltstack/salt | salt/modules/win_network.py | traceroute | 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... | 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... | [
"def",
"traceroute",
"(",
"host",
")",
":",
"ret",
"=",
"[",
"]",
"cmd",
"=",
"[",
"'tracert'",
",",
"salt",
".",
"utils",
".",
"network",
".",
"sanitize_host",
"(",
"host",
")",
"]",
"lines",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
","... | Performs a traceroute to a 3rd party host
CLI Example:
.. code-block:: bash
salt '*' network.traceroute archlinux.org | [
"Performs",
"a",
"traceroute",
"to",
"a",
"3rd",
"party",
"host"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L142-L193 | train |
saltstack/salt | salt/modules/win_network.py | nslookup | 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, ... | 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, ... | [
"def",
"nslookup",
"(",
"host",
")",
":",
"ret",
"=",
"[",
"]",
"addresses",
"=",
"[",
"]",
"cmd",
"=",
"[",
"'nslookup'",
",",
"salt",
".",
"utils",
".",
"network",
".",
"sanitize_host",
"(",
"host",
")",
"]",
"lines",
"=",
"__salt__",
"[",
"'cmd.... | Query DNS for information about a domain or ip address
CLI Example:
.. code-block:: bash
salt '*' network.nslookup archlinux.org | [
"Query",
"DNS",
"for",
"information",
"about",
"a",
"domain",
"or",
"ip",
"address"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L196-L226 | train |
saltstack/salt | salt/modules/win_network.py | get_route | 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... | 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... | [
"def",
"get_route",
"(",
"ip",
")",
":",
"cmd",
"=",
"'Find-NetRoute -RemoteIPAddress {0}'",
".",
"format",
"(",
"ip",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"shell",
"=",
"'powershell'",
",",
"python_shell",
"=",
"True",
")",... | Return routing information for given destination ip
.. versionadded:: 2016.11.5
CLI Example::
salt '*' network.get_route 10.10.10.10 | [
"Return",
"routing",
"information",
"for",
"given",
"destination",
"ip"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L229-L255 | train |
saltstack/salt | salt/modules/win_network.py | dig | 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... | 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... | [
"def",
"dig",
"(",
"host",
")",
":",
"cmd",
"=",
"[",
"'dig'",
",",
"salt",
".",
"utils",
".",
"network",
".",
"sanitize_host",
"(",
"host",
")",
"]",
"return",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")"
] | 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 | [
"Performs",
"a",
"DNS",
"lookup",
"with",
"dig"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L258-L271 | train |
saltstack/salt | salt/modules/win_network.py | interfaces_names | 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... | 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... | [
"def",
"interfaces_names",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"with",
"salt",
".",
"utils",
".",
"winapi",
".",
"Com",
"(",
")",
":",
"c",
"=",
"wmi",
".",
"WMI",
"(",
")",
"for",
"iface",
"in",
"c",
".",
"Win32_NetworkAdapter",
"(",
"NetEnabled"... | Return a list of all the interfaces names
CLI Example:
.. code-block:: bash
salt '*' network.interfaces_names | [
"Return",
"a",
"list",
"of",
"all",
"the",
"interfaces",
"names"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L274-L290 | train |
saltstack/salt | salt/modules/win_network.py | ip_addrs | 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... | 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... | [
"def",
"ip_addrs",
"(",
"interface",
"=",
"None",
",",
"include_loopback",
"=",
"False",
",",
"cidr",
"=",
"None",
",",
"type",
"=",
"None",
")",
":",
"addrs",
"=",
"salt",
".",
"utils",
".",
"network",
".",
"ip_addrs",
"(",
"interface",
"=",
"interfac... | 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 ... | [
"Returns",
"a",
"list",
"of",
"IPv4",
"addresses",
"assigned",
"to",
"the",
"host",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L349-L389 | train |
saltstack/salt | salt/modules/win_network.py | ip_addrs6 | 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 ... | 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 ... | [
"def",
"ip_addrs6",
"(",
"interface",
"=",
"None",
",",
"include_loopback",
"=",
"False",
",",
"cidr",
"=",
"None",
")",
":",
"addrs",
"=",
"salt",
".",
"utils",
".",
"network",
".",
"ip_addrs6",
"(",
"interface",
"=",
"interface",
",",
"include_loopback",... | 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... | [
"Returns",
"a",
"list",
"of",
"IPv6",
"addresses",
"assigned",
"to",
"the",
"host",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L395-L423 | train |
saltstack/salt | salt/modules/win_network.py | connect | 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
... | 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
... | [
"def",
"connect",
"(",
"host",
",",
"port",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"not",
"host",
":",
"ret",
"[",
"'result'",
"]",
"=",
"False",
"ret",
... | 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=... | [
"Test",
"connectivity",
"to",
"a",
"host",
"using",
"a",
"particular",
"port",
"from",
"the",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L429-L518 | train |
saltstack/salt | salt/returners/pushover_returner.py | _post_message | 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... | 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... | [
"def",
"_post_message",
"(",
"user",
",",
"device",
",",
"message",
",",
"title",
",",
"priority",
",",
"expire",
",",
"retry",
",",
"sound",
",",
"api_version",
"=",
"1",
",",
"token",
"=",
"None",
")",
":",
"user_validate",
"=",
"salt",
".",
"utils",... | 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... | [
"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",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/pushover_returner.py#L151-L198 | train |
saltstack/salt | salt/returners/pushover_returner.py | returner | 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... | 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... | [
"def",
"returner",
"(",
"ret",
")",
":",
"_options",
"=",
"_get_options",
"(",
"ret",
")",
"user",
"=",
"_options",
".",
"get",
"(",
"'user'",
")",
"device",
"=",
"_options",
".",
"get",
"(",
"'device'",
")",
"token",
"=",
"_options",
".",
"get",
"("... | Send an PushOver message with the data | [
"Send",
"an",
"PushOver",
"message",
"with",
"the",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/pushover_returner.py#L201-L251 | train |
saltstack/salt | salt/loader.py | _format_entrypoint_target | 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 | 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 | [
"def",
"_format_entrypoint_target",
"(",
"ep",
")",
":",
"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__(). | [
"Makes",
"a",
"string",
"describing",
"the",
"target",
"of",
"an",
"EntryPoint",
"object",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L147-L156 | train |
saltstack/salt | salt/loader.py | minion_mods | 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... | 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... | [
"def",
"minion_mods",
"(",
"opts",
",",
"context",
"=",
"None",
",",
"utils",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"initial_load",
"=",
"False",
",",
"loaded_base_name",
"=",
"None",
",",
"notify",
"=",
"False",
",",
"static_modules",
"=",
"N... | 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
... | [
"Load",
"execution",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L205-L287 | train |
saltstack/salt | salt/loader.py | raw_mod | 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_... | 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_... | [
"def",
"raw_mod",
"(",
"opts",
",",
"name",
",",
"functions",
",",
"mod",
"=",
"'modules'",
")",
":",
"loader",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"mod",
",",
"'module'",
")",
",",
"opts",
",",
"tag",
"=",
"'rawmodule'",
",",
"... | 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']() | [
"Returns",
"a",
"single",
"module",
"loaded",
"raw",
"and",
"bypassing",
"the",
"__virtual__",
"function"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L290-L315 | train |
saltstack/salt | salt/loader.py | engines | 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... | 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... | [
"def",
"engines",
"(",
"opts",
",",
"functions",
",",
"runners",
",",
"utils",
",",
"proxy",
"=",
"None",
")",
":",
"pack",
"=",
"{",
"'__salt__'",
":",
"functions",
",",
"'__runners__'",
":",
"runners",
",",
"'__proxy__'",
":",
"proxy",
",",
"'__utils__... | Return the master services plugins | [
"Return",
"the",
"master",
"services",
"plugins"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L341-L354 | train |
saltstack/salt | salt/loader.py | proxy | 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... | 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... | [
"def",
"proxy",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"returners",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"utils",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'proxy'",
")",
",",
"opts... | Returns the proxy module for this salt-proxy-minion | [
"Returns",
"the",
"proxy",
"module",
"for",
"this",
"salt",
"-",
"proxy",
"-",
"minion"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L357-L370 | train |
saltstack/salt | salt/loader.py | returners | 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... | 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... | [
"def",
"returners",
"(",
"opts",
",",
"functions",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'returners'",
",",
"'returner'",
")",
",",... | Returns the returner modules | [
"Returns",
"the",
"returner",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L373-L383 | train |
saltstack/salt | salt/loader.py | utils | 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 ... | 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 ... | [
"def",
"utils",
"(",
"opts",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"proxy",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'utils'",
",",
"ext_type_dirs",
"=",
"'utils_dirs'",
")",
",",
... | Returns the utility modules | [
"Returns",
"the",
"utility",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L386-L396 | train |
saltstack/salt | salt/loader.py | pillars | def pillars(opts, functions, context=None):
'''
Returns the pillars modules
'''
ret = LazyLoader(_module_dirs(opts, 'pillar'),
opts,
tag='pillar',
pack={'__salt__': functions,
'__context__': context,
... | 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,
... | [
"def",
"pillars",
"(",
"opts",
",",
"functions",
",",
"context",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'pillar'",
")",
",",
"opts",
",",
"tag",
"=",
"'pillar'",
",",
"pack",
"=",
"{",
"'__salt__'",
"... | Returns the pillars modules | [
"Returns",
"the",
"pillars",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L399-L410 | train |
saltstack/salt | salt/loader.py | tops | 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... | 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... | [
"def",
"tops",
"(",
"opts",
")",
":",
"if",
"'master_tops'",
"not",
"in",
"opts",
":",
"return",
"{",
"}",
"whitelist",
"=",
"list",
"(",
"opts",
"[",
"'master_tops'",
"]",
".",
"keys",
"(",
")",
")",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(... | Returns the tops modules | [
"Returns",
"the",
"tops",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L413-L426 | train |
saltstack/salt | salt/loader.py | wheels | 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},
) | 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},
) | [
"def",
"wheels",
"(",
"opts",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'wheel'",
")",
",",
"opt... | Returns the wheels modules | [
"Returns",
"the",
"wheels",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L429-L441 | train |
saltstack/salt | salt/loader.py | outputters | 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... | 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... | [
"def",
"outputters",
"(",
"opts",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'output'",
",",
"ext_type_dirs",
"=",
"'outputter_dirs'",
")",
",",
"opts",
",",
"tag",
"=",
"'output'",
",",
")",
"wrapped_ret",
"=",
"FilterDict... | Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace | [
"Returns",
"the",
"outputters",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L444-L459 | train |
saltstack/salt | salt/loader.py | auth | 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)},... | 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)},... | [
"def",
"auth",
"(",
"opts",
",",
"whitelist",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'auth'",
")",
",",
"opts",
",",
"tag",
"=",
"'auth'",
",",
"whitelist",
"=",
"whitelist",
",",
"pack",
"=",
"{",
"'__... | Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader | [
"Returns",
"the",
"auth",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L488-L501 | train |
saltstack/salt | salt/loader.py | fileserver | def fileserver(opts, backends):
'''
Returns the file server modules
'''
return LazyLoader(_module_dirs(opts, 'fileserver'),
opts,
tag='fileserver',
whitelist=backends,
pack={'__utils__': utils(opts)}) | 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)}) | [
"def",
"fileserver",
"(",
"opts",
",",
"backends",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'fileserver'",
")",
",",
"opts",
",",
"tag",
"=",
"'fileserver'",
",",
"whitelist",
"=",
"backends",
",",
"pack",
"=",
"{",
"'__u... | Returns the file server modules | [
"Returns",
"the",
"file",
"server",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L504-L512 | train |
saltstack/salt | salt/loader.py | roster | 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,
... | 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,
... | [
"def",
"roster",
"(",
"opts",
",",
"runner",
"=",
"None",
",",
"utils",
"=",
"None",
",",
"whitelist",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'roster'",
")",
",",
"opts",
",",
"tag",
"=",
"'roster'",
",... | Returns the roster modules | [
"Returns",
"the",
"roster",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L515-L528 | train |
saltstack/salt | salt/loader.py | thorium | 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... | 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... | [
"def",
"thorium",
"(",
"opts",
",",
"functions",
",",
"runners",
")",
":",
"pack",
"=",
"{",
"'__salt__'",
":",
"functions",
",",
"'__runner__'",
":",
"runners",
",",
"'__context__'",
":",
"{",
"}",
"}",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"("... | Load the thorium runtime modules | [
"Load",
"the",
"thorium",
"runtime",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L531-L541 | train |
saltstack/salt | salt/loader.py | states | 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.
.... | 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.
.... | [
"def",
"states",
"(",
"opts",
",",
"functions",
",",
"utils",
",",
"serializers",
",",
"whitelist",
"=",
"None",
",",
"proxy",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"ret",
... | 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... | [
"Returns",
"the",
"state",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L544-L574 | train |
saltstack/salt | salt/loader.py | beacons | 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... | 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... | [
"def",
"beacons",
"(",
"opts",
",",
"functions",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'beacons'",
")",
",",
"opts",
",",
"tag",
"=",
"'beacons'",
",",
"pack",
... | 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. | [
"Load",
"the",
"beacon",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L577-L591 | train |
saltstack/salt | salt/loader.py | log_handlers | 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'),
... | 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'),
... | [
"def",
"log_handlers",
"(",
"opts",
")",
":",
"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 | [
"Returns",
"the",
"custom",
"logging",
"handler",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L594-L610 | train |
saltstack/salt | salt/loader.py | ssh_wrapper | 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... | 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... | [
"def",
"ssh_wrapper",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'wrapper'",
",",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SALT_BASE_PA... | Returns the custom logging handler modules | [
"Returns",
"the",
"custom",
"logging",
"handler",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L613-L631 | train |
saltstack/salt | salt/loader.py | render | 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... | 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... | [
"def",
"render",
"(",
"opts",
",",
"functions",
",",
"states",
"=",
"None",
",",
"proxy",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"pack",
"=",
"{",
"'__salt__'",
":",
"functi... | Returns the render modules | [
"Returns",
"the",
"render",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L634-L666 | train |
saltstack/salt | salt/loader.py | grain_funcs | 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(
... | 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(
... | [
"def",
"grain_funcs",
"(",
"opts",
",",
"proxy",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'grains'",
",",
"'grain'",
",",
"ext_type_dirs",
"=",
"'grains_dirs'",
",",
")",
",",
"opts",
",",
"tag",
"=",
"'g... | 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__) | [
"Returns",
"the",
"grain",
"functions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L669-L692 | train |
saltstack/salt | salt/loader.py | _load_cached_grains | 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... | 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... | [
"def",
"_load_cached_grains",
"(",
"opts",
",",
"cfn",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"cfn",
")",
":",
"log",
".",
"debug",
"(",
"'Grains cache file does not exist.'",
")",
"return",
"None",
"grains_cache_age",
"=",
"int",
"(... | Returns the grains cached in cfn, or None if the cache is too old or is
corrupted. | [
"Returns",
"the",
"grains",
"cached",
"in",
"cfn",
"or",
"None",
"if",
"the",
"cache",
"is",
"too",
"old",
"or",
"is",
"corrupted",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L695-L729 | train |
saltstack/salt | salt/loader.py | grains | 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 ... | 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 ... | [
"def",
"grains",
"(",
"opts",
",",
"force_refresh",
"=",
"False",
",",
"proxy",
"=",
"None",
")",
":",
"# Need to re-import salt.config, somehow it got lost when a minion is starting",
"import",
"salt",
".",
"config",
"# if we have no grains, lets try loading from disk (TODO: m... | 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
... | [
"Return",
"the",
"functions",
"for",
"the",
"dynamic",
"grains",
"and",
"the",
"values",
"for",
"the",
"static",
"grains",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L732-L909 | train |
saltstack/salt | salt/loader.py | call | 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,
)
... | 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,
)
... | [
"def",
"call",
"(",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"kwargs",
".",
"get",
"(",
"'args'",
",",
"[",
"]",
")",
"dirs",
"=",
"kwargs",
".",
"get",
"(",
"'dirs'",
",",
"[",
"]",
")",
"funcs",
"=",
"LazyLoader",
"(",
"[",
"o... | Directly call a function inside a loader directory | [
"Directly",
"call",
"a",
"function",
"inside",
"a",
"loader",
"directory"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L913-L926 | train |
saltstack/salt | salt/loader.py | runner | 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'),
... | 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'),
... | [
"def",
"runner",
"(",
"opts",
",",
"utils",
"=",
"None",
",",
"context",
"=",
"None",
",",
"whitelist",
"=",
"None",
")",
":",
"if",
"utils",
"is",
"None",
":",
"utils",
"=",
"{",
"}",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",... | Directly call a function inside a loader directory | [
"Directly",
"call",
"a",
"function",
"inside",
"a",
"loader",
"directory"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L929-L946 | train |
saltstack/salt | salt/loader.py | sdb | 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... | 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... | [
"def",
"sdb",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"utils",
"=",
"None",
")",
":",
"if",
"utils",
"is",
"None",
":",
"utils",
"=",
"{",
"}",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"... | Make a very small database call | [
"Make",
"a",
"very",
"small",
"database",
"call"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L960-L978 | train |
saltstack/salt | salt/loader.py | pkgdb | 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'
) | 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'
) | [
"def",
"pkgdb",
"(",
"opts",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'pkgdb'",
",",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SALT_BASE_PATH",
",",
"'spm'",
")",
")",
",",
"opts",
",",
"tag",
"=",
"'pkg... | Return modules for SPM's package database
.. versionadded:: 2015.8.0 | [
"Return",
"modules",
"for",
"SPM",
"s",
"package",
"database"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L981-L995 | train |
saltstack/salt | salt/loader.py | clouds | 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,
... | 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,
... | [
"def",
"clouds",
"(",
"opts",
")",
":",
"# 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 | [
"Return",
"the",
"cloud",
"functions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1015-L1039 | train |
saltstack/salt | salt/loader.py | executors | 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 ... | 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 ... | [
"def",
"executors",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"executors",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'executors'",
",",
"'executor'",
")",
",",
"opts",
... | Returns the executor modules | [
"Returns",
"the",
"executor",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1053-L1064 | train |
saltstack/salt | salt/loader.py | cache | def cache(opts, serial):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'cache', 'cache'),
opts,
tag='cache',
pack={'__opts__': opts, '__context__': {'serial': serial}},
) | 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}},
) | [
"def",
"cache",
"(",
"opts",
",",
"serial",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'cache'",
",",
"'cache'",
")",
",",
"opts",
",",
"tag",
"=",
"'cache'",
",",
"pack",
"=",
"{",
"'__opts__'",
":",
"opts",
",",
"'__c... | Returns the returner modules | [
"Returns",
"the",
"returner",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1067-L1076 | train |
saltstack/salt | salt/loader.py | _inject_into_mod | 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... | 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... | [
"def",
"_inject_into_mod",
"(",
"mod",
",",
"name",
",",
"value",
",",
"force_lock",
"=",
"False",
")",
":",
"old_value",
"=",
"getattr",
"(",
"mod",
",",
"name",
",",
"None",
")",
"# We use a double-checked locking scheme in order to avoid taking the lock",
"# when... | 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... | [
"Inject",
"a",
"variable",
"into",
"a",
"module",
".",
"This",
"is",
"used",
"to",
"inject",
"globals",
"like",
"__salt__",
"__pillar",
"or",
"grains",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1096-L1155 | train |
saltstack/salt | salt/loader.py | global_injector_decorator | 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):
... | 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):
... | [
"def",
"global_injector_decorator",
"(",
"inject_globals",
")",
":",
"def",
"inner_decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"salt",
"."... | Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject | [
"Decorator",
"used",
"by",
"the",
"LazyLoader",
"to",
"inject",
"globals",
"into",
"a",
"function",
"at",
"execute",
"time",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L2044-L2058 | train |
saltstack/salt | salt/loader.py | LazyLoader.missing_fun_string | 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}\'... | 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}\'... | [
"def",
"missing_fun_string",
"(",
"self",
",",
"function_name",
")",
":",
"mod_name",
"=",
"function_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"if",
"mod_name",
"in",
"self",
".",
"loaded_modules",
":",
"return",
"'\\'{0}\\' is not available.'",
"."... | Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False | [
"Return",
"the",
"error",
"string",
"for",
"a",
"missing",
"function",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1348-L1366 | train |
saltstack/salt | salt/loader.py | LazyLoader._refresh_file_mapping | 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: ... | 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: ... | [
"def",
"_refresh_file_mapping",
"(",
"self",
")",
":",
"# map of suffix to description for imp",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'cython_enable'",
",",
"True",
")",
"is",
"True",
":",
"try",
":",
"global",
"pyximport",
"pyximport",
"=",
"__import__"... | refresh the mapping of the FS on disk | [
"refresh",
"the",
"mapping",
"of",
"the",
"FS",
"on",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1368-L1520 | train |
saltstack/salt | salt/loader.py | LazyLoader.clear | 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... | 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... | [
"def",
"clear",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"super",
"(",
"LazyLoader",
",",
"self",
")",
".",
"clear",
"(",
")",
"# clear the lazy loader",
"self",
".",
"loaded_files",
"=",
"set",
"(",
")",
"self",
".",
"missing_modules",
... | Clear the dict | [
"Clear",
"the",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1522-L1535 | train |
saltstack/salt | salt/loader.py | LazyLoader.__prep_mod_opts | 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... | 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... | [
"def",
"__prep_mod_opts",
"(",
"self",
",",
"opts",
")",
":",
"if",
"'__grains__'",
"not",
"in",
"self",
".",
"pack",
":",
"grains",
"=",
"opts",
".",
"get",
"(",
"'grains'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"grains",
",",
"ThreadLocalProxy... | Strip out of the opts any logger instance | [
"Strip",
"out",
"of",
"the",
"opts",
"any",
"logger",
"instance"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1537-L1564 | train |
saltstack/salt | salt/loader.py | LazyLoader._iter_files | 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:
... | 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:
... | [
"def",
"_iter_files",
"(",
"self",
",",
"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",
":",
"if",
... | Iterate over all file_mapping files in order of closeness to mod_name | [
"Iterate",
"over",
"all",
"file_mapping",
"files",
"in",
"order",
"of",
"closeness",
"to",
"mod_name"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1566-L1582 | train |
saltstack/salt | salt/loader.py | LazyLoader._load | 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... | 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... | [
"def",
"_load",
"(",
"self",
",",
"key",
")",
":",
"# 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.'",
")",
... | Load a single item if you have it | [
"Load",
"a",
"single",
"item",
"if",
"you",
"have",
"it"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1851-L1902 | train |
saltstack/salt | salt/loader.py | LazyLoader._load_all | 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 | 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 | [
"def",
"_load_all",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"for",
"name",
"in",
"self",
".",
"file_mapping",
":",
"if",
"name",
"in",
"self",
".",
"loaded_files",
"or",
"name",
"in",
"self",
".",
"missing_modules",
":",
"continue",
"... | Load all of them | [
"Load",
"all",
"of",
"them"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1904-L1914 | train |
saltstack/salt | salt/loader.py | LazyLoader._apply_outputter | 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__] | 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__] | [
"def",
"_apply_outputter",
"(",
"self",
",",
"func",
",",
"mod",
")",
":",
"if",
"hasattr",
"(",
"mod",
",",
"'__outputter__'",
")",
":",
"outp",
"=",
"mod",
".",
"__outputter__",
"if",
"func",
".",
"__name__",
"in",
"outp",
":",
"func",
".",
"__output... | Apply the __outputter__ variable to the functions | [
"Apply",
"the",
"__outputter__",
"variable",
"to",
"the",
"functions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1921-L1928 | train |
saltstack/salt | salt/loader.py | LazyLoader._process_virtual | 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... | 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... | [
"def",
"_process_virtual",
"(",
"self",
",",
"mod",
",",
"module_name",
",",
"virtual_func",
"=",
"'__virtual__'",
")",
":",
"# The __virtual__ function will return either a True or False value.",
"# If it returns a True value it can also set a module level attribute",
"# named __vir... | 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... | [
"Given",
"a",
"loaded",
"module",
"and",
"its",
"default",
"name",
"determine",
"its",
"virtual",
"name"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1930-L2041 | train |
saltstack/salt | salt/modules/smbios.py | get | 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``
... | 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``
... | [
"def",
"get",
"(",
"string",
",",
"clean",
"=",
"True",
")",
":",
"val",
"=",
"_dmidecoder",
"(",
"'-s {0}'",
".",
"format",
"(",
"string",
")",
")",
".",
"strip",
"(",
")",
"# Cleanup possible comments in strings.",
"val",
"=",
"'\\n'",
".",
"join",
"("... | 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... | [
"Get",
"an",
"individual",
"DMI",
"string",
"from",
"SMBIOS",
"info"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L41-L89 | train |
saltstack/salt | salt/modules/smbios.py | records | 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
==== ===============... | 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
==== ===============... | [
"def",
"records",
"(",
"rec_type",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"clean",
"=",
"True",
")",
":",
"if",
"rec_type",
"is",
"None",
":",
"smbios",
"=",
"_dmi_parse",
"(",
"_dmidecoder",
"(",
")",
",",
"clean",
",",
"fields",
")",
"else",... | 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
... | [
"Return",
"DMI",
"records",
"from",
"SMBIOS"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L92-L167 | train |
saltstack/salt | salt/modules/smbios.py | _dmi_parse | 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... | 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... | [
"def",
"_dmi_parse",
"(",
"data",
",",
"clean",
"=",
"True",
",",
"fields",
"=",
"None",
")",
":",
"dmi",
"=",
"[",
"]",
"# Detect & split Handle records",
"dmi_split",
"=",
"re",
".",
"compile",
"(",
"'(handle [0-9]x[0-9a-f]+[^\\n]+)\\n'",
",",
"re",
".",
"... | Structurize DMI records into a nice list
Optionally trash bogus entries and filter output | [
"Structurize",
"DMI",
"records",
"into",
"a",
"nice",
"list",
"Optionally",
"trash",
"bogus",
"entries",
"and",
"filter",
"output"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L170-L207 | train |
saltstack/salt | salt/modules/smbios.py | _dmi_data | 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:... | 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:... | [
"def",
"_dmi_data",
"(",
"dmi_raw",
",",
"clean",
",",
"fields",
")",
":",
"dmi_data",
"=",
"{",
"}",
"key",
"=",
"None",
"key_data",
"=",
"[",
"None",
",",
"[",
"]",
"]",
"for",
"line",
"in",
"dmi_raw",
":",
"if",
"re",
".",
"match",
"(",
"r'\\t... | Parse the raw DMIdecode output of a single handle
into a nice dict | [
"Parse",
"the",
"raw",
"DMIdecode",
"output",
"of",
"a",
"single",
"handle",
"into",
"a",
"nice",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L210-L259 | train |
saltstack/salt | salt/modules/smbios.py | _dmi_cast | 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.... | 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.... | [
"def",
"_dmi_cast",
"(",
"key",
",",
"val",
",",
"clean",
"=",
"True",
")",
":",
"if",
"clean",
"and",
"not",
"_dmi_isclean",
"(",
"key",
",",
"val",
")",
":",
"return",
"elif",
"not",
"re",
".",
"match",
"(",
"r'serial|part|asset|product'",
",",
"key"... | Simple caster thingy for trying to fish out at least ints & lists from strings | [
"Simple",
"caster",
"thingy",
"for",
"trying",
"to",
"fish",
"out",
"at",
"least",
"ints",
"&",
"lists",
"from",
"strings"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L262-L277 | train |
saltstack/salt | salt/modules/smbios.py | _dmidecoder | 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 | 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 | [
"def",
"_dmidecoder",
"(",
"args",
"=",
"None",
")",
":",
"dmidecoder",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which_bin",
"(",
"[",
"'dmidecode'",
",",
"'smbios'",
"]",
")",
"if",
"not",
"args",
":",
"out",
"=",
"salt",
".",
"modules",
".",
... | Call DMIdecode | [
"Call",
"DMIdecode"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L316-L327 | train |
saltstack/salt | salt/utils/yamlloader.py | SaltYamlSafeLoader.construct_mapping | 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),
... | 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),
... | [
"def",
"construct_mapping",
"(",
"self",
",",
"node",
",",
"deep",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"MappingNode",
")",
":",
"raise",
"ConstructorError",
"(",
"None",
",",
"None",
",",
"'expected a mapping node, but found {0... | Build the mapping for YAML | [
"Build",
"the",
"mapping",
"for",
"YAML"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L72-L105 | train |
saltstack/salt | salt/utils/yamlloader.py | SaltYamlSafeLoader.construct_scalar | 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... | 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... | [
"def",
"construct_scalar",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"tag",
"==",
"'tag:yaml.org,2002:int'",
":",
"if",
"node",
".",
"value",
"==",
"'0'",
":",
"pass",
"elif",
"node",
".",
"value",
".",
"startswith",
"(",
"'0'",
")",
"and"... | Verify integers and pass them in correctly is they are declared
as octal | [
"Verify",
"integers",
"and",
"pass",
"them",
"in",
"correctly",
"is",
"they",
"are",
"declared",
"as",
"octal"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L107-L121 | train |
saltstack/salt | salt/ext/ipaddress.py | ip_address | def ip_address(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... | python | def ip_address(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... | [
"def",
"ip_address",
"(",
"address",
")",
":",
"try",
":",
"return",
"IPv4Address",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Address",
"(",
"address",
")",
"except",
"(",
... | 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... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L93-L120 | train |
saltstack/salt | salt/ext/ipaddress.py | ip_network | def ip_network(address, strict=True):
"""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... | python | def ip_network(address, strict=True):
"""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... | [
"def",
"ip_network",
"(",
"address",
",",
"strict",
"=",
"True",
")",
":",
"try",
":",
"return",
"IPv4Network",
"(",
"address",
",",
"strict",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6N... | 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... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L123-L150 | train |
saltstack/salt | salt/ext/ipaddress.py | _split_optional_netmask | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | python | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | [
"def",
"_split_optional_netmask",
"(",
"address",
")",
":",
"addr",
"=",
"str",
"(",
"address",
")",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"addr",
")",
">",
"2",
":",
"raise",
"AddressValueError",
"(",
"\"Only one '/' permitted in %r\"",
"%",
"a... | Helper to split the netmask and raise AddressValueError if needed | [
"Helper",
"to",
"split",
"the",
"netmask",
"and",
"raise",
"AddressValueError",
"if",
"needed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L224-L229 | train |
saltstack/salt | salt/ext/ipaddress.py | _count_righthand_zero_bits | def _count_righthand_zero_bits(number, 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.
"""
if number == 0:
return... | python | def _count_righthand_zero_bits(number, 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.
"""
if number == 0:
return... | [
"def",
"_count_righthand_zero_bits",
"(",
"number",
",",
"bits",
")",
":",
"if",
"number",
"==",
"0",
":",
"return",
"bits",
"for",
"i",
"in",
"range",
"(",
"bits",
")",
":",
"if",
"(",
"number",
">>",
"i",
")",
"&",
"1",
":",
"return",
"i",
"# All... | 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. | [
"Count",
"the",
"number",
"of",
"zero",
"bits",
"on",
"the",
"right",
"hand",
"side",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L251-L268 | train |
saltstack/salt | salt/ext/ipaddress.py | _collapse_addresses_recursive | def _collapse_addresses_recursive(addresses):
"""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')
_collaps... | python | def _collapse_addresses_recursive(addresses):
"""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')
_collaps... | [
"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",
... | 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]) ->
... | [
"Loops",
"through",
"the",
"addresses",
"collapsing",
"concurrent",
"netblocks",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L327-L372 | train |
saltstack/salt | salt/ext/ipaddress.py | collapse_addresses | def collapse_addresses(addresses):
"""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... | python | def collapse_addresses(addresses):
"""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... | [
"def",
"collapse_addresses",
"(",
"addresses",
")",
":",
"i",
"=",
"0",
"addrs",
"=",
"[",
"]",
"ips",
"=",
"[",
"]",
"nets",
"=",
"[",
"]",
"# split IP addresses and networks",
"for",
"ip",
"in",
"addresses",
":",
"if",
"isinstance",
"(",
"ip",
",",
"... | 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:
... | [
"Collapse",
"a",
"list",
"of",
"IP",
"objects",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L375-L429 | train |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_ip_int | def _prefix_from_ip_int(self, ip_int):
"""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 & ... | python | def _prefix_from_ip_int(self, ip_int):
"""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 & ... | [
"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",... | 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 | [
"Return",
"prefix",
"length",
"from",
"the",
"bitwise",
"netmask",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L548-L570 | train |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_prefix_string | def _prefix_from_prefix_string(self, prefixlen_str):
"""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... | python | def _prefix_from_prefix_string(self, prefixlen_str):
"""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... | [
"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",
")",... | 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 | [
"Return",
"prefix",
"length",
"from",
"a",
"numeric",
"string"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L576-L598 | train |
saltstack/salt | salt/ext/ipaddress.py | _IPAddressBase._prefix_from_ip_string | def _prefix_from_ip_string(self, ip_str):
"""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 netmas... | python | def _prefix_from_ip_string(self, ip_str):
"""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 netmas... | [
"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_inva... | 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 | [
"Turn",
"a",
"netmask",
"/",
"hostmask",
"string",
"into",
"a",
"prefix",
"length"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L600-L631 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseNetwork.subnets | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""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:
pre... | python | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""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:
pre... | [
"def",
"subnets",
"(",
"self",
",",
"prefixlen_diff",
"=",
"1",
",",
"new_prefix",
"=",
"None",
")",
":",
"if",
"self",
".",
"_prefixlen",
"==",
"self",
".",
"_max_prefixlen",
":",
"yield",
"self",
"return",
"if",
"new_prefix",
"is",
"not",
"None",
":",
... | 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
... | [
"The",
"subnets",
"which",
"join",
"to",
"make",
"the",
"current",
"subnet",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L967-L1027 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseNetwork.supernet | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""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 ... | python | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""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 ... | [
"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",... | 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.
... | [
"The",
"supernet",
"containing",
"the",
"current",
"network",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1029-L1068 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._ip_int_from_string | def _ip_int_from_string(self, ip_str):
"""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.
... | python | def _ip_int_from_string(self, ip_str):
"""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.
... | [
"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",
")",
"!... | 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. | [
"Turn",
"the",
"given",
"IP",
"string",
"into",
"an",
"integer",
"for",
"comparison",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1176-L1199 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._parse_octet | def _parse_octet(self, octet_str):
"""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].
"""
... | python | def _parse_octet(self, octet_str):
"""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].
"""
... | [
"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_D... | 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]. | [
"Convert",
"a",
"decimal",
"octet",
"into",
"an",
"integer",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1201-L1235 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseV4._is_valid_netmask | def _is_valid_netmask(self, netmask):
"""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.
"""
mask = n... | python | def _is_valid_netmask(self, netmask):
"""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.
"""
mask = n... | [
"def",
"_is_valid_netmask",
"(",
"self",
",",
"netmask",
")",
":",
"mask",
"=",
"netmask",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"mask",
")",
"==",
"4",
":",
"try",
":",
"for",
"x",
"in",
"mask",
":",
"if",
"int",
"(",
"x",
")",
"not... | 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. | [
"Verify",
"that",
"the",
"netmask",
"is",
"valid",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1249-L1278 | train |
saltstack/salt | salt/ext/ipaddress.py | IPv4Address.is_private | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8')... | python | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8')... | [
"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",
... | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry. | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"private",
"networks",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1377-L1398 | train |
saltstack/salt | salt/ext/ipaddress.py | _BaseV6._explode_shorthand_ip_string | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = str(self.network_address)
... | python | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = str(self.network_address)
... | [
"def",
"_explode_shorthand_ip_string",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"IPv6Network",
")",
":",
"ip_str",
"=",
"str",
"(",
"self",
".",
"network_address",
")",
"elif",
"isinstance",
"(",
"self",
",",
"IPv6Interface",
")",
":",
... | Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address. | [
"Expand",
"a",
"shortened",
"IPv6",
"address",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1847-L1869 | train |
saltstack/salt | salt/ext/ipaddress.py | IPv6Address.is_reserved | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
"""
reserved_networks = [IPv6Network('::/8'), IPv6Network('100::/8'),
... | python | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
"""
reserved_networks = [IPv6Network('::/8'), IPv6Network('100::/8'),
... | [
"def",
"is_reserved",
"(",
"self",
")",
":",
"reserved_networks",
"=",
"[",
"IPv6Network",
"(",
"'::/8'",
")",
",",
"IPv6Network",
"(",
"'100::/8'",
")",
",",
"IPv6Network",
"(",
"'200::/7'",
")",
",",
"IPv6Network",
"(",
"'400::/6'",
")",
",",
"IPv6Network"... | Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges. | [
"Test",
"if",
"the",
"address",
"is",
"otherwise",
"IETF",
"reserved",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1948-L1965 | train |
saltstack/salt | salt/ext/ipaddress.py | IPv6Address.is_private | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
"""
return (self in IPv6Network('::1/128') or
self in IPv6Network('::/128') or
... | python | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
"""
return (self in IPv6Network('::1/128') or
self in IPv6Network('::/128') or
... | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"(",
"self",
"in",
"IPv6Network",
"(",
"'::1/128'",
")",
"or",
"self",
"in",
"IPv6Network",
"(",
"'::/128'",
")",
"or",
"self",
"in",
"IPv6Network",
"(",
"'::ffff:0:0/96'",
")",
"or",
"self",
"in",
"I... | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry. | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"private",
"networks",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1994-L2011 | train |
saltstack/salt | salt/ext/ipaddress.py | IPv6Network.hosts | def hosts(self):
"""Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
"""
network = int(self.network_address)
broadcast = int(self.broadcast_address)
for x in long_range(1, bro... | python | def hosts(self):
"""Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
"""
network = int(self.network_address)
broadcast = int(self.broadcast_address)
for x in long_range(1, bro... | [
"def",
"hosts",
"(",
"self",
")",
":",
"network",
"=",
"int",
"(",
"self",
".",
"network_address",
")",
"broadcast",
"=",
"int",
"(",
"self",
".",
"broadcast_address",
")",
"for",
"x",
"in",
"long_range",
"(",
"1",
",",
"broadcast",
"-",
"network",
"+"... | Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address. | [
"Generate",
"Iterator",
"over",
"usable",
"hosts",
"in",
"a",
"network",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L2250-L2260 | train |
saltstack/salt | salt/beacons/network_info.py | _to_list | def _to_list(obj):
'''
Convert snetinfo object to list
'''
ret = {}
for attr in __attrs:
if hasattr(obj, attr):
ret[attr] = getattr(obj, attr)
return ret | python | def _to_list(obj):
'''
Convert snetinfo object to list
'''
ret = {}
for attr in __attrs:
if hasattr(obj, attr):
ret[attr] = getattr(obj, attr)
return ret | [
"def",
"_to_list",
"(",
"obj",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"attr",
"in",
"__attrs",
":",
"if",
"hasattr",
"(",
"obj",
",",
"attr",
")",
":",
"ret",
"[",
"attr",
"]",
"=",
"getattr",
"(",
"obj",
",",
"attr",
")",
"return",
"ret"
] | Convert snetinfo object to list | [
"Convert",
"snetinfo",
"object",
"to",
"list"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L33-L42 | train |
saltstack/salt | salt/beacons/network_info.py | validate | def validate(config):
'''
Validate the beacon configuration
'''
VALID_ITEMS = [
'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
'packets_recv', 'errin', 'errout', 'dropin',
'dropout'
]
# Configuration for load beacon should be a list of dicts
if not isinstance(c... | python | def validate(config):
'''
Validate the beacon configuration
'''
VALID_ITEMS = [
'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
'packets_recv', 'errin', 'errout', 'dropin',
'dropout'
]
# Configuration for load beacon should be a list of dicts
if not isinstance(c... | [
"def",
"validate",
"(",
"config",
")",
":",
"VALID_ITEMS",
"=",
"[",
"'type'",
",",
"'bytes_sent'",
",",
"'bytes_recv'",
",",
"'packets_sent'",
",",
"'packets_recv'",
",",
"'errin'",
",",
"'errout'",
",",
"'dropin'",
",",
"'dropout'",
"]",
"# Configuration for l... | Validate the beacon configuration | [
"Validate",
"the",
"beacon",
"configuration"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L51-L78 | train |
saltstack/salt | salt/beacons/network_info.py | beacon | def beacon(config):
'''
Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
... | python | def beacon(config):
'''
Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
... | [
"def",
"beacon",
"(",
"config",
")",
":",
"ret",
"=",
"[",
"]",
"_config",
"=",
"{",
"}",
"list",
"(",
"map",
"(",
"_config",
".",
"update",
",",
"config",
")",
")",
"log",
".",
"debug",
"(",
"'psutil.net_io_counters %s'",
",",
"psutil",
".",
"net_io... | Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
- interfaces:
... | [
"Emit",
"the",
"network",
"statistics",
"of",
"this",
"host",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L81-L166 | train |
saltstack/salt | salt/modules/apcups.py | status | def status():
'''
Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status
'''
ret = {}
apcaccess = _check_apcaccess()
res = __salt__['cmd.run_all'](apcaccess)
retcode = res['retcode']
if retcode != 0:
ret['Error'] = 'Something with wron... | python | def status():
'''
Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status
'''
ret = {}
apcaccess = _check_apcaccess()
res = __salt__['cmd.run_all'](apcaccess)
retcode = res['retcode']
if retcode != 0:
ret['Error'] = 'Something with wron... | [
"def",
"status",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"apcaccess",
"=",
"_check_apcaccess",
"(",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"apcaccess",
")",
"retcode",
"=",
"res",
"[",
"'retcode'",
"]",
"if",
"retcode",
"!=",
"0",
... | Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status | [
"Return",
"apcaccess",
"output"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L42-L64 | train |
saltstack/salt | salt/modules/apcups.py | status_load | def status_load():
'''
Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load
'''
data = status()
if 'LOADPCT' in data:
load = data['LOADPCT'].split()
if load[1].lower() == 'percent':
return float(load[0])
return {'Error': 'Load ... | python | def status_load():
'''
Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load
'''
data = status()
if 'LOADPCT' in data:
load = data['LOADPCT'].split()
if load[1].lower() == 'percent':
return float(load[0])
return {'Error': 'Load ... | [
"def",
"status_load",
"(",
")",
":",
"data",
"=",
"status",
"(",
")",
"if",
"'LOADPCT'",
"in",
"data",
":",
"load",
"=",
"data",
"[",
"'LOADPCT'",
"]",
".",
"split",
"(",
")",
"if",
"load",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"==",
"'percent'"... | Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load | [
"Return",
"load"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L67-L83 | train |
saltstack/salt | salt/modules/apcups.py | status_charge | def status_charge():
'''
Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge
'''
data = status()
if 'BCHARGE' in data:
charge = data['BCHARGE'].split()
if charge[1].lower() == 'percent':
return float(charge[0])
ret... | python | def status_charge():
'''
Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge
'''
data = status()
if 'BCHARGE' in data:
charge = data['BCHARGE'].split()
if charge[1].lower() == 'percent':
return float(charge[0])
ret... | [
"def",
"status_charge",
"(",
")",
":",
"data",
"=",
"status",
"(",
")",
"if",
"'BCHARGE'",
"in",
"data",
":",
"charge",
"=",
"data",
"[",
"'BCHARGE'",
"]",
".",
"split",
"(",
")",
"if",
"charge",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"==",
"'per... | Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge | [
"Return",
"battery",
"charge"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L86-L102 | train |
saltstack/salt | salt/states/esxi.py | coredump_configured | def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500):
'''
Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False``... | python | def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500):
'''
Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False``... | [
"def",
"coredump_configured",
"(",
"name",
",",
"enabled",
",",
"dump_ip",
",",
"host_vnic",
"=",
"'vmk0'",
",",
"dump_port",
"=",
"6500",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",... | Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False`` to enable
or disable core dumps.
Note that ESXi requires that the core dump m... | [
"Ensures",
"a",
"host",
"s",
"core",
"dump",
"configuration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L139-L274 | train |
saltstack/salt | salt/states/esxi.py | password_present | def password_present(name, password):
'''
Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
chang... | python | def password_present(name, password):
'''
Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
chang... | [
"def",
"password_present",
"(",
"name",
",",
"password",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"'old'",
":",
"'unknown'",
",",
"'new'",
":",
"'********'",
"}",
",",
"'comment'",
":",... | Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
changes dictionary will always be populated.
The u... | [
"Ensures",
"the",
"given",
"password",
"is",
"set",
"on",
"the",
"ESXi",
"host",
".",
"Passwords",
"cannot",
"be",
"obtained",
"from",
"host",
"so",
"if",
"a",
"password",
"is",
"set",
"in",
"this",
"state",
"the",
"vsphere",
".",
"update_host_password",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L277-L323 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.