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/states/docker_container.py | _resolve_image | def _resolve_image(ret, image, client_timeout):
'''
Resolve the image ID and pull the image if necessary
'''
image_id = __salt__['docker.resolve_image_id'](image)
if image_id is False:
if not __opts__['test']:
# Image not pulled locally, so try pulling it
try:
... | python | def _resolve_image(ret, image, client_timeout):
'''
Resolve the image ID and pull the image if necessary
'''
image_id = __salt__['docker.resolve_image_id'](image)
if image_id is False:
if not __opts__['test']:
# Image not pulled locally, so try pulling it
try:
... | [
"def",
"_resolve_image",
"(",
"ret",
",",
"image",
",",
"client_timeout",
")",
":",
"image_id",
"=",
"__salt__",
"[",
"'docker.resolve_image_id'",
"]",
"(",
"image",
")",
"if",
"image_id",
"is",
"False",
":",
"if",
"not",
"__opts__",
"[",
"'test'",
"]",
":... | Resolve the image ID and pull the image if necessary | [
"Resolve",
"the",
"image",
"ID",
"and",
"pull",
"the",
"image",
"if",
"necessary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L189-L217 | train |
saltstack/salt | salt/states/docker_container.py | running | def running(name,
image=None,
skip_translate=None,
ignore_collisions=False,
validate_ip_addrs=True,
force=False,
watch_action='force',
start=True,
shutdown_timeout=None,
client_timeout=salt.utils.docker.CLIENT_TI... | python | def running(name,
image=None,
skip_translate=None,
ignore_collisions=False,
validate_ip_addrs=True,
force=False,
watch_action='force',
start=True,
shutdown_timeout=None,
client_timeout=salt.utils.docker.CLIENT_TI... | [
"def",
"running",
"(",
"name",
",",
"image",
"=",
"None",
",",
"skip_translate",
"=",
"None",
",",
"ignore_collisions",
"=",
"False",
",",
"validate_ip_addrs",
"=",
"True",
",",
"force",
"=",
"False",
",",
"watch_action",
"=",
"'force'",
",",
"start",
"=",... | Ensure that a container with a specific configuration is present and
running
name
Name of the container
image
Image to use for the container
.. note::
This state will pull the image if it is not present. However, if
the image needs to be built from a Docker... | [
"Ensure",
"that",
"a",
"container",
"with",
"a",
"specific",
"configuration",
"is",
"present",
"and",
"running"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L220-L2097 | train |
saltstack/salt | salt/states/docker_container.py | run | def run(name,
image=None,
onlyif=None,
unless=None,
creates=None,
bg=False,
failhard=True,
replace=False,
force=False,
skip_translate=None,
ignore_collisions=False,
validate_ip_addrs=True,
client_timeout=salt.utils.docker.CL... | python | def run(name,
image=None,
onlyif=None,
unless=None,
creates=None,
bg=False,
failhard=True,
replace=False,
force=False,
skip_translate=None,
ignore_collisions=False,
validate_ip_addrs=True,
client_timeout=salt.utils.docker.CL... | [
"def",
"run",
"(",
"name",
",",
"image",
"=",
"None",
",",
"onlyif",
"=",
"None",
",",
"unless",
"=",
"None",
",",
"creates",
"=",
"None",
",",
"bg",
"=",
"False",
",",
"failhard",
"=",
"True",
",",
"replace",
"=",
"False",
",",
"force",
"=",
"Fa... | .. versionadded:: 2018.3.0
.. note::
If no tag is specified in the image name, and nothing matching the
specified image is pulled on the minion, the ``docker pull`` that
retrieves the image will pull *all tags* for the image. A tag of
``latest`` is not implicit for the pull. For thi... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L2100-L2330 | train |
saltstack/salt | salt/states/docker_container.py | stopped | def stopped(name=None,
containers=None,
shutdown_timeout=None,
unpause=False,
error_on_absent=True,
**kwargs):
'''
Ensure that a container (or containers) is stopped
name
Name or ID of the container
containers
Run this state o... | python | def stopped(name=None,
containers=None,
shutdown_timeout=None,
unpause=False,
error_on_absent=True,
**kwargs):
'''
Ensure that a container (or containers) is stopped
name
Name or ID of the container
containers
Run this state o... | [
"def",
"stopped",
"(",
"name",
"=",
"None",
",",
"containers",
"=",
"None",
",",
"shutdown_timeout",
"=",
"None",
",",
"unpause",
"=",
"False",
",",
"error_on_absent",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"n... | Ensure that a container (or containers) is stopped
name
Name or ID of the container
containers
Run this state on more than one container at a time. The following two
examples accomplish the same thing:
.. code-block:: yaml
stopped_containers:
docker_... | [
"Ensure",
"that",
"a",
"container",
"(",
"or",
"containers",
")",
"is",
"stopped"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L2333-L2485 | train |
saltstack/salt | salt/states/docker_container.py | absent | def absent(name, force=False):
'''
Ensure that a container is absent
name
Name of the container
force : False
Set to ``True`` to remove the container even if it is running
Usage Examples:
.. code-block:: yaml
mycontainer:
docker_container.absent
mu... | python | def absent(name, force=False):
'''
Ensure that a container is absent
name
Name of the container
force : False
Set to ``True`` to remove the container even if it is running
Usage Examples:
.. code-block:: yaml
mycontainer:
docker_container.absent
mu... | [
"def",
"absent",
"(",
"name",
",",
"force",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"if",
"name",
"not",
"in",
"__salt__",
"... | Ensure that a container is absent
name
Name of the container
force : False
Set to ``True`` to remove the container even if it is running
Usage Examples:
.. code-block:: yaml
mycontainer:
docker_container.absent
multiple_containers:
docker_contain... | [
"Ensure",
"that",
"a",
"container",
"is",
"absent"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L2488-L2549 | train |
saltstack/salt | salt/states/docker_container.py | mod_run_check | def mod_run_check(onlyif, unless, creates):
'''
Execute the onlyif/unless/creates logic. Returns a result dict if any of
the checks fail, otherwise returns True
'''
cmd_kwargs = {'use_vt': False, 'bg': False}
if onlyif is not None:
if isinstance(onlyif, six.string_types):
on... | python | def mod_run_check(onlyif, unless, creates):
'''
Execute the onlyif/unless/creates logic. Returns a result dict if any of
the checks fail, otherwise returns True
'''
cmd_kwargs = {'use_vt': False, 'bg': False}
if onlyif is not None:
if isinstance(onlyif, six.string_types):
on... | [
"def",
"mod_run_check",
"(",
"onlyif",
",",
"unless",
",",
"creates",
")",
":",
"cmd_kwargs",
"=",
"{",
"'use_vt'",
":",
"False",
",",
"'bg'",
":",
"False",
"}",
"if",
"onlyif",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"onlyif",
",",
"six",
... | Execute the onlyif/unless/creates logic. Returns a result dict if any of
the checks fail, otherwise returns True | [
"Execute",
"the",
"onlyif",
"/",
"unless",
"/",
"creates",
"logic",
".",
"Returns",
"a",
"result",
"dict",
"if",
"any",
"of",
"the",
"checks",
"fail",
"otherwise",
"returns",
"True"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L2552-L2615 | train |
saltstack/salt | salt/states/docker_container.py | mod_watch | def mod_watch(name, sfun=None, **kwargs):
'''
The docker_container watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function sho... | python | def mod_watch(name, sfun=None, **kwargs):
'''
The docker_container watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function sho... | [
"def",
"mod_watch",
"(",
"name",
",",
"sfun",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sfun",
"==",
"'running'",
":",
"watch_kwargs",
"=",
"copy",
".",
"deepcopy",
"(",
"kwargs",
")",
"if",
"watch_kwargs",
".",
"get",
"(",
"'watch_action'... | The docker_container watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function should be set by the state being triggered. | [
"The",
"docker_container",
"watcher",
"called",
"to",
"invoke",
"the",
"watch",
"command",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_container.py#L2618-L2647 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | _cache_provider_details | def _cache_provider_details(conn=None):
'''
Provide a place to hang onto results of --list-[locations|sizes|images]
so we don't have to go out to the API and get them every time.
'''
DETAILS['avail_locations'] = {}
DETAILS['avail_sizes'] = {}
DETAILS['avail_images'] = {}
locations = avai... | python | def _cache_provider_details(conn=None):
'''
Provide a place to hang onto results of --list-[locations|sizes|images]
so we don't have to go out to the API and get them every time.
'''
DETAILS['avail_locations'] = {}
DETAILS['avail_sizes'] = {}
DETAILS['avail_images'] = {}
locations = avai... | [
"def",
"_cache_provider_details",
"(",
"conn",
"=",
"None",
")",
":",
"DETAILS",
"[",
"'avail_locations'",
"]",
"=",
"{",
"}",
"DETAILS",
"[",
"'avail_sizes'",
"]",
"=",
"{",
"}",
"DETAILS",
"[",
"'avail_images'",
"]",
"=",
"{",
"}",
"locations",
"=",
"a... | Provide a place to hang onto results of --list-[locations|sizes|images]
so we don't have to go out to the API and get them every time. | [
"Provide",
"a",
"place",
"to",
"hang",
"onto",
"results",
"of",
"--",
"list",
"-",
"[",
"locations|sizes|images",
"]",
"so",
"we",
"don",
"t",
"have",
"to",
"go",
"out",
"to",
"the",
"API",
"and",
"get",
"them",
"every",
"time",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L100-L122 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | list_nodes | def list_nodes(**kwargs):
'''
Return basic data on nodes
'''
ret = {}
nodes = list_nodes_full()
for node in nodes:
ret[node] = {}
for prop in 'id', 'image', 'size', 'state', 'private_ips', 'public_ips':
ret[node][prop] = nodes[node][prop]
return ret | python | def list_nodes(**kwargs):
'''
Return basic data on nodes
'''
ret = {}
nodes = list_nodes_full()
for node in nodes:
ret[node] = {}
for prop in 'id', 'image', 'size', 'state', 'private_ips', 'public_ips':
ret[node][prop] = nodes[node][prop]
return ret | [
"def",
"list_nodes",
"(",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"}",
"nodes",
"=",
"list_nodes_full",
"(",
")",
"for",
"node",
"in",
"nodes",
":",
"ret",
"[",
"node",
"]",
"=",
"{",
"}",
"for",
"prop",
"in",
"'id'",
",",
"'image'",
",",
... | Return basic data on nodes | [
"Return",
"basic",
"data",
"on",
"nodes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L160-L172 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | list_nodes_full | def list_nodes_full(**kwargs):
'''
Return all data on nodes
'''
nodes = _query('server/list')
ret = {}
for node in nodes:
name = nodes[node]['label']
ret[name] = nodes[node].copy()
ret[name]['id'] = node
ret[name]['image'] = nodes[node]['os']
ret[name]['s... | python | def list_nodes_full(**kwargs):
'''
Return all data on nodes
'''
nodes = _query('server/list')
ret = {}
for node in nodes:
name = nodes[node]['label']
ret[name] = nodes[node].copy()
ret[name]['id'] = node
ret[name]['image'] = nodes[node]['os']
ret[name]['s... | [
"def",
"list_nodes_full",
"(",
"*",
"*",
"kwargs",
")",
":",
"nodes",
"=",
"_query",
"(",
"'server/list'",
")",
"ret",
"=",
"{",
"}",
"for",
"node",
"in",
"nodes",
":",
"name",
"=",
"nodes",
"[",
"node",
"]",
"[",
"'label'",
"]",
"ret",
"[",
"name"... | Return all data on nodes | [
"Return",
"all",
"data",
"on",
"nodes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L175-L192 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | destroy | def destroy(name):
'''
Remove a node from Vultr
'''
node = show_instance(name, call='action')
params = {'SUBID': node['SUBID']}
result = _query('server/destroy', method='POST', decode=False, data=_urlencode(params))
# The return of a destroy call is empty in the case of a success.
# Err... | python | def destroy(name):
'''
Remove a node from Vultr
'''
node = show_instance(name, call='action')
params = {'SUBID': node['SUBID']}
result = _query('server/destroy', method='POST', decode=False, data=_urlencode(params))
# The return of a destroy call is empty in the case of a success.
# Err... | [
"def",
"destroy",
"(",
"name",
")",
":",
"node",
"=",
"show_instance",
"(",
"name",
",",
"call",
"=",
"'action'",
")",
"params",
"=",
"{",
"'SUBID'",
":",
"node",
"[",
"'SUBID'",
"]",
"}",
"result",
"=",
"_query",
"(",
"'server/destroy'",
",",
"method"... | Remove a node from Vultr | [
"Remove",
"a",
"node",
"from",
"Vultr"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L204-L217 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | show_instance | def show_instance(name, call=None):
'''
Show the details from the provider concerning an instance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance action must be called with -a or --action.'
)
nodes = list_nodes_full()
# Find under which cloud s... | python | def show_instance(name, call=None):
'''
Show the details from the provider concerning an instance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance action must be called with -a or --action.'
)
nodes = list_nodes_full()
# Find under which cloud s... | [
"def",
"show_instance",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The show_instance action must be called with -a or --action.'",
")",
"nodes",
"=",
"list_nodes_full",
"(",
")",
"# Fi... | Show the details from the provider concerning an instance | [
"Show",
"the",
"details",
"from",
"the",
"provider",
"concerning",
"an",
"instance"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L234-L248 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | _lookup_vultrid | def _lookup_vultrid(which_key, availkey, keyname):
'''
Helper function to retrieve a Vultr ID
'''
if DETAILS == {}:
_cache_provider_details()
which_key = six.text_type(which_key)
try:
return DETAILS[availkey][which_key][keyname]
except KeyError:
return False | python | def _lookup_vultrid(which_key, availkey, keyname):
'''
Helper function to retrieve a Vultr ID
'''
if DETAILS == {}:
_cache_provider_details()
which_key = six.text_type(which_key)
try:
return DETAILS[availkey][which_key][keyname]
except KeyError:
return False | [
"def",
"_lookup_vultrid",
"(",
"which_key",
",",
"availkey",
",",
"keyname",
")",
":",
"if",
"DETAILS",
"==",
"{",
"}",
":",
"_cache_provider_details",
"(",
")",
"which_key",
"=",
"six",
".",
"text_type",
"(",
"which_key",
")",
"try",
":",
"return",
"DETAI... | Helper function to retrieve a Vultr ID | [
"Helper",
"function",
"to",
"retrieve",
"a",
"Vultr",
"ID"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L251-L262 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | create | def create(vm_):
'''
Create a single VM from a data dict
'''
if 'driver' not in vm_:
vm_['driver'] = vm_['provider']
private_networking = config.get_cloud_config_value(
'enable_private_network', vm_, __opts__, search_global=False, default=False,
)
startup_script = config.ge... | python | def create(vm_):
'''
Create a single VM from a data dict
'''
if 'driver' not in vm_:
vm_['driver'] = vm_['provider']
private_networking = config.get_cloud_config_value(
'enable_private_network', vm_, __opts__, search_global=False, default=False,
)
startup_script = config.ge... | [
"def",
"create",
"(",
"vm_",
")",
":",
"if",
"'driver'",
"not",
"in",
"vm_",
":",
"vm_",
"[",
"'driver'",
"]",
"=",
"vm_",
"[",
"'provider'",
"]",
"private_networking",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'enable_private_network'",
",",
"vm_"... | Create a single VM from a data dict | [
"Create",
"a",
"single",
"VM",
"from",
"a",
"data",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L265-L474 | train |
saltstack/salt | salt/cloud/clouds/vultrpy.py | _query | def _query(path, method='GET', data=None, params=None, header_dict=None, decode=True):
'''
Perform a query directly against the Vultr REST API
'''
api_key = config.get_cloud_config_value(
'api_key',
get_configured_provider(),
__opts__,
search_global=False,
)
manag... | python | def _query(path, method='GET', data=None, params=None, header_dict=None, decode=True):
'''
Perform a query directly against the Vultr REST API
'''
api_key = config.get_cloud_config_value(
'api_key',
get_configured_provider(),
__opts__,
search_global=False,
)
manag... | [
"def",
"_query",
"(",
"path",
",",
"method",
"=",
"'GET'",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
",",
"header_dict",
"=",
"None",
",",
"decode",
"=",
"True",
")",
":",
"api_key",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'api_... | Perform a query directly against the Vultr REST API | [
"Perform",
"a",
"query",
"directly",
"against",
"the",
"Vultr",
"REST",
"API"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vultrpy.py#L477-L519 | train |
saltstack/salt | salt/pillar/redismod.py | ext_pillar | def ext_pillar(minion_id, pillar, function, **kwargs):
'''
Grabs external pillar data based on configured function
'''
if function.startswith('_') or function not in globals():
return {}
# Call specified function to pull redis data
return globals()[function](minion_id, pillar, **kwargs) | python | def ext_pillar(minion_id, pillar, function, **kwargs):
'''
Grabs external pillar data based on configured function
'''
if function.startswith('_') or function not in globals():
return {}
# Call specified function to pull redis data
return globals()[function](minion_id, pillar, **kwargs) | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"function",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"function",
".",
"startswith",
"(",
"'_'",
")",
"or",
"function",
"not",
"in",
"globals",
"(",
")",
":",
"return",
"{",
"}",
"# Call specifi... | Grabs external pillar data based on configured function | [
"Grabs",
"external",
"pillar",
"data",
"based",
"on",
"configured",
"function"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/redismod.py#L51-L58 | train |
saltstack/salt | salt/pillar/redismod.py | key_value | def key_value(minion_id,
pillar, # pylint: disable=W0613
pillar_key='redis_pillar'):
'''
Looks for key in redis matching minion_id, returns a structure based on the
data type of the redis key. String for string type, dict for hash type and
lists for lists, sets and sorted se... | python | def key_value(minion_id,
pillar, # pylint: disable=W0613
pillar_key='redis_pillar'):
'''
Looks for key in redis matching minion_id, returns a structure based on the
data type of the redis key. String for string type, dict for hash type and
lists for lists, sets and sorted se... | [
"def",
"key_value",
"(",
"minion_id",
",",
"pillar",
",",
"# pylint: disable=W0613",
"pillar_key",
"=",
"'redis_pillar'",
")",
":",
"# Identify key type and process as needed based on that type",
"key_type",
"=",
"__salt__",
"[",
"'redis.key_type'",
"]",
"(",
"minion_id",
... | Looks for key in redis matching minion_id, returns a structure based on the
data type of the redis key. String for string type, dict for hash type and
lists for lists, sets and sorted sets.
pillar_key
Pillar key to return data into | [
"Looks",
"for",
"key",
"in",
"redis",
"matching",
"minion_id",
"returns",
"a",
"structure",
"based",
"on",
"the",
"data",
"type",
"of",
"the",
"redis",
"key",
".",
"String",
"for",
"string",
"type",
"dict",
"for",
"hash",
"type",
"and",
"lists",
"for",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/redismod.py#L61-L93 | train |
saltstack/salt | salt/pillar/redismod.py | key_json | def key_json(minion_id,
pillar, # pylint: disable=W0613
pillar_key=None):
'''
Pulls a string from redis and deserializes it from json. Deserialized
dictionary data loaded directly into top level if pillar_key is not set.
pillar_key
Pillar key to return data into
'... | python | def key_json(minion_id,
pillar, # pylint: disable=W0613
pillar_key=None):
'''
Pulls a string from redis and deserializes it from json. Deserialized
dictionary data loaded directly into top level if pillar_key is not set.
pillar_key
Pillar key to return data into
'... | [
"def",
"key_json",
"(",
"minion_id",
",",
"pillar",
",",
"# pylint: disable=W0613",
"pillar_key",
"=",
"None",
")",
":",
"key_data",
"=",
"__salt__",
"[",
"'redis.get_key'",
"]",
"(",
"minion_id",
")",
"# Return nothing for non-existent keys",
"if",
"not",
"key_data... | Pulls a string from redis and deserializes it from json. Deserialized
dictionary data loaded directly into top level if pillar_key is not set.
pillar_key
Pillar key to return data into | [
"Pulls",
"a",
"string",
"from",
"redis",
"and",
"deserializes",
"it",
"from",
"json",
".",
"Deserialized",
"dictionary",
"data",
"loaded",
"directly",
"into",
"top",
"level",
"if",
"pillar_key",
"is",
"not",
"set",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/redismod.py#L96-L118 | train |
saltstack/salt | salt/modules/eix.py | sync | def sync():
'''
Sync portage/overlay trees and update the eix database
CLI Example:
.. code-block:: bash
salt '*' eix.sync
'''
# Funtoo patches eix to use 'ego sync'
if __grains__['os'] == 'Funtoo':
cmd = 'eix-sync -q'
else:
cmd = 'eix-sync -q -C "--ask" -C "n"... | python | def sync():
'''
Sync portage/overlay trees and update the eix database
CLI Example:
.. code-block:: bash
salt '*' eix.sync
'''
# Funtoo patches eix to use 'ego sync'
if __grains__['os'] == 'Funtoo':
cmd = 'eix-sync -q'
else:
cmd = 'eix-sync -q -C "--ask" -C "n"... | [
"def",
"sync",
"(",
")",
":",
"# Funtoo patches eix to use 'ego sync'",
"if",
"__grains__",
"[",
"'os'",
"]",
"==",
"'Funtoo'",
":",
"cmd",
"=",
"'eix-sync -q'",
"else",
":",
"cmd",
"=",
"'eix-sync -q -C \"--ask\" -C \"n\"'",
"if",
"'makeconf.features_contains'",
"in"... | Sync portage/overlay trees and update the eix database
CLI Example:
.. code-block:: bash
salt '*' eix.sync | [
"Sync",
"portage",
"/",
"overlay",
"trees",
"and",
"update",
"the",
"eix",
"database"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/eix.py#L20-L50 | train |
saltstack/salt | salt/modules/pw_group.py | add | def add(name, gid=None, **kwargs):
'''
Add the specified group
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456
'''
kwargs = salt.utils.args.clean_kwargs(**kwargs)
if salt.utils.data.is_true(kwargs.pop('system', False)):
log.warning('pw_group module does not s... | python | def add(name, gid=None, **kwargs):
'''
Add the specified group
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456
'''
kwargs = salt.utils.args.clean_kwargs(**kwargs)
if salt.utils.data.is_true(kwargs.pop('system', False)):
log.warning('pw_group module does not s... | [
"def",
"add",
"(",
"name",
",",
"gid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"if",
"salt",
".",
"utils",
".",
"data",
".",
"is_true",
... | Add the specified group
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456 | [
"Add",
"the",
"specified",
"group"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pw_group.py#L43-L65 | train |
saltstack/salt | salt/modules/pw_group.py | adduser | def adduser(name, username):
'''
Add a user in the group.
CLI Example:
.. code-block:: bash
salt '*' group.adduser foo bar
Verifies if a valid username 'bar' as a member of an existing group 'foo',
if not then adds it.
'''
# Note: pw exits with code 65 if group is unknown
... | python | def adduser(name, username):
'''
Add a user in the group.
CLI Example:
.. code-block:: bash
salt '*' group.adduser foo bar
Verifies if a valid username 'bar' as a member of an existing group 'foo',
if not then adds it.
'''
# Note: pw exits with code 65 if group is unknown
... | [
"def",
"adduser",
"(",
"name",
",",
"username",
")",
":",
"# Note: pw exits with code 65 if group is unknown",
"retcode",
"=",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"'pw groupmod {0} -m {1}'",
".",
"format",
"(",
"name",
",",
"username",
")",
",",
"python_shel... | Add a user in the group.
CLI Example:
.. code-block:: bash
salt '*' group.adduser foo bar
Verifies if a valid username 'bar' as a member of an existing group 'foo',
if not then adds it. | [
"Add",
"a",
"user",
"in",
"the",
"group",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pw_group.py#L145-L162 | train |
saltstack/salt | salt/modules/pw_group.py | deluser | def deluser(name, username):
'''
Remove a user from the group.
CLI Example:
.. code-block:: bash
salt '*' group.deluser foo bar
Removes a member user 'bar' from a group 'foo'. If group is not present
then returns True.
'''
grp_info = __salt__['group.info'](name)
if user... | python | def deluser(name, username):
'''
Remove a user from the group.
CLI Example:
.. code-block:: bash
salt '*' group.deluser foo bar
Removes a member user 'bar' from a group 'foo'. If group is not present
then returns True.
'''
grp_info = __salt__['group.info'](name)
if user... | [
"def",
"deluser",
"(",
"name",
",",
"username",
")",
":",
"grp_info",
"=",
"__salt__",
"[",
"'group.info'",
"]",
"(",
"name",
")",
"if",
"username",
"not",
"in",
"grp_info",
"[",
"'members'",
"]",
":",
"return",
"True",
"# Note: pw exits with code 65 if group ... | Remove a user from the group.
CLI Example:
.. code-block:: bash
salt '*' group.deluser foo bar
Removes a member user 'bar' from a group 'foo'. If group is not present
then returns True. | [
"Remove",
"a",
"user",
"from",
"the",
"group",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pw_group.py#L165-L187 | train |
saltstack/salt | salt/states/jboss7.py | datasource_exists | def datasource_exists(name, jboss_config, datasource_properties, recreate=False, profile=None):
'''
Ensures that a datasource with given properties exist on the jboss instance.
If datasource doesn't exist, it is created, otherwise only the properties that are different will be updated.
name
Dat... | python | def datasource_exists(name, jboss_config, datasource_properties, recreate=False, profile=None):
'''
Ensures that a datasource with given properties exist on the jboss instance.
If datasource doesn't exist, it is created, otherwise only the properties that are different will be updated.
name
Dat... | [
"def",
"datasource_exists",
"(",
"name",
",",
"jboss_config",
",",
"datasource_properties",
",",
"recreate",
"=",
"False",
",",
"profile",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\" ======================== STATE: jboss7.datasource_exists (name: %s) \"",
",",
... | Ensures that a datasource with given properties exist on the jboss instance.
If datasource doesn't exist, it is created, otherwise only the properties that are different will be updated.
name
Datasource property name
jboss_config
Dict with connection properties (see state description)
d... | [
"Ensures",
"that",
"a",
"datasource",
"with",
"given",
"properties",
"exist",
"on",
"the",
"jboss",
"instance",
".",
"If",
"datasource",
"doesn",
"t",
"exist",
"it",
"is",
"created",
"otherwise",
"only",
"the",
"properties",
"that",
"are",
"different",
"will",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jboss7.py#L56-L176 | train |
saltstack/salt | salt/states/jboss7.py | bindings_exist | def bindings_exist(name, jboss_config, bindings, profile=None):
'''
Ensures that given JNDI binding are present on the server.
If a binding doesn't exist on the server it will be created.
If it already exists its value will be changed.
jboss_config:
Dict with connection properties (see stat... | python | def bindings_exist(name, jboss_config, bindings, profile=None):
'''
Ensures that given JNDI binding are present on the server.
If a binding doesn't exist on the server it will be created.
If it already exists its value will be changed.
jboss_config:
Dict with connection properties (see stat... | [
"def",
"bindings_exist",
"(",
"name",
",",
"jboss_config",
",",
"bindings",
",",
"profile",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\" ======================== STATE: jboss7.bindings_exist (name: %s) (profile: %s) \"",
",",
"name",
",",
"profile",
")",
"log"... | Ensures that given JNDI binding are present on the server.
If a binding doesn't exist on the server it will be created.
If it already exists its value will be changed.
jboss_config:
Dict with connection properties (see state description)
bindings:
Dict with bindings to set.
profile:... | [
"Ensures",
"that",
"given",
"JNDI",
"binding",
"are",
"present",
"on",
"the",
"server",
".",
"If",
"a",
"binding",
"doesn",
"t",
"exist",
"on",
"the",
"server",
"it",
"will",
"be",
"created",
".",
"If",
"it",
"already",
"exists",
"its",
"value",
"will",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jboss7.py#L203-L261 | train |
saltstack/salt | salt/states/jboss7.py | deployed | def deployed(name, jboss_config, salt_source=None):
'''Ensures that the given application is deployed on server.
jboss_config:
Dict with connection properties (see state description)
salt_source:
How to find the artifact to be deployed.
target_file:
Where to look... | python | def deployed(name, jboss_config, salt_source=None):
'''Ensures that the given application is deployed on server.
jboss_config:
Dict with connection properties (see state description)
salt_source:
How to find the artifact to be deployed.
target_file:
Where to look... | [
"def",
"deployed",
"(",
"name",
",",
"jboss_config",
",",
"salt_source",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\" ======================== STATE: jboss7.deployed (name: %s) \"",
",",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'... | Ensures that the given application is deployed on server.
jboss_config:
Dict with connection properties (see state description)
salt_source:
How to find the artifact to be deployed.
target_file:
Where to look in the minion's file system for the artifact to be deploye... | [
"Ensures",
"that",
"the",
"given",
"application",
"is",
"deployed",
"on",
"server",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jboss7.py#L273-L380 | train |
saltstack/salt | salt/states/jboss7.py | reloaded | def reloaded(name, jboss_config, timeout=60, interval=5):
'''
Reloads configuration of jboss server.
jboss_config:
Dict with connection properties (see state description)
timeout:
Time to wait until jboss is back in running state. Default timeout is 60s.
interval:
Interval b... | python | def reloaded(name, jboss_config, timeout=60, interval=5):
'''
Reloads configuration of jboss server.
jboss_config:
Dict with connection properties (see state description)
timeout:
Time to wait until jboss is back in running state. Default timeout is 60s.
interval:
Interval b... | [
"def",
"reloaded",
"(",
"name",
",",
"jboss_config",
",",
"timeout",
"=",
"60",
",",
"interval",
"=",
"5",
")",
":",
"log",
".",
"debug",
"(",
"\" ======================== STATE: jboss7.reloaded (name: %s) \"",
",",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",... | Reloads configuration of jboss server.
jboss_config:
Dict with connection properties (see state description)
timeout:
Time to wait until jboss is back in running state. Default timeout is 60s.
interval:
Interval between state checks. Default interval is 5s. Decreasing the interval m... | [
"Reloads",
"configuration",
"of",
"jboss",
"server",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jboss7.py#L484-L549 | train |
saltstack/salt | salt/utils/validate/user.py | valid_username | def valid_username(user):
'''
Validates a username based on the guidelines in `useradd(8)`
'''
if not isinstance(user, six.string_types):
return False
if len(user) > 32:
return False
return VALID_USERNAME.match(user) is not None | python | def valid_username(user):
'''
Validates a username based on the guidelines in `useradd(8)`
'''
if not isinstance(user, six.string_types):
return False
if len(user) > 32:
return False
return VALID_USERNAME.match(user) is not None | [
"def",
"valid_username",
"(",
"user",
")",
":",
"if",
"not",
"isinstance",
"(",
"user",
",",
"six",
".",
"string_types",
")",
":",
"return",
"False",
"if",
"len",
"(",
"user",
")",
">",
"32",
":",
"return",
"False",
"return",
"VALID_USERNAME",
".",
"ma... | Validates a username based on the guidelines in `useradd(8)` | [
"Validates",
"a",
"username",
"based",
"on",
"the",
"guidelines",
"in",
"useradd",
"(",
"8",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/validate/user.py#L17-L27 | train |
saltstack/salt | salt/renderers/pyobjects.py | load_states | def load_states():
'''
This loads our states into the salt __context__
'''
states = {}
# the loader expects to find pillar & grain data
__opts__['grains'] = salt.loader.grains(__opts__)
__opts__['pillar'] = __pillar__
lazy_utils = salt.loader.utils(__opts__)
lazy_funcs = salt.loader... | python | def load_states():
'''
This loads our states into the salt __context__
'''
states = {}
# the loader expects to find pillar & grain data
__opts__['grains'] = salt.loader.grains(__opts__)
__opts__['pillar'] = __pillar__
lazy_utils = salt.loader.utils(__opts__)
lazy_funcs = salt.loader... | [
"def",
"load_states",
"(",
")",
":",
"states",
"=",
"{",
"}",
"# the loader expects to find pillar & grain data",
"__opts__",
"[",
"'grains'",
"]",
"=",
"salt",
".",
"loader",
".",
"grains",
"(",
"__opts__",
")",
"__opts__",
"[",
"'pillar'",
"]",
"=",
"__pilla... | This loads our states into the salt __context__ | [
"This",
"loads",
"our",
"states",
"into",
"the",
"salt",
"__context__"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/pyobjects.py#L339-L365 | train |
saltstack/salt | salt/modules/google_chat.py | send_message | def send_message(url, message):
'''
Send a message to the google chat room specified in the webhook url.
.. code-block:: bash
salt '*' google_chat.send_message "https://chat.googleapis.com/v1/spaces/example_space/messages?key=example_key" "This is a test message"
'''
headers = {'Content-Ty... | python | def send_message(url, message):
'''
Send a message to the google chat room specified in the webhook url.
.. code-block:: bash
salt '*' google_chat.send_message "https://chat.googleapis.com/v1/spaces/example_space/messages?key=example_key" "This is a test message"
'''
headers = {'Content-Ty... | [
"def",
"send_message",
"(",
"url",
",",
"message",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"data",
"=",
"{",
"'text'",
":",
"message",
"}",
"result",
"=",
"__utils__",
"[",
"'http.query'",
"]",
"(",
"url",
",",
"'... | Send a message to the google chat room specified in the webhook url.
.. code-block:: bash
salt '*' google_chat.send_message "https://chat.googleapis.com/v1/spaces/example_space/messages?key=example_key" "This is a test message" | [
"Send",
"a",
"message",
"to",
"the",
"google",
"chat",
"room",
"specified",
"in",
"the",
"webhook",
"url",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/google_chat.py#L36-L56 | train |
saltstack/salt | salt/utils/error.py | raise_error | def raise_error(name=None, args=None, message=''):
'''
Raise an exception with __name__ from name, args from args
If args is None Otherwise message from message\
If name is empty then use "Exception"
'''
name = name or 'Exception'
if hasattr(salt.exceptions, name):
ex = getattr(salt.... | python | def raise_error(name=None, args=None, message=''):
'''
Raise an exception with __name__ from name, args from args
If args is None Otherwise message from message\
If name is empty then use "Exception"
'''
name = name or 'Exception'
if hasattr(salt.exceptions, name):
ex = getattr(salt.... | [
"def",
"raise_error",
"(",
"name",
"=",
"None",
",",
"args",
"=",
"None",
",",
"message",
"=",
"''",
")",
":",
"name",
"=",
"name",
"or",
"'Exception'",
"if",
"hasattr",
"(",
"salt",
".",
"exceptions",
",",
"name",
")",
":",
"ex",
"=",
"getattr",
"... | Raise an exception with __name__ from name, args from args
If args is None Otherwise message from message\
If name is empty then use "Exception" | [
"Raise",
"an",
"exception",
"with",
"__name__",
"from",
"name",
"args",
"from",
"args",
"If",
"args",
"is",
"None",
"Otherwise",
"message",
"from",
"message",
"\\",
"If",
"name",
"is",
"empty",
"then",
"use",
"Exception"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/error.py#L16-L33 | train |
saltstack/salt | salt/utils/error.py | fire_exception | def fire_exception(exc, opts, job=None, node='minion'):
'''
Fire raw exception across the event bus
'''
if job is None:
job = {}
event = salt.utils.event.SaltEvent(node, opts=opts, listen=False)
event.fire_event(pack_exception(exc), '_salt_error') | python | def fire_exception(exc, opts, job=None, node='minion'):
'''
Fire raw exception across the event bus
'''
if job is None:
job = {}
event = salt.utils.event.SaltEvent(node, opts=opts, listen=False)
event.fire_event(pack_exception(exc), '_salt_error') | [
"def",
"fire_exception",
"(",
"exc",
",",
"opts",
",",
"job",
"=",
"None",
",",
"node",
"=",
"'minion'",
")",
":",
"if",
"job",
"is",
"None",
":",
"job",
"=",
"{",
"}",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"SaltEvent",
"(",
"nod... | Fire raw exception across the event bus | [
"Fire",
"raw",
"exception",
"across",
"the",
"event",
"bus"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/error.py#L44-L51 | train |
saltstack/salt | salt/renderers/msgpack.py | render | def render(msgpack_data, saltenv='base', sls='', **kws):
'''
Accepts a message pack string or a file object, renders said data back to
a python dict.
.. note:
This renderer is NOT intended for use in creating sls files by hand,
but exists to allow for data backends to serialize the high... | python | def render(msgpack_data, saltenv='base', sls='', **kws):
'''
Accepts a message pack string or a file object, renders said data back to
a python dict.
.. note:
This renderer is NOT intended for use in creating sls files by hand,
but exists to allow for data backends to serialize the high... | [
"def",
"render",
"(",
"msgpack_data",
",",
"saltenv",
"=",
"'base'",
",",
"sls",
"=",
"''",
",",
"*",
"*",
"kws",
")",
":",
"if",
"not",
"isinstance",
"(",
"msgpack_data",
",",
"six",
".",
"string_types",
")",
":",
"msgpack_data",
"=",
"msgpack_data",
... | Accepts a message pack string or a file object, renders said data back to
a python dict.
.. note:
This renderer is NOT intended for use in creating sls files by hand,
but exists to allow for data backends to serialize the highdata
structure in an easily transportable way. This is to all... | [
"Accepts",
"a",
"message",
"pack",
"string",
"or",
"a",
"file",
"object",
"renders",
"said",
"data",
"back",
"to",
"a",
"python",
"dict",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/msgpack.py#L9-L29 | train |
saltstack/salt | salt/daemons/masterapi.py | init_git_pillar | def init_git_pillar(opts):
'''
Clear out the ext pillar caches, used when the master starts
'''
ret = []
for opts_dict in [x for x in opts.get('ext_pillar', [])]:
if 'git' in opts_dict:
try:
pillar = salt.utils.gitfs.GitPillar(
opts,
... | python | def init_git_pillar(opts):
'''
Clear out the ext pillar caches, used when the master starts
'''
ret = []
for opts_dict in [x for x in opts.get('ext_pillar', [])]:
if 'git' in opts_dict:
try:
pillar = salt.utils.gitfs.GitPillar(
opts,
... | [
"def",
"init_git_pillar",
"(",
"opts",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"opts_dict",
"in",
"[",
"x",
"for",
"x",
"in",
"opts",
".",
"get",
"(",
"'ext_pillar'",
",",
"[",
"]",
")",
"]",
":",
"if",
"'git'",
"in",
"opts_dict",
":",
"try",
":",... | Clear out the ext pillar caches, used when the master starts | [
"Clear",
"out",
"the",
"ext",
"pillar",
"caches",
"used",
"when",
"the",
"master",
"starts"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L68-L88 | train |
saltstack/salt | salt/daemons/masterapi.py | clean_fsbackend | def clean_fsbackend(opts):
'''
Clean out the old fileserver backends
'''
# Clear remote fileserver backend caches so they get recreated
for backend in ('git', 'hg', 'svn'):
if backend in opts['fileserver_backend']:
env_cache = os.path.join(
opts['cachedir'],
... | python | def clean_fsbackend(opts):
'''
Clean out the old fileserver backends
'''
# Clear remote fileserver backend caches so they get recreated
for backend in ('git', 'hg', 'svn'):
if backend in opts['fileserver_backend']:
env_cache = os.path.join(
opts['cachedir'],
... | [
"def",
"clean_fsbackend",
"(",
"opts",
")",
":",
"# Clear remote fileserver backend caches so they get recreated",
"for",
"backend",
"in",
"(",
"'git'",
",",
"'hg'",
",",
"'svn'",
")",
":",
"if",
"backend",
"in",
"opts",
"[",
"'fileserver_backend'",
"]",
":",
"env... | Clean out the old fileserver backends | [
"Clean",
"out",
"the",
"old",
"fileserver",
"backends"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L91-L130 | train |
saltstack/salt | salt/daemons/masterapi.py | clean_expired_tokens | def clean_expired_tokens(opts):
'''
Clean expired tokens from the master
'''
loadauth = salt.auth.LoadAuth(opts)
for tok in loadauth.list_tokens():
token_data = loadauth.get_tok(tok)
if 'expire' not in token_data or token_data.get('expire', 0) < time.time():
loadauth.rm_t... | python | def clean_expired_tokens(opts):
'''
Clean expired tokens from the master
'''
loadauth = salt.auth.LoadAuth(opts)
for tok in loadauth.list_tokens():
token_data = loadauth.get_tok(tok)
if 'expire' not in token_data or token_data.get('expire', 0) < time.time():
loadauth.rm_t... | [
"def",
"clean_expired_tokens",
"(",
"opts",
")",
":",
"loadauth",
"=",
"salt",
".",
"auth",
".",
"LoadAuth",
"(",
"opts",
")",
"for",
"tok",
"in",
"loadauth",
".",
"list_tokens",
"(",
")",
":",
"token_data",
"=",
"loadauth",
".",
"get_tok",
"(",
"tok",
... | Clean expired tokens from the master | [
"Clean",
"expired",
"tokens",
"from",
"the",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L133-L141 | train |
saltstack/salt | salt/daemons/masterapi.py | clean_old_jobs | def clean_old_jobs(opts):
'''
Clean out the old jobs from the job cache
'''
# TODO: better way to not require creating the masterminion every time?
mminion = salt.minion.MasterMinion(
opts,
states=False,
rend=False,
)
# If the maste... | python | def clean_old_jobs(opts):
'''
Clean out the old jobs from the job cache
'''
# TODO: better way to not require creating the masterminion every time?
mminion = salt.minion.MasterMinion(
opts,
states=False,
rend=False,
)
# If the maste... | [
"def",
"clean_old_jobs",
"(",
"opts",
")",
":",
"# TODO: better way to not require creating the masterminion every time?",
"mminion",
"=",
"salt",
".",
"minion",
".",
"MasterMinion",
"(",
"opts",
",",
"states",
"=",
"False",
",",
"rend",
"=",
"False",
",",
")",
"#... | Clean out the old jobs from the job cache | [
"Clean",
"out",
"the",
"old",
"jobs",
"from",
"the",
"job",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L162-L175 | train |
saltstack/salt | salt/daemons/masterapi.py | clean_proc_dir | def clean_proc_dir(opts):
'''
Clean out old tracked jobs running on the master
Generally, anything tracking a job should remove the job
once the job has finished. However, this will remove any
jobs that for some reason were not properly removed
when finished or errored.
'''
serial = sal... | python | def clean_proc_dir(opts):
'''
Clean out old tracked jobs running on the master
Generally, anything tracking a job should remove the job
once the job has finished. However, this will remove any
jobs that for some reason were not properly removed
when finished or errored.
'''
serial = sal... | [
"def",
"clean_proc_dir",
"(",
"opts",
")",
":",
"serial",
"=",
"salt",
".",
"payload",
".",
"Serial",
"(",
"opts",
")",
"proc_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"opts",
"[",
"'cachedir'",
"]",
",",
"'proc'",
")",
"for",
"fn_",
"in",
"o... | Clean out old tracked jobs running on the master
Generally, anything tracking a job should remove the job
once the job has finished. However, this will remove any
jobs that for some reason were not properly removed
when finished or errored. | [
"Clean",
"out",
"old",
"tracked",
"jobs",
"running",
"on",
"the",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L178-L211 | train |
saltstack/salt | salt/daemons/masterapi.py | access_keys | def access_keys(opts):
'''
A key needs to be placed in the filesystem with permissions 0400 so
clients are required to run as root.
'''
# TODO: Need a way to get all available users for systems not supported by pwd module.
# For now users pattern matching will not work for publisher_acl.
... | python | def access_keys(opts):
'''
A key needs to be placed in the filesystem with permissions 0400 so
clients are required to run as root.
'''
# TODO: Need a way to get all available users for systems not supported by pwd module.
# For now users pattern matching will not work for publisher_acl.
... | [
"def",
"access_keys",
"(",
"opts",
")",
":",
"# TODO: Need a way to get all available users for systems not supported by pwd module.",
"# For now users pattern matching will not work for publisher_acl.",
"keys",
"=",
"{",
"}",
"publisher_acl",
"=",
"opts",
"[",
"'publisher_acl'... | A key needs to be placed in the filesystem with permissions 0400 so
clients are required to run as root. | [
"A",
"key",
"needs",
"to",
"be",
"placed",
"in",
"the",
"filesystem",
"with",
"permissions",
"0400",
"so",
"clients",
"are",
"required",
"to",
"run",
"as",
"root",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L259-L287 | train |
saltstack/salt | salt/daemons/masterapi.py | fileserver_update | def fileserver_update(fileserver):
'''
Update the fileserver backends, requires that a salt.fileserver.Fileserver
object be passed in
'''
try:
if not fileserver.servers:
log.error(
'No fileservers loaded, the master will not be able to '
'serve fil... | python | def fileserver_update(fileserver):
'''
Update the fileserver backends, requires that a salt.fileserver.Fileserver
object be passed in
'''
try:
if not fileserver.servers:
log.error(
'No fileservers loaded, the master will not be able to '
'serve fil... | [
"def",
"fileserver_update",
"(",
"fileserver",
")",
":",
"try",
":",
"if",
"not",
"fileserver",
".",
"servers",
":",
"log",
".",
"error",
"(",
"'No fileservers loaded, the master will not be able to '",
"'serve files to minions'",
")",
"raise",
"salt",
".",
"exception... | Update the fileserver backends, requires that a salt.fileserver.Fileserver
object be passed in | [
"Update",
"the",
"fileserver",
"backends",
"requires",
"that",
"a",
"salt",
".",
"fileserver",
".",
"Fileserver",
"object",
"be",
"passed",
"in"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L290-L307 | train |
saltstack/salt | salt/daemons/masterapi.py | AutoKey.check_permissions | def check_permissions(self, filename):
'''
Check if the specified filename has correct permissions
'''
if salt.utils.platform.is_windows():
return True
# After we've ascertained we're not on windows
groups = salt.utils.user.get_gid_list(self.opts['user'], inc... | python | def check_permissions(self, filename):
'''
Check if the specified filename has correct permissions
'''
if salt.utils.platform.is_windows():
return True
# After we've ascertained we're not on windows
groups = salt.utils.user.get_gid_list(self.opts['user'], inc... | [
"def",
"check_permissions",
"(",
"self",
",",
"filename",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"return",
"True",
"# After we've ascertained we're not on windows",
"groups",
"=",
"salt",
".",
"utils",
".",
"us... | Check if the specified filename has correct permissions | [
"Check",
"if",
"the",
"specified",
"filename",
"has",
"correct",
"permissions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L318-L342 | train |
saltstack/salt | salt/daemons/masterapi.py | AutoKey.check_signing_file | def check_signing_file(self, keyid, signing_file):
'''
Check a keyid for membership in a signing file
'''
if not signing_file or not os.path.exists(signing_file):
return False
if not self.check_permissions(signing_file):
log.warning('Wrong permissions for... | python | def check_signing_file(self, keyid, signing_file):
'''
Check a keyid for membership in a signing file
'''
if not signing_file or not os.path.exists(signing_file):
return False
if not self.check_permissions(signing_file):
log.warning('Wrong permissions for... | [
"def",
"check_signing_file",
"(",
"self",
",",
"keyid",
",",
"signing_file",
")",
":",
"if",
"not",
"signing_file",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"signing_file",
")",
":",
"return",
"False",
"if",
"not",
"self",
".",
"check_permission... | Check a keyid for membership in a signing file | [
"Check",
"a",
"keyid",
"for",
"membership",
"in",
"a",
"signing",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L344-L363 | train |
saltstack/salt | salt/daemons/masterapi.py | AutoKey.check_autosign_dir | def check_autosign_dir(self, keyid):
'''
Check a keyid for membership in a autosign directory.
'''
autosign_dir = os.path.join(self.opts['pki_dir'], 'minions_autosign')
# cleanup expired files
expire_minutes = self.opts.get('autosign_timeout', 120)
if expire_minu... | python | def check_autosign_dir(self, keyid):
'''
Check a keyid for membership in a autosign directory.
'''
autosign_dir = os.path.join(self.opts['pki_dir'], 'minions_autosign')
# cleanup expired files
expire_minutes = self.opts.get('autosign_timeout', 120)
if expire_minu... | [
"def",
"check_autosign_dir",
"(",
"self",
",",
"keyid",
")",
":",
"autosign_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"'minions_autosign'",
")",
"# cleanup expired files",
"expire_minutes",
"=",
"self",
... | Check a keyid for membership in a autosign directory. | [
"Check",
"a",
"keyid",
"for",
"membership",
"in",
"a",
"autosign",
"directory",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L365-L387 | train |
saltstack/salt | salt/daemons/masterapi.py | AutoKey.check_autosign_grains | def check_autosign_grains(self, autosign_grains):
'''
Check for matching grains in the autosign_grains_dir.
'''
if not autosign_grains or 'autosign_grains_dir' not in self.opts:
return False
autosign_grains_dir = self.opts['autosign_grains_dir']
for root, dir... | python | def check_autosign_grains(self, autosign_grains):
'''
Check for matching grains in the autosign_grains_dir.
'''
if not autosign_grains or 'autosign_grains_dir' not in self.opts:
return False
autosign_grains_dir = self.opts['autosign_grains_dir']
for root, dir... | [
"def",
"check_autosign_grains",
"(",
"self",
",",
"autosign_grains",
")",
":",
"if",
"not",
"autosign_grains",
"or",
"'autosign_grains_dir'",
"not",
"in",
"self",
".",
"opts",
":",
"return",
"False",
"autosign_grains_dir",
"=",
"self",
".",
"opts",
"[",
"'autosi... | Check for matching grains in the autosign_grains_dir. | [
"Check",
"for",
"matching",
"grains",
"in",
"the",
"autosign_grains_dir",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L389-L416 | train |
saltstack/salt | salt/daemons/masterapi.py | AutoKey.check_autosign | def check_autosign(self, keyid, autosign_grains=None):
'''
Checks if the specified keyid should automatically be signed.
'''
if self.opts['auto_accept']:
return True
if self.check_signing_file(keyid, self.opts.get('autosign_file', None)):
return True
... | python | def check_autosign(self, keyid, autosign_grains=None):
'''
Checks if the specified keyid should automatically be signed.
'''
if self.opts['auto_accept']:
return True
if self.check_signing_file(keyid, self.opts.get('autosign_file', None)):
return True
... | [
"def",
"check_autosign",
"(",
"self",
",",
"keyid",
",",
"autosign_grains",
"=",
"None",
")",
":",
"if",
"self",
".",
"opts",
"[",
"'auto_accept'",
"]",
":",
"return",
"True",
"if",
"self",
".",
"check_signing_file",
"(",
"keyid",
",",
"self",
".",
"opts... | Checks if the specified keyid should automatically be signed. | [
"Checks",
"if",
"the",
"specified",
"keyid",
"should",
"automatically",
"be",
"signed",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L427-L439 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.__setup_fileserver | def __setup_fileserver(self):
'''
Set the local file objects from the file server interface
'''
fs_ = salt.fileserver.Fileserver(self.opts)
self._serve_file = fs_.serve_file
self._file_find = fs_._find_file
self._file_hash = fs_.file_hash
self._file_list =... | python | def __setup_fileserver(self):
'''
Set the local file objects from the file server interface
'''
fs_ = salt.fileserver.Fileserver(self.opts)
self._serve_file = fs_.serve_file
self._file_find = fs_._find_file
self._file_hash = fs_.file_hash
self._file_list =... | [
"def",
"__setup_fileserver",
"(",
"self",
")",
":",
"fs_",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"self",
".",
"opts",
")",
"self",
".",
"_serve_file",
"=",
"fs_",
".",
"serve_file",
"self",
".",
"_file_find",
"=",
"fs_",
".",
"_find_fil... | Set the local file objects from the file server interface | [
"Set",
"the",
"local",
"file",
"objects",
"from",
"the",
"file",
"server",
"interface"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L469-L481 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.__verify_minion_publish | def __verify_minion_publish(self, load):
'''
Verify that the passed information authorized a minion to execute
'''
# Verify that the load is valid
if 'peer' not in self.opts:
return False
if not isinstance(self.opts['peer'], dict):
return False
... | python | def __verify_minion_publish(self, load):
'''
Verify that the passed information authorized a minion to execute
'''
# Verify that the load is valid
if 'peer' not in self.opts:
return False
if not isinstance(self.opts['peer'], dict):
return False
... | [
"def",
"__verify_minion_publish",
"(",
"self",
",",
"load",
")",
":",
"# Verify that the load is valid",
"if",
"'peer'",
"not",
"in",
"self",
".",
"opts",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"self",
".",
"opts",
"[",
"'peer'",
"]",
",",
... | Verify that the passed information authorized a minion to execute | [
"Verify",
"that",
"the",
"passed",
"information",
"authorized",
"a",
"minion",
"to",
"execute"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L483-L517 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._master_opts | def _master_opts(self, load):
'''
Return the master options to the minion
'''
mopts = {}
file_roots = {}
envs = self._file_envs()
for saltenv in envs:
if saltenv not in file_roots:
file_roots[saltenv] = []
mopts['file_roots'] = ... | python | def _master_opts(self, load):
'''
Return the master options to the minion
'''
mopts = {}
file_roots = {}
envs = self._file_envs()
for saltenv in envs:
if saltenv not in file_roots:
file_roots[saltenv] = []
mopts['file_roots'] = ... | [
"def",
"_master_opts",
"(",
"self",
",",
"load",
")",
":",
"mopts",
"=",
"{",
"}",
"file_roots",
"=",
"{",
"}",
"envs",
"=",
"self",
".",
"_file_envs",
"(",
")",
"for",
"saltenv",
"in",
"envs",
":",
"if",
"saltenv",
"not",
"in",
"file_roots",
":",
... | Return the master options to the minion | [
"Return",
"the",
"master",
"options",
"to",
"the",
"minion"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L519-L547 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._master_tops | def _master_tops(self, load, skip_verify=False):
'''
Return the results from master_tops if configured
'''
if not skip_verify:
if 'id' not in load:
log.error('Received call for external nodes without an id')
return {}
if not salt.ut... | python | def _master_tops(self, load, skip_verify=False):
'''
Return the results from master_tops if configured
'''
if not skip_verify:
if 'id' not in load:
log.error('Received call for external nodes without an id')
return {}
if not salt.ut... | [
"def",
"_master_tops",
"(",
"self",
",",
"load",
",",
"skip_verify",
"=",
"False",
")",
":",
"if",
"not",
"skip_verify",
":",
"if",
"'id'",
"not",
"in",
"load",
":",
"log",
".",
"error",
"(",
"'Received call for external nodes without an id'",
")",
"return",
... | Return the results from master_tops if configured | [
"Return",
"the",
"results",
"from",
"master_tops",
"if",
"configured"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L549-L580 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._mine_get | def _mine_get(self, load, skip_verify=False):
'''
Gathers the data from the specified minions' mine
'''
if not skip_verify:
if any(key not in load for key in ('id', 'tgt', 'fun')):
return {}
if isinstance(load['fun'], six.string_types):
fu... | python | def _mine_get(self, load, skip_verify=False):
'''
Gathers the data from the specified minions' mine
'''
if not skip_verify:
if any(key not in load for key in ('id', 'tgt', 'fun')):
return {}
if isinstance(load['fun'], six.string_types):
fu... | [
"def",
"_mine_get",
"(",
"self",
",",
"load",
",",
"skip_verify",
"=",
"False",
")",
":",
"if",
"not",
"skip_verify",
":",
"if",
"any",
"(",
"key",
"not",
"in",
"load",
"for",
"key",
"in",
"(",
"'id'",
",",
"'tgt'",
",",
"'fun'",
")",
")",
":",
"... | Gathers the data from the specified minions' mine | [
"Gathers",
"the",
"data",
"from",
"the",
"specified",
"minions",
"mine"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L582-L658 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._mine | def _mine(self, load, skip_verify=False):
'''
Return the mine data
'''
if not skip_verify:
if 'id' not in load or 'data' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
c... | python | def _mine(self, load, skip_verify=False):
'''
Return the mine data
'''
if not skip_verify:
if 'id' not in load or 'data' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
c... | [
"def",
"_mine",
"(",
"self",
",",
"load",
",",
"skip_verify",
"=",
"False",
")",
":",
"if",
"not",
"skip_verify",
":",
"if",
"'id'",
"not",
"in",
"load",
"or",
"'data'",
"not",
"in",
"load",
":",
"return",
"False",
"if",
"self",
".",
"opts",
".",
"... | Return the mine data | [
"Return",
"the",
"mine",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L660-L676 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._mine_delete | def _mine_delete(self, load):
'''
Allow the minion to delete a specific function from its own mine
'''
if 'id' not in load or 'fun' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
cbank ... | python | def _mine_delete(self, load):
'''
Allow the minion to delete a specific function from its own mine
'''
if 'id' not in load or 'fun' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
cbank ... | [
"def",
"_mine_delete",
"(",
"self",
",",
"load",
")",
":",
"if",
"'id'",
"not",
"in",
"load",
"or",
"'fun'",
"not",
"in",
"load",
":",
"return",
"False",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'minion_data_cache'",
",",
"False",
")",
"or",
"sel... | Allow the minion to delete a specific function from its own mine | [
"Allow",
"the",
"minion",
"to",
"delete",
"a",
"specific",
"function",
"from",
"its",
"own",
"mine"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L678-L696 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._mine_flush | def _mine_flush(self, load, skip_verify=False):
'''
Allow the minion to delete all of its own mine contents
'''
if not skip_verify and 'id' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
... | python | def _mine_flush(self, load, skip_verify=False):
'''
Allow the minion to delete all of its own mine contents
'''
if not skip_verify and 'id' not in load:
return False
if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
... | [
"def",
"_mine_flush",
"(",
"self",
",",
"load",
",",
"skip_verify",
"=",
"False",
")",
":",
"if",
"not",
"skip_verify",
"and",
"'id'",
"not",
"in",
"load",
":",
"return",
"False",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'minion_data_cache'",
",",
... | Allow the minion to delete all of its own mine contents | [
"Allow",
"the",
"minion",
"to",
"delete",
"all",
"of",
"its",
"own",
"mine",
"contents"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L698-L706 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._file_recv | def _file_recv(self, load):
'''
Allows minions to send files to the master, files are sent to the
master file cache
'''
if any(key not in load for key in ('id', 'path', 'loc')):
return False
if not self.opts['file_recv'] or os.path.isabs(load['path']):
... | python | def _file_recv(self, load):
'''
Allows minions to send files to the master, files are sent to the
master file cache
'''
if any(key not in load for key in ('id', 'path', 'loc')):
return False
if not self.opts['file_recv'] or os.path.isabs(load['path']):
... | [
"def",
"_file_recv",
"(",
"self",
",",
"load",
")",
":",
"if",
"any",
"(",
"key",
"not",
"in",
"load",
"for",
"key",
"in",
"(",
"'id'",
",",
"'path'",
",",
"'loc'",
")",
")",
":",
"return",
"False",
"if",
"not",
"self",
".",
"opts",
"[",
"'file_r... | Allows minions to send files to the master, files are sent to the
master file cache | [
"Allows",
"minions",
"to",
"send",
"files",
"to",
"the",
"master",
"files",
"are",
"sent",
"to",
"the",
"master",
"file",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L708-L767 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._pillar | def _pillar(self, load):
'''
Return the pillar data for the minion
'''
if any(key not in load for key in ('id', 'grains')):
return False
# pillar = salt.pillar.Pillar(
log.debug('Master _pillar using ext: %s', load.get('ext'))
pillar = salt.pillar.get_p... | python | def _pillar(self, load):
'''
Return the pillar data for the minion
'''
if any(key not in load for key in ('id', 'grains')):
return False
# pillar = salt.pillar.Pillar(
log.debug('Master _pillar using ext: %s', load.get('ext'))
pillar = salt.pillar.get_p... | [
"def",
"_pillar",
"(",
"self",
",",
"load",
")",
":",
"if",
"any",
"(",
"key",
"not",
"in",
"load",
"for",
"key",
"in",
"(",
"'id'",
",",
"'grains'",
")",
")",
":",
"return",
"False",
"# pillar = salt.pillar.Pillar(",
"log",
".",
"debug",
"(",
"... | Return the pillar data for the minion | [
"Return",
"the",
"pillar",
"data",
"for",
"the",
"minion"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L769-L792 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._minion_event | def _minion_event(self, load):
'''
Receive an event from the minion and fire it on the master event
interface
'''
if 'id' not in load:
return False
if 'events' not in load and ('tag' not in load or 'data' not in load):
return False
if 'even... | python | def _minion_event(self, load):
'''
Receive an event from the minion and fire it on the master event
interface
'''
if 'id' not in load:
return False
if 'events' not in load and ('tag' not in load or 'data' not in load):
return False
if 'even... | [
"def",
"_minion_event",
"(",
"self",
",",
"load",
")",
":",
"if",
"'id'",
"not",
"in",
"load",
":",
"return",
"False",
"if",
"'events'",
"not",
"in",
"load",
"and",
"(",
"'tag'",
"not",
"in",
"load",
"or",
"'data'",
"not",
"in",
"load",
")",
":",
"... | Receive an event from the minion and fire it on the master event
interface | [
"Receive",
"an",
"event",
"from",
"the",
"minion",
"and",
"fire",
"it",
"on",
"the",
"master",
"event",
"interface"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L794-L815 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._return | def _return(self, load):
'''
Handle the return data sent from the minions
'''
# Generate EndTime
endtime = salt.utils.jid.jid_to_time(salt.utils.jid.gen_jid(self.opts))
# If the return data is invalid, just ignore it
if any(key not in load for key in ('return', 'j... | python | def _return(self, load):
'''
Handle the return data sent from the minions
'''
# Generate EndTime
endtime = salt.utils.jid.jid_to_time(salt.utils.jid.gen_jid(self.opts))
# If the return data is invalid, just ignore it
if any(key not in load for key in ('return', 'j... | [
"def",
"_return",
"(",
"self",
",",
"load",
")",
":",
"# Generate EndTime",
"endtime",
"=",
"salt",
".",
"utils",
".",
"jid",
".",
"jid_to_time",
"(",
"salt",
".",
"utils",
".",
"jid",
".",
"gen_jid",
"(",
"self",
".",
"opts",
")",
")",
"# If the retur... | Handle the return data sent from the minions | [
"Handle",
"the",
"return",
"data",
"sent",
"from",
"the",
"minions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L817-L848 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs._syndic_return | def _syndic_return(self, load):
'''
Receive a syndic minion return and format it to look like returns from
individual minions.
'''
# Verify the load
if any(key not in load for key in ('return', 'jid', 'id')):
return None
# if we have a load, save it
... | python | def _syndic_return(self, load):
'''
Receive a syndic minion return and format it to look like returns from
individual minions.
'''
# Verify the load
if any(key not in load for key in ('return', 'jid', 'id')):
return None
# if we have a load, save it
... | [
"def",
"_syndic_return",
"(",
"self",
",",
"load",
")",
":",
"# Verify the load",
"if",
"any",
"(",
"key",
"not",
"in",
"load",
"for",
"key",
"in",
"(",
"'return'",
",",
"'jid'",
",",
"'id'",
")",
")",
":",
"return",
"None",
"# if we have a load, save it",... | Receive a syndic minion return and format it to look like returns from
individual minions. | [
"Receive",
"a",
"syndic",
"minion",
"return",
"and",
"format",
"it",
"to",
"look",
"like",
"returns",
"from",
"individual",
"minions",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L850-L870 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.minion_runner | def minion_runner(self, load):
'''
Execute a runner from a minion, return the runner's function data
'''
if 'peer_run' not in self.opts:
return {}
if not isinstance(self.opts['peer_run'], dict):
return {}
if any(key not in load for key in ('fun', '... | python | def minion_runner(self, load):
'''
Execute a runner from a minion, return the runner's function data
'''
if 'peer_run' not in self.opts:
return {}
if not isinstance(self.opts['peer_run'], dict):
return {}
if any(key not in load for key in ('fun', '... | [
"def",
"minion_runner",
"(",
"self",
",",
"load",
")",
":",
"if",
"'peer_run'",
"not",
"in",
"self",
".",
"opts",
":",
"return",
"{",
"}",
"if",
"not",
"isinstance",
"(",
"self",
".",
"opts",
"[",
"'peer_run'",
"]",
",",
"dict",
")",
":",
"return",
... | Execute a runner from a minion, return the runner's function data | [
"Execute",
"a",
"runner",
"from",
"a",
"minion",
"return",
"the",
"runner",
"s",
"function",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L872-L908 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.pub_ret | def pub_ret(self, load, skip_verify=False):
'''
Request the return data from a specific jid, only allowed
if the requesting minion also initialted the execution.
'''
if not skip_verify and any(key not in load for key in ('jid', 'id')):
return {}
else:
... | python | def pub_ret(self, load, skip_verify=False):
'''
Request the return data from a specific jid, only allowed
if the requesting minion also initialted the execution.
'''
if not skip_verify and any(key not in load for key in ('jid', 'id')):
return {}
else:
... | [
"def",
"pub_ret",
"(",
"self",
",",
"load",
",",
"skip_verify",
"=",
"False",
")",
":",
"if",
"not",
"skip_verify",
"and",
"any",
"(",
"key",
"not",
"in",
"load",
"for",
"key",
"in",
"(",
"'jid'",
",",
"'id'",
")",
")",
":",
"return",
"{",
"}",
"... | Request the return data from a specific jid, only allowed
if the requesting minion also initialted the execution. | [
"Request",
"the",
"return",
"data",
"from",
"a",
"specific",
"jid",
"only",
"allowed",
"if",
"the",
"requesting",
"minion",
"also",
"initialted",
"the",
"execution",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L910-L928 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.minion_pub | def minion_pub(self, load):
'''
Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt functions... | python | def minion_pub(self, load):
'''
Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt functions... | [
"def",
"minion_pub",
"(",
"self",
",",
"load",
")",
":",
"if",
"not",
"self",
".",
"__verify_minion_publish",
"(",
"load",
")",
":",
"return",
"{",
"}",
"# Set up the publication payload",
"pub_load",
"=",
"{",
"'fun'",
":",
"load",
"[",
"'fun'",
"]",
",",... | Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt functions, so the minions can only publish allowed salt f... | [
"Publish",
"a",
"command",
"initiated",
"from",
"a",
"minion",
"this",
"method",
"executes",
"minion",
"restrictions",
"so",
"that",
"the",
"minion",
"publication",
"will",
"only",
"work",
"if",
"it",
"is",
"enabled",
"in",
"the",
"config",
".",
"The",
"conf... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L930-L984 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.minion_publish | def minion_publish(self, load):
'''
Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt funct... | python | def minion_publish(self, load):
'''
Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt funct... | [
"def",
"minion_publish",
"(",
"self",
",",
"load",
")",
":",
"if",
"not",
"self",
".",
"__verify_minion_publish",
"(",
"load",
")",
":",
"return",
"{",
"}",
"# Set up the publication payload",
"pub_load",
"=",
"{",
"'fun'",
":",
"load",
"[",
"'fun'",
"]",
... | Publish a command initiated from a minion, this method executes minion
restrictions so that the minion publication will only work if it is
enabled in the config.
The configuration on the master allows minions to be matched to
salt functions, so the minions can only publish allowed salt f... | [
"Publish",
"a",
"command",
"initiated",
"from",
"a",
"minion",
"this",
"method",
"executes",
"minion",
"restrictions",
"so",
"that",
"the",
"minion",
"publication",
"will",
"only",
"work",
"if",
"it",
"is",
"enabled",
"in",
"the",
"config",
".",
"The",
"conf... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L986-L1060 | train |
saltstack/salt | salt/daemons/masterapi.py | RemoteFuncs.revoke_auth | def revoke_auth(self, load):
'''
Allow a minion to request revocation of its own key
'''
if 'id' not in load:
return False
keyapi = salt.key.Key(self.opts)
keyapi.delete_key(load['id'],
preserve_minions=load.get('preserve_minion_cache... | python | def revoke_auth(self, load):
'''
Allow a minion to request revocation of its own key
'''
if 'id' not in load:
return False
keyapi = salt.key.Key(self.opts)
keyapi.delete_key(load['id'],
preserve_minions=load.get('preserve_minion_cache... | [
"def",
"revoke_auth",
"(",
"self",
",",
"load",
")",
":",
"if",
"'id'",
"not",
"in",
"load",
":",
"return",
"False",
"keyapi",
"=",
"salt",
".",
"key",
".",
"Key",
"(",
"self",
".",
"opts",
")",
"keyapi",
".",
"delete_key",
"(",
"load",
"[",
"'id'"... | Allow a minion to request revocation of its own key | [
"Allow",
"a",
"minion",
"to",
"request",
"revocation",
"of",
"its",
"own",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L1062-L1072 | train |
saltstack/salt | salt/daemons/masterapi.py | LocalFuncs.runner | def runner(self, load):
'''
Send a master control function back to the runner system
'''
# All runner opts pass through eauth
auth_type, err_name, key = self._prep_auth_info(load)
# Authenticate
auth_check = self.loadauth.check_authentication(load, auth_type)
... | python | def runner(self, load):
'''
Send a master control function back to the runner system
'''
# All runner opts pass through eauth
auth_type, err_name, key = self._prep_auth_info(load)
# Authenticate
auth_check = self.loadauth.check_authentication(load, auth_type)
... | [
"def",
"runner",
"(",
"self",
",",
"load",
")",
":",
"# All runner opts pass through eauth",
"auth_type",
",",
"err_name",
",",
"key",
"=",
"self",
".",
"_prep_auth_info",
"(",
"load",
")",
"# Authenticate",
"auth_check",
"=",
"self",
".",
"loadauth",
".",
"ch... | Send a master control function back to the runner system | [
"Send",
"a",
"master",
"control",
"function",
"back",
"to",
"the",
"runner",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L1108-L1149 | train |
saltstack/salt | salt/daemons/masterapi.py | LocalFuncs.wheel | def wheel(self, load):
'''
Send a master control function back to the wheel system
'''
# All wheel ops pass through eauth
auth_type, err_name, key = self._prep_auth_info(load)
# Authenticate
auth_check = self.loadauth.check_authentication(
load,
... | python | def wheel(self, load):
'''
Send a master control function back to the wheel system
'''
# All wheel ops pass through eauth
auth_type, err_name, key = self._prep_auth_info(load)
# Authenticate
auth_check = self.loadauth.check_authentication(
load,
... | [
"def",
"wheel",
"(",
"self",
",",
"load",
")",
":",
"# All wheel ops pass through eauth",
"auth_type",
",",
"err_name",
",",
"key",
"=",
"self",
".",
"_prep_auth_info",
"(",
"load",
")",
"# Authenticate",
"auth_check",
"=",
"self",
".",
"loadauth",
".",
"check... | Send a master control function back to the wheel system | [
"Send",
"a",
"master",
"control",
"function",
"back",
"to",
"the",
"wheel",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L1151-L1213 | train |
saltstack/salt | salt/daemons/masterapi.py | LocalFuncs.mk_token | def mk_token(self, load):
'''
Create and return an authentication token, the clear load needs to
contain the eauth key and the needed authentication creds.
'''
token = self.loadauth.mk_token(load)
if not token:
log.warning('Authentication failure of type "eaut... | python | def mk_token(self, load):
'''
Create and return an authentication token, the clear load needs to
contain the eauth key and the needed authentication creds.
'''
token = self.loadauth.mk_token(load)
if not token:
log.warning('Authentication failure of type "eaut... | [
"def",
"mk_token",
"(",
"self",
",",
"load",
")",
":",
"token",
"=",
"self",
".",
"loadauth",
".",
"mk_token",
"(",
"load",
")",
"if",
"not",
"token",
":",
"log",
".",
"warning",
"(",
"'Authentication failure of type \"eauth\" occurred.'",
")",
"return",
"''... | Create and return an authentication token, the clear load needs to
contain the eauth key and the needed authentication creds. | [
"Create",
"and",
"return",
"an",
"authentication",
"token",
"the",
"clear",
"load",
"needs",
"to",
"contain",
"the",
"eauth",
"key",
"and",
"the",
"needed",
"authentication",
"creds",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L1215-L1224 | train |
saltstack/salt | salt/daemons/masterapi.py | LocalFuncs.publish | def publish(self, load):
'''
This method sends out publications to the minions, it can only be used
by the LocalClient.
'''
extra = load.get('kwargs', {})
publisher_acl = salt.acl.PublisherACL(self.opts['publisher_acl_blacklist'])
if publisher_acl.user_is_blackl... | python | def publish(self, load):
'''
This method sends out publications to the minions, it can only be used
by the LocalClient.
'''
extra = load.get('kwargs', {})
publisher_acl = salt.acl.PublisherACL(self.opts['publisher_acl_blacklist'])
if publisher_acl.user_is_blackl... | [
"def",
"publish",
"(",
"self",
",",
"load",
")",
":",
"extra",
"=",
"load",
".",
"get",
"(",
"'kwargs'",
",",
"{",
"}",
")",
"publisher_acl",
"=",
"salt",
".",
"acl",
".",
"PublisherACL",
"(",
"self",
".",
"opts",
"[",
"'publisher_acl_blacklist'",
"]",... | This method sends out publications to the minions, it can only be used
by the LocalClient. | [
"This",
"method",
"sends",
"out",
"publications",
"to",
"the",
"minions",
"it",
"can",
"only",
"be",
"used",
"by",
"the",
"LocalClient",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/daemons/masterapi.py#L1234-L1428 | train |
saltstack/salt | salt/engines/slack.py | start | def start(token,
control=False,
trigger='!',
groups=None,
groups_pillar_name=None,
fire_all=False,
tag='salt/engines/slack'):
'''
Listen to slack events and forward them to salt, new version
'''
if (not token) or (not token.startswith('xoxb'))... | python | def start(token,
control=False,
trigger='!',
groups=None,
groups_pillar_name=None,
fire_all=False,
tag='salt/engines/slack'):
'''
Listen to slack events and forward them to salt, new version
'''
if (not token) or (not token.startswith('xoxb'))... | [
"def",
"start",
"(",
"token",
",",
"control",
"=",
"False",
",",
"trigger",
"=",
"'!'",
",",
"groups",
"=",
"None",
",",
"groups_pillar_name",
"=",
"None",
",",
"fire_all",
"=",
"False",
",",
"tag",
"=",
"'salt/engines/slack'",
")",
":",
"if",
"(",
"no... | Listen to slack events and forward them to salt, new version | [
"Listen",
"to",
"slack",
"events",
"and",
"forward",
"them",
"to",
"salt",
"new",
"version"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L828-L849 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.get_slack_users | def get_slack_users(self, token):
'''
Get all users from Slack
'''
ret = salt.utils.slack.query(function='users',
api_key=token,
opts=__opts__)
users = {}
if 'message' in ret:
for item ... | python | def get_slack_users(self, token):
'''
Get all users from Slack
'''
ret = salt.utils.slack.query(function='users',
api_key=token,
opts=__opts__)
users = {}
if 'message' in ret:
for item ... | [
"def",
"get_slack_users",
"(",
"self",
",",
"token",
")",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"slack",
".",
"query",
"(",
"function",
"=",
"'users'",
",",
"api_key",
"=",
"token",
",",
"opts",
"=",
"__opts__",
")",
"users",
"=",
"{",
"}",
"... | Get all users from Slack | [
"Get",
"all",
"users",
"from",
"Slack"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L197-L212 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.get_slack_channels | def get_slack_channels(self, token):
'''
Get all channel names from Slack
'''
ret = salt.utils.slack.query(
function='rooms',
api_key=token,
# These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged
opts={... | python | def get_slack_channels(self, token):
'''
Get all channel names from Slack
'''
ret = salt.utils.slack.query(
function='rooms',
api_key=token,
# These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged
opts={... | [
"def",
"get_slack_channels",
"(",
"self",
",",
"token",
")",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"slack",
".",
"query",
"(",
"function",
"=",
"'rooms'",
",",
"api_key",
"=",
"token",
",",
"# These won't be honored until https://github.com/saltstack/salt/pu... | Get all channel names from Slack | [
"Get",
"all",
"channel",
"names",
"from",
"Slack"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L214-L231 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.get_config_groups | def get_config_groups(self, groups_conf, groups_pillar_name):
'''
get info from groups in config, and from the named pillar
todo: add specification for the minion to use to recover pillar
'''
# Get groups
# Default to returning something that'll never match
ret_g... | python | def get_config_groups(self, groups_conf, groups_pillar_name):
'''
get info from groups in config, and from the named pillar
todo: add specification for the minion to use to recover pillar
'''
# Get groups
# Default to returning something that'll never match
ret_g... | [
"def",
"get_config_groups",
"(",
"self",
",",
"groups_conf",
",",
"groups_pillar_name",
")",
":",
"# Get groups",
"# Default to returning something that'll never match",
"ret_groups",
"=",
"{",
"'default'",
":",
"{",
"'users'",
":",
"set",
"(",
")",
",",
"'commands'",... | get info from groups in config, and from the named pillar
todo: add specification for the minion to use to recover pillar | [
"get",
"info",
"from",
"groups",
"in",
"config",
"and",
"from",
"the",
"named",
"pillar"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L233-L286 | train |
saltstack/salt | salt/engines/slack.py | SlackClient._groups_from_pillar | def _groups_from_pillar(self, pillar_name):
'''
pillar_prefix is the pillar.get syntax for the pillar to be queried.
Group name is gotten via the equivalent of using
``salt['pillar.get']('{}:{}'.format(pillar_prefix, group_name))``
in a jinja template.
returns a dictiona... | python | def _groups_from_pillar(self, pillar_name):
'''
pillar_prefix is the pillar.get syntax for the pillar to be queried.
Group name is gotten via the equivalent of using
``salt['pillar.get']('{}:{}'.format(pillar_prefix, group_name))``
in a jinja template.
returns a dictiona... | [
"def",
"_groups_from_pillar",
"(",
"self",
",",
"pillar_name",
")",
":",
"if",
"pillar_name",
"and",
"__opts__",
"[",
"'__role'",
"]",
"==",
"'minion'",
":",
"pillar_groups",
"=",
"__salt__",
"[",
"'pillar.get'",
"]",
"(",
"pillar_name",
",",
"{",
"}",
")",
... | pillar_prefix is the pillar.get syntax for the pillar to be queried.
Group name is gotten via the equivalent of using
``salt['pillar.get']('{}:{}'.format(pillar_prefix, group_name))``
in a jinja template.
returns a dictionary (unless the pillar is mis-formatted)
XXX: instead of ... | [
"pillar_prefix",
"is",
"the",
"pillar",
".",
"get",
"syntax",
"for",
"the",
"pillar",
"to",
"be",
"queried",
".",
"Group",
"name",
"is",
"gotten",
"via",
"the",
"equivalent",
"of",
"using",
"salt",
"[",
"pillar",
".",
"get",
"]",
"(",
"{}",
":",
"{}",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L288-L306 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.fire | def fire(self, tag, msg):
'''
This replaces a function in main called 'fire'
It fires an event into the salt bus.
'''
if __opts__.get('__role') == 'master':
fire_master = salt.utils.event.get_master_event(
__opts__,
__opts__['sock_dir'... | python | def fire(self, tag, msg):
'''
This replaces a function in main called 'fire'
It fires an event into the salt bus.
'''
if __opts__.get('__role') == 'master':
fire_master = salt.utils.event.get_master_event(
__opts__,
__opts__['sock_dir'... | [
"def",
"fire",
"(",
"self",
",",
"tag",
",",
"msg",
")",
":",
"if",
"__opts__",
".",
"get",
"(",
"'__role'",
")",
"==",
"'master'",
":",
"fire_master",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"get_master_event",
"(",
"__opts__",
",",
"__opts__",
... | This replaces a function in main called 'fire'
It fires an event into the salt bus. | [
"This",
"replaces",
"a",
"function",
"in",
"main",
"called",
"fire"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L308-L324 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.can_user_run | def can_user_run(self, user, command, groups):
'''
Break out the permissions into the following:
Check whether a user is in any group, including whether a group has the '*' membership
:type user: str
:param user: The username being checked against
:type command: str
... | python | def can_user_run(self, user, command, groups):
'''
Break out the permissions into the following:
Check whether a user is in any group, including whether a group has the '*' membership
:type user: str
:param user: The username being checked against
:type command: str
... | [
"def",
"can_user_run",
"(",
"self",
",",
"user",
",",
"command",
",",
"groups",
")",
":",
"log",
".",
"info",
"(",
"'%s wants to run %s with groups %s'",
",",
"user",
",",
"command",
",",
"groups",
")",
"for",
"key",
",",
"val",
"in",
"groups",
".",
"ite... | Break out the permissions into the following:
Check whether a user is in any group, including whether a group has the '*' membership
:type user: str
:param user: The username being checked against
:type command: str
:param command: The command that is being invoked (e.g. test.... | [
"Break",
"out",
"the",
"permissions",
"into",
"the",
"following",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L326-L360 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.commandline_to_list | def commandline_to_list(self, cmdline_str, trigger_string):
'''
cmdline_str is the string of the command line
trigger_string is the trigger string, to be removed
'''
cmdline = salt.utils.args.shlex_split(cmdline_str[len(trigger_string):])
# Remove slack url parsing
... | python | def commandline_to_list(self, cmdline_str, trigger_string):
'''
cmdline_str is the string of the command line
trigger_string is the trigger string, to be removed
'''
cmdline = salt.utils.args.shlex_split(cmdline_str[len(trigger_string):])
# Remove slack url parsing
... | [
"def",
"commandline_to_list",
"(",
"self",
",",
"cmdline_str",
",",
"trigger_string",
")",
":",
"cmdline",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"shlex_split",
"(",
"cmdline_str",
"[",
"len",
"(",
"trigger_string",
")",
":",
"]",
")",
"# Remove slack ... | cmdline_str is the string of the command line
trigger_string is the trigger string, to be removed | [
"cmdline_str",
"is",
"the",
"string",
"of",
"the",
"command",
"line",
"trigger_string",
"is",
"the",
"trigger",
"string",
"to",
"be",
"removed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L362-L380 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.control_message_target | def control_message_target(self, slack_user_name, text, loaded_groups, trigger_string):
'''Returns a tuple of (target, cmdline,) for the response
Raises IndexError if a user can't be looked up from all_slack_users
Returns (False, False) if the user doesn't have permission
These are re... | python | def control_message_target(self, slack_user_name, text, loaded_groups, trigger_string):
'''Returns a tuple of (target, cmdline,) for the response
Raises IndexError if a user can't be looked up from all_slack_users
Returns (False, False) if the user doesn't have permission
These are re... | [
"def",
"control_message_target",
"(",
"self",
",",
"slack_user_name",
",",
"text",
",",
"loaded_groups",
",",
"trigger_string",
")",
":",
"# Trim the trigger string from the front",
"# cmdline = _text[1:].split(' ', 1)",
"cmdline",
"=",
"self",
".",
"commandline_to_list",
"... | Returns a tuple of (target, cmdline,) for the response
Raises IndexError if a user can't be looked up from all_slack_users
Returns (False, False) if the user doesn't have permission
These are returned together because the commandline and the targeting
interact with the group config (s... | [
"Returns",
"a",
"tuple",
"of",
"(",
"target",
"cmdline",
")",
"for",
"the",
"response"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L382-L424 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.message_text | def message_text(self, m_data):
'''
Raises ValueError if a value doesn't work out, and TypeError if
this isn't a message type
'''
if m_data.get('type') != 'message':
raise TypeError('This is not a message')
# Edited messages have text in message
_text ... | python | def message_text(self, m_data):
'''
Raises ValueError if a value doesn't work out, and TypeError if
this isn't a message type
'''
if m_data.get('type') != 'message':
raise TypeError('This is not a message')
# Edited messages have text in message
_text ... | [
"def",
"message_text",
"(",
"self",
",",
"m_data",
")",
":",
"if",
"m_data",
".",
"get",
"(",
"'type'",
")",
"!=",
"'message'",
":",
"raise",
"TypeError",
"(",
"'This is not a message'",
")",
"# Edited messages have text in message",
"_text",
"=",
"m_data",
".",... | Raises ValueError if a value doesn't work out, and TypeError if
this isn't a message type | [
"Raises",
"ValueError",
"if",
"a",
"value",
"doesn",
"t",
"work",
"out",
"and",
"TypeError",
"if",
"this",
"isn",
"t",
"a",
"message",
"type"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L426-L446 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.generate_triggered_messages | def generate_triggered_messages(self, token, trigger_string, groups, groups_pillar_name):
'''
slack_token = string
trigger_string = string
input_valid_users = set
input_valid_commands = set
When the trigger_string prefixes the message text, yields a dictionary
of... | python | def generate_triggered_messages(self, token, trigger_string, groups, groups_pillar_name):
'''
slack_token = string
trigger_string = string
input_valid_users = set
input_valid_commands = set
When the trigger_string prefixes the message text, yields a dictionary
of... | [
"def",
"generate_triggered_messages",
"(",
"self",
",",
"token",
",",
"trigger_string",
",",
"groups",
",",
"groups_pillar_name",
")",
":",
"all_slack_users",
"=",
"self",
".",
"get_slack_users",
"(",
"token",
")",
"# re-checks this if we have an negative lookup result",
... | slack_token = string
trigger_string = string
input_valid_users = set
input_valid_commands = set
When the trigger_string prefixes the message text, yields a dictionary
of::
{
'message_data': m_data,
'cmdline': cmdline_list, # this is a... | [
"slack_token",
"=",
"string",
"trigger_string",
"=",
"string",
"input_valid_users",
"=",
"set",
"input_valid_commands",
"=",
"set"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L448-L569 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.get_target | def get_target(self, permitted_group, cmdline, alias_cmdline):
'''
When we are permitted to run a command on a target, look to see
what the default targeting is for that group, and for that specific
command (if provided).
It's possible for None or False to be the result of eithe... | python | def get_target(self, permitted_group, cmdline, alias_cmdline):
'''
When we are permitted to run a command on a target, look to see
what the default targeting is for that group, and for that specific
command (if provided).
It's possible for None or False to be the result of eithe... | [
"def",
"get_target",
"(",
"self",
",",
"permitted_group",
",",
"cmdline",
",",
"alias_cmdline",
")",
":",
"# Default to targeting all minions with a type of glob",
"null_target",
"=",
"{",
"'target'",
":",
"'*'",
",",
"'tgt_type'",
":",
"'glob'",
"}",
"def",
"check_... | When we are permitted to run a command on a target, look to see
what the default targeting is for that group, and for that specific
command (if provided).
It's possible for None or False to be the result of either, which means
that it's expected that the caller provide a specific target... | [
"When",
"we",
"are",
"permitted",
"to",
"run",
"a",
"command",
"on",
"a",
"target",
"look",
"to",
"see",
"what",
"the",
"default",
"targeting",
"is",
"for",
"that",
"group",
"and",
"for",
"that",
"specific",
"command",
"(",
"if",
"provided",
")",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L571-L631 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.format_return_text | def format_return_text(self, data, function, **kwargs): # pylint: disable=unused-argument
'''
Print out YAML using the block mode
'''
# emulate the yaml_out output formatter. It relies on a global __opts__ object which
# we can't obviously pass in
try:
try:
... | python | def format_return_text(self, data, function, **kwargs): # pylint: disable=unused-argument
'''
Print out YAML using the block mode
'''
# emulate the yaml_out output formatter. It relies on a global __opts__ object which
# we can't obviously pass in
try:
try:
... | [
"def",
"format_return_text",
"(",
"self",
",",
"data",
",",
"function",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=unused-argument",
"# emulate the yaml_out output formatter. It relies on a global __opts__ object which",
"# we can't obviously pass in",
"try",
":",
"t... | Print out YAML using the block mode | [
"Print",
"out",
"YAML",
"using",
"the",
"block",
"mode"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L633-L655 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.parse_args_and_kwargs | def parse_args_and_kwargs(self, cmdline):
'''
cmdline: list
returns tuple of: args (list), kwargs (dict)
'''
# Parse args and kwargs
args = []
kwargs = {}
if len(cmdline) > 1:
for item in cmdline[1:]:
if '=' in item:
... | python | def parse_args_and_kwargs(self, cmdline):
'''
cmdline: list
returns tuple of: args (list), kwargs (dict)
'''
# Parse args and kwargs
args = []
kwargs = {}
if len(cmdline) > 1:
for item in cmdline[1:]:
if '=' in item:
... | [
"def",
"parse_args_and_kwargs",
"(",
"self",
",",
"cmdline",
")",
":",
"# Parse args and kwargs",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"if",
"len",
"(",
"cmdline",
")",
">",
"1",
":",
"for",
"item",
"in",
"cmdline",
"[",
"1",
":",
"]",
":"... | cmdline: list
returns tuple of: args (list), kwargs (dict) | [
"cmdline",
":",
"list"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L657-L674 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.get_jobs_from_runner | def get_jobs_from_runner(self, outstanding_jids):
'''
Given a list of job_ids, return a dictionary of those job_ids that have
completed and their results.
Query the salt event bus via the jobs runner. jobs.list_job will show
a job in progress, jobs.lookup_jid will return a job t... | python | def get_jobs_from_runner(self, outstanding_jids):
'''
Given a list of job_ids, return a dictionary of those job_ids that have
completed and their results.
Query the salt event bus via the jobs runner. jobs.list_job will show
a job in progress, jobs.lookup_jid will return a job t... | [
"def",
"get_jobs_from_runner",
"(",
"self",
",",
"outstanding_jids",
")",
":",
"# Can't use the runner because of https://github.com/saltstack/salt/issues/40671",
"runner",
"=",
"salt",
".",
"runner",
".",
"RunnerClient",
"(",
"__opts__",
")",
"source",
"=",
"__opts__",
"... | Given a list of job_ids, return a dictionary of those job_ids that have
completed and their results.
Query the salt event bus via the jobs runner. jobs.list_job will show
a job in progress, jobs.lookup_jid will return a job that has
completed.
returns a dictionary of job id: re... | [
"Given",
"a",
"list",
"of",
"job_ids",
"return",
"a",
"dictionary",
"of",
"those",
"job_ids",
"that",
"have",
"completed",
"and",
"their",
"results",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L676-L706 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.run_commands_from_slack_async | def run_commands_from_slack_async(self, message_generator, fire_all, tag, control, interval=1):
'''
Pull any pending messages from the message_generator, sending each
one to either the event bus, the command_async or both, depending on
the values of fire_all and command
'''
... | python | def run_commands_from_slack_async(self, message_generator, fire_all, tag, control, interval=1):
'''
Pull any pending messages from the message_generator, sending each
one to either the event bus, the command_async or both, depending on
the values of fire_all and command
'''
... | [
"def",
"run_commands_from_slack_async",
"(",
"self",
",",
"message_generator",
",",
"fire_all",
",",
"tag",
",",
"control",
",",
"interval",
"=",
"1",
")",
":",
"outstanding",
"=",
"{",
"}",
"# set of job_id that we need to check for",
"while",
"True",
":",
"log",... | Pull any pending messages from the message_generator, sending each
one to either the event bus, the command_async or both, depending on
the values of fire_all and command | [
"Pull",
"any",
"pending",
"messages",
"from",
"the",
"message_generator",
"sending",
"each",
"one",
"to",
"either",
"the",
"event",
"bus",
"the",
"command_async",
"or",
"both",
"depending",
"on",
"the",
"values",
"of",
"fire_all",
"and",
"command"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L708-L774 | train |
saltstack/salt | salt/engines/slack.py | SlackClient.run_command_async | def run_command_async(self, msg):
'''
:type message_generator: generator of dict
:param message_generator: Generates messages from slack that should be run
:type fire_all: bool
:param fire_all: Whether to also fire messages to the event bus
:type tag: str
:para... | python | def run_command_async(self, msg):
'''
:type message_generator: generator of dict
:param message_generator: Generates messages from slack that should be run
:type fire_all: bool
:param fire_all: Whether to also fire messages to the event bus
:type tag: str
:para... | [
"def",
"run_command_async",
"(",
"self",
",",
"msg",
")",
":",
"log",
".",
"debug",
"(",
"'Going to run a command asynchronous'",
")",
"runner_functions",
"=",
"sorted",
"(",
"salt",
".",
"runner",
".",
"Runner",
"(",
"__opts__",
")",
".",
"functions",
")",
... | :type message_generator: generator of dict
:param message_generator: Generates messages from slack that should be run
:type fire_all: bool
:param fire_all: Whether to also fire messages to the event bus
:type tag: str
:param tag: The tag to send to use to send to the event bus
... | [
":",
"type",
"message_generator",
":",
"generator",
"of",
"dict",
":",
"param",
"message_generator",
":",
"Generates",
"messages",
"from",
"slack",
"that",
"should",
"be",
"run"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/slack.py#L776-L825 | train |
saltstack/salt | salt/returners/postgres.py | _get_serv | def _get_serv(ret=None, commit=False):
'''
Return a Pg cursor
'''
_options = _get_options(ret)
try:
conn = psycopg2.connect(host=_options.get('host'),
user=_options.get('user'),
password=_options.get('passwd'),
... | python | def _get_serv(ret=None, commit=False):
'''
Return a Pg cursor
'''
_options = _get_options(ret)
try:
conn = psycopg2.connect(host=_options.get('host'),
user=_options.get('user'),
password=_options.get('passwd'),
... | [
"def",
"_get_serv",
"(",
"ret",
"=",
"None",
",",
"commit",
"=",
"False",
")",
":",
"_options",
"=",
"_get_options",
"(",
"ret",
")",
"try",
":",
"conn",
"=",
"psycopg2",
".",
"connect",
"(",
"host",
"=",
"_options",
".",
"get",
"(",
"'host'",
")",
... | Return a Pg cursor | [
"Return",
"a",
"Pg",
"cursor"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres.py#L190-L220 | train |
saltstack/salt | salt/returners/postgres.py | returner | def returner(ret):
'''
Return data to a postgres server
'''
try:
with _get_serv(ret, commit=True) as cur:
sql = '''INSERT INTO salt_returns
(fun, jid, return, id, success, full_ret)
VALUES (%s, %s, %s, %s, %s, %s)'''
cur.execute(
... | python | def returner(ret):
'''
Return data to a postgres server
'''
try:
with _get_serv(ret, commit=True) as cur:
sql = '''INSERT INTO salt_returns
(fun, jid, return, id, success, full_ret)
VALUES (%s, %s, %s, %s, %s, %s)'''
cur.execute(
... | [
"def",
"returner",
"(",
"ret",
")",
":",
"try",
":",
"with",
"_get_serv",
"(",
"ret",
",",
"commit",
"=",
"True",
")",
"as",
"cur",
":",
"sql",
"=",
"'''INSERT INTO salt_returns\n (fun, jid, return, id, success, full_ret)\n VALUES (%s... | Return data to a postgres server | [
"Return",
"data",
"to",
"a",
"postgres",
"server"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres.py#L223-L241 | train |
saltstack/salt | salt/returners/postgres.py | get_jids | def get_jids():
'''
Return a list of all job ids
'''
with _get_serv(ret=None, commit=True) as cur:
sql = '''SELECT jid, load
FROM jids'''
cur.execute(sql)
data = cur.fetchall()
ret = {}
for jid, load in data:
ret[jid] = salt.utils.jid... | python | def get_jids():
'''
Return a list of all job ids
'''
with _get_serv(ret=None, commit=True) as cur:
sql = '''SELECT jid, load
FROM jids'''
cur.execute(sql)
data = cur.fetchall()
ret = {}
for jid, load in data:
ret[jid] = salt.utils.jid... | [
"def",
"get_jids",
"(",
")",
":",
"with",
"_get_serv",
"(",
"ret",
"=",
"None",
",",
"commit",
"=",
"True",
")",
"as",
"cur",
":",
"sql",
"=",
"'''SELECT jid, load\n FROM jids'''",
"cur",
".",
"execute",
"(",
"sql",
")",
"data",
"=",
"cur",
... | Return a list of all job ids | [
"Return",
"a",
"list",
"of",
"all",
"job",
"ids"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres.py#L344-L359 | train |
saltstack/salt | salt/states/zabbix_hostgroup.py | present | def present(name, **kwargs):
'''
Ensures that the host group exists, eventually creates new host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_... | python | def present(name, **kwargs):
'''
Ensures that the host group exists, eventually creates new host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_... | [
"def",
"present",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"connection_args",
"=",
"{",
"}",
"if",
"'_connection_user'",
"in",
"kwargs",
":",
"connection_args",
"[",
"'_connection_user'",
"]",
"=",
"kwargs",
"[",
"'_connection_user'",
"]",
"if",
"'_co... | Ensures that the host group exists, eventually creates new host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can... | [
"Ensures",
"that",
"the",
"host",
"group",
"exists",
"eventually",
"creates",
"new",
"host",
"group",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_hostgroup.py#L24-L88 | train |
saltstack/salt | salt/states/zabbix_hostgroup.py | absent | def absent(name, **kwargs):
'''
Ensures that the host group does not exist, eventually delete host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connectio... | python | def absent(name, **kwargs):
'''
Ensures that the host group does not exist, eventually delete host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connectio... | [
"def",
"absent",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"# Comment and change messages",
"comment_hostgroup... | Ensures that the host group does not exist, eventually delete host group.
.. versionadded:: 2016.3.0
:param name: name of the host group
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (... | [
"Ensures",
"that",
"the",
"host",
"group",
"does",
"not",
"exist",
"eventually",
"delete",
"host",
"group",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_hostgroup.py#L91-L162 | train |
saltstack/salt | salt/states/glassfish.py | _json_to_unicode | def _json_to_unicode(data):
'''
Encode json values in unicode to match that of the API
'''
ret = {}
for key, value in data.items():
if not isinstance(value, six.text_type):
if isinstance(value, dict):
ret[key] = _json_to_unicode(value)
else:
... | python | def _json_to_unicode(data):
'''
Encode json values in unicode to match that of the API
'''
ret = {}
for key, value in data.items():
if not isinstance(value, six.text_type):
if isinstance(value, dict):
ret[key] = _json_to_unicode(value)
else:
... | [
"def",
"_json_to_unicode",
"(",
"data",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"if",
"isinstance",
"(",... | Encode json values in unicode to match that of the API | [
"Encode",
"json",
"values",
"in",
"unicode",
"to",
"match",
"that",
"of",
"the",
"API"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L36-L49 | train |
saltstack/salt | salt/states/glassfish.py | _is_updated | def _is_updated(old_conf, new_conf):
'''
Compare the API results to the current statefile data
'''
changed = {}
# Dirty json hacking to get parameters in the same format
new_conf = _json_to_unicode(salt.utils.json.loads(
salt.utils.json.dumps(new_conf, ensure_ascii=False)))
old_conf... | python | def _is_updated(old_conf, new_conf):
'''
Compare the API results to the current statefile data
'''
changed = {}
# Dirty json hacking to get parameters in the same format
new_conf = _json_to_unicode(salt.utils.json.loads(
salt.utils.json.dumps(new_conf, ensure_ascii=False)))
old_conf... | [
"def",
"_is_updated",
"(",
"old_conf",
",",
"new_conf",
")",
":",
"changed",
"=",
"{",
"}",
"# Dirty json hacking to get parameters in the same format",
"new_conf",
"=",
"_json_to_unicode",
"(",
"salt",
".",
"utils",
".",
"json",
".",
"loads",
"(",
"salt",
".",
... | Compare the API results to the current statefile data | [
"Compare",
"the",
"API",
"results",
"to",
"the",
"current",
"statefile",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L52-L71 | train |
saltstack/salt | salt/states/glassfish.py | _do_element_present | def _do_element_present(name, elem_type, data, server=None):
'''
Generic function to create or update an element
'''
ret = {'changes': {}, 'update': False, 'create': False, 'error': None}
try:
elements = __salt__['glassfish.enum_{0}'.format(elem_type)]()
except requests.ConnectionError a... | python | def _do_element_present(name, elem_type, data, server=None):
'''
Generic function to create or update an element
'''
ret = {'changes': {}, 'update': False, 'create': False, 'error': None}
try:
elements = __salt__['glassfish.enum_{0}'.format(elem_type)]()
except requests.ConnectionError a... | [
"def",
"_do_element_present",
"(",
"name",
",",
"elem_type",
",",
"data",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'changes'",
":",
"{",
"}",
",",
"'update'",
":",
"False",
",",
"'create'",
":",
"False",
",",
"'error'",
":",
"None",
"}... | Generic function to create or update an element | [
"Generic",
"function",
"to",
"create",
"or",
"update",
"an",
"element"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L74-L110 | train |
saltstack/salt | salt/states/glassfish.py | _do_element_absent | def _do_element_absent(name, elem_type, data, server=None):
'''
Generic function to delete an element
'''
ret = {'delete': False, 'error': None}
try:
elements = __salt__['glassfish.enum_{0}'.format(elem_type)]()
except requests.ConnectionError as error:
if __opts__['test']:
... | python | def _do_element_absent(name, elem_type, data, server=None):
'''
Generic function to delete an element
'''
ret = {'delete': False, 'error': None}
try:
elements = __salt__['glassfish.enum_{0}'.format(elem_type)]()
except requests.ConnectionError as error:
if __opts__['test']:
... | [
"def",
"_do_element_absent",
"(",
"name",
",",
"elem_type",
",",
"data",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'delete'",
":",
"False",
",",
"'error'",
":",
"None",
"}",
"try",
":",
"elements",
"=",
"__salt__",
"[",
"'glassfish.enum_{0}... | Generic function to delete an element | [
"Generic",
"function",
"to",
"delete",
"an",
"element"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L113-L135 | train |
saltstack/salt | salt/states/glassfish.py | connection_factory_present | def connection_factory_present(name,
restype='connection_factory',
description='',
enabled=True,
min_size=1,
max_size=250,
resize_quan... | python | def connection_factory_present(name,
restype='connection_factory',
description='',
enabled=True,
min_size=1,
max_size=250,
resize_quan... | [
"def",
"connection_factory_present",
"(",
"name",
",",
"restype",
"=",
"'connection_factory'",
",",
"description",
"=",
"''",
",",
"enabled",
"=",
"True",
",",
"min_size",
"=",
"1",
",",
"max_size",
"=",
"250",
",",
"resize_quantity",
"=",
"2",
",",
"idle_ti... | Ensures that the Connection Factory is present
name
Name of the connection factory
restype
Type of the connection factory, can be either ``connection_factory``,
``queue_connection_factory` or ``topic_connection_factory``,
defaults to ``connection_factory``
description
... | [
"Ensures",
"that",
"the",
"Connection",
"Factory",
"is",
"present"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L138-L259 | train |
saltstack/salt | salt/states/glassfish.py | connection_factory_absent | def connection_factory_absent(name, both=True, server=None):
'''
Ensures the transaction factory is absent.
name
Name of the connection factory
both
Delete both the pool and the resource, defaults to ``true``
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': ... | python | def connection_factory_absent(name, both=True, server=None):
'''
Ensures the transaction factory is absent.
name
Name of the connection factory
both
Delete both the pool and the resource, defaults to ``true``
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': ... | [
"def",
"connection_factory_absent",
"(",
"name",
",",
"both",
"=",
"True",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"None",
",",
"'changes'",
":",
"{",
"}",
"}"... | Ensures the transaction factory is absent.
name
Name of the connection factory
both
Delete both the pool and the resource, defaults to ``true`` | [
"Ensures",
"the",
"transaction",
"factory",
"is",
"absent",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L262-L288 | train |
saltstack/salt | salt/states/glassfish.py | destination_present | def destination_present(name,
physical,
restype='queue',
description='',
enabled=True,
server=None):
'''
Ensures that the JMS Destination Resource (queue or topic) is present
name
... | python | def destination_present(name,
physical,
restype='queue',
description='',
enabled=True,
server=None):
'''
Ensures that the JMS Destination Resource (queue or topic) is present
name
... | [
"def",
"destination_present",
"(",
"name",
",",
"physical",
",",
"restype",
"=",
"'queue'",
",",
"description",
"=",
"''",
",",
"enabled",
"=",
"True",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
... | Ensures that the JMS Destination Resource (queue or topic) is present
name
The JMS Queue/Topic name
physical
The Physical destination name
restype
The JMS Destination resource type, either ``queue`` or ``topic``, defaults is ``queue``
description
A description of the ... | [
"Ensures",
"that",
"the",
"JMS",
"Destination",
"Resource",
"(",
"queue",
"or",
"topic",
")",
"is",
"present"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L291-L353 | train |
saltstack/salt | salt/states/glassfish.py | destination_absent | def destination_absent(name, server=None):
'''
Ensures that the JMS Destination doesn't exists
name
Name of the JMS Destination
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}
jms_ret = _do_element_absent(name, 'admin_object_resource', {}, server)
if not jms... | python | def destination_absent(name, server=None):
'''
Ensures that the JMS Destination doesn't exists
name
Name of the JMS Destination
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}
jms_ret = _do_element_absent(name, 'admin_object_resource', {}, server)
if not jms... | [
"def",
"destination_absent",
"(",
"name",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"None",
",",
"'changes'",
":",
"{",
"}",
"}",
"jms_ret",
"=",
"_do_element_abse... | Ensures that the JMS Destination doesn't exists
name
Name of the JMS Destination | [
"Ensures",
"that",
"the",
"JMS",
"Destination",
"doesn",
"t",
"exists"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L356-L377 | train |
saltstack/salt | salt/states/glassfish.py | jdbc_datasource_present | def jdbc_datasource_present(name,
description='',
enabled=True,
restype='datasource',
vendor='mysql',
sql_url='',
sql_user='',
... | python | def jdbc_datasource_present(name,
description='',
enabled=True,
restype='datasource',
vendor='mysql',
sql_url='',
sql_user='',
... | [
"def",
"jdbc_datasource_present",
"(",
"name",
",",
"description",
"=",
"''",
",",
"enabled",
"=",
"True",
",",
"restype",
"=",
"'datasource'",
",",
"vendor",
"=",
"'mysql'",
",",
"sql_url",
"=",
"''",
",",
"sql_user",
"=",
"''",
",",
"sql_password",
"=",
... | Ensures that the JDBC Datasource exists
name
Name of the datasource
description
Description of the datasource
enabled
Is the datasource enabled? defaults to ``true``
restype
Resource type, can be ``datasource``, ``xa_datasource``,
``connection_pool_datasource`... | [
"Ensures",
"that",
"the",
"JDBC",
"Datasource",
"exists"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L380-L537 | train |
saltstack/salt | salt/states/glassfish.py | jdbc_datasource_absent | def jdbc_datasource_absent(name, both=True, server=None):
'''
Ensures the JDBC Datasource doesn't exists
name
Name of the datasource
both
Delete both the pool and the resource, defaults to ``true``
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}
pool... | python | def jdbc_datasource_absent(name, both=True, server=None):
'''
Ensures the JDBC Datasource doesn't exists
name
Name of the datasource
both
Delete both the pool and the resource, defaults to ``true``
'''
ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}
pool... | [
"def",
"jdbc_datasource_absent",
"(",
"name",
",",
"both",
"=",
"True",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"None",
",",
"'changes'",
":",
"{",
"}",
"}",
... | Ensures the JDBC Datasource doesn't exists
name
Name of the datasource
both
Delete both the pool and the resource, defaults to ``true`` | [
"Ensures",
"the",
"JDBC",
"Datasource",
"doesn",
"t",
"exists"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L540-L564 | train |
saltstack/salt | salt/states/glassfish.py | system_properties_present | def system_properties_present(server=None, **kwargs):
'''
Ensures that the system properties are present
properties
The system properties
'''
ret = {'name': '', 'result': None, 'comment': None, 'changes': {}}
del kwargs['name']
try:
data = __salt__['glassfish.get_system_pro... | python | def system_properties_present(server=None, **kwargs):
'''
Ensures that the system properties are present
properties
The system properties
'''
ret = {'name': '', 'result': None, 'comment': None, 'changes': {}}
del kwargs['name']
try:
data = __salt__['glassfish.get_system_pro... | [
"def",
"system_properties_present",
"(",
"server",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"''",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"None",
",",
"'changes'",
":",
"{",
"}",
"}",
"del",
"kwargs... | Ensures that the system properties are present
properties
The system properties | [
"Ensures",
"that",
"the",
"system",
"properties",
"are",
"present"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L567-L608 | train |
saltstack/salt | salt/states/glassfish.py | system_properties_absent | def system_properties_absent(name, server=None):
'''
Ensures that the system property doesn't exists
name
Name of the system property
'''
ret = {'name': '', 'result': None, 'comment': None, 'changes': {}}
try:
data = __salt__['glassfish.get_system_properties'](server=server)
... | python | def system_properties_absent(name, server=None):
'''
Ensures that the system property doesn't exists
name
Name of the system property
'''
ret = {'name': '', 'result': None, 'comment': None, 'changes': {}}
try:
data = __salt__['glassfish.get_system_properties'](server=server)
... | [
"def",
"system_properties_absent",
"(",
"name",
",",
"server",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"''",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"None",
",",
"'changes'",
":",
"{",
"}",
"}",
"try",
":",
"data",
"=",
... | Ensures that the system property doesn't exists
name
Name of the system property | [
"Ensures",
"that",
"the",
"system",
"property",
"doesn",
"t",
"exists"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glassfish.py#L611-L647 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.