repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/nilrt_ip.py | build_network_settings | def build_network_settings(**settings):
'''
Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings>
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this versi... | python | def build_network_settings(**settings):
'''
Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings>
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this versi... | [
"def",
"build_network_settings",
"(",
"*",
"*",
"settings",
")",
":",
"if",
"__grains__",
"[",
"'lsb_distrib_id'",
"]",
"==",
"'nilrt'",
":",
"raise",
"salt",
".",
"exceptions",
".",
"CommandExecutionError",
"(",
"'Not supported in this version.'",
")",
"changes",
... | Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings> | [
"Build",
"the",
"global",
"network",
"script",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L951-L978 | train |
saltstack/salt | salt/modules/nilrt_ip.py | get_network_settings | def get_network_settings():
'''
Return the contents of the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_network_settings
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this version.')
... | python | def get_network_settings():
'''
Return the contents of the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_network_settings
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this version.')
... | [
"def",
"get_network_settings",
"(",
")",
":",
"if",
"__grains__",
"[",
"'lsb_distrib_id'",
"]",
"==",
"'nilrt'",
":",
"raise",
"salt",
".",
"exceptions",
".",
"CommandExecutionError",
"(",
"'Not supported in this version.'",
")",
"settings",
"=",
"[",
"]",
"networ... | Return the contents of the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_network_settings | [
"Return",
"the",
"contents",
"of",
"the",
"global",
"network",
"script",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L981-L998 | train |
saltstack/salt | salt/modules/nilrt_ip.py | apply_network_settings | def apply_network_settings(**settings):
'''
Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this version.')
... | python | def apply_network_settings(**settings):
'''
Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings
'''
if __grains__['lsb_distrib_id'] == 'nilrt':
raise salt.exceptions.CommandExecutionError('Not supported in this version.')
... | [
"def",
"apply_network_settings",
"(",
"*",
"*",
"settings",
")",
":",
"if",
"__grains__",
"[",
"'lsb_distrib_id'",
"]",
"==",
"'nilrt'",
":",
"raise",
"salt",
".",
"exceptions",
".",
"CommandExecutionError",
"(",
"'Not supported in this version.'",
")",
"if",
"'re... | Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings | [
"Apply",
"global",
"network",
"configuration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L1001-L1042 | train |
saltstack/salt | salt/utils/event.py | get_event | def get_event(
node, sock_dir=None, transport='zeromq',
opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):
'''
Return an event object suitable for the named transport
:param IOLoop io_loop: Pass in an io_loop if you want asynchronous
opera... | python | def get_event(
node, sock_dir=None, transport='zeromq',
opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):
'''
Return an event object suitable for the named transport
:param IOLoop io_loop: Pass in an io_loop if you want asynchronous
opera... | [
"def",
"get_event",
"(",
"node",
",",
"sock_dir",
"=",
"None",
",",
"transport",
"=",
"'zeromq'",
",",
"opts",
"=",
"None",
",",
"listen",
"=",
"True",
",",
"io_loop",
"=",
"None",
",",
"keep_loop",
"=",
"False",
",",
"raise_errors",
"=",
"False",
")",... | Return an event object suitable for the named transport
:param IOLoop io_loop: Pass in an io_loop if you want asynchronous
operation for obtaining events. Eg use of
set_event_handler() API. Otherwise, operation
will be synchronous. | [
"Return",
"an",
"event",
"object",
"suitable",
"for",
"the",
"named",
"transport"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L119-L145 | train |
saltstack/salt | salt/utils/event.py | get_master_event | def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):
'''
Return an event object suitable for the named transport
'''
# TODO: AIO core is separate from transport
if opts['transport'] in ('zeromq', 'tcp', 'detect'):
return MasterEvent(sock_dir, ... | python | def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):
'''
Return an event object suitable for the named transport
'''
# TODO: AIO core is separate from transport
if opts['transport'] in ('zeromq', 'tcp', 'detect'):
return MasterEvent(sock_dir, ... | [
"def",
"get_master_event",
"(",
"opts",
",",
"sock_dir",
",",
"listen",
"=",
"True",
",",
"io_loop",
"=",
"None",
",",
"raise_errors",
"=",
"False",
",",
"keep_loop",
"=",
"False",
")",
":",
"# TODO: AIO core is separate from transport",
"if",
"opts",
"[",
"'t... | Return an event object suitable for the named transport | [
"Return",
"an",
"event",
"object",
"suitable",
"for",
"the",
"named",
"transport"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L148-L154 | train |
saltstack/salt | salt/utils/event.py | fire_args | def fire_args(opts, jid, tag_data, prefix=''):
'''
Fire an event containing the arguments passed to an orchestration job
'''
try:
tag_suffix = [jid, 'args']
except NameError:
pass
else:
tag = tagify(tag_suffix, prefix)
try:
_event = get_master_event(op... | python | def fire_args(opts, jid, tag_data, prefix=''):
'''
Fire an event containing the arguments passed to an orchestration job
'''
try:
tag_suffix = [jid, 'args']
except NameError:
pass
else:
tag = tagify(tag_suffix, prefix)
try:
_event = get_master_event(op... | [
"def",
"fire_args",
"(",
"opts",
",",
"jid",
",",
"tag_data",
",",
"prefix",
"=",
"''",
")",
":",
"try",
":",
"tag_suffix",
"=",
"[",
"jid",
",",
"'args'",
"]",
"except",
"NameError",
":",
"pass",
"else",
":",
"tag",
"=",
"tagify",
"(",
"tag_suffix",... | Fire an event containing the arguments passed to an orchestration job | [
"Fire",
"an",
"event",
"containing",
"the",
"arguments",
"passed",
"to",
"an",
"orchestration",
"job"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L157-L175 | train |
saltstack/salt | salt/utils/event.py | tagify | def tagify(suffix='', prefix='', base=SALT):
'''
convenience function to build a namespaced event tag string
from joining with the TABPART character the base, prefix and suffix
If string prefix is a valid key in TAGS Then use the value of key prefix
Else use prefix string
If suffix is a list T... | python | def tagify(suffix='', prefix='', base=SALT):
'''
convenience function to build a namespaced event tag string
from joining with the TABPART character the base, prefix and suffix
If string prefix is a valid key in TAGS Then use the value of key prefix
Else use prefix string
If suffix is a list T... | [
"def",
"tagify",
"(",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"''",
",",
"base",
"=",
"SALT",
")",
":",
"parts",
"=",
"[",
"base",
",",
"TAGS",
".",
"get",
"(",
"prefix",
",",
"prefix",
")",
"]",
"if",
"hasattr",
"(",
"suffix",
",",
"'append'",
... | convenience function to build a namespaced event tag string
from joining with the TABPART character the base, prefix and suffix
If string prefix is a valid key in TAGS Then use the value of key prefix
Else use prefix string
If suffix is a list Then join all string elements of suffix individually
E... | [
"convenience",
"function",
"to",
"build",
"a",
"namespaced",
"event",
"tag",
"string",
"from",
"joining",
"with",
"the",
"TABPART",
"character",
"the",
"base",
"prefix",
"and",
"suffix"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L178-L201 | train |
saltstack/salt | salt/utils/event.py | update_stats | def update_stats(stats, start_time, data):
'''
Calculate the master stats and return the updated stat info
'''
end_time = time.time()
cmd = data['cmd']
# the jid is used as the create time
try:
jid = data['jid']
except KeyError:
try:
jid = data['data']['__pub_... | python | def update_stats(stats, start_time, data):
'''
Calculate the master stats and return the updated stat info
'''
end_time = time.time()
cmd = data['cmd']
# the jid is used as the create time
try:
jid = data['jid']
except KeyError:
try:
jid = data['data']['__pub_... | [
"def",
"update_stats",
"(",
"stats",
",",
"start_time",
",",
"data",
")",
":",
"end_time",
"=",
"time",
".",
"time",
"(",
")",
"cmd",
"=",
"data",
"[",
"'cmd'",
"]",
"# the jid is used as the create time",
"try",
":",
"jid",
"=",
"data",
"[",
"'jid'",
"]... | Calculate the master stats and return the updated stat info | [
"Calculate",
"the",
"master",
"stats",
"and",
"return",
"the",
"updated",
"stat",
"info"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L204-L227 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.__load_uri | def __load_uri(self, sock_dir, node):
'''
Return the string URI for the location of the pull and pub sockets to
use for firing and listening to events
'''
if node == 'master':
if self.opts['ipc_mode'] == 'tcp':
puburi = int(self.opts['tcp_master_pub_po... | python | def __load_uri(self, sock_dir, node):
'''
Return the string URI for the location of the pull and pub sockets to
use for firing and listening to events
'''
if node == 'master':
if self.opts['ipc_mode'] == 'tcp':
puburi = int(self.opts['tcp_master_pub_po... | [
"def",
"__load_uri",
"(",
"self",
",",
"sock_dir",
",",
"node",
")",
":",
"if",
"node",
"==",
"'master'",
":",
"if",
"self",
".",
"opts",
"[",
"'ipc_mode'",
"]",
"==",
"'tcp'",
":",
"puburi",
"=",
"int",
"(",
"self",
".",
"opts",
"[",
"'tcp_master_pu... | Return the string URI for the location of the pull and pub sockets to
use for firing and listening to events | [
"Return",
"the",
"string",
"URI",
"for",
"the",
"location",
"of",
"the",
"pull",
"and",
"pub",
"sockets",
"to",
"use",
"for",
"firing",
"and",
"listening",
"to",
"events"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L302-L339 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.subscribe | def subscribe(self, tag=None, match_type=None):
'''
Subscribe to events matching the passed tag.
If you do not subscribe to a tag, events will be discarded by calls to
get_event that request a different tag. In contexts where many different
jobs are outstanding it is important t... | python | def subscribe(self, tag=None, match_type=None):
'''
Subscribe to events matching the passed tag.
If you do not subscribe to a tag, events will be discarded by calls to
get_event that request a different tag. In contexts where many different
jobs are outstanding it is important t... | [
"def",
"subscribe",
"(",
"self",
",",
"tag",
"=",
"None",
",",
"match_type",
"=",
"None",
")",
":",
"if",
"tag",
"is",
"None",
":",
"return",
"match_func",
"=",
"self",
".",
"_get_match_func",
"(",
"match_type",
")",
"self",
".",
"pending_tags",
".",
"... | Subscribe to events matching the passed tag.
If you do not subscribe to a tag, events will be discarded by calls to
get_event that request a different tag. In contexts where many different
jobs are outstanding it is important to subscribe to prevent one call
to get_event from discarding... | [
"Subscribe",
"to",
"events",
"matching",
"the",
"passed",
"tag",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L341-L354 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.unsubscribe | def unsubscribe(self, tag, match_type=None):
'''
Un-subscribe to events matching the passed tag.
'''
if tag is None:
return
match_func = self._get_match_func(match_type)
self.pending_tags.remove([tag, match_func])
old_events = self.pending_events
... | python | def unsubscribe(self, tag, match_type=None):
'''
Un-subscribe to events matching the passed tag.
'''
if tag is None:
return
match_func = self._get_match_func(match_type)
self.pending_tags.remove([tag, match_func])
old_events = self.pending_events
... | [
"def",
"unsubscribe",
"(",
"self",
",",
"tag",
",",
"match_type",
"=",
"None",
")",
":",
"if",
"tag",
"is",
"None",
":",
"return",
"match_func",
"=",
"self",
".",
"_get_match_func",
"(",
"match_type",
")",
"self",
".",
"pending_tags",
".",
"remove",
"(",... | Un-subscribe to events matching the passed tag. | [
"Un",
"-",
"subscribe",
"to",
"events",
"matching",
"the",
"passed",
"tag",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L356-L370 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.connect_pub | def connect_pub(self, timeout=None):
'''
Establish the publish connection
'''
if self.cpub:
return True
if self._run_io_loop_sync:
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if self.subscriber is None:
s... | python | def connect_pub(self, timeout=None):
'''
Establish the publish connection
'''
if self.cpub:
return True
if self._run_io_loop_sync:
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if self.subscriber is None:
s... | [
"def",
"connect_pub",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"cpub",
":",
"return",
"True",
"if",
"self",
".",
"_run_io_loop_sync",
":",
"with",
"salt",
".",
"utils",
".",
"asynchronous",
".",
"current_ioloop",
"(",
"self"... | Establish the publish connection | [
"Establish",
"the",
"publish",
"connection"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L372-L402 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.close_pub | def close_pub(self):
'''
Close the publish connection (if established)
'''
if not self.cpub:
return
self.subscriber.close()
self.subscriber = None
self.pending_events = []
self.cpub = False | python | def close_pub(self):
'''
Close the publish connection (if established)
'''
if not self.cpub:
return
self.subscriber.close()
self.subscriber = None
self.pending_events = []
self.cpub = False | [
"def",
"close_pub",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"cpub",
":",
"return",
"self",
".",
"subscriber",
".",
"close",
"(",
")",
"self",
".",
"subscriber",
"=",
"None",
"self",
".",
"pending_events",
"=",
"[",
"]",
"self",
".",
"cpub",
... | Close the publish connection (if established) | [
"Close",
"the",
"publish",
"connection",
"(",
"if",
"established",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L404-L414 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.connect_pull | def connect_pull(self, timeout=1):
'''
Establish a connection with the event pull socket
Default timeout is 1 s
'''
if self.cpush:
return True
if self._run_io_loop_sync:
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if... | python | def connect_pull(self, timeout=1):
'''
Establish a connection with the event pull socket
Default timeout is 1 s
'''
if self.cpush:
return True
if self._run_io_loop_sync:
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if... | [
"def",
"connect_pull",
"(",
"self",
",",
"timeout",
"=",
"1",
")",
":",
"if",
"self",
".",
"cpush",
":",
"return",
"True",
"if",
"self",
".",
"_run_io_loop_sync",
":",
"with",
"salt",
".",
"utils",
".",
"asynchronous",
".",
"current_ioloop",
"(",
"self",... | Establish a connection with the event pull socket
Default timeout is 1 s | [
"Establish",
"a",
"connection",
"with",
"the",
"event",
"pull",
"socket",
"Default",
"timeout",
"is",
"1",
"s"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L416-L446 | train |
saltstack/salt | salt/utils/event.py | SaltEvent._check_pending | def _check_pending(self, tag, match_func=None):
"""Check the pending_events list for events that match the tag
:param tag: The tag to search for
:type tag: str
:param tags_regex: List of re expressions to search for also
:type tags_regex: list[re.compile()]
:return:
... | python | def _check_pending(self, tag, match_func=None):
"""Check the pending_events list for events that match the tag
:param tag: The tag to search for
:type tag: str
:param tags_regex: List of re expressions to search for also
:type tags_regex: list[re.compile()]
:return:
... | [
"def",
"_check_pending",
"(",
"self",
",",
"tag",
",",
"match_func",
"=",
"None",
")",
":",
"if",
"match_func",
"is",
"None",
":",
"match_func",
"=",
"self",
".",
"_get_match_func",
"(",
")",
"old_events",
"=",
"self",
".",
"pending_events",
"self",
".",
... | Check the pending_events list for events that match the tag
:param tag: The tag to search for
:type tag: str
:param tags_regex: List of re expressions to search for also
:type tags_regex: list[re.compile()]
:return: | [
"Check",
"the",
"pending_events",
"list",
"for",
"events",
"that",
"match",
"the",
"tag"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L467-L492 | train |
saltstack/salt | salt/utils/event.py | SaltEvent._match_tag_regex | def _match_tag_regex(self, event_tag, search_tag):
'''
Check if the event_tag matches the search check.
Uses regular expression search to check.
Return True (matches) or False (no match)
'''
return self.cache_regex.get(search_tag).search(event_tag) is not None | python | def _match_tag_regex(self, event_tag, search_tag):
'''
Check if the event_tag matches the search check.
Uses regular expression search to check.
Return True (matches) or False (no match)
'''
return self.cache_regex.get(search_tag).search(event_tag) is not None | [
"def",
"_match_tag_regex",
"(",
"self",
",",
"event_tag",
",",
"search_tag",
")",
":",
"return",
"self",
".",
"cache_regex",
".",
"get",
"(",
"search_tag",
")",
".",
"search",
"(",
"event_tag",
")",
"is",
"not",
"None"
] | Check if the event_tag matches the search check.
Uses regular expression search to check.
Return True (matches) or False (no match) | [
"Check",
"if",
"the",
"event_tag",
"matches",
"the",
"search",
"check",
".",
"Uses",
"regular",
"expression",
"search",
"to",
"check",
".",
"Return",
"True",
"(",
"matches",
")",
"or",
"False",
"(",
"no",
"match",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L521-L527 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.get_event | def get_event(self,
wait=5,
tag='',
full=False,
match_type=None,
no_block=False,
auto_reconnect=False):
'''
Get a single publication.
If no publication is available, then block for up to `... | python | def get_event(self,
wait=5,
tag='',
full=False,
match_type=None,
no_block=False,
auto_reconnect=False):
'''
Get a single publication.
If no publication is available, then block for up to `... | [
"def",
"get_event",
"(",
"self",
",",
"wait",
"=",
"5",
",",
"tag",
"=",
"''",
",",
"full",
"=",
"False",
",",
"match_type",
"=",
"None",
",",
"no_block",
"=",
"False",
",",
"auto_reconnect",
"=",
"False",
")",
":",
"assert",
"self",
".",
"_run_io_lo... | Get a single publication.
If no publication is available, then block for up to ``wait`` seconds.
Return publication if it is available or ``None`` if no publication is
available.
If wait is 0, then block forever.
tag
Only return events matching the given tag. If not... | [
"Get",
"a",
"single",
"publication",
".",
"If",
"no",
"publication",
"is",
"available",
"then",
"block",
"for",
"up",
"to",
"wait",
"seconds",
".",
"Return",
"publication",
"if",
"it",
"is",
"available",
"or",
"None",
"if",
"no",
"publication",
"is",
"avai... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L590-L667 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.get_event_noblock | def get_event_noblock(self):
'''
Get the raw event without blocking or any other niceties
'''
assert self._run_io_loop_sync
if not self.cpub:
if not self.connect_pub():
return None
raw = self.subscriber.read_sync(timeout=0)
if raw is N... | python | def get_event_noblock(self):
'''
Get the raw event without blocking or any other niceties
'''
assert self._run_io_loop_sync
if not self.cpub:
if not self.connect_pub():
return None
raw = self.subscriber.read_sync(timeout=0)
if raw is N... | [
"def",
"get_event_noblock",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_run_io_loop_sync",
"if",
"not",
"self",
".",
"cpub",
":",
"if",
"not",
"self",
".",
"connect_pub",
"(",
")",
":",
"return",
"None",
"raw",
"=",
"self",
".",
"subscriber",
".",
... | Get the raw event without blocking or any other niceties | [
"Get",
"the",
"raw",
"event",
"without",
"blocking",
"or",
"any",
"other",
"niceties"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L669-L682 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.iter_events | def iter_events(self, tag='', full=False, match_type=None, auto_reconnect=False):
'''
Creates a generator that continuously listens for events
'''
while True:
data = self.get_event(tag=tag, full=full, match_type=match_type,
auto_reconnect=aut... | python | def iter_events(self, tag='', full=False, match_type=None, auto_reconnect=False):
'''
Creates a generator that continuously listens for events
'''
while True:
data = self.get_event(tag=tag, full=full, match_type=match_type,
auto_reconnect=aut... | [
"def",
"iter_events",
"(",
"self",
",",
"tag",
"=",
"''",
",",
"full",
"=",
"False",
",",
"match_type",
"=",
"None",
",",
"auto_reconnect",
"=",
"False",
")",
":",
"while",
"True",
":",
"data",
"=",
"self",
".",
"get_event",
"(",
"tag",
"=",
"tag",
... | Creates a generator that continuously listens for events | [
"Creates",
"a",
"generator",
"that",
"continuously",
"listens",
"for",
"events"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L700-L709 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.fire_event | def fire_event(self, data, tag, timeout=1000):
'''
Send a single event into the publisher with payload dict "data" and
event identifier "tag"
The default is 1000 ms
'''
if not six.text_type(tag): # no empty tags allowed
raise ValueError('Empty tag.')
... | python | def fire_event(self, data, tag, timeout=1000):
'''
Send a single event into the publisher with payload dict "data" and
event identifier "tag"
The default is 1000 ms
'''
if not six.text_type(tag): # no empty tags allowed
raise ValueError('Empty tag.')
... | [
"def",
"fire_event",
"(",
"self",
",",
"data",
",",
"tag",
",",
"timeout",
"=",
"1000",
")",
":",
"if",
"not",
"six",
".",
"text_type",
"(",
"tag",
")",
":",
"# no empty tags allowed",
"raise",
"ValueError",
"(",
"'Empty tag.'",
")",
"if",
"not",
"isinst... | Send a single event into the publisher with payload dict "data" and
event identifier "tag"
The default is 1000 ms | [
"Send",
"a",
"single",
"event",
"into",
"the",
"publisher",
"with",
"payload",
"dict",
"data",
"and",
"event",
"identifier",
"tag"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L711-L767 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.fire_master | def fire_master(self, data, tag, timeout=1000):
''''
Send a single event to the master, with the payload "data" and the
event identifier "tag".
Default timeout is 1000ms
'''
msg = {
'tag': tag,
'data': data,
'events': None,
... | python | def fire_master(self, data, tag, timeout=1000):
''''
Send a single event to the master, with the payload "data" and the
event identifier "tag".
Default timeout is 1000ms
'''
msg = {
'tag': tag,
'data': data,
'events': None,
... | [
"def",
"fire_master",
"(",
"self",
",",
"data",
",",
"tag",
",",
"timeout",
"=",
"1000",
")",
":",
"msg",
"=",
"{",
"'tag'",
":",
"tag",
",",
"'data'",
":",
"data",
",",
"'events'",
":",
"None",
",",
"'pretag'",
":",
"None",
"}",
"return",
"self",
... | Send a single event to the master, with the payload "data" and the
event identifier "tag".
Default timeout is 1000ms | [
"Send",
"a",
"single",
"event",
"to",
"the",
"master",
"with",
"the",
"payload",
"data",
"and",
"the",
"event",
"identifier",
"tag",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L769-L782 | train |
saltstack/salt | salt/utils/event.py | SaltEvent._fire_ret_load_specific_fun | def _fire_ret_load_specific_fun(self, load, fun_index=0):
'''
Helper function for fire_ret_load
'''
if isinstance(load['fun'], list):
# Multi-function job
fun = load['fun'][fun_index]
# 'retcode' was already validated to exist and be non-zero
... | python | def _fire_ret_load_specific_fun(self, load, fun_index=0):
'''
Helper function for fire_ret_load
'''
if isinstance(load['fun'], list):
# Multi-function job
fun = load['fun'][fun_index]
# 'retcode' was already validated to exist and be non-zero
... | [
"def",
"_fire_ret_load_specific_fun",
"(",
"self",
",",
"load",
",",
"fun_index",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"load",
"[",
"'fun'",
"]",
",",
"list",
")",
":",
"# Multi-function job",
"fun",
"=",
"load",
"[",
"'fun'",
"]",
"[",
"fun_inde... | Helper function for fire_ret_load | [
"Helper",
"function",
"for",
"fire_ret_load"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L792-L844 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.fire_ret_load | def fire_ret_load(self, load):
'''
Fire events based on information in the return load
'''
if load.get('retcode') and load.get('fun'):
if isinstance(load['fun'], list):
# Multi-function job
if isinstance(load['retcode'], list):
... | python | def fire_ret_load(self, load):
'''
Fire events based on information in the return load
'''
if load.get('retcode') and load.get('fun'):
if isinstance(load['fun'], list):
# Multi-function job
if isinstance(load['retcode'], list):
... | [
"def",
"fire_ret_load",
"(",
"self",
",",
"load",
")",
":",
"if",
"load",
".",
"get",
"(",
"'retcode'",
")",
"and",
"load",
".",
"get",
"(",
"'fun'",
")",
":",
"if",
"isinstance",
"(",
"load",
"[",
"'fun'",
"]",
",",
"list",
")",
":",
"# Multi-func... | Fire events based on information in the return load | [
"Fire",
"events",
"based",
"on",
"information",
"in",
"the",
"return",
"load"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L846-L874 | train |
saltstack/salt | salt/utils/event.py | SaltEvent.set_event_handler | def set_event_handler(self, event_handler):
'''
Invoke the event_handler callback each time an event arrives.
'''
assert not self._run_io_loop_sync
if not self.cpub:
self.connect_pub()
self.subscriber.callbacks.add(event_handler)
if not self.subscrib... | python | def set_event_handler(self, event_handler):
'''
Invoke the event_handler callback each time an event arrives.
'''
assert not self._run_io_loop_sync
if not self.cpub:
self.connect_pub()
self.subscriber.callbacks.add(event_handler)
if not self.subscrib... | [
"def",
"set_event_handler",
"(",
"self",
",",
"event_handler",
")",
":",
"assert",
"not",
"self",
".",
"_run_io_loop_sync",
"if",
"not",
"self",
".",
"cpub",
":",
"self",
".",
"connect_pub",
"(",
")",
"self",
".",
"subscriber",
".",
"callbacks",
".",
"add"... | Invoke the event_handler callback each time an event arrives. | [
"Invoke",
"the",
"event_handler",
"callback",
"each",
"time",
"an",
"event",
"arrives",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L880-L892 | train |
saltstack/salt | salt/utils/event.py | EventPublisher.run | def run(self):
'''
Bind the pub and pull sockets for events
'''
salt.utils.process.appendproctitle(self.__class__.__name__)
self.io_loop = tornado.ioloop.IOLoop()
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if self.opts['ipc_mode'] == 'tcp':
... | python | def run(self):
'''
Bind the pub and pull sockets for events
'''
salt.utils.process.appendproctitle(self.__class__.__name__)
self.io_loop = tornado.ioloop.IOLoop()
with salt.utils.asynchronous.current_ioloop(self.io_loop):
if self.opts['ipc_mode'] == 'tcp':
... | [
"def",
"run",
"(",
"self",
")",
":",
"salt",
".",
"utils",
".",
"process",
".",
"appendproctitle",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"io_loop",
"=",
"tornado",
".",
"ioloop",
".",
"IOLoop",
"(",
")",
"with",
"salt",
".... | Bind the pub and pull sockets for events | [
"Bind",
"the",
"pub",
"and",
"pull",
"sockets",
"for",
"events"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1100-L1147 | train |
saltstack/salt | salt/utils/event.py | EventPublisher.handle_publish | def handle_publish(self, package, _):
'''
Get something from epull, publish it out epub, and return the package (or None)
'''
try:
self.publisher.publish(package)
return package
# Add an extra fallback in case a forked process leeks through
except ... | python | def handle_publish(self, package, _):
'''
Get something from epull, publish it out epub, and return the package (or None)
'''
try:
self.publisher.publish(package)
return package
# Add an extra fallback in case a forked process leeks through
except ... | [
"def",
"handle_publish",
"(",
"self",
",",
"package",
",",
"_",
")",
":",
"try",
":",
"self",
".",
"publisher",
".",
"publish",
"(",
"package",
")",
"return",
"package",
"# Add an extra fallback in case a forked process leeks through",
"except",
"Exception",
":",
... | Get something from epull, publish it out epub, and return the package (or None) | [
"Get",
"something",
"from",
"epull",
"publish",
"it",
"out",
"epub",
"and",
"return",
"the",
"package",
"(",
"or",
"None",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1149-L1160 | train |
saltstack/salt | salt/utils/event.py | EventReturn.run | def run(self):
'''
Spin up the multiprocess event returner
'''
salt.utils.process.appendproctitle(self.__class__.__name__)
self.event = get_event('master', opts=self.opts, listen=True)
events = self.event.iter_events(full=True)
self.event.fire_event({}, 'salt/even... | python | def run(self):
'''
Spin up the multiprocess event returner
'''
salt.utils.process.appendproctitle(self.__class__.__name__)
self.event = get_event('master', opts=self.opts, listen=True)
events = self.event.iter_events(full=True)
self.event.fire_event({}, 'salt/even... | [
"def",
"run",
"(",
"self",
")",
":",
"salt",
".",
"utils",
".",
"process",
".",
"appendproctitle",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"event",
"=",
"get_event",
"(",
"'master'",
",",
"opts",
"=",
"self",
".",
"opts",
",... | Spin up the multiprocess event returner | [
"Spin",
"up",
"the",
"multiprocess",
"event",
"returner"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1270-L1290 | train |
saltstack/salt | salt/utils/event.py | EventReturn._filter | def _filter(self, event):
'''
Take an event and run it through configured filters.
Returns True if event should be stored, else False
'''
tag = event['tag']
if self.opts['event_return_whitelist']:
ret = False
else:
ret = True
for w... | python | def _filter(self, event):
'''
Take an event and run it through configured filters.
Returns True if event should be stored, else False
'''
tag = event['tag']
if self.opts['event_return_whitelist']:
ret = False
else:
ret = True
for w... | [
"def",
"_filter",
"(",
"self",
",",
"event",
")",
":",
"tag",
"=",
"event",
"[",
"'tag'",
"]",
"if",
"self",
".",
"opts",
"[",
"'event_return_whitelist'",
"]",
":",
"ret",
"=",
"False",
"else",
":",
"ret",
"=",
"True",
"for",
"whitelist_match",
"in",
... | Take an event and run it through configured filters.
Returns True if event should be stored, else False | [
"Take",
"an",
"event",
"and",
"run",
"it",
"through",
"configured",
"filters",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1292-L1311 | train |
saltstack/salt | salt/utils/event.py | StateFire.fire_master | def fire_master(self, data, tag, preload=None):
'''
Fire an event off on the master server
CLI Example:
.. code-block:: bash
salt '*' event.fire_master 'stuff to be in the event' 'tag'
'''
load = {}
if preload:
load.update(preload)
... | python | def fire_master(self, data, tag, preload=None):
'''
Fire an event off on the master server
CLI Example:
.. code-block:: bash
salt '*' event.fire_master 'stuff to be in the event' 'tag'
'''
load = {}
if preload:
load.update(preload)
... | [
"def",
"fire_master",
"(",
"self",
",",
"data",
",",
"tag",
",",
"preload",
"=",
"None",
")",
":",
"load",
"=",
"{",
"}",
"if",
"preload",
":",
"load",
".",
"update",
"(",
"preload",
")",
"load",
".",
"update",
"(",
"{",
"'id'",
":",
"self",
".",... | Fire an event off on the master server
CLI Example:
.. code-block:: bash
salt '*' event.fire_master 'stuff to be in the event' 'tag' | [
"Fire",
"an",
"event",
"off",
"on",
"the",
"master",
"server"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1327-L1356 | train |
saltstack/salt | salt/utils/event.py | StateFire.fire_running | def fire_running(self, running):
'''
Pass in a state "running" dict, this is the return dict from a state
call. The dict will be processed and fire events.
By default yellows and reds fire events on the master and minion, but
this can be configured.
'''
load = {'... | python | def fire_running(self, running):
'''
Pass in a state "running" dict, this is the return dict from a state
call. The dict will be processed and fire events.
By default yellows and reds fire events on the master and minion, but
this can be configured.
'''
load = {'... | [
"def",
"fire_running",
"(",
"self",
",",
"running",
")",
":",
"load",
"=",
"{",
"'id'",
":",
"self",
".",
"opts",
"[",
"'id'",
"]",
",",
"'events'",
":",
"[",
"]",
",",
"'cmd'",
":",
"'_minion_event'",
"}",
"for",
"stag",
"in",
"sorted",
"(",
"runn... | Pass in a state "running" dict, this is the return dict from a state
call. The dict will be processed and fire events.
By default yellows and reds fire events on the master and minion, but
this can be configured. | [
"Pass",
"in",
"a",
"state",
"running",
"dict",
"this",
"is",
"the",
"return",
"dict",
"from",
"a",
"state",
"call",
".",
"The",
"dict",
"will",
"be",
"processed",
"and",
"fire",
"events",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1358-L1388 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter.load | def load(self, **descr):
'''
Load data by keys.
:param data:
:return:
'''
for obj, data in descr.items():
setattr(self._data, obj, data)
return self | python | def load(self, **descr):
'''
Load data by keys.
:param data:
:return:
'''
for obj, data in descr.items():
setattr(self._data, obj, data)
return self | [
"def",
"load",
"(",
"self",
",",
"*",
"*",
"descr",
")",
":",
"for",
"obj",
",",
"data",
"in",
"descr",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
".",
"_data",
",",
"obj",
",",
"data",
")",
"return",
"self"
] | Load data by keys.
:param data:
:return: | [
"Load",
"data",
"by",
"keys",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L50-L60 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter.export | def export(self, name):
'''
Export to the Kiwi config.xml as text.
:return:
'''
self.name = name
root = self._create_doc()
self._set_description(root)
self._set_preferences(root)
self._set_repositories(root)
self._set_users(root)
... | python | def export(self, name):
'''
Export to the Kiwi config.xml as text.
:return:
'''
self.name = name
root = self._create_doc()
self._set_description(root)
self._set_preferences(root)
self._set_repositories(root)
self._set_users(root)
... | [
"def",
"export",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"root",
"=",
"self",
".",
"_create_doc",
"(",
")",
"self",
".",
"_set_description",
"(",
"root",
")",
"self",
".",
"_set_preferences",
"(",
"root",
")",
"self",
".... | Export to the Kiwi config.xml as text.
:return: | [
"Export",
"to",
"the",
"Kiwi",
"config",
".",
"xml",
"as",
"text",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L62-L79 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._get_package_manager | def _get_package_manager(self):
'''
Get package manager.
:return:
'''
ret = None
if self.__grains__.get('os_family') in ('Kali', 'Debian'):
ret = 'apt-get'
elif self.__grains__.get('os_family', '') == 'Suse':
ret = 'zypper'
elif se... | python | def _get_package_manager(self):
'''
Get package manager.
:return:
'''
ret = None
if self.__grains__.get('os_family') in ('Kali', 'Debian'):
ret = 'apt-get'
elif self.__grains__.get('os_family', '') == 'Suse':
ret = 'zypper'
elif se... | [
"def",
"_get_package_manager",
"(",
"self",
")",
":",
"ret",
"=",
"None",
"if",
"self",
".",
"__grains__",
".",
"get",
"(",
"'os_family'",
")",
"in",
"(",
"'Kali'",
",",
"'Debian'",
")",
":",
"ret",
"=",
"'apt-get'",
"elif",
"self",
".",
"__grains__",
... | Get package manager.
:return: | [
"Get",
"package",
"manager",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L81-L98 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._set_preferences | def _set_preferences(self, node):
'''
Set preferences.
:return:
'''
pref = etree.SubElement(node, 'preferences')
pacman = etree.SubElement(pref, 'packagemanager')
pacman.text = self._get_package_manager()
p_version = etree.SubElement(pref, 'version')
... | python | def _set_preferences(self, node):
'''
Set preferences.
:return:
'''
pref = etree.SubElement(node, 'preferences')
pacman = etree.SubElement(pref, 'packagemanager')
pacman.text = self._get_package_manager()
p_version = etree.SubElement(pref, 'version')
... | [
"def",
"_set_preferences",
"(",
"self",
",",
"node",
")",
":",
"pref",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'preferences'",
")",
"pacman",
"=",
"etree",
".",
"SubElement",
"(",
"pref",
",",
"'packagemanager'",
")",
"pacman",
".",
"text",
"... | Set preferences.
:return: | [
"Set",
"preferences",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L100-L126 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._get_user_groups | def _get_user_groups(self, user):
'''
Get user groups.
:param user:
:return:
'''
return [g.gr_name for g in grp.getgrall()
if user in g.gr_mem] + [grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name] | python | def _get_user_groups(self, user):
'''
Get user groups.
:param user:
:return:
'''
return [g.gr_name for g in grp.getgrall()
if user in g.gr_mem] + [grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name] | [
"def",
"_get_user_groups",
"(",
"self",
",",
"user",
")",
":",
"return",
"[",
"g",
".",
"gr_name",
"for",
"g",
"in",
"grp",
".",
"getgrall",
"(",
")",
"if",
"user",
"in",
"g",
".",
"gr_mem",
"]",
"+",
"[",
"grp",
".",
"getgrgid",
"(",
"pwd",
".",... | Get user groups.
:param user:
:return: | [
"Get",
"user",
"groups",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L128-L136 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._set_users | def _set_users(self, node):
'''
Create existing local users.
<users group="root">
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
</users>
:param node:
:return:
'''
# Get real local users with the local passwords
... | python | def _set_users(self, node):
'''
Create existing local users.
<users group="root">
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
</users>
:param node:
:return:
'''
# Get real local users with the local passwords
... | [
"def",
"_set_users",
"(",
"self",
",",
"node",
")",
":",
"# Get real local users with the local passwords",
"shadow",
"=",
"{",
"}",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"'/etc/shadow'",
")",
"as",
"rfh",
":",
"for",
"sh_line",
"in"... | Create existing local users.
<users group="root">
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
</users>
:param node:
:return: | [
"Create",
"existing",
"local",
"users",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L138-L177 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._set_repositories | def _set_repositories(self, node):
'''
Create repositories.
:param node:
:return:
'''
priority = 99
for repo_id, repo_data in self._data.software.get('repositories', {}).items():
if type(repo_data) == list:
repo_data = repo_data[0]
... | python | def _set_repositories(self, node):
'''
Create repositories.
:param node:
:return:
'''
priority = 99
for repo_id, repo_data in self._data.software.get('repositories', {}).items():
if type(repo_data) == list:
repo_data = repo_data[0]
... | [
"def",
"_set_repositories",
"(",
"self",
",",
"node",
")",
":",
"priority",
"=",
"99",
"for",
"repo_id",
",",
"repo_data",
"in",
"self",
".",
"_data",
".",
"software",
".",
"get",
"(",
"'repositories'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":"... | Create repositories.
:param node:
:return: | [
"Create",
"repositories",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L179-L206 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._set_packages | def _set_packages(self, node):
'''
Set packages and collections.
:param node:
:return:
'''
pkgs = etree.SubElement(node, 'packages')
for pkg_name, pkg_version in sorted(self._data.software.get('packages', {}).items()):
pkg = etree.SubElement(pkgs, 'pa... | python | def _set_packages(self, node):
'''
Set packages and collections.
:param node:
:return:
'''
pkgs = etree.SubElement(node, 'packages')
for pkg_name, pkg_version in sorted(self._data.software.get('packages', {}).items()):
pkg = etree.SubElement(pkgs, 'pa... | [
"def",
"_set_packages",
"(",
"self",
",",
"node",
")",
":",
"pkgs",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'packages'",
")",
"for",
"pkg_name",
",",
"pkg_version",
"in",
"sorted",
"(",
"self",
".",
"_data",
".",
"software",
".",
"get",
"("... | Set packages and collections.
:param node:
:return: | [
"Set",
"packages",
"and",
"collections",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L208-L227 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._set_description | def _set_description(self, node):
'''
Create a system description.
:return:
'''
hostname = socket.getfqdn() or platform.node()
descr = etree.SubElement(node, 'description')
author = etree.SubElement(descr, 'author')
author.text = "salt.modules.node on {0... | python | def _set_description(self, node):
'''
Create a system description.
:return:
'''
hostname = socket.getfqdn() or platform.node()
descr = etree.SubElement(node, 'description')
author = etree.SubElement(descr, 'author')
author.text = "salt.modules.node on {0... | [
"def",
"_set_description",
"(",
"self",
",",
"node",
")",
":",
"hostname",
"=",
"socket",
".",
"getfqdn",
"(",
")",
"or",
"platform",
".",
"node",
"(",
")",
"descr",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'description'",
")",
"author",
"="... | Create a system description.
:return: | [
"Create",
"a",
"system",
"description",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L229-L245 | train |
saltstack/salt | salt/modules/inspectlib/kiwiproc.py | KiwiExporter._create_doc | def _create_doc(self):
'''
Create document.
:return:
'''
root = etree.Element('image')
root.set('schemaversion', '6.3')
root.set('name', self.name)
return root | python | def _create_doc(self):
'''
Create document.
:return:
'''
root = etree.Element('image')
root.set('schemaversion', '6.3')
root.set('name', self.name)
return root | [
"def",
"_create_doc",
"(",
"self",
")",
":",
"root",
"=",
"etree",
".",
"Element",
"(",
"'image'",
")",
"root",
".",
"set",
"(",
"'schemaversion'",
",",
"'6.3'",
")",
"root",
".",
"set",
"(",
"'name'",
",",
"self",
".",
"name",
")",
"return",
"root"
... | Create document.
:return: | [
"Create",
"document",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L247-L257 | train |
saltstack/salt | salt/sdb/vault.py | set_ | def set_(key, value, profile=None):
'''
Set a key/value pair in the vault service
'''
if '?' in key:
__utils__['versions.warn_until'](
'Neon',
(
'Using ? to seperate between the path and key for vault has been deprecated '
'and will be remo... | python | def set_(key, value, profile=None):
'''
Set a key/value pair in the vault service
'''
if '?' in key:
__utils__['versions.warn_until'](
'Neon',
(
'Using ? to seperate between the path and key for vault has been deprecated '
'and will be remo... | [
"def",
"set_",
"(",
"key",
",",
"value",
",",
"profile",
"=",
"None",
")",
":",
"if",
"'?'",
"in",
"key",
":",
"__utils__",
"[",
"'versions.warn_until'",
"]",
"(",
"'Neon'",
",",
"(",
"'Using ? to seperate between the path and key for vault has been deprecated '",
... | Set a key/value pair in the vault service | [
"Set",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"vault",
"service"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/vault.py#L55-L85 | train |
saltstack/salt | salt/thorium/timer.py | hold | def hold(name, seconds):
'''
Wait for a given period of time, then fire a result of True, requiring
this state allows for an action to be blocked for evaluation based on
time
USAGE:
.. code-block:: yaml
hold_on_a_moment:
timer.hold:
- seconds: 30
'''
ret ... | python | def hold(name, seconds):
'''
Wait for a given period of time, then fire a result of True, requiring
this state allows for an action to be blocked for evaluation based on
time
USAGE:
.. code-block:: yaml
hold_on_a_moment:
timer.hold:
- seconds: 30
'''
ret ... | [
"def",
"hold",
"(",
"name",
",",
"seconds",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"start",
"=",
"time",
".",
"time",
"(",
")",
"if",
"... | Wait for a given period of time, then fire a result of True, requiring
this state allows for an action to be blocked for evaluation based on
time
USAGE:
.. code-block:: yaml
hold_on_a_moment:
timer.hold:
- seconds: 30 | [
"Wait",
"for",
"a",
"given",
"period",
"of",
"time",
"then",
"fire",
"a",
"result",
"of",
"True",
"requiring",
"this",
"state",
"allows",
"for",
"an",
"action",
"to",
"be",
"blocked",
"for",
"evaluation",
"based",
"on",
"time"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/timer.py#L11-L37 | train |
saltstack/salt | salt/modules/mongodb.py | _connect | def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values.
'''
if not user:
user = __salt__['config.option']('mongodb.user')
if not password:
... | python | def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values.
'''
if not user:
user = __salt__['config.option']('mongodb.user')
if not password:
... | [
"def",
"_connect",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"user",
"=",
"__salt__",... | Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values. | [
"Returns",
"a",
"tuple",
"of",
"(",
"user",
"host",
"port",
")",
"with",
"config",
"pillar",
"or",
"default",
"values",
"assigned",
"to",
"missing",
"values",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L49-L74 | train |
saltstack/salt | salt/modules/mongodb.py | _to_dict | def _to_dict(objects):
'''
Potentially interprets a string as JSON for usage with mongo
'''
try:
if isinstance(objects, six.string_types):
objects = salt.utils.json.loads(objects)
except ValueError as err:
log.error("Could not parse objects: %s", err)
raise err
... | python | def _to_dict(objects):
'''
Potentially interprets a string as JSON for usage with mongo
'''
try:
if isinstance(objects, six.string_types):
objects = salt.utils.json.loads(objects)
except ValueError as err:
log.error("Could not parse objects: %s", err)
raise err
... | [
"def",
"_to_dict",
"(",
"objects",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"objects",
",",
"six",
".",
"string_types",
")",
":",
"objects",
"=",
"salt",
".",
"utils",
".",
"json",
".",
"loads",
"(",
"objects",
")",
"except",
"ValueError",
"as",
... | Potentially interprets a string as JSON for usage with mongo | [
"Potentially",
"interprets",
"a",
"string",
"as",
"JSON",
"for",
"usage",
"with",
"mongo"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L77-L88 | train |
saltstack/salt | salt/modules/mongodb.py | db_list | def db_list(user=None, password=None, host=None, port=None, authdb=None):
'''
List all MongoDB databases
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_list <user> <password> <host> <port>
'''
conn = _connect(user, password, host, port, authdb=authdb)
if not conn:
r... | python | def db_list(user=None, password=None, host=None, port=None, authdb=None):
'''
List all MongoDB databases
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_list <user> <password> <host> <port>
'''
conn = _connect(user, password, host, port, authdb=authdb)
if not conn:
r... | [
"def",
"db_list",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"password",
",",
"host",
",",
"port",
"... | List all MongoDB databases
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_list <user> <password> <host> <port> | [
"List",
"all",
"MongoDB",
"databases"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L91-L110 | train |
saltstack/salt | salt/modules/mongodb.py | db_exists | def db_exists(name, user=None, password=None, host=None, port=None, authdb=None):
'''
Checks if a database exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_exists <name> <user> <password> <host> <port>
'''
dbs = db_list(user, password, host, port, authdb=authdb)... | python | def db_exists(name, user=None, password=None, host=None, port=None, authdb=None):
'''
Checks if a database exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_exists <name> <user> <password> <host> <port>
'''
dbs = db_list(user, password, host, port, authdb=authdb)... | [
"def",
"db_exists",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"dbs",
"=",
"db_list",
"(",
"user",
",",
"password",
",",
"host",
"... | Checks if a database exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_exists <name> <user> <password> <host> <port> | [
"Checks",
"if",
"a",
"database",
"exists",
"in",
"MongoDB"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L113-L128 | train |
saltstack/salt | salt/modules/mongodb.py | db_remove | def db_remove(name, user=None, password=None, host=None, port=None, authdb=None):
'''
Remove a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_remove <name> <user> <password> <host> <port>
'''
conn = _connect(user, password, host, port, authdb=authdb)
if not... | python | def db_remove(name, user=None, password=None, host=None, port=None, authdb=None):
'''
Remove a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_remove <name> <user> <password> <host> <port>
'''
conn = _connect(user, password, host, port, authdb=authdb)
if not... | [
"def",
"db_remove",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"password",
",",
"host",
... | Remove a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_remove <name> <user> <password> <host> <port> | [
"Remove",
"a",
"MongoDB",
"database"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L131-L152 | train |
saltstack/salt | salt/modules/mongodb.py | version | def version(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Get MongoDB instance version
CLI Example:
.. code-block:: bash
salt '*' mongodb.version <user> <password> <host> <port> <database>
'''
conn = _connect(user, password, host, port, authdb=aut... | python | def version(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Get MongoDB instance version
CLI Example:
.. code-block:: bash
salt '*' mongodb.version <user> <password> <host> <port> <database>
'''
conn = _connect(user, password, host, port, authdb=aut... | [
"def",
"version",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"passwor... | Get MongoDB instance version
CLI Example:
.. code-block:: bash
salt '*' mongodb.version <user> <password> <host> <port> <database> | [
"Get",
"MongoDB",
"instance",
"version"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L159-L180 | train |
saltstack/salt | salt/modules/mongodb.py | user_list | def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
List users of a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_list <user> <password> <host> <port> <database>
'''
conn = _connect(user, password, host, port, au... | python | def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
List users of a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_list <user> <password> <host> <port> <database>
'''
conn = _connect(user, password, host, port, au... | [
"def",
"user_list",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"passw... | List users of a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_list <user> <password> <host> <port> <database> | [
"List",
"users",
"of",
"a",
"MongoDB",
"database"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L208-L245 | train |
saltstack/salt | salt/modules/mongodb.py | user_exists | def user_exists(name, user=None, password=None, host=None, port=None,
database='admin', authdb=None):
'''
Checks if a user exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database>
'''
users = use... | python | def user_exists(name, user=None, password=None, host=None, port=None,
database='admin', authdb=None):
'''
Checks if a user exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database>
'''
users = use... | [
"def",
"user_exists",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"users",
"=",
"user_list",
"(",
"u... | Checks if a user exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database> | [
"Checks",
"if",
"a",
"user",
"exists",
"in",
"MongoDB"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L248-L268 | train |
saltstack/salt | salt/modules/mongodb.py | user_create | def user_create(name, passwd, user=None, password=None, host=None, port=None,
database='admin', authdb=None, roles=None):
'''
Create a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port... | python | def user_create(name, passwd, user=None, password=None, host=None, port=None,
database='admin', authdb=None, roles=None):
'''
Create a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port... | [
"def",
"user_create",
"(",
"name",
",",
"passwd",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
",",
"roles",
"=",
"None",
")... | Create a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port> <database> | [
"Create",
"a",
"MongoDB",
"user"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L271-L296 | train |
saltstack/salt | salt/modules/mongodb.py | user_remove | def user_remove(name, user=None, password=None, host=None, port=None,
database='admin', authdb=None):
'''
Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
'''
conn = _connect(user, pa... | python | def user_remove(name, user=None, password=None, host=None, port=None,
database='admin', authdb=None):
'''
Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
'''
conn = _connect(user, pa... | [
"def",
"user_remove",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"use... | Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database> | [
"Remove",
"a",
"MongoDB",
"user"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L299-L322 | train |
saltstack/salt | salt/modules/mongodb.py | user_roles_exists | def user_roles_exists(name, roles, database, user=None, password=None, host=None,
port=None, authdb=None):
'''
Checks if a user of a MongoDB database has specified roles
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname ... | python | def user_roles_exists(name, roles, database, user=None, password=None, host=None,
port=None, authdb=None):
'''
Checks if a user of a MongoDB database has specified roles
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname ... | [
"def",
"user_roles_exists",
"(",
"name",
",",
"roles",
",",
"database",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"try",
":",
"roles",
"=",
"_to... | Checks if a user of a MongoDB database has specified roles
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname admin adminpwd localhost 27017
.. code-block:: bash
salt '*' mongodb.user_roles_exists johndoe '[{"role": "readWrite", "db": "d... | [
"Checks",
"if",
"a",
"user",
"of",
"a",
"MongoDB",
"database",
"has",
"specified",
"roles"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L325-L360 | train |
saltstack/salt | salt/modules/mongodb.py | user_grant_roles | def user_grant_roles(name, roles, database, user=None, password=None, host=None,
port=None, authdb=None):
'''
Grant one or many roles to a MongoDB user
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd local... | python | def user_grant_roles(name, roles, database, user=None, password=None, host=None,
port=None, authdb=None):
'''
Grant one or many roles to a MongoDB user
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd local... | [
"def",
"user_grant_roles",
"(",
"name",
",",
"roles",
",",
"database",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"... | Grant one or many roles to a MongoDB user
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd localhost 27017
.. code-block:: bash
salt '*' mongodb.user_grant_roles janedoe '[{"role": "readWrite", "db": "dbname" }, {"role": ... | [
"Grant",
"one",
"or",
"many",
"roles",
"to",
"a",
"MongoDB",
"user"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L363-L395 | train |
saltstack/salt | salt/modules/mongodb.py | insert | def insert(objects, collection, user=None, password=None,
host=None, port=None, database='admin', authdb=None):
'''
Insert an object or list of objects into a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": ... | python | def insert(objects, collection, user=None, password=None,
host=None, port=None, database='admin', authdb=None):
'''
Insert an object or list of objects into a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": ... | [
"def",
"insert",
"(",
"objects",
",",
"collection",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_co... | Insert an object or list of objects into a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": "BAM"}]' mycollection <user> <password> <host> <port> <database> | [
"Insert",
"an",
"object",
"or",
"list",
"of",
"objects",
"into",
"a",
"collection"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L433-L462 | train |
saltstack/salt | salt/modules/mongodb.py | update_one | def update_one(objects, collection, user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Update an object into a collection
http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one
.. versionadded:: 2016.11.0
CLI Exam... | python | def update_one(objects, collection, user=None, password=None, host=None, port=None, database='admin', authdb=None):
'''
Update an object into a collection
http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one
.. versionadded:: 2016.11.0
CLI Exam... | [
"def",
"update_one",
"(",
"objects",
",",
"collection",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
... | Update an object into a collection
http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one
.. versionadded:: 2016.11.0
CLI Example:
.. code-block:: bash
salt '*' mongodb.update_one '{"_id": "my_minion"} {"bar": "BAR"}' mycollection <user> <p... | [
"Update",
"an",
"object",
"into",
"a",
"collection",
"http",
":",
"//",
"api",
".",
"mongodb",
".",
"com",
"/",
"python",
"/",
"current",
"/",
"api",
"/",
"pymongo",
"/",
"collection",
".",
"html#pymongo",
".",
"collection",
".",
"Collection",
".",
"upda... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L465-L530 | train |
saltstack/salt | salt/modules/mongodb.py | find | def find(collection, query=None, user=None, password=None,
host=None, port=None, database='admin', authdb=None):
'''
Find an object or list of objects in a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <passwor... | python | def find(collection, query=None, user=None, password=None,
host=None, port=None, database='admin', authdb=None):
'''
Find an object or list of objects in a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <passwor... | [
"def",
"find",
"(",
"collection",
",",
"query",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
... | Find an object or list of objects in a collection
CLI Example:
.. code-block:: bash
salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <password> <host> <port> <database> | [
"Find",
"an",
"object",
"or",
"list",
"of",
"objects",
"in",
"a",
"collection"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L533-L562 | train |
saltstack/salt | salt/states/infoblox_host_record.py | present | def present(name=None, data=None, ensure_data=True, **api_opts):
'''
This will ensure that a host with the provided name exists.
This will try to ensure that the state of the host matches the given data
If the host is not found then one will be created.
When trying to update a hostname ensure `name... | python | def present(name=None, data=None, ensure_data=True, **api_opts):
'''
This will ensure that a host with the provided name exists.
This will try to ensure that the state of the host matches the given data
If the host is not found then one will be created.
When trying to update a hostname ensure `name... | [
"def",
"present",
"(",
"name",
"=",
"None",
",",
"data",
"=",
"None",
",",
"ensure_data",
"=",
"True",
",",
"*",
"*",
"api_opts",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"... | This will ensure that a host with the provided name exists.
This will try to ensure that the state of the host matches the given data
If the host is not found then one will be created.
When trying to update a hostname ensure `name` is set to the hostname
of the current record. You can give a new name i... | [
"This",
"will",
"ensure",
"that",
"a",
"host",
"with",
"the",
"provided",
"name",
"exists",
".",
"This",
"will",
"try",
"to",
"ensure",
"that",
"the",
"state",
"of",
"the",
"host",
"matches",
"the",
"given",
"data",
"If",
"the",
"host",
"is",
"not",
"f... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/infoblox_host_record.py#L17-L128 | train |
saltstack/salt | salt/proxy/marathon.py | init | def init(opts):
'''
Perform any needed setup.
'''
if CONFIG_BASE_URL in opts['proxy']:
CONFIG[CONFIG_BASE_URL] = opts['proxy'][CONFIG_BASE_URL]
else:
log.error('missing proxy property %s', CONFIG_BASE_URL)
log.debug('CONFIG: %s', CONFIG) | python | def init(opts):
'''
Perform any needed setup.
'''
if CONFIG_BASE_URL in opts['proxy']:
CONFIG[CONFIG_BASE_URL] = opts['proxy'][CONFIG_BASE_URL]
else:
log.error('missing proxy property %s', CONFIG_BASE_URL)
log.debug('CONFIG: %s', CONFIG) | [
"def",
"init",
"(",
"opts",
")",
":",
"if",
"CONFIG_BASE_URL",
"in",
"opts",
"[",
"'proxy'",
"]",
":",
"CONFIG",
"[",
"CONFIG_BASE_URL",
"]",
"=",
"opts",
"[",
"'proxy'",
"]",
"[",
"CONFIG_BASE_URL",
"]",
"else",
":",
"log",
".",
"error",
"(",
"'missin... | Perform any needed setup. | [
"Perform",
"any",
"needed",
"setup",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L43-L51 | train |
saltstack/salt | salt/proxy/marathon.py | ping | def ping():
'''
Is the marathon api responding?
'''
try:
response = salt.utils.http.query(
"{0}/ping".format(CONFIG[CONFIG_BASE_URL]),
decode_type='plain',
decode=True,
)
log.debug(
'marathon.info returned successfully: %s',
... | python | def ping():
'''
Is the marathon api responding?
'''
try:
response = salt.utils.http.query(
"{0}/ping".format(CONFIG[CONFIG_BASE_URL]),
decode_type='plain',
decode=True,
)
log.debug(
'marathon.info returned successfully: %s',
... | [
"def",
"ping",
"(",
")",
":",
"try",
":",
"response",
"=",
"salt",
".",
"utils",
".",
"http",
".",
"query",
"(",
"\"{0}/ping\"",
".",
"format",
"(",
"CONFIG",
"[",
"CONFIG_BASE_URL",
"]",
")",
",",
"decode_type",
"=",
"'plain'",
",",
"decode",
"=",
"... | Is the marathon api responding? | [
"Is",
"the",
"marathon",
"api",
"responding?"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L54-L76 | train |
saltstack/salt | salt/modules/glance.py | _auth | def _auth(profile=None, api_version=2, **connection_args):
'''
Set up glance credentials, returns
`glanceclient.client.Client`. Optional parameter
"api_version" defaults to 2.
Only intended to be used within glance-enabled modules
'''
__utils__['versions.warn_until'](
'Neon',
... | python | def _auth(profile=None, api_version=2, **connection_args):
'''
Set up glance credentials, returns
`glanceclient.client.Client`. Optional parameter
"api_version" defaults to 2.
Only intended to be used within glance-enabled modules
'''
__utils__['versions.warn_until'](
'Neon',
... | [
"def",
"_auth",
"(",
"profile",
"=",
"None",
",",
"api_version",
"=",
"2",
",",
"*",
"*",
"connection_args",
")",
":",
"__utils__",
"[",
"'versions.warn_until'",
"]",
"(",
"'Neon'",
",",
"(",
"'The glance module has been deprecated and will be removed in {version}. '... | Set up glance credentials, returns
`glanceclient.client.Client`. Optional parameter
"api_version" defaults to 2.
Only intended to be used within glance-enabled modules | [
"Set",
"up",
"glance",
"credentials",
"returns",
"glanceclient",
".",
"client",
".",
"Client",
".",
"Optional",
"parameter",
"api_version",
"defaults",
"to",
"2",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L98-L182 | train |
saltstack/salt | salt/modules/glance.py | _add_image | def _add_image(collection, image):
'''
Add image to given dictionary
'''
image_prep = {
'id': image.id,
'name': image.name,
'created_at': image.created_at,
'file': image.file,
'min_disk': image.min_disk,
'min_ram': image.min_ram,
... | python | def _add_image(collection, image):
'''
Add image to given dictionary
'''
image_prep = {
'id': image.id,
'name': image.name,
'created_at': image.created_at,
'file': image.file,
'min_disk': image.min_disk,
'min_ram': image.min_ram,
... | [
"def",
"_add_image",
"(",
"collection",
",",
"image",
")",
":",
"image_prep",
"=",
"{",
"'id'",
":",
"image",
".",
"id",
",",
"'name'",
":",
"image",
".",
"name",
",",
"'created_at'",
":",
"image",
".",
"created_at",
",",
"'file'",
":",
"image",
".",
... | Add image to given dictionary | [
"Add",
"image",
"to",
"given",
"dictionary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L185-L216 | train |
saltstack/salt | salt/modules/glance.py | image_create | def image_create(name,
location=None,
profile=None,
visibility=None,
container_format='bare',
disk_format='raw',
protected=None,):
'''
Create an image (glance image-create)
CLI Example, old format:
..... | python | def image_create(name,
location=None,
profile=None,
visibility=None,
container_format='bare',
disk_format='raw',
protected=None,):
'''
Create an image (glance image-create)
CLI Example, old format:
..... | [
"def",
"image_create",
"(",
"name",
",",
"location",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"visibility",
"=",
"None",
",",
"container_format",
"=",
"'bare'",
",",
"disk_format",
"=",
"'raw'",
",",
"protected",
"=",
"None",
",",
")",
":",
"kwargs... | Create an image (glance image-create)
CLI Example, old format:
.. code-block:: bash
salt '*' glance.image_create name=f16-jeos \\
disk_format=qcow2 container_format=ovf
CLI Example, new format resembling Glance API v2:
.. code-block:: bash
salt '*' glance.image_cre... | [
"Create",
"an",
"image",
"(",
"glance",
"image",
"-",
"create",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L219-L282 | train |
saltstack/salt | salt/modules/glance.py | image_delete | def image_delete(id=None, name=None, profile=None): # pylint: disable=C0103
'''
Delete an image (glance image-delete)
CLI Examples:
.. code-block:: bash
salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df
salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae... | python | def image_delete(id=None, name=None, profile=None): # pylint: disable=C0103
'''
Delete an image (glance image-delete)
CLI Examples:
.. code-block:: bash
salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df
salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae... | [
"def",
"image_delete",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"image",
"=",
"{",
"'id'",
":",
"False",
",",
"'name'",
":",
"None... | Delete an image (glance image-delete)
CLI Examples:
.. code-block:: bash
salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df
salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae7df
salt '*' glance.image_delete name=f16-jeos | [
"Delete",
"an",
"image",
"(",
"glance",
"image",
"-",
"delete",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L285-L329 | train |
saltstack/salt | salt/modules/glance.py | image_show | def image_show(id=None, name=None, profile=None): # pylint: disable=C0103
'''
Return details about a specific image (glance image-show)
CLI Example:
.. code-block:: bash
salt '*' glance.image_show
'''
g_client = _auth(profile)
ret = {}
if name:
for image in g_client.i... | python | def image_show(id=None, name=None, profile=None): # pylint: disable=C0103
'''
Return details about a specific image (glance image-show)
CLI Example:
.. code-block:: bash
salt '*' glance.image_show
'''
g_client = _auth(profile)
ret = {}
if name:
for image in g_client.i... | [
"def",
"image_show",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"{",
"}",
"if",
"name",
":",
"for",
"image",
"in",
"g_... | Return details about a specific image (glance image-show)
CLI Example:
.. code-block:: bash
salt '*' glance.image_show | [
"Return",
"details",
"about",
"a",
"specific",
"image",
"(",
"glance",
"image",
"-",
"show",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L332-L374 | train |
saltstack/salt | salt/modules/glance.py | image_list | def image_list(id=None, profile=None, name=None): # pylint: disable=C0103
'''
Return a list of available images (glance image-list)
CLI Example:
.. code-block:: bash
salt '*' glance.image_list
'''
g_client = _auth(profile)
ret = []
for image in g_client.images.list():
... | python | def image_list(id=None, profile=None, name=None): # pylint: disable=C0103
'''
Return a list of available images (glance image-list)
CLI Example:
.. code-block:: bash
salt '*' glance.image_list
'''
g_client = _auth(profile)
ret = []
for image in g_client.images.list():
... | [
"def",
"image_list",
"(",
"id",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"[",
"]",
"for",
"image",
"in",
"g_client",
".",
"images... | Return a list of available images (glance image-list)
CLI Example:
.. code-block:: bash
salt '*' glance.image_list | [
"Return",
"a",
"list",
"of",
"available",
"images",
"(",
"glance",
"image",
"-",
"list",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L377-L407 | train |
saltstack/salt | salt/modules/glance.py | image_update | def image_update(id=None, name=None, profile=None, **kwargs): # pylint: disable=C0103
'''
Update properties of given image.
Known to work for:
- min_ram (in MB)
- protected (bool)
- visibility ('public' or 'private')
CLI Example:
.. code-block:: bash
salt '*' glance.image_upd... | python | def image_update(id=None, name=None, profile=None, **kwargs): # pylint: disable=C0103
'''
Update properties of given image.
Known to work for:
- min_ram (in MB)
- protected (bool)
- visibility ('public' or 'private')
CLI Example:
.. code-block:: bash
salt '*' glance.image_upd... | [
"def",
"image_update",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0103",
"if",
"id",
":",
"image",
"=",
"image_show",
"(",
"id",
"=",
"id",
",",
"profile",
"="... | Update properties of given image.
Known to work for:
- min_ram (in MB)
- protected (bool)
- visibility ('public' or 'private')
CLI Example:
.. code-block:: bash
salt '*' glance.image_update id=c2eb2eb0-53e1-4a80-b990-8ec887eae7df
salt '*' glance.image_update name=f16-jeos | [
"Update",
"properties",
"of",
"given",
"image",
".",
"Known",
"to",
"work",
"for",
":",
"-",
"min_ram",
"(",
"in",
"MB",
")",
"-",
"protected",
"(",
"bool",
")",
"-",
"visibility",
"(",
"public",
"or",
"private",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L424-L473 | train |
saltstack/salt | salt/modules/glance.py | schema_get | def schema_get(name, profile=None):
'''
Known valid names of schemas are:
- image
- images
- member
- members
CLI Example:
.. code-block:: bash
salt '*' glance.schema_get name=f16-jeos
'''
g_client = _auth(profile)
schema_props = {}
for prop in g_client... | python | def schema_get(name, profile=None):
'''
Known valid names of schemas are:
- image
- images
- member
- members
CLI Example:
.. code-block:: bash
salt '*' glance.schema_get name=f16-jeos
'''
g_client = _auth(profile)
schema_props = {}
for prop in g_client... | [
"def",
"schema_get",
"(",
"name",
",",
"profile",
"=",
"None",
")",
":",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"schema_props",
"=",
"{",
"}",
"for",
"prop",
"in",
"g_client",
".",
"schemas",
".",
"get",
"(",
"name",
")",
".",
"properties",
"... | Known valid names of schemas are:
- image
- images
- member
- members
CLI Example:
.. code-block:: bash
salt '*' glance.schema_get name=f16-jeos | [
"Known",
"valid",
"names",
"of",
"schemas",
"are",
":",
"-",
"image",
"-",
"images",
"-",
"member",
"-",
"members"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L476-L498 | train |
saltstack/salt | salt/modules/glance.py | _item_list | def _item_list(profile=None):
'''
Template for writing list functions
Return a list of available items (glance items-list)
CLI Example:
.. code-block:: bash
salt '*' glance.item_list
'''
g_client = _auth(profile)
ret = []
for item in g_client.items.list():
ret.appe... | python | def _item_list(profile=None):
'''
Template for writing list functions
Return a list of available items (glance items-list)
CLI Example:
.. code-block:: bash
salt '*' glance.item_list
'''
g_client = _auth(profile)
ret = []
for item in g_client.items.list():
ret.appe... | [
"def",
"_item_list",
"(",
"profile",
"=",
"None",
")",
":",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"[",
"]",
"for",
"item",
"in",
"g_client",
".",
"items",
".",
"list",
"(",
")",
":",
"ret",
".",
"append",
"(",
"item",
".",
"_... | Template for writing list functions
Return a list of available items (glance items-list)
CLI Example:
.. code-block:: bash
salt '*' glance.item_list | [
"Template",
"for",
"writing",
"list",
"functions",
"Return",
"a",
"list",
"of",
"available",
"items",
"(",
"glance",
"items",
"-",
"list",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L501-L519 | train |
saltstack/salt | salt/states/loop.py | until | def until(name,
m_args=None,
m_kwargs=None,
condition=None,
period=0,
timeout=604800):
'''
Loop over an execution module until a condition is met.
name
The name of the execution module
m_args
The execution module's positional arguments
... | python | def until(name,
m_args=None,
m_kwargs=None,
condition=None,
period=0,
timeout=604800):
'''
Loop over an execution module until a condition is met.
name
The name of the execution module
m_args
The execution module's positional arguments
... | [
"def",
"until",
"(",
"name",
",",
"m_args",
"=",
"None",
",",
"m_kwargs",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"period",
"=",
"0",
",",
"timeout",
"=",
"604800",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
... | Loop over an execution module until a condition is met.
name
The name of the execution module
m_args
The execution module's positional arguments
m_kwargs
The execution module's keyword arguments
condition
The condition which must be met for the loop to break. This
... | [
"Loop",
"over",
"an",
"execution",
"module",
"until",
"a",
"condition",
"is",
"met",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/loop.py#L47-L118 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _authenticate | def _authenticate():
'''
Retrieve CSRF and API tickets for the Proxmox API
'''
global url, port, ticket, csrf, verify_ssl
url = config.get_cloud_config_value(
'url', get_configured_provider(), __opts__, search_global=False
)
port = config.get_cloud_config_value(
'port', get_c... | python | def _authenticate():
'''
Retrieve CSRF and API tickets for the Proxmox API
'''
global url, port, ticket, csrf, verify_ssl
url = config.get_cloud_config_value(
'url', get_configured_provider(), __opts__, search_global=False
)
port = config.get_cloud_config_value(
'port', get_c... | [
"def",
"_authenticate",
"(",
")",
":",
"global",
"url",
",",
"port",
",",
"ticket",
",",
"csrf",
",",
"verify_ssl",
"url",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'url'",
",",
"get_configured_provider",
"(",
")",
",",
"__opts__",
",",
"search_glo... | Retrieve CSRF and API tickets for the Proxmox API | [
"Retrieve",
"CSRF",
"and",
"API",
"tickets",
"for",
"the",
"Proxmox",
"API"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L116-L146 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | query | def query(conn_type, option, post_data=None):
'''
Execute the HTTP request to the API
'''
if ticket is None or csrf is None or url is None:
log.debug('Not authenticated yet, doing that now..')
_authenticate()
full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, option)
... | python | def query(conn_type, option, post_data=None):
'''
Execute the HTTP request to the API
'''
if ticket is None or csrf is None or url is None:
log.debug('Not authenticated yet, doing that now..')
_authenticate()
full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, option)
... | [
"def",
"query",
"(",
"conn_type",
",",
"option",
",",
"post_data",
"=",
"None",
")",
":",
"if",
"ticket",
"is",
"None",
"or",
"csrf",
"is",
"None",
"or",
"url",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"'Not authenticated yet, doing that now..'",
")",
... | Execute the HTTP request to the API | [
"Execute",
"the",
"HTTP",
"request",
"to",
"the",
"API"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L149-L196 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _get_vm_by_name | def _get_vm_by_name(name, allDetails=False):
'''
Since Proxmox works based op id's rather than names as identifiers this
requires some filtering to retrieve the required information.
'''
vms = get_resources_vms(includeConfig=allDetails)
if name in vms:
return vms[name]
log.info('VM ... | python | def _get_vm_by_name(name, allDetails=False):
'''
Since Proxmox works based op id's rather than names as identifiers this
requires some filtering to retrieve the required information.
'''
vms = get_resources_vms(includeConfig=allDetails)
if name in vms:
return vms[name]
log.info('VM ... | [
"def",
"_get_vm_by_name",
"(",
"name",
",",
"allDetails",
"=",
"False",
")",
":",
"vms",
"=",
"get_resources_vms",
"(",
"includeConfig",
"=",
"allDetails",
")",
"if",
"name",
"in",
"vms",
":",
"return",
"vms",
"[",
"name",
"]",
"log",
".",
"info",
"(",
... | Since Proxmox works based op id's rather than names as identifiers this
requires some filtering to retrieve the required information. | [
"Since",
"Proxmox",
"works",
"based",
"op",
"id",
"s",
"rather",
"than",
"names",
"as",
"identifiers",
"this",
"requires",
"some",
"filtering",
"to",
"retrieve",
"the",
"required",
"information",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L199-L209 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _get_vm_by_id | def _get_vm_by_id(vmid, allDetails=False):
'''
Retrieve a VM based on the ID.
'''
for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=allDetails)):
if six.text_type(vm_details['vmid']) == six.text_type(vmid):
return vm_details
log.info('VM with ID "%s" could... | python | def _get_vm_by_id(vmid, allDetails=False):
'''
Retrieve a VM based on the ID.
'''
for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=allDetails)):
if six.text_type(vm_details['vmid']) == six.text_type(vmid):
return vm_details
log.info('VM with ID "%s" could... | [
"def",
"_get_vm_by_id",
"(",
"vmid",
",",
"allDetails",
"=",
"False",
")",
":",
"for",
"vm_name",
",",
"vm_details",
"in",
"six",
".",
"iteritems",
"(",
"get_resources_vms",
"(",
"includeConfig",
"=",
"allDetails",
")",
")",
":",
"if",
"six",
".",
"text_ty... | Retrieve a VM based on the ID. | [
"Retrieve",
"a",
"VM",
"based",
"on",
"the",
"ID",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L212-L221 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _check_ip_available | def _check_ip_available(ip_addr):
'''
Proxmox VMs refuse to start when the IP is already being used.
This function can be used to prevent VMs being created with duplicate
IP's or to generate a warning.
'''
for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
v... | python | def _check_ip_available(ip_addr):
'''
Proxmox VMs refuse to start when the IP is already being used.
This function can be used to prevent VMs being created with duplicate
IP's or to generate a warning.
'''
for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
v... | [
"def",
"_check_ip_available",
"(",
"ip_addr",
")",
":",
"for",
"vm_name",
",",
"vm_details",
"in",
"six",
".",
"iteritems",
"(",
"get_resources_vms",
"(",
"includeConfig",
"=",
"True",
")",
")",
":",
"vm_config",
"=",
"vm_details",
"[",
"'config'",
"]",
"if"... | Proxmox VMs refuse to start when the IP is already being used.
This function can be used to prevent VMs being created with duplicate
IP's or to generate a warning. | [
"Proxmox",
"VMs",
"refuse",
"to",
"start",
"when",
"the",
"IP",
"is",
"already",
"being",
"used",
".",
"This",
"function",
"can",
"be",
"used",
"to",
"prevent",
"VMs",
"being",
"created",
"with",
"duplicate",
"IP",
"s",
"or",
"to",
"generate",
"a",
"warn... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L232-L245 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _parse_proxmox_upid | def _parse_proxmox_upid(node, vm_=None):
'''
Upon requesting a task that runs for a longer period of time a UPID is given.
This includes information about the job and can be used to lookup information in the log.
'''
ret = {}
upid = node
# Parse node response
node = node.split(':')
... | python | def _parse_proxmox_upid(node, vm_=None):
'''
Upon requesting a task that runs for a longer period of time a UPID is given.
This includes information about the job and can be used to lookup information in the log.
'''
ret = {}
upid = node
# Parse node response
node = node.split(':')
... | [
"def",
"_parse_proxmox_upid",
"(",
"node",
",",
"vm_",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"upid",
"=",
"node",
"# Parse node response",
"node",
"=",
"node",
".",
"split",
"(",
"':'",
")",
"if",
"node",
"[",
"0",
"]",
"==",
"'UPID'",
":",
... | Upon requesting a task that runs for a longer period of time a UPID is given.
This includes information about the job and can be used to lookup information in the log. | [
"Upon",
"requesting",
"a",
"task",
"that",
"runs",
"for",
"a",
"longer",
"period",
"of",
"time",
"a",
"UPID",
"is",
"given",
".",
"This",
"includes",
"information",
"about",
"the",
"job",
"and",
"can",
"be",
"used",
"to",
"lookup",
"information",
"in",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L248-L272 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _lookup_proxmox_task | def _lookup_proxmox_task(upid):
'''
Retrieve the (latest) logs and retrieve the status for a UPID.
This can be used to verify whether a task has completed.
'''
log.debug('Getting creation status for upid: %s', upid)
tasks = query('get', 'cluster/tasks')
if tasks:
for task in tasks:
... | python | def _lookup_proxmox_task(upid):
'''
Retrieve the (latest) logs and retrieve the status for a UPID.
This can be used to verify whether a task has completed.
'''
log.debug('Getting creation status for upid: %s', upid)
tasks = query('get', 'cluster/tasks')
if tasks:
for task in tasks:
... | [
"def",
"_lookup_proxmox_task",
"(",
"upid",
")",
":",
"log",
".",
"debug",
"(",
"'Getting creation status for upid: %s'",
",",
"upid",
")",
"tasks",
"=",
"query",
"(",
"'get'",
",",
"'cluster/tasks'",
")",
"if",
"tasks",
":",
"for",
"task",
"in",
"tasks",
":... | Retrieve the (latest) logs and retrieve the status for a UPID.
This can be used to verify whether a task has completed. | [
"Retrieve",
"the",
"(",
"latest",
")",
"logs",
"and",
"retrieve",
"the",
"status",
"for",
"a",
"UPID",
".",
"This",
"can",
"be",
"used",
"to",
"verify",
"whether",
"a",
"task",
"has",
"completed",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L275-L289 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | get_resources_nodes | def get_resources_nodes(call=None, resFilter=None):
'''
Retrieve all hypervisors (nodes) available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_nodes my-proxmox-config
'''
log.debug('Getting resource: nodes.. (filter: %s)', resFilter)
resources ... | python | def get_resources_nodes(call=None, resFilter=None):
'''
Retrieve all hypervisors (nodes) available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_nodes my-proxmox-config
'''
log.debug('Getting resource: nodes.. (filter: %s)', resFilter)
resources ... | [
"def",
"get_resources_nodes",
"(",
"call",
"=",
"None",
",",
"resFilter",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Getting resource: nodes.. (filter: %s)'",
",",
"resFilter",
")",
"resources",
"=",
"query",
"(",
"'get'",
",",
"'cluster/resources'",
")"... | Retrieve all hypervisors (nodes) available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_nodes my-proxmox-config | [
"Retrieve",
"all",
"hypervisors",
"(",
"nodes",
")",
"available",
"on",
"this",
"environment",
"CLI",
"Example",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L292-L316 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | get_resources_vms | def get_resources_vms(call=None, resFilter=None, includeConfig=True):
'''
Retrieve all VMs available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_vms my-proxmox-config
'''
timeoutTime = time.time() + 60
while True:
log.debug('Getting r... | python | def get_resources_vms(call=None, resFilter=None, includeConfig=True):
'''
Retrieve all VMs available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_vms my-proxmox-config
'''
timeoutTime = time.time() + 60
while True:
log.debug('Getting r... | [
"def",
"get_resources_vms",
"(",
"call",
"=",
"None",
",",
"resFilter",
"=",
"None",
",",
"includeConfig",
"=",
"True",
")",
":",
"timeoutTime",
"=",
"time",
".",
"time",
"(",
")",
"+",
"60",
"while",
"True",
":",
"log",
".",
"debug",
"(",
"'Getting re... | Retrieve all VMs available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_vms my-proxmox-config | [
"Retrieve",
"all",
"VMs",
"available",
"on",
"this",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L319-L372 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | script | def script(vm_):
'''
Return the script deployment object
'''
script_name = config.get_cloud_config_value('script', vm_, __opts__)
if not script_name:
script_name = 'bootstrap-salt'
return salt.utils.cloud.os_script(
script_name,
vm_,
__opts__,
salt.utils.... | python | def script(vm_):
'''
Return the script deployment object
'''
script_name = config.get_cloud_config_value('script', vm_, __opts__)
if not script_name:
script_name = 'bootstrap-salt'
return salt.utils.cloud.os_script(
script_name,
vm_,
__opts__,
salt.utils.... | [
"def",
"script",
"(",
"vm_",
")",
":",
"script_name",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'script'",
",",
"vm_",
",",
"__opts__",
")",
"if",
"not",
"script_name",
":",
"script_name",
"=",
"'bootstrap-salt'",
"return",
"salt",
".",
"utils",
".... | Return the script deployment object | [
"Return",
"the",
"script",
"deployment",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L375-L390 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | avail_locations | def avail_locations(call=None):
'''
Return a list of the hypervisors (nodes) which this Proxmox PVE machine manages
CLI Example:
.. code-block:: bash
salt-cloud --list-locations my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locati... | python | def avail_locations(call=None):
'''
Return a list of the hypervisors (nodes) which this Proxmox PVE machine manages
CLI Example:
.. code-block:: bash
salt-cloud --list-locations my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locati... | [
"def",
"avail_locations",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_locations function must be called with '",
"'-f or --function, or with the --list-locations option'",
")",
"# could also use the g... | Return a list of the hypervisors (nodes) which this Proxmox PVE machine manages
CLI Example:
.. code-block:: bash
salt-cloud --list-locations my-proxmox-config | [
"Return",
"a",
"list",
"of",
"the",
"hypervisors",
"(",
"nodes",
")",
"which",
"this",
"Proxmox",
"PVE",
"machine",
"manages"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L393-L417 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | avail_images | def avail_images(call=None, location='local'):
'''
Return a list of the images that are on the provider
CLI Example:
.. code-block:: bash
salt-cloud --list-images my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must ... | python | def avail_images(call=None, location='local'):
'''
Return a list of the images that are on the provider
CLI Example:
.. code-block:: bash
salt-cloud --list-images my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must ... | [
"def",
"avail_images",
"(",
"call",
"=",
"None",
",",
"location",
"=",
"'local'",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_images function must be called with '",
"'-f or --function, or with the --list-images option'",
... | Return a list of the images that are on the provider
CLI Example:
.. code-block:: bash
salt-cloud --list-images my-proxmox-config | [
"Return",
"a",
"list",
"of",
"the",
"images",
"that",
"are",
"on",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L420-L440 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | list_nodes | def list_nodes(call=None):
'''
Return a list of the VMs that are managed by the provider
CLI Example:
.. code-block:: bash
salt-cloud -Q my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --funct... | python | def list_nodes(call=None):
'''
Return a list of the VMs that are managed by the provider
CLI Example:
.. code-block:: bash
salt-cloud -Q my-proxmox-config
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --funct... | [
"def",
"list_nodes",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes function must be called with -f or --function.'",
")",
"ret",
"=",
"{",
"}",
"for",
"vm_name",
",",
"vm_details",
"i... | Return a list of the VMs that are managed by the provider
CLI Example:
.. code-block:: bash
salt-cloud -Q my-proxmox-config | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"managed",
"by",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L443-L485 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _stringlist_to_dictionary | def _stringlist_to_dictionary(input_string):
'''
Convert a stringlist (comma separated settings) to a dictionary
The result of the string setting1=value1,setting2=value2 will be a python dictionary:
{'setting1':'value1','setting2':'value2'}
'''
li = str(input_string).split(',')
ret = {}
... | python | def _stringlist_to_dictionary(input_string):
'''
Convert a stringlist (comma separated settings) to a dictionary
The result of the string setting1=value1,setting2=value2 will be a python dictionary:
{'setting1':'value1','setting2':'value2'}
'''
li = str(input_string).split(',')
ret = {}
... | [
"def",
"_stringlist_to_dictionary",
"(",
"input_string",
")",
":",
"li",
"=",
"str",
"(",
"input_string",
")",
".",
"split",
"(",
"','",
")",
"ret",
"=",
"{",
"}",
"for",
"item",
"in",
"li",
":",
"pair",
"=",
"str",
"(",
"item",
")",
".",
"replace",
... | Convert a stringlist (comma separated settings) to a dictionary
The result of the string setting1=value1,setting2=value2 will be a python dictionary:
{'setting1':'value1','setting2':'value2'} | [
"Convert",
"a",
"stringlist",
"(",
"comma",
"separated",
"settings",
")",
"to",
"a",
"dictionary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L521-L538 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _dictionary_to_stringlist | def _dictionary_to_stringlist(input_dict):
'''
Convert a dictionary to a stringlist (comma separated settings)
The result of the dictionary {'setting1':'value1','setting2':'value2'} will be:
setting1=value1,setting2=value2
'''
string_value = ""
for s in input_dict:
string_value += ... | python | def _dictionary_to_stringlist(input_dict):
'''
Convert a dictionary to a stringlist (comma separated settings)
The result of the dictionary {'setting1':'value1','setting2':'value2'} will be:
setting1=value1,setting2=value2
'''
string_value = ""
for s in input_dict:
string_value += ... | [
"def",
"_dictionary_to_stringlist",
"(",
"input_dict",
")",
":",
"string_value",
"=",
"\"\"",
"for",
"s",
"in",
"input_dict",
":",
"string_value",
"+=",
"\"{0}={1},\"",
".",
"format",
"(",
"s",
",",
"input_dict",
"[",
"s",
"]",
")",
"string_value",
"=",
"str... | Convert a dictionary to a stringlist (comma separated settings)
The result of the dictionary {'setting1':'value1','setting2':'value2'} will be:
setting1=value1,setting2=value2 | [
"Convert",
"a",
"dictionary",
"to",
"a",
"stringlist",
"(",
"comma",
"separated",
"settings",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L541-L553 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | create | def create(vm_):
'''
Create a single VM from a data dict
CLI Example:
.. code-block:: bash
salt-cloud -p proxmox-ubuntu vmhostname
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__... | python | def create(vm_):
'''
Create a single VM from a data dict
CLI Example:
.. code-block:: bash
salt-cloud -p proxmox-ubuntu vmhostname
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__... | [
"def",
"create",
"(",
"vm_",
")",
":",
"try",
":",
"# Check for required profile parameters before sending any API calls.",
"if",
"vm_",
"[",
"'profile'",
"]",
"and",
"config",
".",
"is_profile_configured",
"(",
"__opts__",
",",
"__active_provider_name__",
"or",
"'proxm... | Create a single VM from a data dict
CLI Example:
.. code-block:: bash
salt-cloud -p proxmox-ubuntu vmhostname | [
"Create",
"a",
"single",
"VM",
"from",
"a",
"data",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L556-L867 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _import_api | def _import_api():
'''
Download https://<url>/pve-docs/api-viewer/apidoc.js
Extract content of pveapi var (json formated)
Load this json content into global variable "api"
'''
global api
full_url = 'https://{0}:{1}/pve-docs/api-viewer/apidoc.js'.format(url, port)
returned_data = requests... | python | def _import_api():
'''
Download https://<url>/pve-docs/api-viewer/apidoc.js
Extract content of pveapi var (json formated)
Load this json content into global variable "api"
'''
global api
full_url = 'https://{0}:{1}/pve-docs/api-viewer/apidoc.js'.format(url, port)
returned_data = requests... | [
"def",
"_import_api",
"(",
")",
":",
"global",
"api",
"full_url",
"=",
"'https://{0}:{1}/pve-docs/api-viewer/apidoc.js'",
".",
"format",
"(",
"url",
",",
"port",
")",
"returned_data",
"=",
"requests",
".",
"get",
"(",
"full_url",
",",
"verify",
"=",
"verify_ssl"... | Download https://<url>/pve-docs/api-viewer/apidoc.js
Extract content of pveapi var (json formated)
Load this json content into global variable "api" | [
"Download",
"https",
":",
"//",
"<url",
">",
"/",
"pve",
"-",
"docs",
"/",
"api",
"-",
"viewer",
"/",
"apidoc",
".",
"js",
"Extract",
"content",
"of",
"pveapi",
"var",
"(",
"json",
"formated",
")",
"Load",
"this",
"json",
"content",
"into",
"global",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L870-L882 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | _get_properties | def _get_properties(path="", method="GET", forced_params=None):
'''
Return the parameter list from api for defined path and HTTP method
'''
if api is None:
_import_api()
sub = api
path_levels = [level for level in path.split('/') if level != '']
search_path = ''
props = []
p... | python | def _get_properties(path="", method="GET", forced_params=None):
'''
Return the parameter list from api for defined path and HTTP method
'''
if api is None:
_import_api()
sub = api
path_levels = [level for level in path.split('/') if level != '']
search_path = ''
props = []
p... | [
"def",
"_get_properties",
"(",
"path",
"=",
"\"\"",
",",
"method",
"=",
"\"GET\"",
",",
"forced_params",
"=",
"None",
")",
":",
"if",
"api",
"is",
"None",
":",
"_import_api",
"(",
")",
"sub",
"=",
"api",
"path_levels",
"=",
"[",
"level",
"for",
"level"... | Return the parameter list from api for defined path and HTTP method | [
"Return",
"the",
"parameter",
"list",
"from",
"api",
"for",
"defined",
"path",
"and",
"HTTP",
"method"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L885-L919 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | create_node | def create_node(vm_, newid):
'''
Build and submit the requestdata to create a new node
'''
newnode = {}
if 'technology' not in vm_:
vm_['technology'] = 'openvz' # default virt tech if none is given
if vm_['technology'] not in ['qemu', 'openvz', 'lxc']:
# Wrong VM type given
... | python | def create_node(vm_, newid):
'''
Build and submit the requestdata to create a new node
'''
newnode = {}
if 'technology' not in vm_:
vm_['technology'] = 'openvz' # default virt tech if none is given
if vm_['technology'] not in ['qemu', 'openvz', 'lxc']:
# Wrong VM type given
... | [
"def",
"create_node",
"(",
"vm_",
",",
"newid",
")",
":",
"newnode",
"=",
"{",
"}",
"if",
"'technology'",
"not",
"in",
"vm_",
":",
"vm_",
"[",
"'technology'",
"]",
"=",
"'openvz'",
"# default virt tech if none is given",
"if",
"vm_",
"[",
"'technology'",
"]"... | Build and submit the requestdata to create a new node | [
"Build",
"and",
"submit",
"the",
"requestdata",
"to",
"create",
"a",
"new",
"node"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L922-L1042 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | get_vmconfig | def get_vmconfig(vmid, node=None, node_type='openvz'):
'''
Get VM configuration
'''
if node is None:
# We need to figure out which node this VM is on.
for host_name, host_details in six.iteritems(avail_locations()):
for item in query('get', 'nodes/{0}/{1}'.format(host_name, n... | python | def get_vmconfig(vmid, node=None, node_type='openvz'):
'''
Get VM configuration
'''
if node is None:
# We need to figure out which node this VM is on.
for host_name, host_details in six.iteritems(avail_locations()):
for item in query('get', 'nodes/{0}/{1}'.format(host_name, n... | [
"def",
"get_vmconfig",
"(",
"vmid",
",",
"node",
"=",
"None",
",",
"node_type",
"=",
"'openvz'",
")",
":",
"if",
"node",
"is",
"None",
":",
"# We need to figure out which node this VM is on.",
"for",
"host_name",
",",
"host_details",
"in",
"six",
".",
"iteritems... | Get VM configuration | [
"Get",
"VM",
"configuration"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1059-L1073 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | wait_for_state | def wait_for_state(vmid, state, timeout=300):
'''
Wait until a specific state has been reached on a node
'''
start_time = time.time()
node = get_vm_status(vmid=vmid)
if not node:
log.error('wait_for_state: No VM retrieved based on given criteria.')
raise SaltCloudExecutionFailure... | python | def wait_for_state(vmid, state, timeout=300):
'''
Wait until a specific state has been reached on a node
'''
start_time = time.time()
node = get_vm_status(vmid=vmid)
if not node:
log.error('wait_for_state: No VM retrieved based on given criteria.')
raise SaltCloudExecutionFailure... | [
"def",
"wait_for_state",
"(",
"vmid",
",",
"state",
",",
"timeout",
"=",
"300",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"node",
"=",
"get_vm_status",
"(",
"vmid",
"=",
"vmid",
")",
"if",
"not",
"node",
":",
"log",
".",
"error",
... | Wait until a specific state has been reached on a node | [
"Wait",
"until",
"a",
"specific",
"state",
"has",
"been",
"reached",
"on",
"a",
"node"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1098-L1119 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | wait_for_task | def wait_for_task(upid, timeout=300):
'''
Wait until a the task has been finished successfully
'''
start_time = time.time()
info = _lookup_proxmox_task(upid)
if not info:
log.error('wait_for_task: No task information '
'retrieved based on given criteria.')
raise... | python | def wait_for_task(upid, timeout=300):
'''
Wait until a the task has been finished successfully
'''
start_time = time.time()
info = _lookup_proxmox_task(upid)
if not info:
log.error('wait_for_task: No task information '
'retrieved based on given criteria.')
raise... | [
"def",
"wait_for_task",
"(",
"upid",
",",
"timeout",
"=",
"300",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"info",
"=",
"_lookup_proxmox_task",
"(",
"upid",
")",
"if",
"not",
"info",
":",
"log",
".",
"error",
"(",
"'wait_for_task: No ta... | Wait until a the task has been finished successfully | [
"Wait",
"until",
"a",
"the",
"task",
"has",
"been",
"finished",
"successfully"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1122-L1141 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | destroy | def destroy(name, call=None):
'''
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)... | python | def destroy(name, call=None):
'''
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)... | [
"def",
"destroy",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a or --action.'",
")",
"__utils__",
"[",
"'cloud.fire_event'",
... | Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine | [
"Destroy",
"a",
"node",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1144-L1198 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | set_vm_status | def set_vm_status(status, name=None, vmid=None):
'''
Convenience function for setting VM status
'''
log.debug('Set status to %s for %s (%s)', status, name, vmid)
if vmid is not None:
log.debug('set_vm_status: via ID - VMID %s (%s): %s',
vmid, name, status)
vmobj = ... | python | def set_vm_status(status, name=None, vmid=None):
'''
Convenience function for setting VM status
'''
log.debug('Set status to %s for %s (%s)', status, name, vmid)
if vmid is not None:
log.debug('set_vm_status: via ID - VMID %s (%s): %s',
vmid, name, status)
vmobj = ... | [
"def",
"set_vm_status",
"(",
"status",
",",
"name",
"=",
"None",
",",
"vmid",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Set status to %s for %s (%s)'",
",",
"status",
",",
"name",
",",
"vmid",
")",
"if",
"vmid",
"is",
"not",
"None",
":",
"log"... | Convenience function for setting VM status | [
"Convenience",
"function",
"for",
"setting",
"VM",
"status"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1201-L1231 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | get_vm_status | def get_vm_status(vmid=None, name=None):
'''
Get the status for a VM, either via the ID or the hostname
'''
if vmid is not None:
log.debug('get_vm_status: VMID %s', vmid)
vmobj = _get_vm_by_id(vmid)
elif name is not None:
log.debug('get_vm_status: name %s', name)
vmob... | python | def get_vm_status(vmid=None, name=None):
'''
Get the status for a VM, either via the ID or the hostname
'''
if vmid is not None:
log.debug('get_vm_status: VMID %s', vmid)
vmobj = _get_vm_by_id(vmid)
elif name is not None:
log.debug('get_vm_status: name %s', name)
vmob... | [
"def",
"get_vm_status",
"(",
"vmid",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"vmid",
"is",
"not",
"None",
":",
"log",
".",
"debug",
"(",
"'get_vm_status: VMID %s'",
",",
"vmid",
")",
"vmobj",
"=",
"_get_vm_by_id",
"(",
"vmid",
")",
"elif... | Get the status for a VM, either via the ID or the hostname | [
"Get",
"the",
"status",
"for",
"a",
"VM",
"either",
"via",
"the",
"ID",
"or",
"the",
"hostname"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1234-L1258 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | start | def start(name, vmid=None, call=None):
'''
Start a node.
CLI Example:
.. code-block:: bash
salt-cloud -a start mymachine
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be called with -a or --action.'
)
log.debug('Start: %s (... | python | def start(name, vmid=None, call=None):
'''
Start a node.
CLI Example:
.. code-block:: bash
salt-cloud -a start mymachine
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be called with -a or --action.'
)
log.debug('Start: %s (... | [
"def",
"start",
"(",
"name",
",",
"vmid",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The start action must be called with -a or --action.'",
")",
"log",
".",
"debug",
"(",
"'Star... | Start a node.
CLI Example:
.. code-block:: bash
salt-cloud -a start mymachine | [
"Start",
"a",
"node",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1261-L1283 | train |
saltstack/salt | salt/cloud/clouds/proxmox.py | stop | def stop(name, vmid=None, call=None):
'''
Stop a node ("pulling the plug").
CLI Example:
.. code-block:: bash
salt-cloud -a stop mymachine
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
if no... | python | def stop(name, vmid=None, call=None):
'''
Stop a node ("pulling the plug").
CLI Example:
.. code-block:: bash
salt-cloud -a stop mymachine
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
if no... | [
"def",
"stop",
"(",
"name",
",",
"vmid",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The stop action must be called with -a or --action.'",
")",
"if",
"not",
"set_vm_status",
"(",
... | Stop a node ("pulling the plug").
CLI Example:
.. code-block:: bash
salt-cloud -a stop mymachine | [
"Stop",
"a",
"node",
"(",
"pulling",
"the",
"plug",
")",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1286-L1307 | train |
saltstack/salt | salt/states/rsync.py | _get_summary | def _get_summary(rsync_out):
'''
Get summary from the rsync successful output.
'''
return "- " + "\n- ".join([elm for elm in rsync_out.split("\n\n")[-1].replace(" ", "\n").split("\n") if elm]) | python | def _get_summary(rsync_out):
'''
Get summary from the rsync successful output.
'''
return "- " + "\n- ".join([elm for elm in rsync_out.split("\n\n")[-1].replace(" ", "\n").split("\n") if elm]) | [
"def",
"_get_summary",
"(",
"rsync_out",
")",
":",
"return",
"\"- \"",
"+",
"\"\\n- \"",
".",
"join",
"(",
"[",
"elm",
"for",
"elm",
"in",
"rsync_out",
".",
"split",
"(",
"\"\\n\\n\"",
")",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"\" \"",
",",
"\"\... | Get summary from the rsync successful output. | [
"Get",
"summary",
"from",
"the",
"rsync",
"successful",
"output",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L48-L53 | train |
saltstack/salt | salt/states/rsync.py | _get_changes | def _get_changes(rsync_out):
'''
Get changes from the rsync successful output.
'''
copied = list()
deleted = list()
for line in rsync_out.split("\n\n")[0].split("\n")[1:]:
if line.startswith("deleting "):
deleted.append(line.split(" ", 1)[-1])
else:
copie... | python | def _get_changes(rsync_out):
'''
Get changes from the rsync successful output.
'''
copied = list()
deleted = list()
for line in rsync_out.split("\n\n")[0].split("\n")[1:]:
if line.startswith("deleting "):
deleted.append(line.split(" ", 1)[-1])
else:
copie... | [
"def",
"_get_changes",
"(",
"rsync_out",
")",
":",
"copied",
"=",
"list",
"(",
")",
"deleted",
"=",
"list",
"(",
")",
"for",
"line",
"in",
"rsync_out",
".",
"split",
"(",
"\"\\n\\n\"",
")",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
"1"... | Get changes from the rsync successful output. | [
"Get",
"changes",
"from",
"the",
"rsync",
"successful",
"output",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L56-L77 | train |
saltstack/salt | salt/states/rsync.py | synchronized | def synchronized(name, source,
delete=False,
force=False,
update=False,
passwordfile=None,
exclude=None,
excludefrom=None,
prepare=False,
dryrun=False,
additional_opts... | python | def synchronized(name, source,
delete=False,
force=False,
update=False,
passwordfile=None,
exclude=None,
excludefrom=None,
prepare=False,
dryrun=False,
additional_opts... | [
"def",
"synchronized",
"(",
"name",
",",
"source",
",",
"delete",
"=",
"False",
",",
"force",
"=",
"False",
",",
"update",
"=",
"False",
",",
"passwordfile",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"excludefrom",
"=",
"None",
",",
"prepare",
"="... | Guarantees that the source directory is always copied to the target.
name
Name of the target directory.
source
Source directory.
prepare
Create destination directory if it does not exists.
delete
Delete extraneous files from the destination dirs (True or False)
f... | [
"Guarantees",
"that",
"the",
"source",
"directory",
"is",
"always",
"copied",
"to",
"the",
"target",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L80-L170 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.