id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
35,200 | saltstack/salt | salt/cloud/clouds/packet.py | avail_locations | def avail_locations(call=None):
'''
Return available Packet datacenter locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations packet-provider
salt-cloud -f avail_locations packet-provider
'''
if call == 'action':
raise SaltCloudException(
... | python | def avail_locations(call=None):
'''
Return available Packet datacenter locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations packet-provider
salt-cloud -f avail_locations packet-provider
'''
if call == 'action':
raise SaltCloudException(
... | [
"def",
"avail_locations",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudException",
"(",
"'The avail_locations function must be called with -f or --function.'",
")",
"vm_",
"=",
"get_configured_provider",
"(",
")",
"manager"... | Return available Packet datacenter locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations packet-provider
salt-cloud -f avail_locations packet-provider | [
"Return",
"available",
"Packet",
"datacenter",
"locations",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L146-L170 |
35,201 | saltstack/salt | salt/cloud/clouds/packet.py | avail_sizes | def avail_sizes(call=None):
'''
Return available Packet sizes.
CLI Example:
.. code-block:: bash
salt-cloud --list-sizes packet-provider
salt-cloud -f avail_sizes packet-provider
'''
if call == 'action':
raise SaltCloudException(
'The avail_locations functi... | python | def avail_sizes(call=None):
'''
Return available Packet sizes.
CLI Example:
.. code-block:: bash
salt-cloud --list-sizes packet-provider
salt-cloud -f avail_sizes packet-provider
'''
if call == 'action':
raise SaltCloudException(
'The avail_locations functi... | [
"def",
"avail_sizes",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudException",
"(",
"'The avail_locations function must be called with -f or --function.'",
")",
"vm_",
"=",
"get_configured_provider",
"(",
")",
"manager",
... | Return available Packet sizes.
CLI Example:
.. code-block:: bash
salt-cloud --list-sizes packet-provider
salt-cloud -f avail_sizes packet-provider | [
"Return",
"available",
"Packet",
"sizes",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L173-L198 |
35,202 | saltstack/salt | salt/cloud/clouds/packet.py | avail_projects | def avail_projects(call=None):
'''
Return available Packet projects.
CLI Example:
.. code-block:: bash
salt-cloud -f avail_projects packet-provider
'''
if call == 'action':
raise SaltCloudException(
'The avail_projects function must be called with -f or --function.... | python | def avail_projects(call=None):
'''
Return available Packet projects.
CLI Example:
.. code-block:: bash
salt-cloud -f avail_projects packet-provider
'''
if call == 'action':
raise SaltCloudException(
'The avail_projects function must be called with -f or --function.... | [
"def",
"avail_projects",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudException",
"(",
"'The avail_projects function must be called with -f or --function.'",
")",
"vm_",
"=",
"get_configured_provider",
"(",
")",
"manager",
... | Return available Packet projects.
CLI Example:
.. code-block:: bash
salt-cloud -f avail_projects packet-provider | [
"Return",
"available",
"Packet",
"projects",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L201-L224 |
35,203 | saltstack/salt | salt/cloud/clouds/packet.py | _wait_for_status | def _wait_for_status(status_type, object_id, status=None, timeout=500, quiet=True):
'''
Wait for a certain status from Packet.
status_type
device or volume
object_id
The ID of the Packet device or volume to wait on. Required.
status
The status to wait for.
timeout
... | python | def _wait_for_status(status_type, object_id, status=None, timeout=500, quiet=True):
'''
Wait for a certain status from Packet.
status_type
device or volume
object_id
The ID of the Packet device or volume to wait on. Required.
status
The status to wait for.
timeout
... | [
"def",
"_wait_for_status",
"(",
"status_type",
",",
"object_id",
",",
"status",
"=",
"None",
",",
"timeout",
"=",
"500",
",",
"quiet",
"=",
"True",
")",
":",
"if",
"status",
"is",
"None",
":",
"status",
"=",
"\"ok\"",
"interval",
"=",
"5",
"iterations",
... | Wait for a certain status from Packet.
status_type
device or volume
object_id
The ID of the Packet device or volume to wait on. Required.
status
The status to wait for.
timeout
The amount of time to wait for a status to update.
quiet
Log status updates to debu... | [
"Wait",
"for",
"a",
"certain",
"status",
"from",
"Packet",
".",
"status_type",
"device",
"or",
"volume",
"object_id",
"The",
"ID",
"of",
"the",
"Packet",
"device",
"or",
"volume",
"to",
"wait",
"on",
".",
"Required",
".",
"status",
"The",
"status",
"to",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L227-L264 |
35,204 | saltstack/salt | salt/cloud/clouds/packet.py | list_nodes_full | def list_nodes_full(call=None):
'''
List devices, with all available information.
CLI Example:
.. code-block:: bash
salt-cloud -F
salt-cloud --full-query
salt-cloud -f list_nodes_full packet-provider
..
'''
if call == 'action':
raise SaltCloudException(
... | python | def list_nodes_full(call=None):
'''
List devices, with all available information.
CLI Example:
.. code-block:: bash
salt-cloud -F
salt-cloud --full-query
salt-cloud -f list_nodes_full packet-provider
..
'''
if call == 'action':
raise SaltCloudException(
... | [
"def",
"list_nodes_full",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudException",
"(",
"'The list_nodes_full function must be called with -f or --function.'",
")",
"ret",
"=",
"{",
"}",
"for",
"device",
"in",
"get_devi... | List devices, with all available information.
CLI Example:
.. code-block:: bash
salt-cloud -F
salt-cloud --full-query
salt-cloud -f list_nodes_full packet-provider
.. | [
"List",
"devices",
"with",
"all",
"available",
"information",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L437-L461 |
35,205 | saltstack/salt | salt/cloud/clouds/packet.py | destroy | def destroy(name, call=None):
'''
Destroys a Packet device by name.
name
The hostname of VM to be be destroyed.
CLI Example:
.. code-block:: bash
salt-cloud -d name
'''
if call == 'function':
raise SaltCloudException(
'The destroy action must be called... | python | def destroy(name, call=None):
'''
Destroys a Packet device by name.
name
The hostname of VM to be be destroyed.
CLI Example:
.. code-block:: bash
salt-cloud -d name
'''
if call == 'function':
raise SaltCloudException(
'The destroy action must be called... | [
"def",
"destroy",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudException",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a or --action.'",
")",
"__utils__",
"[",
"'cloud.fire_event'",
... | Destroys a Packet device by name.
name
The hostname of VM to be be destroyed.
CLI Example:
.. code-block:: bash
salt-cloud -d name | [
"Destroys",
"a",
"Packet",
"device",
"by",
"name",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L539-L593 |
35,206 | saltstack/salt | salt/beacons/smartos_imgadm.py | beacon | def beacon(config):
'''
Poll imgadm and compare available images
'''
ret = []
# NOTE: lookup current images
current_images = __salt__['imgadm.list'](verbose=True)
# NOTE: apply configuration
if IMGADM_STATE['first_run']:
log.info('Applying configuration for imgadm beacon')
... | python | def beacon(config):
'''
Poll imgadm and compare available images
'''
ret = []
# NOTE: lookup current images
current_images = __salt__['imgadm.list'](verbose=True)
# NOTE: apply configuration
if IMGADM_STATE['first_run']:
log.info('Applying configuration for imgadm beacon')
... | [
"def",
"beacon",
"(",
"config",
")",
":",
"ret",
"=",
"[",
"]",
"# NOTE: lookup current images",
"current_images",
"=",
"__salt__",
"[",
"'imgadm.list'",
"]",
"(",
"verbose",
"=",
"True",
")",
"# NOTE: apply configuration",
"if",
"IMGADM_STATE",
"[",
"'first_run'"... | Poll imgadm and compare available images | [
"Poll",
"imgadm",
"and",
"compare",
"available",
"images"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/smartos_imgadm.py#L69-L117 |
35,207 | saltstack/salt | doc/conf.py | mock_decorator_with_params | def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument
'''
Optionally mock a decorator that takes parameters
E.g.:
@blah(stuff=True)
def things():
pass
'''
def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
if hasattr(fn, '__... | python | def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument
'''
Optionally mock a decorator that takes parameters
E.g.:
@blah(stuff=True)
def things():
pass
'''
def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
if hasattr(fn, '__... | [
"def",
"mock_decorator_with_params",
"(",
"*",
"oargs",
",",
"*",
"*",
"okwargs",
")",
":",
"# pylint: disable=unused-argument",
"def",
"inner",
"(",
"fn",
",",
"*",
"iargs",
",",
"*",
"*",
"ikwargs",
")",
":",
"# pylint: disable=unused-argument",
"if",
"hasattr... | Optionally mock a decorator that takes parameters
E.g.:
@blah(stuff=True)
def things():
pass | [
"Optionally",
"mock",
"a",
"decorator",
"that",
"takes",
"parameters"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/conf.py#L63-L77 |
35,208 | saltstack/salt | salt/states/process.py | absent | def absent(name, user=None, signal=None):
'''
Ensures that the named command is not running.
name
The pattern to match.
user
The user to which the process belongs
signal
Signal to send to the process(es).
'''
ret = {'name': name,
'changes': {},
... | python | def absent(name, user=None, signal=None):
'''
Ensures that the named command is not running.
name
The pattern to match.
user
The user to which the process belongs
signal
Signal to send to the process(es).
'''
ret = {'name': name,
'changes': {},
... | [
"def",
"absent",
"(",
"name",
",",
"user",
"=",
"None",
",",
"signal",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"if",
"__opts_... | Ensures that the named command is not running.
name
The pattern to match.
user
The user to which the process belongs
signal
Signal to send to the process(es). | [
"Ensures",
"that",
"the",
"named",
"command",
"is",
"not",
"running",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/process.py#L21-L61 |
35,209 | saltstack/salt | salt/tops/ext_nodes.py | top | def top(**kwargs):
'''
Run the command configured
'''
if 'id' not in kwargs['opts']:
return {}
cmd = '{0} {1}'.format(
__opts__['master_tops']['ext_nodes'],
kwargs['opts']['id']
)
ndata = salt.utils.yaml.safe_load(
subprocess.Popen(
... | python | def top(**kwargs):
'''
Run the command configured
'''
if 'id' not in kwargs['opts']:
return {}
cmd = '{0} {1}'.format(
__opts__['master_tops']['ext_nodes'],
kwargs['opts']['id']
)
ndata = salt.utils.yaml.safe_load(
subprocess.Popen(
... | [
"def",
"top",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"'id'",
"not",
"in",
"kwargs",
"[",
"'opts'",
"]",
":",
"return",
"{",
"}",
"cmd",
"=",
"'{0} {1}'",
".",
"format",
"(",
"__opts__",
"[",
"'master_tops'",
"]",
"[",
"'ext_nodes'",
"]",
",",
"kw... | Run the command configured | [
"Run",
"the",
"command",
"configured"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/tops/ext_nodes.py#L69-L103 |
35,210 | saltstack/salt | salt/states/gnomedesktop.py | _check_current_value | def _check_current_value(gnome_kwargs, value):
'''
Check the current value with the passed value
'''
current_value = __salt__['gnome.get'](**gnome_kwargs)
return six.text_type(current_value) == six.text_type(value) | python | def _check_current_value(gnome_kwargs, value):
'''
Check the current value with the passed value
'''
current_value = __salt__['gnome.get'](**gnome_kwargs)
return six.text_type(current_value) == six.text_type(value) | [
"def",
"_check_current_value",
"(",
"gnome_kwargs",
",",
"value",
")",
":",
"current_value",
"=",
"__salt__",
"[",
"'gnome.get'",
"]",
"(",
"*",
"*",
"gnome_kwargs",
")",
"return",
"six",
".",
"text_type",
"(",
"current_value",
")",
"==",
"six",
".",
"text_t... | Check the current value with the passed value | [
"Check",
"the",
"current",
"value",
"with",
"the",
"passed",
"value"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L38-L43 |
35,211 | saltstack/salt | salt/states/gnomedesktop.py | _do | def _do(name, gnome_kwargs, preferences):
'''
worker function for the others to use
this handles all the gsetting magic
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': ''}
messages = []
for pref in preferences:
key = pref
... | python | def _do(name, gnome_kwargs, preferences):
'''
worker function for the others to use
this handles all the gsetting magic
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': ''}
messages = []
for pref in preferences:
key = pref
... | [
"def",
"_do",
"(",
"name",
",",
"gnome_kwargs",
",",
"preferences",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"messages",
"=",
"[",
"]",
"for",... | worker function for the others to use
this handles all the gsetting magic | [
"worker",
"function",
"for",
"the",
"others",
"to",
"use",
"this",
"handles",
"all",
"the",
"gsetting",
"magic"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L46-L92 |
35,212 | saltstack/salt | salt/serializers/toml.py | deserialize | def deserialize(stream_or_string, **options):
'''
Deserialize from TOML into Python data structure.
:param stream_or_string: toml stream or string to deserialize.
:param options: options given to lower pytoml module.
'''
try:
if not isinstance(stream_or_string, (bytes, six.string_types... | python | def deserialize(stream_or_string, **options):
'''
Deserialize from TOML into Python data structure.
:param stream_or_string: toml stream or string to deserialize.
:param options: options given to lower pytoml module.
'''
try:
if not isinstance(stream_or_string, (bytes, six.string_types... | [
"def",
"deserialize",
"(",
"stream_or_string",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"stream_or_string",
",",
"(",
"bytes",
",",
"six",
".",
"string_types",
")",
")",
":",
"return",
"toml",
".",
"load",
"(",
"s... | Deserialize from TOML into Python data structure.
:param stream_or_string: toml stream or string to deserialize.
:param options: options given to lower pytoml module. | [
"Deserialize",
"from",
"TOML",
"into",
"Python",
"data",
"structure",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/toml.py#L29-L46 |
35,213 | saltstack/salt | salt/serializers/toml.py | serialize | def serialize(obj, **options):
'''
Serialize Python data to TOML.
:param obj: the data structure to serialize.
:param options: options given to lower pytoml module.
'''
try:
if 'file_out' in options:
return toml.dump(obj, options['file_out'], **options)
else:
... | python | def serialize(obj, **options):
'''
Serialize Python data to TOML.
:param obj: the data structure to serialize.
:param options: options given to lower pytoml module.
'''
try:
if 'file_out' in options:
return toml.dump(obj, options['file_out'], **options)
else:
... | [
"def",
"serialize",
"(",
"obj",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"if",
"'file_out'",
"in",
"options",
":",
"return",
"toml",
".",
"dump",
"(",
"obj",
",",
"options",
"[",
"'file_out'",
"]",
",",
"*",
"*",
"options",
")",
"else",
":",... | Serialize Python data to TOML.
:param obj: the data structure to serialize.
:param options: options given to lower pytoml module. | [
"Serialize",
"Python",
"data",
"to",
"TOML",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/toml.py#L49-L63 |
35,214 | saltstack/salt | salt/renderers/mako.py | render | def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws):
'''
Render the template_file, passing the functions and grains into the
Mako rendering system.
:rtype: string
'''
tmp_data = salt.utils.templates.MAKO(template_file, to_str=True,
salt=__sa... | python | def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws):
'''
Render the template_file, passing the functions and grains into the
Mako rendering system.
:rtype: string
'''
tmp_data = salt.utils.templates.MAKO(template_file, to_str=True,
salt=__sa... | [
"def",
"render",
"(",
"template_file",
",",
"saltenv",
"=",
"'base'",
",",
"sls",
"=",
"''",
",",
"context",
"=",
"None",
",",
"tmplpath",
"=",
"None",
",",
"*",
"*",
"kws",
")",
":",
"tmp_data",
"=",
"salt",
".",
"utils",
".",
"templates",
".",
"M... | Render the template_file, passing the functions and grains into the
Mako rendering system.
:rtype: string | [
"Render",
"the",
"template_file",
"passing",
"the",
"functions",
"and",
"grains",
"into",
"the",
"Mako",
"rendering",
"system",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/mako.py#L15-L35 |
35,215 | saltstack/salt | salt/proxy/fx2.py | init | def init(opts):
'''
This function gets called when the proxy starts up.
We check opts to see if a fallback user and password are supplied.
If they are present, and the primary credentials don't work, then
we try the backup before failing.
Whichever set of credentials works is placed in the pers... | python | def init(opts):
'''
This function gets called when the proxy starts up.
We check opts to see if a fallback user and password are supplied.
If they are present, and the primary credentials don't work, then
we try the backup before failing.
Whichever set of credentials works is placed in the pers... | [
"def",
"init",
"(",
"opts",
")",
":",
"if",
"'host'",
"not",
"in",
"opts",
"[",
"'proxy'",
"]",
":",
"log",
".",
"critical",
"(",
"'No \"host\" key found in pillar for this proxy'",
")",
"return",
"False",
"DETAILS",
"[",
"'host'",
"]",
"=",
"opts",
"[",
"... | This function gets called when the proxy starts up.
We check opts to see if a fallback user and password are supplied.
If they are present, and the primary credentials don't work, then
we try the backup before failing.
Whichever set of credentials works is placed in the persistent
DETAILS dictionar... | [
"This",
"function",
"gets",
"called",
"when",
"the",
"proxy",
"starts",
"up",
".",
"We",
"check",
"opts",
"to",
"see",
"if",
"a",
"fallback",
"user",
"and",
"password",
"are",
"supplied",
".",
"If",
"they",
"are",
"present",
"and",
"the",
"primary",
"cre... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L203-L220 |
35,216 | saltstack/salt | salt/proxy/fx2.py | ping | def ping():
'''
Is the chassis responding?
:return: Returns False if the chassis didn't respond, True otherwise.
'''
r = __salt__['dracr.system_info'](host=DETAILS['host'],
admin_username=DETAILS['admin_username'],
admin_p... | python | def ping():
'''
Is the chassis responding?
:return: Returns False if the chassis didn't respond, True otherwise.
'''
r = __salt__['dracr.system_info'](host=DETAILS['host'],
admin_username=DETAILS['admin_username'],
admin_p... | [
"def",
"ping",
"(",
")",
":",
"r",
"=",
"__salt__",
"[",
"'dracr.system_info'",
"]",
"(",
"host",
"=",
"DETAILS",
"[",
"'host'",
"]",
",",
"admin_username",
"=",
"DETAILS",
"[",
"'admin_username'",
"]",
",",
"admin_password",
"=",
"DETAILS",
"[",
"'admin_p... | Is the chassis responding?
:return: Returns False if the chassis didn't respond, True otherwise. | [
"Is",
"the",
"chassis",
"responding?"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L351-L368 |
35,217 | saltstack/salt | salt/modules/sensehat.py | set_pixel | def set_pixel(x, y, color):
'''
Sets a single pixel on the LED matrix to a specified color.
x
The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
y
The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.
color
The new color of the ... | python | def set_pixel(x, y, color):
'''
Sets a single pixel on the LED matrix to a specified color.
x
The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
y
The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.
color
The new color of the ... | [
"def",
"set_pixel",
"(",
"x",
",",
"y",
",",
"color",
")",
":",
"_sensehat",
".",
"set_pixel",
"(",
"x",
",",
"y",
",",
"color",
")",
"return",
"{",
"'color'",
":",
"color",
"}"
] | Sets a single pixel on the LED matrix to a specified color.
x
The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
y
The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.
color
The new color of the pixel as a list of ``[R, G, B]`` values.... | [
"Sets",
"a",
"single",
"pixel",
"on",
"the",
"LED",
"matrix",
"to",
"a",
"specified",
"color",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L89-L107 |
35,218 | saltstack/salt | salt/modules/sensehat.py | show_message | def show_message(message, msg_type=None,
text_color=None, back_color=None, scroll_speed=0.1):
'''
Displays a message on the LED matrix.
message
The message to display
msg_type
The type of the message. Changes the appearance of the message.
Available types are::
... | python | def show_message(message, msg_type=None,
text_color=None, back_color=None, scroll_speed=0.1):
'''
Displays a message on the LED matrix.
message
The message to display
msg_type
The type of the message. Changes the appearance of the message.
Available types are::
... | [
"def",
"show_message",
"(",
"message",
",",
"msg_type",
"=",
"None",
",",
"text_color",
"=",
"None",
",",
"back_color",
"=",
"None",
",",
"scroll_speed",
"=",
"0.1",
")",
":",
"text_color",
"=",
"text_color",
"or",
"[",
"255",
",",
"255",
",",
"255",
"... | Displays a message on the LED matrix.
message
The message to display
msg_type
The type of the message. Changes the appearance of the message.
Available types are::
error: red text
warning: orange text
success: green text
info:... | [
"Displays",
"a",
"message",
"on",
"the",
"LED",
"matrix",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L140-L189 |
35,219 | saltstack/salt | salt/modules/sensehat.py | show_letter | def show_letter(letter, text_color=None, back_color=None):
'''
Displays a single letter on the LED matrix.
letter
The letter to display
text_color
The color in which the letter is shown. Defaults to '[255, 255, 255]' (white).
back_color
The background color of the display. D... | python | def show_letter(letter, text_color=None, back_color=None):
'''
Displays a single letter on the LED matrix.
letter
The letter to display
text_color
The color in which the letter is shown. Defaults to '[255, 255, 255]' (white).
back_color
The background color of the display. D... | [
"def",
"show_letter",
"(",
"letter",
",",
"text_color",
"=",
"None",
",",
"back_color",
"=",
"None",
")",
":",
"text_color",
"=",
"text_color",
"or",
"[",
"255",
",",
"255",
",",
"255",
"]",
"back_color",
"=",
"back_color",
"or",
"[",
"0",
",",
"0",
... | Displays a single letter on the LED matrix.
letter
The letter to display
text_color
The color in which the letter is shown. Defaults to '[255, 255, 255]' (white).
back_color
The background color of the display. Defaults to '[0, 0, 0]' (black).
CLI Example:
.. code-block:: ... | [
"Displays",
"a",
"single",
"letter",
"on",
"the",
"LED",
"matrix",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L192-L215 |
35,220 | saltstack/salt | salt/modules/netbox.py | _add | def _add(app, endpoint, payload):
'''
POST a payload
'''
nb = _nb_obj(auth_required=True)
try:
return getattr(getattr(nb, app), endpoint).create(**payload)
except RequestError as e:
log.error('%s, %s, %s', e.req.request.headers, e.request_body, e.error)
return False | python | def _add(app, endpoint, payload):
'''
POST a payload
'''
nb = _nb_obj(auth_required=True)
try:
return getattr(getattr(nb, app), endpoint).create(**payload)
except RequestError as e:
log.error('%s, %s, %s', e.req.request.headers, e.request_body, e.error)
return False | [
"def",
"_add",
"(",
"app",
",",
"endpoint",
",",
"payload",
")",
":",
"nb",
"=",
"_nb_obj",
"(",
"auth_required",
"=",
"True",
")",
"try",
":",
"return",
"getattr",
"(",
"getattr",
"(",
"nb",
",",
"app",
")",
",",
"endpoint",
")",
".",
"create",
"(... | POST a payload | [
"POST",
"a",
"payload"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L98-L107 |
35,221 | saltstack/salt | salt/modules/netbox.py | _get | def _get(app, endpoint, id=None, auth_required=False, **kwargs):
'''
Helper function to do a GET request to Netbox.
Returns the actual pynetbox object, which allows manipulation from other functions.
'''
nb = _nb_obj(auth_required=auth_required)
if id:
item = getattr(getattr(nb, app), en... | python | def _get(app, endpoint, id=None, auth_required=False, **kwargs):
'''
Helper function to do a GET request to Netbox.
Returns the actual pynetbox object, which allows manipulation from other functions.
'''
nb = _nb_obj(auth_required=auth_required)
if id:
item = getattr(getattr(nb, app), en... | [
"def",
"_get",
"(",
"app",
",",
"endpoint",
",",
"id",
"=",
"None",
",",
"auth_required",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"nb",
"=",
"_nb_obj",
"(",
"auth_required",
"=",
"auth_required",
")",
"if",
"id",
":",
"item",
"=",
"getattr",... | Helper function to do a GET request to Netbox.
Returns the actual pynetbox object, which allows manipulation from other functions. | [
"Helper",
"function",
"to",
"do",
"a",
"GET",
"request",
"to",
"Netbox",
".",
"Returns",
"the",
"actual",
"pynetbox",
"object",
"which",
"allows",
"manipulation",
"from",
"other",
"functions",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L119-L130 |
35,222 | saltstack/salt | salt/modules/netbox.py | filter_ | def filter_(app, endpoint, **kwargs):
'''
Get a list of items from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
kwargs
Optional arguments that can be used to filter.
... | python | def filter_(app, endpoint, **kwargs):
'''
Get a list of items from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
kwargs
Optional arguments that can be used to filter.
... | [
"def",
"filter_",
"(",
"app",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"[",
"]",
"nb",
"=",
"_nb_obj",
"(",
"auth_required",
"=",
"True",
"if",
"app",
"in",
"AUTH_ENDPOINTS",
"else",
"False",
")",
"nb_query",
"=",
"getattr",
"(... | Get a list of items from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
kwargs
Optional arguments that can be used to filter.
All filter keywords are available in Netbox,
... | [
"Get",
"a",
"list",
"of",
"items",
"from",
"NetBox",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L140-L167 |
35,223 | saltstack/salt | salt/modules/netbox.py | get_ | def get_(app, endpoint, id=None, **kwargs):
'''
Get a single item from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
Returns a single dictionary
To get an item based on ID.
... | python | def get_(app, endpoint, id=None, **kwargs):
'''
Get a single item from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
Returns a single dictionary
To get an item based on ID.
... | [
"def",
"get_",
"(",
"app",
",",
"endpoint",
",",
"id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_dict",
"(",
"_get",
"(",
"app",
",",
"endpoint",
",",
"id",
"=",
"id",
",",
"auth_required",
"=",
"True",
"if",
"app",
"in",
"AUTH_... | Get a single item from NetBox.
app
String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
endpoint
String of app endpoint, e.g., ``sites``, ``regions``, ``devices``
Returns a single dictionary
To get an item based on ID.
.. code-block:: bash
salt myminion netbox.ge... | [
"Get",
"a",
"single",
"item",
"from",
"NetBox",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L170-L194 |
35,224 | saltstack/salt | salt/renderers/aws_kms.py | _cfg | def _cfg(key, default=None):
'''
Return the requested value from the aws_kms key in salt configuration.
If it's not set, return the default.
'''
root_cfg = __salt__.get('config.get', __opts__.get)
kms_cfg = root_cfg('aws_kms', {})
return kms_cfg.get(key, default) | python | def _cfg(key, default=None):
'''
Return the requested value from the aws_kms key in salt configuration.
If it's not set, return the default.
'''
root_cfg = __salt__.get('config.get', __opts__.get)
kms_cfg = root_cfg('aws_kms', {})
return kms_cfg.get(key, default) | [
"def",
"_cfg",
"(",
"key",
",",
"default",
"=",
"None",
")",
":",
"root_cfg",
"=",
"__salt__",
".",
"get",
"(",
"'config.get'",
",",
"__opts__",
".",
"get",
")",
"kms_cfg",
"=",
"root_cfg",
"(",
"'aws_kms'",
",",
"{",
"}",
")",
"return",
"kms_cfg",
"... | Return the requested value from the aws_kms key in salt configuration.
If it's not set, return the default. | [
"Return",
"the",
"requested",
"value",
"from",
"the",
"aws_kms",
"key",
"in",
"salt",
"configuration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L102-L110 |
35,225 | saltstack/salt | salt/renderers/aws_kms.py | _session | def _session():
'''
Return the boto3 session to use for the KMS client.
If aws_kms:profile_name is set in the salt configuration, use that profile.
Otherwise, fall back on the default aws profile.
We use the boto3 profile system to avoid having to duplicate
individual boto3 configuration setti... | python | def _session():
'''
Return the boto3 session to use for the KMS client.
If aws_kms:profile_name is set in the salt configuration, use that profile.
Otherwise, fall back on the default aws profile.
We use the boto3 profile system to avoid having to duplicate
individual boto3 configuration setti... | [
"def",
"_session",
"(",
")",
":",
"profile_name",
"=",
"_cfg",
"(",
"'profile_name'",
")",
"if",
"profile_name",
":",
"log",
".",
"info",
"(",
"'Using the \"%s\" aws profile.'",
",",
"profile_name",
")",
"else",
":",
"log",
".",
"info",
"(",
"'aws_kms:profile_... | Return the boto3 session to use for the KMS client.
If aws_kms:profile_name is set in the salt configuration, use that profile.
Otherwise, fall back on the default aws profile.
We use the boto3 profile system to avoid having to duplicate
individual boto3 configuration settings in salt configuration. | [
"Return",
"the",
"boto3",
"session",
"to",
"use",
"for",
"the",
"KMS",
"client",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L125-L151 |
35,226 | saltstack/salt | salt/renderers/aws_kms.py | _api_decrypt | def _api_decrypt():
'''
Return the response dictionary from the KMS decrypt API call.
'''
kms = _kms()
data_key = _cfg_data_key()
try:
return kms.decrypt(CiphertextBlob=data_key)
except botocore.exceptions.ClientError as orig_exc:
error_code = orig_exc.response.get('Error', {... | python | def _api_decrypt():
'''
Return the response dictionary from the KMS decrypt API call.
'''
kms = _kms()
data_key = _cfg_data_key()
try:
return kms.decrypt(CiphertextBlob=data_key)
except botocore.exceptions.ClientError as orig_exc:
error_code = orig_exc.response.get('Error', {... | [
"def",
"_api_decrypt",
"(",
")",
":",
"kms",
"=",
"_kms",
"(",
")",
"data_key",
"=",
"_cfg_data_key",
"(",
")",
"try",
":",
"return",
"kms",
".",
"decrypt",
"(",
"CiphertextBlob",
"=",
"data_key",
")",
"except",
"botocore",
".",
"exceptions",
".",
"Clien... | Return the response dictionary from the KMS decrypt API call. | [
"Return",
"the",
"response",
"dictionary",
"from",
"the",
"KMS",
"decrypt",
"API",
"call",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L162-L176 |
35,227 | saltstack/salt | salt/renderers/aws_kms.py | _plaintext_data_key | def _plaintext_data_key():
'''
Return the configured KMS data key decrypted and encoded in urlsafe base64.
Cache the result to minimize API calls to AWS.
'''
response = getattr(_plaintext_data_key, 'response', None)
cache_hit = response is not None
if not cache_hit:
response = _api_... | python | def _plaintext_data_key():
'''
Return the configured KMS data key decrypted and encoded in urlsafe base64.
Cache the result to minimize API calls to AWS.
'''
response = getattr(_plaintext_data_key, 'response', None)
cache_hit = response is not None
if not cache_hit:
response = _api_... | [
"def",
"_plaintext_data_key",
"(",
")",
":",
"response",
"=",
"getattr",
"(",
"_plaintext_data_key",
",",
"'response'",
",",
"None",
")",
"cache_hit",
"=",
"response",
"is",
"not",
"None",
"if",
"not",
"cache_hit",
":",
"response",
"=",
"_api_decrypt",
"(",
... | Return the configured KMS data key decrypted and encoded in urlsafe base64.
Cache the result to minimize API calls to AWS. | [
"Return",
"the",
"configured",
"KMS",
"data",
"key",
"decrypted",
"and",
"encoded",
"in",
"urlsafe",
"base64",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L179-L195 |
35,228 | saltstack/salt | salt/renderers/aws_kms.py | _decrypt_ciphertext | def _decrypt_ciphertext(cipher, translate_newlines=False):
'''
Given a blob of ciphertext as a bytestring, try to decrypt
the cipher and return the decrypted string. If the cipher cannot be
decrypted, log the error, and return the ciphertext back out.
'''
if translate_newlines:
cipher = ... | python | def _decrypt_ciphertext(cipher, translate_newlines=False):
'''
Given a blob of ciphertext as a bytestring, try to decrypt
the cipher and return the decrypted string. If the cipher cannot be
decrypted, log the error, and return the ciphertext back out.
'''
if translate_newlines:
cipher = ... | [
"def",
"_decrypt_ciphertext",
"(",
"cipher",
",",
"translate_newlines",
"=",
"False",
")",
":",
"if",
"translate_newlines",
":",
"cipher",
"=",
"cipher",
".",
"replace",
"(",
"r'\\n'",
",",
"'\\n'",
")",
"if",
"hasattr",
"(",
"cipher",
",",
"'encode'",
")",
... | Given a blob of ciphertext as a bytestring, try to decrypt
the cipher and return the decrypted string. If the cipher cannot be
decrypted, log the error, and return the ciphertext back out. | [
"Given",
"a",
"blob",
"of",
"ciphertext",
"as",
"a",
"bytestring",
"try",
"to",
"decrypt",
"the",
"cipher",
"and",
"return",
"the",
"decrypted",
"string",
".",
"If",
"the",
"cipher",
"cannot",
"be",
"decrypted",
"log",
"the",
"error",
"and",
"return",
"the... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L206-L222 |
35,229 | saltstack/salt | salt/renderers/aws_kms.py | _decrypt_object | def _decrypt_object(obj, translate_newlines=False):
'''
Recursively try to decrypt any object.
Recur on objects that are not strings.
Decrypt strings that are valid Fernet tokens.
Return the rest unchanged.
'''
if salt.utils.stringio.is_readable(obj):
return _decrypt_object(obj.getva... | python | def _decrypt_object(obj, translate_newlines=False):
'''
Recursively try to decrypt any object.
Recur on objects that are not strings.
Decrypt strings that are valid Fernet tokens.
Return the rest unchanged.
'''
if salt.utils.stringio.is_readable(obj):
return _decrypt_object(obj.getva... | [
"def",
"_decrypt_object",
"(",
"obj",
",",
"translate_newlines",
"=",
"False",
")",
":",
"if",
"salt",
".",
"utils",
".",
"stringio",
".",
"is_readable",
"(",
"obj",
")",
":",
"return",
"_decrypt_object",
"(",
"obj",
".",
"getvalue",
"(",
")",
",",
"tran... | Recursively try to decrypt any object.
Recur on objects that are not strings.
Decrypt strings that are valid Fernet tokens.
Return the rest unchanged. | [
"Recursively",
"try",
"to",
"decrypt",
"any",
"object",
".",
"Recur",
"on",
"objects",
"that",
"are",
"not",
"strings",
".",
"Decrypt",
"strings",
"that",
"are",
"valid",
"Fernet",
"tokens",
".",
"Return",
"the",
"rest",
"unchanged",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L225-L252 |
35,230 | saltstack/salt | salt/renderers/aws_kms.py | render | def render(data, saltenv='base', sls='', argline='', **kwargs): # pylint: disable=unused-argument
'''
Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption.
'''
translate_newlines = kwargs.get('translate_newlines', False)
return _decrypt_object(data, translate_newline... | python | def render(data, saltenv='base', sls='', argline='', **kwargs): # pylint: disable=unused-argument
'''
Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption.
'''
translate_newlines = kwargs.get('translate_newlines', False)
return _decrypt_object(data, translate_newline... | [
"def",
"render",
"(",
"data",
",",
"saltenv",
"=",
"'base'",
",",
"sls",
"=",
"''",
",",
"argline",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=unused-argument",
"translate_newlines",
"=",
"kwargs",
".",
"get",
"(",
"'translate_newlines'... | Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption. | [
"Decrypt",
"the",
"data",
"to",
"be",
"rendered",
"that",
"was",
"encrypted",
"using",
"AWS",
"KMS",
"envelope",
"encryption",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L255-L260 |
35,231 | saltstack/salt | salt/modules/grains.py | get | def get(key, default='', delimiter=DEFAULT_TARGET_DELIM, ordered=True):
'''
Attempt to retrieve the named value from grains, if the named value is not
available return the passed default. The default return is an empty string.
The value can also represent a value in a nested dict using a ":" delimiter
... | python | def get(key, default='', delimiter=DEFAULT_TARGET_DELIM, ordered=True):
'''
Attempt to retrieve the named value from grains, if the named value is not
available return the passed default. The default return is an empty string.
The value can also represent a value in a nested dict using a ":" delimiter
... | [
"def",
"get",
"(",
"key",
",",
"default",
"=",
"''",
",",
"delimiter",
"=",
"DEFAULT_TARGET_DELIM",
",",
"ordered",
"=",
"True",
")",
":",
"if",
"ordered",
"is",
"True",
":",
"grains",
"=",
"__grains__",
"else",
":",
"grains",
"=",
"salt",
".",
"utils"... | Attempt to retrieve the named value from grains, if the named value is not
available return the passed default. The default return is an empty string.
The value can also represent a value in a nested dict using a ":" delimiter
for the dict. This means that if a dict in grains looks like this::
{'p... | [
"Attempt",
"to",
"retrieve",
"the",
"named",
"value",
"from",
"grains",
"if",
"the",
"named",
"value",
"is",
"not",
"available",
"return",
"the",
"passed",
"default",
".",
"The",
"default",
"return",
"is",
"an",
"empty",
"string",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L80-L123 |
35,232 | saltstack/salt | salt/modules/grains.py | has_value | def has_value(key):
'''
Determine whether a key exists in the grains dictionary.
Given a grains dictionary that contains the following structure::
{'pkg': {'apache': 'httpd'}}
One would determine if the apache key in the pkg dict exists by::
pkg:apache
CLI Example:
.. code-... | python | def has_value(key):
'''
Determine whether a key exists in the grains dictionary.
Given a grains dictionary that contains the following structure::
{'pkg': {'apache': 'httpd'}}
One would determine if the apache key in the pkg dict exists by::
pkg:apache
CLI Example:
.. code-... | [
"def",
"has_value",
"(",
"key",
")",
":",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"traverse_dict_and_list",
"(",
"__grains__",
",",
"key",
",",
"KeyError",
")",
"is",
"not",
"KeyError"
] | Determine whether a key exists in the grains dictionary.
Given a grains dictionary that contains the following structure::
{'pkg': {'apache': 'httpd'}}
One would determine if the apache key in the pkg dict exists by::
pkg:apache
CLI Example:
.. code-block:: bash
salt '*' g... | [
"Determine",
"whether",
"a",
"key",
"exists",
"in",
"the",
"grains",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L126-L147 |
35,233 | saltstack/salt | salt/modules/grains.py | items | def items(sanitize=False):
'''
Return all of the minion's grains
CLI Example:
.. code-block:: bash
salt '*' grains.items
Sanitized CLI Example:
.. code-block:: bash
salt '*' grains.items sanitize=True
'''
if salt.utils.data.is_true(sanitize):
out = dict(__gr... | python | def items(sanitize=False):
'''
Return all of the minion's grains
CLI Example:
.. code-block:: bash
salt '*' grains.items
Sanitized CLI Example:
.. code-block:: bash
salt '*' grains.items sanitize=True
'''
if salt.utils.data.is_true(sanitize):
out = dict(__gr... | [
"def",
"items",
"(",
"sanitize",
"=",
"False",
")",
":",
"if",
"salt",
".",
"utils",
".",
"data",
".",
"is_true",
"(",
"sanitize",
")",
":",
"out",
"=",
"dict",
"(",
"__grains__",
")",
"for",
"key",
",",
"func",
"in",
"six",
".",
"iteritems",
"(",
... | Return all of the minion's grains
CLI Example:
.. code-block:: bash
salt '*' grains.items
Sanitized CLI Example:
.. code-block:: bash
salt '*' grains.items sanitize=True | [
"Return",
"all",
"of",
"the",
"minion",
"s",
"grains"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L150-L173 |
35,234 | saltstack/salt | salt/modules/grains.py | setvals | def setvals(grains, destructive=False):
'''
Set new grains values in the grains config file
destructive
If an operation results in a key being removed, delete the key, too.
Defaults to False.
CLI Example:
.. code-block:: bash
salt '*' grains.setvals "{'key1': 'val1', 'key... | python | def setvals(grains, destructive=False):
'''
Set new grains values in the grains config file
destructive
If an operation results in a key being removed, delete the key, too.
Defaults to False.
CLI Example:
.. code-block:: bash
salt '*' grains.setvals "{'key1': 'val1', 'key... | [
"def",
"setvals",
"(",
"grains",
",",
"destructive",
"=",
"False",
")",
":",
"new_grains",
"=",
"grains",
"if",
"not",
"isinstance",
"(",
"new_grains",
",",
"collections",
".",
"Mapping",
")",
":",
"raise",
"SaltException",
"(",
"'setvals grains must be a dictio... | Set new grains values in the grains config file
destructive
If an operation results in a key being removed, delete the key, too.
Defaults to False.
CLI Example:
.. code-block:: bash
salt '*' grains.setvals "{'key1': 'val1', 'key2': 'val2'}" | [
"Set",
"new",
"grains",
"values",
"in",
"the",
"grains",
"config",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L214-L310 |
35,235 | saltstack/salt | salt/modules/grains.py | get_or_set_hash | def get_or_set_hash(name,
length=8,
chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'):
'''
Perform a one-time generation of a hash and write it to the local grains.
If that grain has already been set return the value instead.
This is useful for generating passwords or keys tha... | python | def get_or_set_hash(name,
length=8,
chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'):
'''
Perform a one-time generation of a hash and write it to the local grains.
If that grain has already been set return the value instead.
This is useful for generating passwords or keys tha... | [
"def",
"get_or_set_hash",
"(",
"name",
",",
"length",
"=",
"8",
",",
"chars",
"=",
"'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'",
")",
":",
"ret",
"=",
"get",
"(",
"name",
",",
"None",
")",
"if",
"ret",
"is",
"None",
":",
"val",
"=",
"''",
".",
... | Perform a one-time generation of a hash and write it to the local grains.
If that grain has already been set return the value instead.
This is useful for generating passwords or keys that are specific to a
single minion that don't need to be stored somewhere centrally.
State Example:
.. code-bloc... | [
"Perform",
"a",
"one",
"-",
"time",
"generation",
"of",
"a",
"hash",
"and",
"write",
"it",
"to",
"the",
"local",
"grains",
".",
"If",
"that",
"grain",
"has",
"already",
"been",
"set",
"return",
"the",
"value",
"instead",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L619-L666 |
35,236 | saltstack/salt | salt/modules/grains.py | set | def set(key,
val='',
force=False,
destructive=False,
delimiter=DEFAULT_TARGET_DELIM):
'''
Set a key to an arbitrary value. It is used like setval but works
with nested keys.
This function is conservative. It will only overwrite an entry if
its value and the given one... | python | def set(key,
val='',
force=False,
destructive=False,
delimiter=DEFAULT_TARGET_DELIM):
'''
Set a key to an arbitrary value. It is used like setval but works
with nested keys.
This function is conservative. It will only overwrite an entry if
its value and the given one... | [
"def",
"set",
"(",
"key",
",",
"val",
"=",
"''",
",",
"force",
"=",
"False",
",",
"destructive",
"=",
"False",
",",
"delimiter",
"=",
"DEFAULT_TARGET_DELIM",
")",
":",
"ret",
"=",
"{",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
",",
"... | Set a key to an arbitrary value. It is used like setval but works
with nested keys.
This function is conservative. It will only overwrite an entry if
its value and the given one are not a list or a dict. The ``force``
parameter is used to allow overwriting in all cases.
.. versionadded:: 2015.8.0
... | [
"Set",
"a",
"key",
"to",
"an",
"arbitrary",
"value",
".",
"It",
"is",
"used",
"like",
"setval",
"but",
"works",
"with",
"nested",
"keys",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L669-L787 |
35,237 | saltstack/salt | salt/modules/xapi_virt.py | _get_xapi_session | def _get_xapi_session():
'''
Get a session to XenAPI. By default, use the local UNIX socket.
'''
_xenapi = _check_xenapi()
xapi_uri = __salt__['config.option']('xapi.uri')
xapi_login = __salt__['config.option']('xapi.login')
xapi_password = __salt__['config.option']('xapi.password')
if... | python | def _get_xapi_session():
'''
Get a session to XenAPI. By default, use the local UNIX socket.
'''
_xenapi = _check_xenapi()
xapi_uri = __salt__['config.option']('xapi.uri')
xapi_login = __salt__['config.option']('xapi.login')
xapi_password = __salt__['config.option']('xapi.password')
if... | [
"def",
"_get_xapi_session",
"(",
")",
":",
"_xenapi",
"=",
"_check_xenapi",
"(",
")",
"xapi_uri",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"'xapi.uri'",
")",
"xapi_login",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"'xapi.login'",
")",
"xapi_... | Get a session to XenAPI. By default, use the local UNIX socket. | [
"Get",
"a",
"session",
"to",
"XenAPI",
".",
"By",
"default",
"use",
"the",
"local",
"UNIX",
"socket",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L76-L102 |
35,238 | saltstack/salt | salt/modules/xapi_virt.py | _get_xtool | def _get_xtool():
'''
Internal, returns xl or xm command line path
'''
for xtool in ['xl', 'xm']:
path = salt.utils.path.which(xtool)
if path is not None:
return path | python | def _get_xtool():
'''
Internal, returns xl or xm command line path
'''
for xtool in ['xl', 'xm']:
path = salt.utils.path.which(xtool)
if path is not None:
return path | [
"def",
"_get_xtool",
"(",
")",
":",
"for",
"xtool",
"in",
"[",
"'xl'",
",",
"'xm'",
"]",
":",
"path",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"xtool",
")",
"if",
"path",
"is",
"not",
"None",
":",
"return",
"path"
] | Internal, returns xl or xm command line path | [
"Internal",
"returns",
"xl",
"or",
"xm",
"command",
"line",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L114-L121 |
35,239 | saltstack/salt | salt/modules/xapi_virt.py | _get_label_uuid | def _get_label_uuid(xapi, rectype, label):
'''
Internal, returns label's uuid
'''
try:
return getattr(xapi, rectype).get_by_name_label(label)[0]
except Exception:
return False | python | def _get_label_uuid(xapi, rectype, label):
'''
Internal, returns label's uuid
'''
try:
return getattr(xapi, rectype).get_by_name_label(label)[0]
except Exception:
return False | [
"def",
"_get_label_uuid",
"(",
"xapi",
",",
"rectype",
",",
"label",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"xapi",
",",
"rectype",
")",
".",
"get_by_name_label",
"(",
"label",
")",
"[",
"0",
"]",
"except",
"Exception",
":",
"return",
"False"
] | Internal, returns label's uuid | [
"Internal",
"returns",
"label",
"s",
"uuid"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L131-L138 |
35,240 | saltstack/salt | salt/modules/xapi_virt.py | _get_record_by_label | def _get_record_by_label(xapi, rectype, label):
'''
Internal, returns a full record for uuid
'''
uuid = _get_label_uuid(xapi, rectype, label)
if uuid is False:
return False
return getattr(xapi, rectype).get_record(uuid) | python | def _get_record_by_label(xapi, rectype, label):
'''
Internal, returns a full record for uuid
'''
uuid = _get_label_uuid(xapi, rectype, label)
if uuid is False:
return False
return getattr(xapi, rectype).get_record(uuid) | [
"def",
"_get_record_by_label",
"(",
"xapi",
",",
"rectype",
",",
"label",
")",
":",
"uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"rectype",
",",
"label",
")",
"if",
"uuid",
"is",
"False",
":",
"return",
"False",
"return",
"getattr",
"(",
"xapi",
","... | Internal, returns a full record for uuid | [
"Internal",
"returns",
"a",
"full",
"record",
"for",
"uuid"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L148-L155 |
35,241 | saltstack/salt | salt/modules/xapi_virt.py | _get_metrics_record | def _get_metrics_record(xapi, rectype, record):
'''
Internal, returns metrics record for a rectype
'''
metrics_id = record['metrics']
return getattr(xapi, '{0}_metrics'.format(rectype)).get_record(metrics_id) | python | def _get_metrics_record(xapi, rectype, record):
'''
Internal, returns metrics record for a rectype
'''
metrics_id = record['metrics']
return getattr(xapi, '{0}_metrics'.format(rectype)).get_record(metrics_id) | [
"def",
"_get_metrics_record",
"(",
"xapi",
",",
"rectype",
",",
"record",
")",
":",
"metrics_id",
"=",
"record",
"[",
"'metrics'",
"]",
"return",
"getattr",
"(",
"xapi",
",",
"'{0}_metrics'",
".",
"format",
"(",
"rectype",
")",
")",
".",
"get_record",
"(",... | Internal, returns metrics record for a rectype | [
"Internal",
"returns",
"metrics",
"record",
"for",
"a",
"rectype"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L158-L163 |
35,242 | saltstack/salt | salt/modules/xapi_virt.py | _get_val | def _get_val(record, keys):
'''
Internal, get value from record
'''
data = record
for key in keys:
if key in data:
data = data[key]
else:
return None
return data | python | def _get_val(record, keys):
'''
Internal, get value from record
'''
data = record
for key in keys:
if key in data:
data = data[key]
else:
return None
return data | [
"def",
"_get_val",
"(",
"record",
",",
"keys",
")",
":",
"data",
"=",
"record",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"in",
"data",
":",
"data",
"=",
"data",
"[",
"key",
"]",
"else",
":",
"return",
"None",
"return",
"data"
] | Internal, get value from record | [
"Internal",
"get",
"value",
"from",
"record"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L166-L176 |
35,243 | saltstack/salt | salt/modules/xapi_virt.py | vm_info | def vm_info(vm_=None):
'''
Return detailed information about the vms.
If you pass a VM name in as an argument then it will return info
for just the named VM, otherwise it will return all VMs.
CLI Example:
.. code-block:: bash
salt '*' virt.vm_info
'''
with _get_xapi_session()... | python | def vm_info(vm_=None):
'''
Return detailed information about the vms.
If you pass a VM name in as an argument then it will return info
for just the named VM, otherwise it will return all VMs.
CLI Example:
.. code-block:: bash
salt '*' virt.vm_info
'''
with _get_xapi_session()... | [
"def",
"vm_info",
"(",
"vm_",
"=",
"None",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"def",
"_info",
"(",
"vm_",
")",
":",
"vm_rec",
"=",
"_get_record_by_label",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_rec",
"is... | Return detailed information about the vms.
If you pass a VM name in as an argument then it will return info
for just the named VM, otherwise it will return all VMs.
CLI Example:
.. code-block:: bash
salt '*' virt.vm_info | [
"Return",
"detailed",
"information",
"about",
"the",
"vms",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L200-L240 |
35,244 | saltstack/salt | salt/modules/xapi_virt.py | setmem | def setmem(vm_, memory):
'''
Changes the amount of memory allocated to VM.
Memory is to be specified in MB
CLI Example:
.. code-block:: bash
salt '*' virt.setmem myvm 768
'''
with _get_xapi_session() as xapi:
mem_target = int(memory) * 1024 * 1024
vm_uuid = _get_... | python | def setmem(vm_, memory):
'''
Changes the amount of memory allocated to VM.
Memory is to be specified in MB
CLI Example:
.. code-block:: bash
salt '*' virt.setmem myvm 768
'''
with _get_xapi_session() as xapi:
mem_target = int(memory) * 1024 * 1024
vm_uuid = _get_... | [
"def",
"setmem",
"(",
"vm_",
",",
"memory",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"mem_target",
"=",
"int",
"(",
"memory",
")",
"*",
"1024",
"*",
"1024",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
... | Changes the amount of memory allocated to VM.
Memory is to be specified in MB
CLI Example:
.. code-block:: bash
salt '*' virt.setmem myvm 768 | [
"Changes",
"the",
"amount",
"of",
"memory",
"allocated",
"to",
"VM",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L431-L454 |
35,245 | saltstack/salt | salt/modules/xapi_virt.py | setvcpus | def setvcpus(vm_, vcpus):
'''
Changes the amount of vcpus allocated to VM.
vcpus is an int representing the number to be assigned
CLI Example:
.. code-block:: bash
salt '*' virt.setvcpus myvm 2
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm... | python | def setvcpus(vm_, vcpus):
'''
Changes the amount of vcpus allocated to VM.
vcpus is an int representing the number to be assigned
CLI Example:
.. code-block:: bash
salt '*' virt.setvcpus myvm 2
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm... | [
"def",
"setvcpus",
"(",
"vm_",
",",
"vcpus",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
"False",
"try"... | Changes the amount of vcpus allocated to VM.
vcpus is an int representing the number to be assigned
CLI Example:
.. code-block:: bash
salt '*' virt.setvcpus myvm 2 | [
"Changes",
"the",
"amount",
"of",
"vcpus",
"allocated",
"to",
"VM",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L457-L477 |
35,246 | saltstack/salt | salt/modules/xapi_virt.py | vcpu_pin | def vcpu_pin(vm_, vcpu, cpus):
'''
Set which CPUs a VCPU can use.
CLI Example:
.. code-block:: bash
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if ... | python | def vcpu_pin(vm_, vcpu, cpus):
'''
Set which CPUs a VCPU can use.
CLI Example:
.. code-block:: bash
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if ... | [
"def",
"vcpu_pin",
"(",
"vm_",
",",
"vcpu",
",",
"cpus",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
... | Set which CPUs a VCPU can use.
CLI Example:
.. code-block:: bash
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6 | [
"Set",
"which",
"CPUs",
"a",
"VCPU",
"can",
"use",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L480-L532 |
35,247 | saltstack/salt | salt/modules/xapi_virt.py | shutdown | def shutdown(vm_):
'''
Send a soft shutdown signal to the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.shutdown <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
return False
... | python | def shutdown(vm_):
'''
Send a soft shutdown signal to the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.shutdown <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
return False
... | [
"def",
"shutdown",
"(",
"vm_",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
"False",
"try",
":",
"xapi",... | Send a soft shutdown signal to the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.shutdown <vm name> | [
"Send",
"a",
"soft",
"shutdown",
"signal",
"to",
"the",
"named",
"vm"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L576-L594 |
35,248 | saltstack/salt | salt/modules/xapi_virt.py | resume | def resume(vm_):
'''
Resume the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.resume <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
return False
try:
xapi.VM.unp... | python | def resume(vm_):
'''
Resume the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.resume <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
return False
try:
xapi.VM.unp... | [
"def",
"resume",
"(",
"vm_",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
"False",
"try",
":",
"xapi",
... | Resume the named vm
CLI Example:
.. code-block:: bash
salt '*' virt.resume <vm name> | [
"Resume",
"the",
"named",
"vm"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L618-L636 |
35,249 | saltstack/salt | salt/modules/xapi_virt.py | migrate | def migrate(vm_, target,
live=1, port=0, node=-1, ssl=None, change_home_server=0):
'''
Migrates the virtual machine to another hypervisor
CLI Example:
.. code-block:: bash
salt '*' virt.migrate <vm name> <target hypervisor> [live] [port] [node] [ssl] [change_home_server]
Opti... | python | def migrate(vm_, target,
live=1, port=0, node=-1, ssl=None, change_home_server=0):
'''
Migrates the virtual machine to another hypervisor
CLI Example:
.. code-block:: bash
salt '*' virt.migrate <vm name> <target hypervisor> [live] [port] [node] [ssl] [change_home_server]
Opti... | [
"def",
"migrate",
"(",
"vm_",
",",
"target",
",",
"live",
"=",
"1",
",",
"port",
"=",
"0",
",",
"node",
"=",
"-",
"1",
",",
"ssl",
"=",
"None",
",",
"change_home_server",
"=",
"0",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":... | Migrates the virtual machine to another hypervisor
CLI Example:
.. code-block:: bash
salt '*' virt.migrate <vm name> <target hypervisor> [live] [port] [node] [ssl] [change_home_server]
Optional values:
live
Use live migration
port
Use a specified port
node
Us... | [
"Migrates",
"the",
"virtual",
"machine",
"to",
"another",
"hypervisor"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L698-L736 |
35,250 | saltstack/salt | salt/modules/xapi_virt.py | stop | def stop(vm_):
'''
Hard power down the virtual machine, this is equivalent to pulling the
power
CLI Example:
.. code-block:: bash
salt '*' virt.stop <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
... | python | def stop(vm_):
'''
Hard power down the virtual machine, this is equivalent to pulling the
power
CLI Example:
.. code-block:: bash
salt '*' virt.stop <vm name>
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if vm_uuid is False:
... | [
"def",
"stop",
"(",
"vm_",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
"False",
"try",
":",
"xapi",
"... | Hard power down the virtual machine, this is equivalent to pulling the
power
CLI Example:
.. code-block:: bash
salt '*' virt.stop <vm name> | [
"Hard",
"power",
"down",
"the",
"virtual",
"machine",
"this",
"is",
"equivalent",
"to",
"pulling",
"the",
"power"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L739-L758 |
35,251 | saltstack/salt | salt/modules/xapi_virt.py | is_hyper | def is_hyper():
'''
Returns a bool whether or not this node is a hypervisor of any kind
CLI Example:
.. code-block:: bash
salt '*' virt.is_hyper
'''
try:
if __grains__['virtual_subtype'] != 'Xen Dom0':
return False
except KeyError:
# virtual_subtype isn... | python | def is_hyper():
'''
Returns a bool whether or not this node is a hypervisor of any kind
CLI Example:
.. code-block:: bash
salt '*' virt.is_hyper
'''
try:
if __grains__['virtual_subtype'] != 'Xen Dom0':
return False
except KeyError:
# virtual_subtype isn... | [
"def",
"is_hyper",
"(",
")",
":",
"try",
":",
"if",
"__grains__",
"[",
"'virtual_subtype'",
"]",
"!=",
"'Xen Dom0'",
":",
"return",
"False",
"except",
"KeyError",
":",
"# virtual_subtype isn't set everywhere.",
"return",
"False",
"try",
":",
"with",
"salt",
".",... | Returns a bool whether or not this node is a hypervisor of any kind
CLI Example:
.. code-block:: bash
salt '*' virt.is_hyper | [
"Returns",
"a",
"bool",
"whether",
"or",
"not",
"this",
"node",
"is",
"a",
"hypervisor",
"of",
"any",
"kind"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L761-L784 |
35,252 | saltstack/salt | salt/modules/zonecfg.py | _clean_message | def _clean_message(message):
'''Internal helper to sanitize message output'''
message = message.replace('zonecfg: ', '')
message = message.splitlines()
for line in message:
if line.startswith('On line'):
message.remove(line)
return "\n".join(message) | python | def _clean_message(message):
'''Internal helper to sanitize message output'''
message = message.replace('zonecfg: ', '')
message = message.splitlines()
for line in message:
if line.startswith('On line'):
message.remove(line)
return "\n".join(message) | [
"def",
"_clean_message",
"(",
"message",
")",
":",
"message",
"=",
"message",
".",
"replace",
"(",
"'zonecfg: '",
",",
"''",
")",
"message",
"=",
"message",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"message",
":",
"if",
"line",
".",
"startswith"... | Internal helper to sanitize message output | [
"Internal",
"helper",
"to",
"sanitize",
"message",
"output"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L117-L124 |
35,253 | saltstack/salt | salt/modules/zonecfg.py | _parse_value | def _parse_value(value):
'''Internal helper for parsing configuration values into python values'''
if isinstance(value, bool):
return 'true' if value else 'false'
elif isinstance(value, six.string_types):
# parse compacted notation to dict
listparser = re.compile(r'''((?:[^,"']|"[^"]... | python | def _parse_value(value):
'''Internal helper for parsing configuration values into python values'''
if isinstance(value, bool):
return 'true' if value else 'false'
elif isinstance(value, six.string_types):
# parse compacted notation to dict
listparser = re.compile(r'''((?:[^,"']|"[^"]... | [
"def",
"_parse_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"'true'",
"if",
"value",
"else",
"'false'",
"elif",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"# parse compacted ... | Internal helper for parsing configuration values into python values | [
"Internal",
"helper",
"for",
"parsing",
"configuration",
"values",
"into",
"python",
"values"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L127-L165 |
35,254 | saltstack/salt | salt/modules/zonecfg.py | _sanitize_value | def _sanitize_value(value):
'''Internal helper for converting pythonic values to configuration file values'''
# dump dict into compated
if isinstance(value, dict):
new_value = []
new_value.append('(')
for k, v in value.items():
new_value.append(k)
new_value.ap... | python | def _sanitize_value(value):
'''Internal helper for converting pythonic values to configuration file values'''
# dump dict into compated
if isinstance(value, dict):
new_value = []
new_value.append('(')
for k, v in value.items():
new_value.append(k)
new_value.ap... | [
"def",
"_sanitize_value",
"(",
"value",
")",
":",
"# dump dict into compated",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"new_value",
"=",
"[",
"]",
"new_value",
".",
"append",
"(",
"'('",
")",
"for",
"k",
",",
"v",
"in",
"value",
".",
"... | Internal helper for converting pythonic values to configuration file values | [
"Internal",
"helper",
"for",
"converting",
"pythonic",
"values",
"to",
"configuration",
"file",
"values"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L168-L198 |
35,255 | saltstack/salt | salt/modules/zonecfg.py | _dump_cfg | def _dump_cfg(cfg_file):
'''Internal helper for debugging cfg files'''
if __salt__['file.file_exists'](cfg_file):
with salt.utils.files.fopen(cfg_file, 'r') as fp_:
log.debug(
"zonecfg - configuration file:\n%s",
"".join(salt.utils.data.decode(fp_.readline... | python | def _dump_cfg(cfg_file):
'''Internal helper for debugging cfg files'''
if __salt__['file.file_exists'](cfg_file):
with salt.utils.files.fopen(cfg_file, 'r') as fp_:
log.debug(
"zonecfg - configuration file:\n%s",
"".join(salt.utils.data.decode(fp_.readline... | [
"def",
"_dump_cfg",
"(",
"cfg_file",
")",
":",
"if",
"__salt__",
"[",
"'file.file_exists'",
"]",
"(",
"cfg_file",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"cfg_file",
",",
"'r'",
")",
"as",
"fp_",
":",
"log",
".",
"deb... | Internal helper for debugging cfg files | [
"Internal",
"helper",
"for",
"debugging",
"cfg",
"files"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L201-L208 |
35,256 | saltstack/salt | salt/modules/zonecfg.py | create | def create(zone, brand, zonepath, force=False):
'''
Create an in-memory configuration for the specified zone.
zone : string
name of zone
brand : string
brand name
zonepath : string
path of zone
force : boolean
overwrite configuration
CLI Example:
.. cod... | python | def create(zone, brand, zonepath, force=False):
'''
Create an in-memory configuration for the specified zone.
zone : string
name of zone
brand : string
brand name
zonepath : string
path of zone
force : boolean
overwrite configuration
CLI Example:
.. cod... | [
"def",
"create",
"(",
"zone",
",",
"brand",
",",
"zonepath",
",",
"force",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# write config",
"cfg_file",
"=",
"salt",
".",
"utils",
".",
"files",
".",
"mkstemp",
"(",
")",
"with",... | Create an in-memory configuration for the specified zone.
zone : string
name of zone
brand : string
brand name
zonepath : string
path of zone
force : boolean
overwrite configuration
CLI Example:
.. code-block:: bash
salt '*' zonecfg.create deathscythe ... | [
"Create",
"an",
"in",
"-",
"memory",
"configuration",
"for",
"the",
"specified",
"zone",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L211-L259 |
35,257 | saltstack/salt | salt/modules/zonecfg.py | create_from_template | def create_from_template(zone, template):
'''
Create an in-memory configuration from a template for the specified zone.
zone : string
name of zone
template : string
name of template
.. warning::
existing config will be overwritten!
CLI Example:
.. code-block:: bas... | python | def create_from_template(zone, template):
'''
Create an in-memory configuration from a template for the specified zone.
zone : string
name of zone
template : string
name of template
.. warning::
existing config will be overwritten!
CLI Example:
.. code-block:: bas... | [
"def",
"create_from_template",
"(",
"zone",
",",
"template",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# create from template",
"_dump_cfg",
"(",
"template",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'zonecfg -z {zone} create ... | Create an in-memory configuration from a template for the specified zone.
zone : string
name of zone
template : string
name of template
.. warning::
existing config will be overwritten!
CLI Example:
.. code-block:: bash
salt '*' zonecfg.create_from_template leo t... | [
"Create",
"an",
"in",
"-",
"memory",
"configuration",
"from",
"a",
"template",
"for",
"the",
"specified",
"zone",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L262-L295 |
35,258 | saltstack/salt | salt/modules/zonecfg.py | delete | def delete(zone):
'''
Delete the specified configuration from memory and stable storage.
zone : string
name of zone
CLI Example:
.. code-block:: bash
salt '*' zonecfg.delete epyon
'''
ret = {'status': True}
# delete zone
res = __salt__['cmd.run_all']('zonecfg -z ... | python | def delete(zone):
'''
Delete the specified configuration from memory and stable storage.
zone : string
name of zone
CLI Example:
.. code-block:: bash
salt '*' zonecfg.delete epyon
'''
ret = {'status': True}
# delete zone
res = __salt__['cmd.run_all']('zonecfg -z ... | [
"def",
"delete",
"(",
"zone",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# delete zone",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'zonecfg -z {zone} delete -F'",
".",
"format",
"(",
"zone",
"=",
"zone",
",",
")",
")",
"ret"... | Delete the specified configuration from memory and stable storage.
zone : string
name of zone
CLI Example:
.. code-block:: bash
salt '*' zonecfg.delete epyon | [
"Delete",
"the",
"specified",
"configuration",
"from",
"memory",
"and",
"stable",
"storage",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L298-L324 |
35,259 | saltstack/salt | salt/modules/zonecfg.py | export | def export(zone, path=None):
'''
Export the configuration from memory to stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.export epyon
salt '*' zonecfg.export epyon /zones/epy... | python | def export(zone, path=None):
'''
Export the configuration from memory to stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.export epyon
salt '*' zonecfg.export epyon /zones/epy... | [
"def",
"export",
"(",
"zone",
",",
"path",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# export zone",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'zonecfg -z {zone} export{path}'",
".",
"format",
"(",
"zone",
"=",
... | Export the configuration from memory to stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.export epyon
salt '*' zonecfg.export epyon /zones/epyon.cfg | [
"Export",
"the",
"configuration",
"from",
"memory",
"to",
"stable",
"storage",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L327-L357 |
35,260 | saltstack/salt | salt/modules/zonecfg.py | import_ | def import_(zone, path):
'''
Import the configuration to memory from stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.import epyon /zones/epyon.cfg
'''
ret = {'status': True}
... | python | def import_(zone, path):
'''
Import the configuration to memory from stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.import epyon /zones/epyon.cfg
'''
ret = {'status': True}
... | [
"def",
"import_",
"(",
"zone",
",",
"path",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# create from file",
"_dump_cfg",
"(",
"path",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'zonecfg -z {zone} -f {path}'",
".",
"format",
... | Import the configuration to memory from stable storage.
zone : string
name of zone
path : string
path of file to export to
CLI Example:
.. code-block:: bash
salt '*' zonecfg.import epyon /zones/epyon.cfg | [
"Import",
"the",
"configuration",
"to",
"memory",
"from",
"stable",
"storage",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L360-L390 |
35,261 | saltstack/salt | salt/modules/zonecfg.py | _property | def _property(methode, zone, key, value):
'''
internal handler for set and clear_property
methode : string
either set, add, or clear
zone : string
name of zone
key : string
name of property
value : string
value of property
'''
ret = {'status': True}
... | python | def _property(methode, zone, key, value):
'''
internal handler for set and clear_property
methode : string
either set, add, or clear
zone : string
name of zone
key : string
name of property
value : string
value of property
'''
ret = {'status': True}
... | [
"def",
"_property",
"(",
"methode",
",",
"zone",
",",
"key",
",",
"value",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# generate update script",
"cfg_file",
"=",
"None",
"if",
"methode",
"not",
"in",
"[",
"'set'",
",",
"'clear'",
"]",
":... | internal handler for set and clear_property
methode : string
either set, add, or clear
zone : string
name of zone
key : string
name of property
value : string
value of property | [
"internal",
"handler",
"for",
"set",
"and",
"clear_property"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L393-L443 |
35,262 | saltstack/salt | salt/modules/zonecfg.py | update_resource | def update_resource(zone, resource_type, resource_selector, **kwargs):
'''
Add a resource
zone : string
name of zone
resource_type : string
type of resource
resource_selector : string
unique resource identifier
kwargs : string|int|...
resource properties
.. ... | python | def update_resource(zone, resource_type, resource_selector, **kwargs):
'''
Add a resource
zone : string
name of zone
resource_type : string
type of resource
resource_selector : string
unique resource identifier
kwargs : string|int|...
resource properties
.. ... | [
"def",
"update_resource",
"(",
"zone",
",",
"resource_type",
",",
"resource_selector",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resource",
"(",
"'update'",
",",
"zone",
",",
"resource_type",
",",
"resource_selector",
",",
"*",
"*",
"kwargs",
")"
] | Add a resource
zone : string
name of zone
resource_type : string
type of resource
resource_selector : string
unique resource identifier
kwargs : string|int|...
resource properties
.. note::
Set resource_selector to None for resource that do not require one.
... | [
"Add",
"a",
"resource"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L593-L615 |
35,263 | saltstack/salt | salt/modules/zonecfg.py | remove_resource | def remove_resource(zone, resource_type, resource_key, resource_value):
'''
Remove a resource
zone : string
name of zone
resource_type : string
type of resource
resource_key : string
key for resource selection
resource_value : string
value for resource selection
... | python | def remove_resource(zone, resource_type, resource_key, resource_value):
'''
Remove a resource
zone : string
name of zone
resource_type : string
type of resource
resource_key : string
key for resource selection
resource_value : string
value for resource selection
... | [
"def",
"remove_resource",
"(",
"zone",
",",
"resource_type",
",",
"resource_key",
",",
"resource_value",
")",
":",
"ret",
"=",
"{",
"'status'",
":",
"True",
"}",
"# generate update script",
"cfg_file",
"=",
"salt",
".",
"utils",
".",
"files",
".",
"mkstemp",
... | Remove a resource
zone : string
name of zone
resource_type : string
type of resource
resource_key : string
key for resource selection
resource_value : string
value for resource selection
.. note::
Set resource_selector to None for resource that do not requir... | [
"Remove",
"a",
"resource"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L618-L668 |
35,264 | saltstack/salt | salt/modules/zonecfg.py | info | def info(zone, show_all=False):
'''
Display the configuration from memory
zone : string
name of zone
show_all : boolean
also include calculated values like capped-cpu, cpu-shares, ...
CLI Example:
.. code-block:: bash
salt '*' zonecfg.info tallgeese
'''
ret = ... | python | def info(zone, show_all=False):
'''
Display the configuration from memory
zone : string
name of zone
show_all : boolean
also include calculated values like capped-cpu, cpu-shares, ...
CLI Example:
.. code-block:: bash
salt '*' zonecfg.info tallgeese
'''
ret = ... | [
"def",
"info",
"(",
"zone",
",",
"show_all",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"}",
"# dump zone",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'zonecfg -z {zone} info'",
".",
"format",
"(",
"zone",
"=",
"zone",
",",
")",
")",
"if",
... | Display the configuration from memory
zone : string
name of zone
show_all : boolean
also include calculated values like capped-cpu, cpu-shares, ...
CLI Example:
.. code-block:: bash
salt '*' zonecfg.info tallgeese | [
"Display",
"the",
"configuration",
"from",
"memory"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L671-L769 |
35,265 | saltstack/salt | salt/cli/daemons.py | DaemonsMixin.verify_hash_type | def verify_hash_type(self):
'''
Verify and display a nag-messsage to the log if vulnerable hash-type is used.
:return:
'''
if self.config['hash_type'].lower() in ['md5', 'sha1']:
log.warning(
'IMPORTANT: Do not use %s hashing algorithm! Please set '
... | python | def verify_hash_type(self):
'''
Verify and display a nag-messsage to the log if vulnerable hash-type is used.
:return:
'''
if self.config['hash_type'].lower() in ['md5', 'sha1']:
log.warning(
'IMPORTANT: Do not use %s hashing algorithm! Please set '
... | [
"def",
"verify_hash_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
"[",
"'hash_type'",
"]",
".",
"lower",
"(",
")",
"in",
"[",
"'md5'",
",",
"'sha1'",
"]",
":",
"log",
".",
"warning",
"(",
"'IMPORTANT: Do not use %s hashing algorithm! Please set '"... | Verify and display a nag-messsage to the log if vulnerable hash-type is used.
:return: | [
"Verify",
"and",
"display",
"a",
"nag",
"-",
"messsage",
"to",
"the",
"log",
"if",
"vulnerable",
"hash",
"-",
"type",
"is",
"used",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L65-L76 |
35,266 | saltstack/salt | salt/cli/daemons.py | DaemonsMixin.environment_failure | def environment_failure(self, error):
'''
Log environment failure for the daemon and exit with the error code.
:param error:
:return:
'''
log.exception(
'Failed to create environment for %s: %s',
self.__class__.__name__, get_error_message(error)
... | python | def environment_failure(self, error):
'''
Log environment failure for the daemon and exit with the error code.
:param error:
:return:
'''
log.exception(
'Failed to create environment for %s: %s',
self.__class__.__name__, get_error_message(error)
... | [
"def",
"environment_failure",
"(",
"self",
",",
"error",
")",
":",
"log",
".",
"exception",
"(",
"'Failed to create environment for %s: %s'",
",",
"self",
".",
"__class__",
".",
"__name__",
",",
"get_error_message",
"(",
"error",
")",
")",
"self",
".",
"shutdown... | Log environment failure for the daemon and exit with the error code.
:param error:
:return: | [
"Log",
"environment",
"failure",
"for",
"the",
"daemon",
"and",
"exit",
"with",
"the",
"error",
"code",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L103-L114 |
35,267 | saltstack/salt | salt/cli/daemons.py | Master.prepare | def prepare(self):
'''
Run the preparation sequence required to start a salt master server.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Master, self).prepare()
try:
if self.config['verify_env']:
... | python | def prepare(self):
'''
Run the preparation sequence required to start a salt master server.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Master, self).prepare()
try:
if self.config['verify_env']:
... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"Master",
",",
"self",
")",
".",
"prepare",
"(",
")",
"try",
":",
"if",
"self",
".",
"config",
"[",
"'verify_env'",
"]",
":",
"v_dirs",
"=",
"[",
"self",
".",
"config",
"[",
"'pki_dir'",
"]",
... | Run the preparation sequence required to start a salt master server.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare() | [
"Run",
"the",
"preparation",
"sequence",
"required",
"to",
"start",
"a",
"salt",
"master",
"server",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L130-L190 |
35,268 | saltstack/salt | salt/cli/daemons.py | Minion.prepare | def prepare(self):
'''
Run the preparation sequence required to start a salt minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Minion, self).prepare()
try:
if self.config['verify_env']:
... | python | def prepare(self):
'''
Run the preparation sequence required to start a salt minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Minion, self).prepare()
try:
if self.config['verify_env']:
... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"Minion",
",",
"self",
")",
".",
"prepare",
"(",
")",
"try",
":",
"if",
"self",
".",
"config",
"[",
"'verify_env'",
"]",
":",
"confd",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'default_inc... | Run the preparation sequence required to start a salt minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare() | [
"Run",
"the",
"preparation",
"sequence",
"required",
"to",
"start",
"a",
"salt",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L233-L311 |
35,269 | saltstack/salt | salt/cli/daemons.py | Minion.start | def start(self):
'''
Start the actual minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(Minion, self).start()
while True:
try:
... | python | def start(self):
'''
Start the actual minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(Minion, self).start()
while True:
try:
... | [
"def",
"start",
"(",
"self",
")",
":",
"super",
"(",
"Minion",
",",
"self",
")",
".",
"start",
"(",
")",
"while",
"True",
":",
"try",
":",
"self",
".",
"_real_start",
"(",
")",
"except",
"SaltClientError",
"as",
"exc",
":",
"# Restart for multi_master fa... | Start the actual minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`. | [
"Start",
"the",
"actual",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L313-L331 |
35,270 | saltstack/salt | salt/cli/daemons.py | Minion.call | def call(self, cleanup_protecteds):
'''
Start the actual minion as a caller minion.
cleanup_protecteds is list of yard host addresses that should not be
cleaned up this is to fix race condition when salt-caller minion starts up
If sub-classed, don't **ever** forget to run:
... | python | def call(self, cleanup_protecteds):
'''
Start the actual minion as a caller minion.
cleanup_protecteds is list of yard host addresses that should not be
cleaned up this is to fix race condition when salt-caller minion starts up
If sub-classed, don't **ever** forget to run:
... | [
"def",
"call",
"(",
"self",
",",
"cleanup_protecteds",
")",
":",
"try",
":",
"self",
".",
"prepare",
"(",
")",
"if",
"check_user",
"(",
"self",
".",
"config",
"[",
"'user'",
"]",
")",
":",
"self",
".",
"minion",
".",
"opts",
"[",
"'__role'",
"]",
"... | Start the actual minion as a caller minion.
cleanup_protecteds is list of yard host addresses that should not be
cleaned up this is to fix race condition when salt-caller minion starts up
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE... | [
"Start",
"the",
"actual",
"minion",
"as",
"a",
"caller",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L350-L375 |
35,271 | saltstack/salt | salt/cli/daemons.py | ProxyMinion.prepare | def prepare(self):
'''
Run the preparation sequence required to start a salt proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(ProxyMinion, self).prepare()
if not self.values.proxyid:
self.... | python | def prepare(self):
'''
Run the preparation sequence required to start a salt proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(ProxyMinion, self).prepare()
if not self.values.proxyid:
self.... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"ProxyMinion",
",",
"self",
")",
".",
"prepare",
"(",
")",
"if",
"not",
"self",
".",
"values",
".",
"proxyid",
":",
"self",
".",
"error",
"(",
"'salt-proxy requires --proxyid'",
")",
"# Proxies get the... | Run the preparation sequence required to start a salt proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare() | [
"Run",
"the",
"preparation",
"sequence",
"required",
"to",
"start",
"a",
"salt",
"proxy",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L404-L483 |
35,272 | saltstack/salt | salt/cli/daemons.py | ProxyMinion.start | def start(self):
'''
Start the actual proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(ProxyMinion, self).start()
try:
if check_... | python | def start(self):
'''
Start the actual proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(ProxyMinion, self).start()
try:
if check_... | [
"def",
"start",
"(",
"self",
")",
":",
"super",
"(",
"ProxyMinion",
",",
"self",
")",
".",
"start",
"(",
")",
"try",
":",
"if",
"check_user",
"(",
"self",
".",
"config",
"[",
"'user'",
"]",
")",
":",
"self",
".",
"action_log_info",
"(",
"'The Proxy M... | Start the actual proxy minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`. | [
"Start",
"the",
"actual",
"proxy",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L485-L510 |
35,273 | saltstack/salt | salt/cli/daemons.py | Syndic.prepare | def prepare(self):
'''
Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Syndic, self).prepare()
try:
if self.config['verify_env']:
... | python | def prepare(self):
'''
Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Syndic, self).prepare()
try:
if self.config['verify_env']:
... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"Syndic",
",",
"self",
")",
".",
"prepare",
"(",
")",
"try",
":",
"if",
"self",
".",
"config",
"[",
"'verify_env'",
"]",
":",
"verify_env",
"(",
"[",
"self",
".",
"config",
"[",
"'pki_dir'",
"]... | Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare() | [
"Run",
"the",
"preparation",
"sequence",
"required",
"to",
"start",
"a",
"salt",
"syndic",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L534-L568 |
35,274 | saltstack/salt | salt/cli/daemons.py | Syndic.start | def start(self):
'''
Start the actual syndic.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(Syndic, self).start()
if check_user(self.config['user']):
... | python | def start(self):
'''
Start the actual syndic.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`.
'''
super(Syndic, self).start()
if check_user(self.config['user']):
... | [
"def",
"start",
"(",
"self",
")",
":",
"super",
"(",
"Syndic",
",",
"self",
")",
".",
"start",
"(",
")",
"if",
"check_user",
"(",
"self",
".",
"config",
"[",
"'user'",
"]",
")",
":",
"self",
".",
"action_log_info",
"(",
"'Starting up'",
")",
"self",
... | Start the actual syndic.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).start()
NOTE: Run any required code before calling `super()`. | [
"Start",
"the",
"actual",
"syndic",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L570-L588 |
35,275 | saltstack/salt | salt/modules/drac.py | change_password | def change_password(username, password, uid=None):
'''
Change users password
CLI Example:
.. code-block:: bash
salt dell drac.change_password [USERNAME] [PASSWORD] [UID - optional]
salt dell drac.change_password diana secret
'''
if uid is None:
user = list_users()
... | python | def change_password(username, password, uid=None):
'''
Change users password
CLI Example:
.. code-block:: bash
salt dell drac.change_password [USERNAME] [PASSWORD] [UID - optional]
salt dell drac.change_password diana secret
'''
if uid is None:
user = list_users()
... | [
"def",
"change_password",
"(",
"username",
",",
"password",
",",
"uid",
"=",
"None",
")",
":",
"if",
"uid",
"is",
"None",
":",
"user",
"=",
"list_users",
"(",
")",
"uid",
"=",
"user",
"[",
"username",
"]",
"[",
"'index'",
"]",
"if",
"uid",
":",
"re... | Change users password
CLI Example:
.. code-block:: bash
salt dell drac.change_password [USERNAME] [PASSWORD] [UID - optional]
salt dell drac.change_password diana secret | [
"Change",
"users",
"password"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drac.py#L227-L249 |
35,276 | saltstack/salt | salt/modules/drac.py | create_user | def create_user(username, password, permissions, users=None):
'''
Create user accounts
CLI Example:
.. code-block:: bash
salt dell drac.create_user [USERNAME] [PASSWORD] [PRIVILEGES]
salt dell drac.create_user diana secret login,test_alerts,clear_logs
DRAC Privileges
* logi... | python | def create_user(username, password, permissions, users=None):
'''
Create user accounts
CLI Example:
.. code-block:: bash
salt dell drac.create_user [USERNAME] [PASSWORD] [PRIVILEGES]
salt dell drac.create_user diana secret login,test_alerts,clear_logs
DRAC Privileges
* logi... | [
"def",
"create_user",
"(",
"username",
",",
"password",
",",
"permissions",
",",
"users",
"=",
"None",
")",
":",
"_uids",
"=",
"set",
"(",
")",
"if",
"users",
"is",
"None",
":",
"users",
"=",
"list_users",
"(",
")",
"if",
"username",
"in",
"users",
"... | Create user accounts
CLI Example:
.. code-block:: bash
salt dell drac.create_user [USERNAME] [PASSWORD] [PRIVILEGES]
salt dell drac.create_user diana secret login,test_alerts,clear_logs
DRAC Privileges
* login : Login to iDRAC
* drac : Con... | [
"Create",
"user",
"accounts"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drac.py#L252-L312 |
35,277 | saltstack/salt | salt/modules/drac.py | set_permissions | def set_permissions(username, permissions, uid=None):
'''
Configure users permissions
CLI Example:
.. code-block:: bash
salt dell drac.set_permissions [USERNAME] [PRIVILEGES] [USER INDEX - optional]
salt dell drac.set_permissions diana login,test_alerts,clear_logs 4
DRAC Privileg... | python | def set_permissions(username, permissions, uid=None):
'''
Configure users permissions
CLI Example:
.. code-block:: bash
salt dell drac.set_permissions [USERNAME] [PRIVILEGES] [USER INDEX - optional]
salt dell drac.set_permissions diana login,test_alerts,clear_logs 4
DRAC Privileg... | [
"def",
"set_permissions",
"(",
"username",
",",
"permissions",
",",
"uid",
"=",
"None",
")",
":",
"privileges",
"=",
"{",
"'login'",
":",
"'0x0000001'",
",",
"'drac'",
":",
"'0x0000002'",
",",
"'user_management'",
":",
"'0x0000004'",
",",
"'clear_logs'",
":",
... | Configure users permissions
CLI Example:
.. code-block:: bash
salt dell drac.set_permissions [USERNAME] [PRIVILEGES] [USER INDEX - optional]
salt dell drac.set_permissions diana login,test_alerts,clear_logs 4
DRAC Privileges
* login : Login to iDRAC
* drac ... | [
"Configure",
"users",
"permissions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drac.py#L315-L362 |
35,278 | saltstack/salt | scripts/suse/yum/plugins/yumnotify.py | _get_mtime | def _get_mtime():
"""
Get the modified time of the RPM Database.
Returns:
Unix ticks
"""
return os.path.exists(RPM_PATH) and int(os.path.getmtime(RPM_PATH)) or 0 | python | def _get_mtime():
"""
Get the modified time of the RPM Database.
Returns:
Unix ticks
"""
return os.path.exists(RPM_PATH) and int(os.path.getmtime(RPM_PATH)) or 0 | [
"def",
"_get_mtime",
"(",
")",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"RPM_PATH",
")",
"and",
"int",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"RPM_PATH",
")",
")",
"or",
"0"
] | Get the modified time of the RPM Database.
Returns:
Unix ticks | [
"Get",
"the",
"modified",
"time",
"of",
"the",
"RPM",
"Database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/scripts/suse/yum/plugins/yumnotify.py#L18-L25 |
35,279 | saltstack/salt | scripts/suse/yum/plugins/yumnotify.py | _get_checksum | def _get_checksum():
"""
Get the checksum of the RPM Database.
Returns:
hexdigest
"""
digest = hashlib.sha256()
with open(RPM_PATH, "rb") as rpm_db_fh:
while True:
buff = rpm_db_fh.read(0x1000)
if not buff:
break
digest.update(... | python | def _get_checksum():
"""
Get the checksum of the RPM Database.
Returns:
hexdigest
"""
digest = hashlib.sha256()
with open(RPM_PATH, "rb") as rpm_db_fh:
while True:
buff = rpm_db_fh.read(0x1000)
if not buff:
break
digest.update(... | [
"def",
"_get_checksum",
"(",
")",
":",
"digest",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"with",
"open",
"(",
"RPM_PATH",
",",
"\"rb\"",
")",
"as",
"rpm_db_fh",
":",
"while",
"True",
":",
"buff",
"=",
"rpm_db_fh",
".",
"read",
"(",
"0x1000",
")",
"i... | Get the checksum of the RPM Database.
Returns:
hexdigest | [
"Get",
"the",
"checksum",
"of",
"the",
"RPM",
"Database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/scripts/suse/yum/plugins/yumnotify.py#L28-L42 |
35,280 | saltstack/salt | scripts/suse/yum/plugins/yumnotify.py | posttrans_hook | def posttrans_hook(conduit):
"""
Hook after the package installation transaction.
:param conduit:
:return:
"""
# Integrate Yum with Salt
if 'SALT_RUNNING' not in os.environ:
with open(CK_PATH, 'w') as ck_fh:
ck_fh.write('{chksum} {mtime}\n'.format(chksum=_get_checksum(),... | python | def posttrans_hook(conduit):
"""
Hook after the package installation transaction.
:param conduit:
:return:
"""
# Integrate Yum with Salt
if 'SALT_RUNNING' not in os.environ:
with open(CK_PATH, 'w') as ck_fh:
ck_fh.write('{chksum} {mtime}\n'.format(chksum=_get_checksum(),... | [
"def",
"posttrans_hook",
"(",
"conduit",
")",
":",
"# Integrate Yum with Salt",
"if",
"'SALT_RUNNING'",
"not",
"in",
"os",
".",
"environ",
":",
"with",
"open",
"(",
"CK_PATH",
",",
"'w'",
")",
"as",
"ck_fh",
":",
"ck_fh",
".",
"write",
"(",
"'{chksum} {mtime... | Hook after the package installation transaction.
:param conduit:
:return: | [
"Hook",
"after",
"the",
"package",
"installation",
"transaction",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/scripts/suse/yum/plugins/yumnotify.py#L45-L55 |
35,281 | saltstack/salt | salt/modules/postfix.py | set_master | def set_master(service,
conn_type,
private='y',
unpriv='y',
chroot='y',
wakeup='n',
maxproc='100',
command='',
write_conf=True,
path=MASTER_CF):
'''
Set a single config value in... | python | def set_master(service,
conn_type,
private='y',
unpriv='y',
chroot='y',
wakeup='n',
maxproc='100',
command='',
write_conf=True,
path=MASTER_CF):
'''
Set a single config value in... | [
"def",
"set_master",
"(",
"service",
",",
"conn_type",
",",
"private",
"=",
"'y'",
",",
"unpriv",
"=",
"'y'",
",",
"chroot",
"=",
"'y'",
",",
"wakeup",
"=",
"'n'",
",",
"maxproc",
"=",
"'100'",
",",
"command",
"=",
"''",
",",
"write_conf",
"=",
"True... | Set a single config value in the master.cf file. If the value does not
already exist, it will be appended to the end.
Because of shell parsing issues, '-' cannot be set as a value, as is normal
in the master.cf file; either 'y', 'n' or a number should be used when
calling this function from the command... | [
"Set",
"a",
"single",
"config",
"value",
"in",
"the",
"master",
".",
"cf",
"file",
".",
"If",
"the",
"value",
"does",
"not",
"already",
"exist",
"it",
"will",
"be",
"appended",
"to",
"the",
"end",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postfix.py#L104-L169 |
35,282 | saltstack/salt | salt/modules/postfix.py | _format_master | def _format_master(service,
conn_type,
private,
unpriv,
chroot,
wakeup,
maxproc,
command):
'''
Format the given values into the style of line normally used in the
master.cf fi... | python | def _format_master(service,
conn_type,
private,
unpriv,
chroot,
wakeup,
maxproc,
command):
'''
Format the given values into the style of line normally used in the
master.cf fi... | [
"def",
"_format_master",
"(",
"service",
",",
"conn_type",
",",
"private",
",",
"unpriv",
",",
"chroot",
",",
"wakeup",
",",
"maxproc",
",",
"command",
")",
":",
"#==========================================================================",
"#service type private unpriv c... | Format the given values into the style of line normally used in the
master.cf file. | [
"Format",
"the",
"given",
"values",
"into",
"the",
"style",
"of",
"line",
"normally",
"used",
"in",
"the",
"master",
".",
"cf",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postfix.py#L172-L216 |
35,283 | saltstack/salt | salt/modules/postfix.py | set_main | def set_main(key, value, path=MAIN_CF):
'''
Set a single config value in the main.cf file. If the value does not already
exist, it will be appended to the end.
CLI Example:
salt <minion> postfix.set_main mailq_path /usr/bin/mailq
'''
pairs, conf_list = _parse_main(path)
new_conf =... | python | def set_main(key, value, path=MAIN_CF):
'''
Set a single config value in the main.cf file. If the value does not already
exist, it will be appended to the end.
CLI Example:
salt <minion> postfix.set_main mailq_path /usr/bin/mailq
'''
pairs, conf_list = _parse_main(path)
new_conf =... | [
"def",
"set_main",
"(",
"key",
",",
"value",
",",
"path",
"=",
"MAIN_CF",
")",
":",
"pairs",
",",
"conf_list",
"=",
"_parse_main",
"(",
"path",
")",
"new_conf",
"=",
"[",
"]",
"key_line_match",
"=",
"re",
".",
"compile",
"(",
"\"^{0}([\\\\s=]|$)\"",
".",... | Set a single config value in the main.cf file. If the value does not already
exist, it will be appended to the end.
CLI Example:
salt <minion> postfix.set_main mailq_path /usr/bin/mailq | [
"Set",
"a",
"single",
"config",
"value",
"in",
"the",
"main",
".",
"cf",
"file",
".",
"If",
"the",
"value",
"does",
"not",
"already",
"exist",
"it",
"will",
"be",
"appended",
"to",
"the",
"end",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postfix.py#L284-L308 |
35,284 | saltstack/salt | salt/modules/postfix.py | _write_conf | def _write_conf(conf, path=MAIN_CF):
'''
Write out configuration file.
'''
with salt.utils.files.fopen(path, 'w') as fh_:
for line in conf:
line = salt.utils.stringutils.to_str(line)
if isinstance(line, dict):
fh_.write(' '.join(line))
else:
... | python | def _write_conf(conf, path=MAIN_CF):
'''
Write out configuration file.
'''
with salt.utils.files.fopen(path, 'w') as fh_:
for line in conf:
line = salt.utils.stringutils.to_str(line)
if isinstance(line, dict):
fh_.write(' '.join(line))
else:
... | [
"def",
"_write_conf",
"(",
"conf",
",",
"path",
"=",
"MAIN_CF",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"path",
",",
"'w'",
")",
"as",
"fh_",
":",
"for",
"line",
"in",
"conf",
":",
"line",
"=",
"salt",
".",
"utils... | Write out configuration file. | [
"Write",
"out",
"configuration",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postfix.py#L311-L322 |
35,285 | saltstack/salt | salt/modules/postfix.py | show_queue | def show_queue():
'''
Show contents of the mail queue
CLI Example:
.. code-block:: bash
salt '*' postfix.show_queue
'''
cmd = 'mailq'
out = __salt__['cmd.run'](cmd).splitlines()
queue = []
queue_pattern = re.compile(r"(?P<queue_id>^[A-Z0-9]+)\s+(?P<size>\d+)\s(?P<timesta... | python | def show_queue():
'''
Show contents of the mail queue
CLI Example:
.. code-block:: bash
salt '*' postfix.show_queue
'''
cmd = 'mailq'
out = __salt__['cmd.run'](cmd).splitlines()
queue = []
queue_pattern = re.compile(r"(?P<queue_id>^[A-Z0-9]+)\s+(?P<size>\d+)\s(?P<timesta... | [
"def",
"show_queue",
"(",
")",
":",
"cmd",
"=",
"'mailq'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
".",
"splitlines",
"(",
")",
"queue",
"=",
"[",
"]",
"queue_pattern",
"=",
"re",
".",
"compile",
"(",
"r\"(?P<queue_id>^[A-Z0-9]+)\... | Show contents of the mail queue
CLI Example:
.. code-block:: bash
salt '*' postfix.show_queue | [
"Show",
"contents",
"of",
"the",
"mail",
"queue"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postfix.py#L325-L357 |
35,286 | saltstack/salt | salt/modules/solrcloud.py | collection_get_options | def collection_get_options(collection_name, **kwargs):
'''
Get collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
CLI Example:
.. code-block:: bash
salt '*' solrcloud.collection_get_options collection_name
'''
cluster = cluster_st... | python | def collection_get_options(collection_name, **kwargs):
'''
Get collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
CLI Example:
.. code-block:: bash
salt '*' solrcloud.collection_get_options collection_name
'''
cluster = cluster_st... | [
"def",
"collection_get_options",
"(",
"collection_name",
",",
"*",
"*",
"kwargs",
")",
":",
"cluster",
"=",
"cluster_status",
"(",
"*",
"*",
"kwargs",
")",
"options",
"=",
"{",
"\"collection.configName\"",
":",
"cluster",
"[",
"\"collections\"",
"]",
"[",
"col... | Get collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
CLI Example:
.. code-block:: bash
salt '*' solrcloud.collection_get_options collection_name | [
"Get",
"collection",
"options"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solrcloud.py#L445-L473 |
35,287 | saltstack/salt | salt/modules/solrcloud.py | collection_set_options | def collection_set_options(collection_name, options, **kwargs):
'''
Change collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
Note that not every parameter can be changed after collection creation
CLI Example:
.. code-block:: bash
sal... | python | def collection_set_options(collection_name, options, **kwargs):
'''
Change collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
Note that not every parameter can be changed after collection creation
CLI Example:
.. code-block:: bash
sal... | [
"def",
"collection_set_options",
"(",
"collection_name",
",",
"options",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"option",
"in",
"list",
"(",
"options",
".",
"keys",
"(",
")",
")",
":",
"if",
"option",
"not",
"in",
"CREATION_ONLY_OPTION",
":",
"raise",
... | Change collection options
Additional parameters (kwargs) may be passed, they will be proxied to http.query
Note that not every parameter can be changed after collection creation
CLI Example:
.. code-block:: bash
salt '*' solrcloud.collection_set_options collection_name options={"replication... | [
"Change",
"collection",
"options"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solrcloud.py#L476-L497 |
35,288 | saltstack/salt | salt/modules/keystore.py | list | def list(keystore, passphrase, alias=None, return_cert=False):
'''
Lists certificates in a keytool managed keystore.
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the keystore
:param alias: (Optional) If found, displays details on only t... | python | def list(keystore, passphrase, alias=None, return_cert=False):
'''
Lists certificates in a keytool managed keystore.
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the keystore
:param alias: (Optional) If found, displays details on only t... | [
"def",
"list",
"(",
"keystore",
",",
"passphrase",
",",
"alias",
"=",
"None",
",",
"return_cert",
"=",
"False",
")",
":",
"ASN1",
"=",
"OpenSSL",
".",
"crypto",
".",
"FILETYPE_ASN1",
"PEM",
"=",
"OpenSSL",
".",
"crypto",
".",
"FILETYPE_PEM",
"decoded_certs... | Lists certificates in a keytool managed keystore.
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the keystore
:param alias: (Optional) If found, displays details on only this key
:param return_certs: (Optional) Also return certificate PEM.
... | [
"Lists",
"certificates",
"in",
"a",
"keytool",
"managed",
"keystore",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystore.py#L63-L121 |
35,289 | saltstack/salt | salt/modules/keystore.py | add | def add(name, keystore, passphrase, certificate, private_key=None):
'''
Adds certificates to an existing keystore or creates a new one if necesssary.
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the... | python | def add(name, keystore, passphrase, certificate, private_key=None):
'''
Adds certificates to an existing keystore or creates a new one if necesssary.
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the... | [
"def",
"add",
"(",
"name",
",",
"keystore",
",",
"passphrase",
",",
"certificate",
",",
"private_key",
"=",
"None",
")",
":",
"ASN1",
"=",
"OpenSSL",
".",
"crypto",
".",
"FILETYPE_ASN1",
"PEM",
"=",
"OpenSSL",
".",
"crypto",
".",
"FILETYPE_PEM",
"certs_lis... | Adds certificates to an existing keystore or creates a new one if necesssary.
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the keystore
:param certificate: The PEM public certificate to add to keystore.... | [
"Adds",
"certificates",
"to",
"an",
"existing",
"keystore",
"or",
"creates",
"a",
"new",
"one",
"if",
"necesssary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystore.py#L124-L172 |
35,290 | saltstack/salt | salt/modules/keystore.py | remove | def remove(name, keystore, passphrase):
'''
Removes a certificate from an existing keystore.
Returns True if remove was successful, otherwise False
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode t... | python | def remove(name, keystore, passphrase):
'''
Removes a certificate from an existing keystore.
Returns True if remove was successful, otherwise False
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode t... | [
"def",
"remove",
"(",
"name",
",",
"keystore",
",",
"passphrase",
")",
":",
"certs_list",
"=",
"[",
"]",
"keystore_object",
"=",
"jks",
".",
"KeyStore",
".",
"load",
"(",
"keystore",
",",
"passphrase",
")",
"for",
"alias",
",",
"loaded_cert",
"in",
"keys... | Removes a certificate from an existing keystore.
Returns True if remove was successful, otherwise False
:param name: alias for the certificate
:param keystore: The path to the keystore file to query
:param passphrase: The passphrase to use to decode the keystore
CLI Example:
.. code-block:: b... | [
"Removes",
"a",
"certificate",
"from",
"an",
"existing",
"keystore",
".",
"Returns",
"True",
"if",
"remove",
"was",
"successful",
"otherwise",
"False"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystore.py#L175-L203 |
35,291 | saltstack/salt | salt/cache/localfs.py | store | def store(bank, key, data, cachedir):
'''
Store information in a file.
'''
base = os.path.join(cachedir, os.path.normpath(bank))
try:
os.makedirs(base)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise SaltCacheError(
'The cache directory, {0}... | python | def store(bank, key, data, cachedir):
'''
Store information in a file.
'''
base = os.path.join(cachedir, os.path.normpath(bank))
try:
os.makedirs(base)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise SaltCacheError(
'The cache directory, {0}... | [
"def",
"store",
"(",
"bank",
",",
"key",
",",
"data",
",",
"cachedir",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cachedir",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"bank",
")",
")",
"try",
":",
"os",
".",
"makedirs",
"(... | Store information in a file. | [
"Store",
"information",
"in",
"a",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/localfs.py#L44-L72 |
35,292 | saltstack/salt | salt/cache/localfs.py | fetch | def fetch(bank, key, cachedir):
'''
Fetch information from a file.
'''
inkey = False
key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
if not os.path.isfile(key_file):
# The bank includes the full filename, and the key is inside the file
key_file = os... | python | def fetch(bank, key, cachedir):
'''
Fetch information from a file.
'''
inkey = False
key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
if not os.path.isfile(key_file):
# The bank includes the full filename, and the key is inside the file
key_file = os... | [
"def",
"fetch",
"(",
"bank",
",",
"key",
",",
"cachedir",
")",
":",
"inkey",
"=",
"False",
"key_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cachedir",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"bank",
")",
",",
"'{0}.p'",
".",
"format",
... | Fetch information from a file. | [
"Fetch",
"information",
"from",
"a",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/localfs.py#L75-L100 |
35,293 | saltstack/salt | salt/cache/localfs.py | updated | def updated(bank, key, cachedir):
'''
Return the epoch of the mtime for this cache file
'''
key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
if not os.path.isfile(key_file):
log.warning('Cache file "%s" does not exist', key_file)
return None
try:
... | python | def updated(bank, key, cachedir):
'''
Return the epoch of the mtime for this cache file
'''
key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
if not os.path.isfile(key_file):
log.warning('Cache file "%s" does not exist', key_file)
return None
try:
... | [
"def",
"updated",
"(",
"bank",
",",
"key",
",",
"cachedir",
")",
":",
"key_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cachedir",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"bank",
")",
",",
"'{0}.p'",
".",
"format",
"(",
"key",
")",
")"... | Return the epoch of the mtime for this cache file | [
"Return",
"the",
"epoch",
"of",
"the",
"mtime",
"for",
"this",
"cache",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/localfs.py#L103-L118 |
35,294 | saltstack/salt | salt/utils/win_reg.py | broadcast_change | def broadcast_change():
'''
Refresh the windows environment.
.. note::
This will only effect new processes and windows. Services will not see
the change until the system restarts.
Returns:
bool: True if successful, otherwise False
Usage:
.. code-block:: python
... | python | def broadcast_change():
'''
Refresh the windows environment.
.. note::
This will only effect new processes and windows. Services will not see
the change until the system restarts.
Returns:
bool: True if successful, otherwise False
Usage:
.. code-block:: python
... | [
"def",
"broadcast_change",
"(",
")",
":",
"# https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx",
"_",
",",
"res",
"=",
"win32gui",
".",
"SendMessageTimeout",
"(",
"win32con",
".",
"HWND_BROADCAST",
",",
"win32con",
".",
"WM_SETTINGCHANGE",
",",... | Refresh the windows environment.
.. note::
This will only effect new processes and windows. Services will not see
the change until the system restarts.
Returns:
bool: True if successful, otherwise False
Usage:
.. code-block:: python
import salt.utils.win_reg
... | [
"Refresh",
"the",
"windows",
"environment",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_reg.py#L269-L291 |
35,295 | saltstack/salt | salt/utils/win_reg.py | list_values | def list_values(hive, key=None, use_32bit_registry=False, include_default=True):
'''
Enumerates the values in a registry key or hive.
Args:
hive (str):
The name of the hive. Can be one of the following:
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER o... | python | def list_values(hive, key=None, use_32bit_registry=False, include_default=True):
'''
Enumerates the values in a registry key or hive.
Args:
hive (str):
The name of the hive. Can be one of the following:
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER o... | [
"def",
"list_values",
"(",
"hive",
",",
"key",
"=",
"None",
",",
"use_32bit_registry",
"=",
"False",
",",
"include_default",
"=",
"True",
")",
":",
"local_hive",
"=",
"_to_unicode",
"(",
"hive",
")",
"local_key",
"=",
"_to_unicode",
"(",
"key",
")",
"regis... | Enumerates the values in a registry key or hive.
Args:
hive (str):
The name of the hive. Can be one of the following:
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER or HKCU
- HKEY_USER or HKU
- HKEY_CLASSES_ROOT or HKCR
... | [
"Enumerates",
"the",
"values",
"in",
"a",
"registry",
"key",
"or",
"hive",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_reg.py#L360-L438 |
35,296 | saltstack/salt | salt/utils/win_reg.py | cast_vdata | def cast_vdata(vdata=None, vtype='REG_SZ'):
'''
Cast the ``vdata` value to the appropriate data type for the registry type
specified in ``vtype``
Args:
vdata (str, int, list, bytes): The data to cast
vtype (str):
The type of data to be written to the registry. Must be one ... | python | def cast_vdata(vdata=None, vtype='REG_SZ'):
'''
Cast the ``vdata` value to the appropriate data type for the registry type
specified in ``vtype``
Args:
vdata (str, int, list, bytes): The data to cast
vtype (str):
The type of data to be written to the registry. Must be one ... | [
"def",
"cast_vdata",
"(",
"vdata",
"=",
"None",
",",
"vtype",
"=",
"'REG_SZ'",
")",
":",
"# Check data type and cast to expected type",
"# int will automatically become long on 64bit numbers",
"# https://www.python.org/dev/peps/pep-0237/",
"registry",
"=",
"Registry",
"(",
")",... | Cast the ``vdata` value to the appropriate data type for the registry type
specified in ``vtype``
Args:
vdata (str, int, list, bytes): The data to cast
vtype (str):
The type of data to be written to the registry. Must be one of the
following:
- REG_BIN... | [
"Cast",
"the",
"vdata",
"value",
"to",
"the",
"appropriate",
"data",
"type",
"for",
"the",
"registry",
"type",
"specified",
"in",
"vtype"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_reg.py#L722-L777 |
35,297 | saltstack/salt | salt/utils/win_reg.py | delete_value | def delete_value(hive, key, vname=None, use_32bit_registry=False):
'''
Delete a registry value entry or the default value for a key.
Args:
hive (str):
The name of the hive. Can be one of the following
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER or ... | python | def delete_value(hive, key, vname=None, use_32bit_registry=False):
'''
Delete a registry value entry or the default value for a key.
Args:
hive (str):
The name of the hive. Can be one of the following
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER or ... | [
"def",
"delete_value",
"(",
"hive",
",",
"key",
",",
"vname",
"=",
"None",
",",
"use_32bit_registry",
"=",
"False",
")",
":",
"local_hive",
"=",
"_to_unicode",
"(",
"hive",
")",
"local_key",
"=",
"_to_unicode",
"(",
"key",
")",
"local_vname",
"=",
"_to_uni... | Delete a registry value entry or the default value for a key.
Args:
hive (str):
The name of the hive. Can be one of the following
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_USER or HKCU
- HKEY_USER or HKU
- HKEY_CLASSES_ROOT or ... | [
"Delete",
"a",
"registry",
"value",
"entry",
"or",
"the",
"default",
"value",
"for",
"a",
"key",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_reg.py#L890-L955 |
35,298 | saltstack/salt | salt/modules/ssh.py | _refine_enc | def _refine_enc(enc):
'''
Return the properly formatted ssh value for the authorized encryption key
type. ecdsa defaults to 256 bits, must give full ecdsa enc schema string
if using higher enc. If the type is not found, raise CommandExecutionError.
'''
rsa = ['r', 'rsa', 'ssh-rsa']
dss = ['... | python | def _refine_enc(enc):
'''
Return the properly formatted ssh value for the authorized encryption key
type. ecdsa defaults to 256 bits, must give full ecdsa enc schema string
if using higher enc. If the type is not found, raise CommandExecutionError.
'''
rsa = ['r', 'rsa', 'ssh-rsa']
dss = ['... | [
"def",
"_refine_enc",
"(",
"enc",
")",
":",
"rsa",
"=",
"[",
"'r'",
",",
"'rsa'",
",",
"'ssh-rsa'",
"]",
"dss",
"=",
"[",
"'d'",
",",
"'dsa'",
",",
"'dss'",
",",
"'ssh-dss'",
"]",
"ecdsa",
"=",
"[",
"'e'",
",",
"'ecdsa'",
",",
"'ecdsa-sha2-nistp521'"... | Return the properly formatted ssh value for the authorized encryption key
type. ecdsa defaults to 256 bits, must give full ecdsa enc schema string
if using higher enc. If the type is not found, raise CommandExecutionError. | [
"Return",
"the",
"properly",
"formatted",
"ssh",
"value",
"for",
"the",
"authorized",
"encryption",
"key",
"type",
".",
"ecdsa",
"defaults",
"to",
"256",
"bits",
"must",
"give",
"full",
"ecdsa",
"enc",
"schema",
"string",
"if",
"using",
"higher",
"enc",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ssh.py#L52-L80 |
35,299 | saltstack/salt | salt/modules/ssh.py | _format_auth_line | def _format_auth_line(key, enc, comment, options):
'''
Properly format user input.
'''
line = ''
if options:
line += '{0} '.format(','.join(options))
line += '{0} {1} {2}\n'.format(enc, key, comment)
return line | python | def _format_auth_line(key, enc, comment, options):
'''
Properly format user input.
'''
line = ''
if options:
line += '{0} '.format(','.join(options))
line += '{0} {1} {2}\n'.format(enc, key, comment)
return line | [
"def",
"_format_auth_line",
"(",
"key",
",",
"enc",
",",
"comment",
",",
"options",
")",
":",
"line",
"=",
"''",
"if",
"options",
":",
"line",
"+=",
"'{0} '",
".",
"format",
"(",
"','",
".",
"join",
"(",
"options",
")",
")",
"line",
"+=",
"'{0} {1} {... | Properly format user input. | [
"Properly",
"format",
"user",
"input",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ssh.py#L83-L91 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.