partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | EventPublisher.run | Bind the pub and pull sockets for events | salt/utils/event.py | 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):
'''
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':
... | [
"Bind",
"the",
"pub",
"and",
"pull",
"sockets",
"for",
"events"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1100-L1147 | [
"def",
"run",
"(",
"self",
")",
":",
"salt",
".",
"utils",
".",
"process",
".",
"appendproctitle",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"io_loop",
"=",
"tornado",
".",
"ioloop",
".",
"IOLoop",
"(",
")",
"with",
"salt",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | EventPublisher.handle_publish | Get something from epull, publish it out epub, and return the package (or None) | salt/utils/event.py | 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, _):
'''
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 ... | [
"Get",
"something",
"from",
"epull",
"publish",
"it",
"out",
"epub",
"and",
"return",
"the",
"package",
"(",
"or",
"None",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1149-L1160 | [
"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",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | EventReturn.run | Spin up the multiprocess event returner | salt/utils/event.py | 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):
'''
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... | [
"Spin",
"up",
"the",
"multiprocess",
"event",
"returner"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1270-L1290 | [
"def",
"run",
"(",
"self",
")",
":",
"salt",
".",
"utils",
".",
"process",
".",
"appendproctitle",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"event",
"=",
"get_event",
"(",
"'master'",
",",
"opts",
"=",
"self",
".",
"opts",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | EventReturn._filter | Take an event and run it through configured filters.
Returns True if event should be stored, else False | salt/utils/event.py | 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):
'''
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... | [
"Take",
"an",
"event",
"and",
"run",
"it",
"through",
"configured",
"filters",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1292-L1311 | [
"def",
"_filter",
"(",
"self",
",",
"event",
")",
":",
"tag",
"=",
"event",
"[",
"'tag'",
"]",
"if",
"self",
".",
"opts",
"[",
"'event_return_whitelist'",
"]",
":",
"ret",
"=",
"False",
"else",
":",
"ret",
"=",
"True",
"for",
"whitelist_match",
"in",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | StateFire.fire_master | Fire an event off on the master server
CLI Example:
.. code-block:: bash
salt '*' event.fire_master 'stuff to be in the event' 'tag' | salt/utils/event.py | 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):
'''
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)
... | [
"Fire",
"an",
"event",
"off",
"on",
"the",
"master",
"server"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1327-L1356 | [
"def",
"fire_master",
"(",
"self",
",",
"data",
",",
"tag",
",",
"preload",
"=",
"None",
")",
":",
"load",
"=",
"{",
"}",
"if",
"preload",
":",
"load",
".",
"update",
"(",
"preload",
")",
"load",
".",
"update",
"(",
"{",
"'id'",
":",
"self",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | StateFire.fire_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. | salt/utils/event.py | 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):
'''
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 = {'... | [
"Pass",
"in",
"a",
"state",
"running",
"dict",
"this",
"is",
"the",
"return",
"dict",
"from",
"a",
"state",
"call",
".",
"The",
"dict",
"will",
"be",
"processed",
"and",
"fire",
"events",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1358-L1388 | [
"def",
"fire_running",
"(",
"self",
",",
"running",
")",
":",
"load",
"=",
"{",
"'id'",
":",
"self",
".",
"opts",
"[",
"'id'",
"]",
",",
"'events'",
":",
"[",
"]",
",",
"'cmd'",
":",
"'_minion_event'",
"}",
"for",
"stag",
"in",
"sorted",
"(",
"runn... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter.load | Load data by keys.
:param data:
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
Load data by keys.
:param data:
:return:
'''
for obj, data in descr.items():
setattr(self._data, obj, data)
return self | [
"Load",
"data",
"by",
"keys",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L50-L60 | [
"def",
"load",
"(",
"self",
",",
"*",
"*",
"descr",
")",
":",
"for",
"obj",
",",
"data",
"in",
"descr",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
".",
"_data",
",",
"obj",
",",
"data",
")",
"return",
"self"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter.export | Export to the Kiwi config.xml as text.
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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)
... | [
"Export",
"to",
"the",
"Kiwi",
"config",
".",
"xml",
"as",
"text",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L62-L79 | [
"def",
"export",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"root",
"=",
"self",
".",
"_create_doc",
"(",
")",
"self",
".",
"_set_description",
"(",
"root",
")",
"self",
".",
"_set_preferences",
"(",
"root",
")",
"self",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._get_package_manager | Get package manager.
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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... | [
"Get",
"package",
"manager",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L81-L98 | [
"def",
"_get_package_manager",
"(",
"self",
")",
":",
"ret",
"=",
"None",
"if",
"self",
".",
"__grains__",
".",
"get",
"(",
"'os_family'",
")",
"in",
"(",
"'Kali'",
",",
"'Debian'",
")",
":",
"ret",
"=",
"'apt-get'",
"elif",
"self",
".",
"__grains__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._set_preferences | Set preferences.
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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')
... | [
"Set",
"preferences",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L100-L126 | [
"def",
"_set_preferences",
"(",
"self",
",",
"node",
")",
":",
"pref",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'preferences'",
")",
"pacman",
"=",
"etree",
".",
"SubElement",
"(",
"pref",
",",
"'packagemanager'",
")",
"pacman",
".",
"text",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._get_user_groups | Get user groups.
:param user:
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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] | [
"Get",
"user",
"groups",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L128-L136 | [
"def",
"_get_user_groups",
"(",
"self",
",",
"user",
")",
":",
"return",
"[",
"g",
".",
"gr_name",
"for",
"g",
"in",
"grp",
".",
"getgrall",
"(",
")",
"if",
"user",
"in",
"g",
".",
"gr_mem",
"]",
"+",
"[",
"grp",
".",
"getgrgid",
"(",
"pwd",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._set_users | Create existing local users.
<users group="root">
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
</users>
:param node:
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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
... | [
"Create",
"existing",
"local",
"users",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L138-L177 | [
"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"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._set_repositories | Create repositories.
:param node:
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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]
... | [
"Create",
"repositories",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L179-L206 | [
"def",
"_set_repositories",
"(",
"self",
",",
"node",
")",
":",
"priority",
"=",
"99",
"for",
"repo_id",
",",
"repo_data",
"in",
"self",
".",
"_data",
".",
"software",
".",
"get",
"(",
"'repositories'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._set_packages | Set packages and collections.
:param node:
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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... | [
"Set",
"packages",
"and",
"collections",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L208-L227 | [
"def",
"_set_packages",
"(",
"self",
",",
"node",
")",
":",
"pkgs",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'packages'",
")",
"for",
"pkg_name",
",",
"pkg_version",
"in",
"sorted",
"(",
"self",
".",
"_data",
".",
"software",
".",
"get",
"("... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._set_description | Create a system description.
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
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... | [
"Create",
"a",
"system",
"description",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L229-L245 | [
"def",
"_set_description",
"(",
"self",
",",
"node",
")",
":",
"hostname",
"=",
"socket",
".",
"getfqdn",
"(",
")",
"or",
"platform",
".",
"node",
"(",
")",
"descr",
"=",
"etree",
".",
"SubElement",
"(",
"node",
",",
"'description'",
")",
"author",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KiwiExporter._create_doc | Create document.
:return: | salt/modules/inspectlib/kiwiproc.py | 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):
'''
Create document.
:return:
'''
root = etree.Element('image')
root.set('schemaversion', '6.3')
root.set('name', self.name)
return root | [
"Create",
"document",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L247-L257 | [
"def",
"_create_doc",
"(",
"self",
")",
":",
"root",
"=",
"etree",
".",
"Element",
"(",
"'image'",
")",
"root",
".",
"set",
"(",
"'schemaversion'",
",",
"'6.3'",
")",
"root",
".",
"set",
"(",
"'name'",
",",
"self",
".",
"name",
")",
"return",
"root"
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_ | Set a key/value pair in the vault service | salt/sdb/vault.py | 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):
'''
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... | [
"Set",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"vault",
"service"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/vault.py#L55-L85 | [
"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 '",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | hold | 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 | salt/thorium/timer.py | 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):
'''
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 ... | [
"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"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/timer.py#L11-L37 | [
"def",
"hold",
"(",
"name",
",",
"seconds",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"start",
"=",
"time",
".",
"time",
"(",
")",
"if",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _connect | Returns a tuple of (user, host, port) with config, pillar, or default
values assigned to missing values. | salt/modules/mongodb.py | 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):
'''
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:
... | [
"Returns",
"a",
"tuple",
"of",
"(",
"user",
"host",
"port",
")",
"with",
"config",
"pillar",
"or",
"default",
"values",
"assigned",
"to",
"missing",
"values",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L49-L74 | [
"def",
"_connect",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"user",
"=",
"__salt__",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _to_dict | Potentially interprets a string as JSON for usage with mongo | salt/modules/mongodb.py | 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):
'''
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
... | [
"Potentially",
"interprets",
"a",
"string",
"as",
"JSON",
"for",
"usage",
"with",
"mongo"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L77-L88 | [
"def",
"_to_dict",
"(",
"objects",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"objects",
",",
"six",
".",
"string_types",
")",
":",
"objects",
"=",
"salt",
".",
"utils",
".",
"json",
".",
"loads",
"(",
"objects",
")",
"except",
"ValueError",
"as",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | db_list | List all MongoDB databases
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_list <user> <password> <host> <port> | salt/modules/mongodb.py | 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):
'''
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... | [
"List",
"all",
"MongoDB",
"databases"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L91-L110 | [
"def",
"db_list",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"password",
",",
"host",
",",
"port",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | db_exists | Checks if a database exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_exists <name> <user> <password> <host> <port> | salt/modules/mongodb.py | 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):
'''
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)... | [
"Checks",
"if",
"a",
"database",
"exists",
"in",
"MongoDB"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L113-L128 | [
"def",
"db_exists",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"dbs",
"=",
"db_list",
"(",
"user",
",",
"password",
",",
"host",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | db_remove | Remove a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.db_remove <name> <user> <password> <host> <port> | salt/modules/mongodb.py | 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):
'''
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... | [
"Remove",
"a",
"MongoDB",
"database"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L131-L152 | [
"def",
"db_remove",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"password",
",",
"host",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | version | Get MongoDB instance version
CLI Example:
.. code-block:: bash
salt '*' mongodb.version <user> <password> <host> <port> <database> | salt/modules/mongodb.py | 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):
'''
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... | [
"Get",
"MongoDB",
"instance",
"version"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L159-L180 | [
"def",
"version",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"passwor... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_list | List users of a MongoDB database
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_list <user> <password> <host> <port> <database> | salt/modules/mongodb.py | 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):
'''
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... | [
"List",
"users",
"of",
"a",
"MongoDB",
"database"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L208-L245 | [
"def",
"user_list",
"(",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"user",
",",
"passw... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_exists | Checks if a user exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database> | salt/modules/mongodb.py | 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):
'''
Checks if a user exists in MongoDB
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database>
'''
users = use... | [
"Checks",
"if",
"a",
"user",
"exists",
"in",
"MongoDB"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L248-L268 | [
"def",
"user_exists",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"users",
"=",
"user_list",
"(",
"u... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_create | Create a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port> <database> | salt/modules/mongodb.py | 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... | [
"Create",
"a",
"MongoDB",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L271-L296 | [
"def",
"user_create",
"(",
"name",
",",
"passwd",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
",",
"roles",
"=",
"None",
")... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_remove | Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database> | salt/modules/mongodb.py | 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):
'''
Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
'''
conn = _connect(user, pa... | [
"Remove",
"a",
"MongoDB",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L299-L322 | [
"def",
"user_remove",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"use... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_roles_exists | 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... | salt/modules/mongodb.py | 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):
'''
Checks if a user of a MongoDB database has specified roles
CLI Examples:
.. code-block:: bash
salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname ... | [
"Checks",
"if",
"a",
"user",
"of",
"a",
"MongoDB",
"database",
"has",
"specified",
"roles"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L325-L360 | [
"def",
"user_roles_exists",
"(",
"name",
",",
"roles",
",",
"database",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"try",
":",
"roles",
"=",
"_to... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user_grant_roles | 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": ... | salt/modules/mongodb.py | 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):
'''
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... | [
"Grant",
"one",
"or",
"many",
"roles",
"to",
"a",
"MongoDB",
"user"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L363-L395 | [
"def",
"user_grant_roles",
"(",
"name",
",",
"roles",
",",
"database",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | insert | 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> | salt/modules/mongodb.py | 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):
'''
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": ... | [
"Insert",
"an",
"object",
"or",
"list",
"of",
"objects",
"into",
"a",
"collection"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L433-L462 | [
"def",
"insert",
"(",
"objects",
",",
"collection",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_co... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | update_one | 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... | salt/modules/mongodb.py | 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):
'''
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... | [
"Update",
"an",
"object",
"into",
"a",
"collection",
"http",
":",
"//",
"api",
".",
"mongodb",
".",
"com",
"/",
"python",
"/",
"current",
"/",
"api",
"/",
"pymongo",
"/",
"collection",
".",
"html#pymongo",
".",
"collection",
".",
"Collection",
".",
"upda... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L465-L530 | [
"def",
"update_one",
"(",
"objects",
",",
"collection",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | find | 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> | salt/modules/mongodb.py | 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):
'''
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... | [
"Find",
"an",
"object",
"or",
"list",
"of",
"objects",
"in",
"a",
"collection"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L533-L562 | [
"def",
"find",
"(",
"collection",
",",
"query",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | 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... | salt/states/infoblox_host_record.py | 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):
'''
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... | [
"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... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/infoblox_host_record.py#L17-L128 | [
"def",
"present",
"(",
"name",
"=",
"None",
",",
"data",
"=",
"None",
",",
"ensure_data",
"=",
"True",
",",
"*",
"*",
"api_opts",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | init | Perform any needed setup. | salt/proxy/marathon.py | 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):
'''
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) | [
"Perform",
"any",
"needed",
"setup",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L43-L51 | [
"def",
"init",
"(",
"opts",
")",
":",
"if",
"CONFIG_BASE_URL",
"in",
"opts",
"[",
"'proxy'",
"]",
":",
"CONFIG",
"[",
"CONFIG_BASE_URL",
"]",
"=",
"opts",
"[",
"'proxy'",
"]",
"[",
"CONFIG_BASE_URL",
"]",
"else",
":",
"log",
".",
"error",
"(",
"'missin... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ping | Is the marathon api responding? | salt/proxy/marathon.py | 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():
'''
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',
... | [
"Is",
"the",
"marathon",
"api",
"responding?"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L54-L76 | [
"def",
"ping",
"(",
")",
":",
"try",
":",
"response",
"=",
"salt",
".",
"utils",
".",
"http",
".",
"query",
"(",
"\"{0}/ping\"",
".",
"format",
"(",
"CONFIG",
"[",
"CONFIG_BASE_URL",
"]",
")",
",",
"decode_type",
"=",
"'plain'",
",",
"decode",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _auth | Set up glance credentials, returns
`glanceclient.client.Client`. Optional parameter
"api_version" defaults to 2.
Only intended to be used within glance-enabled modules | salt/modules/glance.py | 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):
'''
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',
... | [
"Set",
"up",
"glance",
"credentials",
"returns",
"glanceclient",
".",
"client",
".",
"Client",
".",
"Optional",
"parameter",
"api_version",
"defaults",
"to",
"2",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L98-L182 | [
"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}. '... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _add_image | Add image to given dictionary | salt/modules/glance.py | 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):
'''
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,
... | [
"Add",
"image",
"to",
"given",
"dictionary"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L185-L216 | [
"def",
"_add_image",
"(",
"collection",
",",
"image",
")",
":",
"image_prep",
"=",
"{",
"'id'",
":",
"image",
".",
"id",
",",
"'name'",
":",
"image",
".",
"name",
",",
"'created_at'",
":",
"image",
".",
"created_at",
",",
"'file'",
":",
"image",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | image_create | 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... | salt/modules/glance.py | 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,):
'''
Create an image (glance image-create)
CLI Example, old format:
..... | [
"Create",
"an",
"image",
"(",
"glance",
"image",
"-",
"create",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L219-L282 | [
"def",
"image_create",
"(",
"name",
",",
"location",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"visibility",
"=",
"None",
",",
"container_format",
"=",
"'bare'",
",",
"disk_format",
"=",
"'raw'",
",",
"protected",
"=",
"None",
",",
")",
":",
"kwargs... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | image_delete | 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 | salt/modules/glance.py | 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
'''
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... | [
"Delete",
"an",
"image",
"(",
"glance",
"image",
"-",
"delete",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L285-L329 | [
"def",
"image_delete",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"image",
"=",
"{",
"'id'",
":",
"False",
",",
"'name'",
":",
"None... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | image_show | Return details about a specific image (glance image-show)
CLI Example:
.. code-block:: bash
salt '*' glance.image_show | salt/modules/glance.py | 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
'''
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... | [
"Return",
"details",
"about",
"a",
"specific",
"image",
"(",
"glance",
"image",
"-",
"show",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L332-L374 | [
"def",
"image_show",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"{",
"}",
"if",
"name",
":",
"for",
"image",
"in",
"g_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | image_list | Return a list of available images (glance image-list)
CLI Example:
.. code-block:: bash
salt '*' glance.image_list | salt/modules/glance.py | 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
'''
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():
... | [
"Return",
"a",
"list",
"of",
"available",
"images",
"(",
"glance",
"image",
"-",
"list",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L377-L407 | [
"def",
"image_list",
"(",
"id",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# pylint: disable=C0103",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"[",
"]",
"for",
"image",
"in",
"g_client",
".",
"images... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | image_update | 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 | salt/modules/glance.py | 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
'''
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... | [
"Update",
"properties",
"of",
"given",
"image",
".",
"Known",
"to",
"work",
"for",
":",
"-",
"min_ram",
"(",
"in",
"MB",
")",
"-",
"protected",
"(",
"bool",
")",
"-",
"visibility",
"(",
"public",
"or",
"private",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L424-L473 | [
"def",
"image_update",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0103",
"if",
"id",
":",
"image",
"=",
"image_show",
"(",
"id",
"=",
"id",
",",
"profile",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | schema_get | Known valid names of schemas are:
- image
- images
- member
- members
CLI Example:
.. code-block:: bash
salt '*' glance.schema_get name=f16-jeos | salt/modules/glance.py | 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):
'''
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... | [
"Known",
"valid",
"names",
"of",
"schemas",
"are",
":",
"-",
"image",
"-",
"images",
"-",
"member",
"-",
"members"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L476-L498 | [
"def",
"schema_get",
"(",
"name",
",",
"profile",
"=",
"None",
")",
":",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"schema_props",
"=",
"{",
"}",
"for",
"prop",
"in",
"g_client",
".",
"schemas",
".",
"get",
"(",
"name",
")",
".",
"properties",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _item_list | Template for writing list functions
Return a list of available items (glance items-list)
CLI Example:
.. code-block:: bash
salt '*' glance.item_list | salt/modules/glance.py | 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):
'''
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... | [
"Template",
"for",
"writing",
"list",
"functions",
"Return",
"a",
"list",
"of",
"available",
"items",
"(",
"glance",
"items",
"-",
"list",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L501-L519 | [
"def",
"_item_list",
"(",
"profile",
"=",
"None",
")",
":",
"g_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"[",
"]",
"for",
"item",
"in",
"g_client",
".",
"items",
".",
"list",
"(",
")",
":",
"ret",
".",
"append",
"(",
"item",
".",
"_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | until | 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
... | salt/states/loop.py | 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):
'''
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
... | [
"Loop",
"over",
"an",
"execution",
"module",
"until",
"a",
"condition",
"is",
"met",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/loop.py#L47-L118 | [
"def",
"until",
"(",
"name",
",",
"m_args",
"=",
"None",
",",
"m_kwargs",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"period",
"=",
"0",
",",
"timeout",
"=",
"604800",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _authenticate | Retrieve CSRF and API tickets for the Proxmox API | salt/cloud/clouds/proxmox.py | 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():
'''
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... | [
"Retrieve",
"CSRF",
"and",
"API",
"tickets",
"for",
"the",
"Proxmox",
"API"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L116-L146 | [
"def",
"_authenticate",
"(",
")",
":",
"global",
"url",
",",
"port",
",",
"ticket",
",",
"csrf",
",",
"verify_ssl",
"url",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'url'",
",",
"get_configured_provider",
"(",
")",
",",
"__opts__",
",",
"search_glo... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | query | Execute the HTTP request to the API | salt/cloud/clouds/proxmox.py | 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):
'''
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)
... | [
"Execute",
"the",
"HTTP",
"request",
"to",
"the",
"API"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L149-L196 | [
"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..'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_vm_by_name | Since Proxmox works based op id's rather than names as identifiers this
requires some filtering to retrieve the required information. | salt/cloud/clouds/proxmox.py | 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):
'''
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 ... | [
"Since",
"Proxmox",
"works",
"based",
"op",
"id",
"s",
"rather",
"than",
"names",
"as",
"identifiers",
"this",
"requires",
"some",
"filtering",
"to",
"retrieve",
"the",
"required",
"information",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L199-L209 | [
"def",
"_get_vm_by_name",
"(",
"name",
",",
"allDetails",
"=",
"False",
")",
":",
"vms",
"=",
"get_resources_vms",
"(",
"includeConfig",
"=",
"allDetails",
")",
"if",
"name",
"in",
"vms",
":",
"return",
"vms",
"[",
"name",
"]",
"log",
".",
"info",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_vm_by_id | Retrieve a VM based on the ID. | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Retrieve",
"a",
"VM",
"based",
"on",
"the",
"ID",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L212-L221 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_ip_available | 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. | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"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... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L232-L245 | [
"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"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_proxmox_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. | salt/cloud/clouds/proxmox.py | 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):
'''
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(':')
... | [
"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",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L248-L272 | [
"def",
"_parse_proxmox_upid",
"(",
"node",
",",
"vm_",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"upid",
"=",
"node",
"# Parse node response",
"node",
"=",
"node",
".",
"split",
"(",
"':'",
")",
"if",
"node",
"[",
"0",
"]",
"==",
"'UPID'",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _lookup_proxmox_task | Retrieve the (latest) logs and retrieve the status for a UPID.
This can be used to verify whether a task has completed. | salt/cloud/clouds/proxmox.py | 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):
'''
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:
... | [
"Retrieve",
"the",
"(",
"latest",
")",
"logs",
"and",
"retrieve",
"the",
"status",
"for",
"a",
"UPID",
".",
"This",
"can",
"be",
"used",
"to",
"verify",
"whether",
"a",
"task",
"has",
"completed",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L275-L289 | [
"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",
":... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_resources_nodes | Retrieve all hypervisors (nodes) available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_nodes my-proxmox-config | salt/cloud/clouds/proxmox.py | 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):
'''
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 ... | [
"Retrieve",
"all",
"hypervisors",
"(",
"nodes",
")",
"available",
"on",
"this",
"environment",
"CLI",
"Example",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L292-L316 | [
"def",
"get_resources_nodes",
"(",
"call",
"=",
"None",
",",
"resFilter",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Getting resource: nodes.. (filter: %s)'",
",",
"resFilter",
")",
"resources",
"=",
"query",
"(",
"'get'",
",",
"'cluster/resources'",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_resources_vms | Retrieve all VMs available on this environment
CLI Example:
.. code-block:: bash
salt-cloud -f get_resources_vms my-proxmox-config | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Retrieve",
"all",
"VMs",
"available",
"on",
"this",
"environment"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L319-L372 | [
"def",
"get_resources_vms",
"(",
"call",
"=",
"None",
",",
"resFilter",
"=",
"None",
",",
"includeConfig",
"=",
"True",
")",
":",
"timeoutTime",
"=",
"time",
".",
"time",
"(",
")",
"+",
"60",
"while",
"True",
":",
"log",
".",
"debug",
"(",
"'Getting re... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | script | Return the script deployment object | salt/cloud/clouds/proxmox.py | 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_):
'''
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.... | [
"Return",
"the",
"script",
"deployment",
"object"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L375-L390 | [
"def",
"script",
"(",
"vm_",
")",
":",
"script_name",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'script'",
",",
"vm_",
",",
"__opts__",
")",
"if",
"not",
"script_name",
":",
"script_name",
"=",
"'bootstrap-salt'",
"return",
"salt",
".",
"utils",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | avail_locations | 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 | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Return",
"a",
"list",
"of",
"the",
"hypervisors",
"(",
"nodes",
")",
"which",
"this",
"Proxmox",
"PVE",
"machine",
"manages"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L393-L417 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | avail_images | Return a list of the images that are on the provider
CLI Example:
.. code-block:: bash
salt-cloud --list-images my-proxmox-config | salt/cloud/clouds/proxmox.py | 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'):
'''
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 ... | [
"Return",
"a",
"list",
"of",
"the",
"images",
"that",
"are",
"on",
"the",
"provider"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L420-L440 | [
"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'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_nodes | Return a list of the VMs that are managed by the provider
CLI Example:
.. code-block:: bash
salt-cloud -Q my-proxmox-config | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"managed",
"by",
"the",
"provider"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L443-L485 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _stringlist_to_dictionary | 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'} | salt/cloud/clouds/proxmox.py | 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):
'''
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 = {}
... | [
"Convert",
"a",
"stringlist",
"(",
"comma",
"separated",
"settings",
")",
"to",
"a",
"dictionary"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L521-L538 | [
"def",
"_stringlist_to_dictionary",
"(",
"input_string",
")",
":",
"li",
"=",
"str",
"(",
"input_string",
")",
".",
"split",
"(",
"','",
")",
"ret",
"=",
"{",
"}",
"for",
"item",
"in",
"li",
":",
"pair",
"=",
"str",
"(",
"item",
")",
".",
"replace",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dictionary_to_stringlist | Convert a dictionary to a stringlist (comma separated settings)
The result of the dictionary {'setting1':'value1','setting2':'value2'} will be:
setting1=value1,setting2=value2 | salt/cloud/clouds/proxmox.py | 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):
'''
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 += ... | [
"Convert",
"a",
"dictionary",
"to",
"a",
"stringlist",
"(",
"comma",
"separated",
"settings",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L541-L553 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create | Create a single VM from a data dict
CLI Example:
.. code-block:: bash
salt-cloud -p proxmox-ubuntu vmhostname | salt/cloud/clouds/proxmox.py | 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_):
'''
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__... | [
"Create",
"a",
"single",
"VM",
"from",
"a",
"data",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L556-L867 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _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" | salt/cloud/clouds/proxmox.py | 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():
'''
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... | [
"Download",
"https",
":",
"//",
"<url",
">",
"/",
"pve",
"-",
"docs",
"/",
"api",
"-",
"viewer",
"/",
"apidoc",
".",
"js",
"Extract",
"content",
"of",
"pveapi",
"var",
"(",
"json",
"formated",
")",
"Load",
"this",
"json",
"content",
"into",
"global",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L870-L882 | [
"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"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_properties | Return the parameter list from api for defined path and HTTP method | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Return",
"the",
"parameter",
"list",
"from",
"api",
"for",
"defined",
"path",
"and",
"HTTP",
"method"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L885-L919 | [
"def",
"_get_properties",
"(",
"path",
"=",
"\"\"",
",",
"method",
"=",
"\"GET\"",
",",
"forced_params",
"=",
"None",
")",
":",
"if",
"api",
"is",
"None",
":",
"_import_api",
"(",
")",
"sub",
"=",
"api",
"path_levels",
"=",
"[",
"level",
"for",
"level"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_node | Build and submit the requestdata to create a new node | salt/cloud/clouds/proxmox.py | 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):
'''
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
... | [
"Build",
"and",
"submit",
"the",
"requestdata",
"to",
"create",
"a",
"new",
"node"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L922-L1042 | [
"def",
"create_node",
"(",
"vm_",
",",
"newid",
")",
":",
"newnode",
"=",
"{",
"}",
"if",
"'technology'",
"not",
"in",
"vm_",
":",
"vm_",
"[",
"'technology'",
"]",
"=",
"'openvz'",
"# default virt tech if none is given",
"if",
"vm_",
"[",
"'technology'",
"]"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_vmconfig | Get VM configuration | salt/cloud/clouds/proxmox.py | 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'):
'''
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... | [
"Get",
"VM",
"configuration"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1059-L1073 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_state | Wait until a specific state has been reached on a node | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Wait",
"until",
"a",
"specific",
"state",
"has",
"been",
"reached",
"on",
"a",
"node"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1098-L1119 | [
"def",
"wait_for_state",
"(",
"vmid",
",",
"state",
",",
"timeout",
"=",
"300",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"node",
"=",
"get_vm_status",
"(",
"vmid",
"=",
"vmid",
")",
"if",
"not",
"node",
":",
"log",
".",
"error",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_task | Wait until a the task has been finished successfully | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Wait",
"until",
"a",
"the",
"task",
"has",
"been",
"finished",
"successfully"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1122-L1141 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | destroy | Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine | salt/cloud/clouds/proxmox.py | 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):
'''
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.'
)... | [
"Destroy",
"a",
"node",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1144-L1198 | [
"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'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_vm_status | Convenience function for setting VM status | salt/cloud/clouds/proxmox.py | 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):
'''
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 = ... | [
"Convenience",
"function",
"for",
"setting",
"VM",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1201-L1231 | [
"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"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_vm_status | Get the status for a VM, either via the ID or the hostname | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Get",
"the",
"status",
"for",
"a",
"VM",
"either",
"via",
"the",
"ID",
"or",
"the",
"hostname"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1234-L1258 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | start | Start a node.
CLI Example:
.. code-block:: bash
salt-cloud -a start mymachine | salt/cloud/clouds/proxmox.py | 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):
'''
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 (... | [
"Start",
"a",
"node",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1261-L1283 | [
"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... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | stop | Stop a node ("pulling the plug").
CLI Example:
.. code-block:: bash
salt-cloud -a stop mymachine | salt/cloud/clouds/proxmox.py | 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):
'''
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... | [
"Stop",
"a",
"node",
"(",
"pulling",
"the",
"plug",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L1286-L1307 | [
"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",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_summary | Get summary from the rsync successful output. | salt/states/rsync.py | 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):
'''
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]) | [
"Get",
"summary",
"from",
"the",
"rsync",
"successful",
"output",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L48-L53 | [
"def",
"_get_summary",
"(",
"rsync_out",
")",
":",
"return",
"\"- \"",
"+",
"\"\\n- \"",
".",
"join",
"(",
"[",
"elm",
"for",
"elm",
"in",
"rsync_out",
".",
"split",
"(",
"\"\\n\\n\"",
")",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"\" \"",
",",
"\"\... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_changes | Get changes from the rsync successful output. | salt/states/rsync.py | 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):
'''
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... | [
"Get",
"changes",
"from",
"the",
"rsync",
"successful",
"output",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L56-L77 | [
"def",
"_get_changes",
"(",
"rsync_out",
")",
":",
"copied",
"=",
"list",
"(",
")",
"deleted",
"=",
"list",
"(",
")",
"for",
"line",
"in",
"rsync_out",
".",
"split",
"(",
"\"\\n\\n\"",
")",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
"1"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | synchronized | 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... | salt/states/rsync.py | 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=False,
dryrun=False,
additional_opts... | [
"Guarantees",
"that",
"the",
"source",
"directory",
"is",
"always",
"copied",
"to",
"the",
"target",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rsync.py#L80-L170 | [
"def",
"synchronized",
"(",
"name",
",",
"source",
",",
"delete",
"=",
"False",
",",
"force",
"=",
"False",
",",
"update",
"=",
"False",
",",
"passwordfile",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"excludefrom",
"=",
"None",
",",
"prepare",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_data | Get the configuration of the device tree at the given path
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the value at,
a list of element names in o... | salt/modules/cisconso.py | def get_data(datastore, path):
'''
Get the configuration of the device tree at the given path
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the val... | def get_data(datastore, path):
'''
Get the configuration of the device tree at the given path
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the val... | [
"Get",
"the",
"configuration",
"of",
"the",
"device",
"tree",
"at",
"the",
"given",
"path"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cisconso.py#L37-L58 | [
"def",
"get_data",
"(",
"datastore",
",",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"path",
"=",
"'/'",
".",
"split",
"(",
"path",
")",
"return",
"_proxy_cmd",
"(",
"'get_data'",
",",
"datastore",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_data_value | Set a data entry in a datastore
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the value at,
a list of element names in order, / separated
:type... | salt/modules/cisconso.py | def set_data_value(datastore, path, data):
'''
Set a data entry in a datastore
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the value at,
... | def set_data_value(datastore, path, data):
'''
Set a data entry in a datastore
:param datastore: The datastore, e.g. running, operational.
One of the NETCONF store IETF types
:type datastore: :class:`DatastoreType` (``str`` enum).
:param path: The device path to set the value at,
... | [
"Set",
"a",
"data",
"entry",
"in",
"a",
"datastore"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cisconso.py#L61-L85 | [
"def",
"set_data_value",
"(",
"datastore",
",",
"path",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"path",
"=",
"'/'",
".",
"split",
"(",
"path",
")",
"return",
"_proxy_cmd",
"(",
"'set_data_value'"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Initialize the PostgreSQL data directory
name
The name of the directory to initialize
user
The database superuser name
password
The password to set for the postgres user
auth
The default authentication method for local connections
encoding
The default enc... | salt/states/postgres_initdb.py | def present(name,
user=None,
password=None,
auth='password',
encoding='UTF8',
locale=None,
runas=None,
waldir=None,
checksums=False):
'''
Initialize the PostgreSQL data directory
name
The name of the directory to initialize
user
... | def present(name,
user=None,
password=None,
auth='password',
encoding='UTF8',
locale=None,
runas=None,
waldir=None,
checksums=False):
'''
Initialize the PostgreSQL data directory
name
The name of the directory to initialize
user
... | [
"Initialize",
"the",
"PostgreSQL",
"data",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_initdb.py#L39-L121 | [
"def",
"present",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"auth",
"=",
"'password'",
",",
"encoding",
"=",
"'UTF8'",
",",
"locale",
"=",
"None",
",",
"runas",
"=",
"None",
",",
"waldir",
"=",
"None",
",",
"checksums"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_plugins | List plugins in an installed wordpress path
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.list_plugins /var/www/html apache | salt/modules/wordpress.py | def list_plugins(path, user):
'''
List plugins in an installed wordpress path
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.list_plugins /var/www/html apache
'''
ret = []
resp ... | def list_plugins(path, user):
'''
List plugins in an installed wordpress path
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.list_plugins /var/www/html apache
'''
ret = []
resp ... | [
"List",
"plugins",
"in",
"an",
"installed",
"wordpress",
"path"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/wordpress.py#L29-L51 | [
"def",
"list_plugins",
"(",
"path",
",",
"user",
")",
":",
"ret",
"=",
"[",
"]",
"resp",
"=",
"__salt__",
"[",
"'cmd.shell'",
"]",
"(",
"(",
"'wp --path={0} plugin list'",
")",
".",
"format",
"(",
"path",
")",
",",
"runas",
"=",
"user",
")",
"for",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show_plugin | Show a plugin in a wordpress install and check if it is installed
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.show_plugin HyperDB /var/www/html apache | salt/modules/wordpress.py | def show_plugin(name, path, user):
'''
Show a plugin in a wordpress install and check if it is installed
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpre... | def show_plugin(name, path, user):
'''
Show a plugin in a wordpress install and check if it is installed
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpre... | [
"Show",
"a",
"plugin",
"in",
"a",
"wordpress",
"install",
"and",
"check",
"if",
"it",
"is",
"installed"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/wordpress.py#L54-L82 | [
"def",
"show_plugin",
"(",
"name",
",",
"path",
",",
"user",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
"}",
"resp",
"=",
"__salt__",
"[",
"'cmd.shell'",
"]",
"(",
"(",
"'wp --path={0} plugin status {1}'",
")",
".",
"format",
"(",
"path",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | activate | Activate a wordpress plugin
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.activate HyperDB /var/www/html apache | salt/modules/wordpress.py | def activate(name, path, user):
'''
Activate a wordpress plugin
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.activate HyperDB /var/www/html apache
... | def activate(name, path, user):
'''
Activate a wordpress plugin
name
Wordpress plugin name
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.activate HyperDB /var/www/html apache
... | [
"Activate",
"a",
"wordpress",
"plugin"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/wordpress.py#L85-L115 | [
"def",
"activate",
"(",
"name",
",",
"path",
",",
"user",
")",
":",
"check",
"=",
"show_plugin",
"(",
"name",
",",
"path",
",",
"user",
")",
"if",
"check",
"[",
"'status'",
"]",
"==",
"'active'",
":",
"# already active",
"return",
"None",
"resp",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | is_installed | Check if wordpress is installed and setup
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.is_installed /var/www/html apache | salt/modules/wordpress.py | def is_installed(path, user=None):
'''
Check if wordpress is installed and setup
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.is_installed /var/www/html apache
'''
retcode = __sal... | def is_installed(path, user=None):
'''
Check if wordpress is installed and setup
path
path to wordpress install location
user
user to run the command as
CLI Example:
.. code-block:: bash
salt '*' wordpress.is_installed /var/www/html apache
'''
retcode = __sal... | [
"Check",
"if",
"wordpress",
"is",
"installed",
"and",
"setup"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/wordpress.py#L151-L172 | [
"def",
"is_installed",
"(",
"path",
",",
"user",
"=",
"None",
")",
":",
"retcode",
"=",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"(",
"'wp --path={0} core is-installed'",
")",
".",
"format",
"(",
"path",
")",
",",
"runas",
"=",
"user",
")",
"if",
"ret... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | install | Run the initial setup functions for a wordpress install
path
path to wordpress install location
user
user to run the command as
admin_user
Username for the Administrative user for the wordpress install
admin_password
Initial Password for the Administrative user for th... | salt/modules/wordpress.py | def install(path, user, admin_user, admin_password, admin_email, title, url):
'''
Run the initial setup functions for a wordpress install
path
path to wordpress install location
user
user to run the command as
admin_user
Username for the Administrative user for the wordpre... | def install(path, user, admin_user, admin_password, admin_email, title, url):
'''
Run the initial setup functions for a wordpress install
path
path to wordpress install location
user
user to run the command as
admin_user
Username for the Administrative user for the wordpre... | [
"Run",
"the",
"initial",
"setup",
"functions",
"for",
"a",
"wordpress",
"install"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/wordpress.py#L175-L225 | [
"def",
"install",
"(",
"path",
",",
"user",
",",
"admin_user",
",",
"admin_password",
",",
"admin_email",
",",
"title",
",",
"url",
")",
":",
"retcode",
"=",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"(",
"'wp --path={0} core install '",
"'--title=\"{1}\" '",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | match | Matches a grain based on regex | salt/matchers/grain_pcre_match.py | def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None):
'''
Matches a grain based on regex
'''
if not opts:
opts = __opts__
log.debug('grains pcre target: %s', tgt)
if delimiter not in tgt:
log.error('Got insufficient arguments for grains pcre match '
'statem... | def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None):
'''
Matches a grain based on regex
'''
if not opts:
opts = __opts__
log.debug('grains pcre target: %s', tgt)
if delimiter not in tgt:
log.error('Got insufficient arguments for grains pcre match '
'statem... | [
"Matches",
"a",
"grain",
"based",
"on",
"regex"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/matchers/grain_pcre_match.py#L15-L28 | [
"def",
"match",
"(",
"tgt",
",",
"delimiter",
"=",
"DEFAULT_TARGET_DELIM",
",",
"opts",
"=",
"None",
")",
":",
"if",
"not",
"opts",
":",
"opts",
"=",
"__opts__",
"log",
".",
"debug",
"(",
"'grains pcre target: %s'",
",",
"tgt",
")",
"if",
"delimiter",
"n... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | dump | .. versionadded:: 2018.3.0
Helper that wraps yaml.dump and ensures that we encode unicode strings
unless explicitly told not to. | salt/utils/yamldumper.py | def dump(data, stream=None, **kwargs):
'''
.. versionadded:: 2018.3.0
Helper that wraps yaml.dump and ensures that we encode unicode strings
unless explicitly told not to.
'''
if 'allow_unicode' not in kwargs:
kwargs['allow_unicode'] = True
return yaml.dump(data, stream, **kwargs) | def dump(data, stream=None, **kwargs):
'''
.. versionadded:: 2018.3.0
Helper that wraps yaml.dump and ensures that we encode unicode strings
unless explicitly told not to.
'''
if 'allow_unicode' not in kwargs:
kwargs['allow_unicode'] = True
return yaml.dump(data, stream, **kwargs) | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamldumper.py#L116-L125 | [
"def",
"dump",
"(",
"data",
",",
"stream",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'allow_unicode'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'allow_unicode'",
"]",
"=",
"True",
"return",
"yaml",
".",
"dump",
"(",
"data",
",",
"stre... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | safe_dump | Use a custom dumper to ensure that defaultdict and OrderedDict are
represented properly. Ensure that unicode strings are encoded unless
explicitly told not to. | salt/utils/yamldumper.py | def safe_dump(data, stream=None, **kwargs):
'''
Use a custom dumper to ensure that defaultdict and OrderedDict are
represented properly. Ensure that unicode strings are encoded unless
explicitly told not to.
'''
if 'allow_unicode' not in kwargs:
kwargs['allow_unicode'] = True
return ... | def safe_dump(data, stream=None, **kwargs):
'''
Use a custom dumper to ensure that defaultdict and OrderedDict are
represented properly. Ensure that unicode strings are encoded unless
explicitly told not to.
'''
if 'allow_unicode' not in kwargs:
kwargs['allow_unicode'] = True
return ... | [
"Use",
"a",
"custom",
"dumper",
"to",
"ensure",
"that",
"defaultdict",
"and",
"OrderedDict",
"are",
"represented",
"properly",
".",
"Ensure",
"that",
"unicode",
"strings",
"are",
"encoded",
"unless",
"explicitly",
"told",
"not",
"to",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamldumper.py#L128-L136 | [
"def",
"safe_dump",
"(",
"data",
",",
"stream",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'allow_unicode'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'allow_unicode'",
"]",
"=",
"True",
"return",
"yaml",
".",
"dump",
"(",
"data",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | avail_images | Return available OpenNebula images.
CLI Example:
.. code-block:: bash
salt-cloud --list-images opennebula
salt-cloud --function avail_images opennebula
salt-cloud -f avail_images opennebula | salt/cloud/clouds/opennebula.py | def avail_images(call=None):
'''
Return available OpenNebula images.
CLI Example:
.. code-block:: bash
salt-cloud --list-images opennebula
salt-cloud --function avail_images opennebula
salt-cloud -f avail_images opennebula
'''
if call == 'action':
raise SaltCl... | def avail_images(call=None):
'''
Return available OpenNebula images.
CLI Example:
.. code-block:: bash
salt-cloud --list-images opennebula
salt-cloud --function avail_images opennebula
salt-cloud -f avail_images opennebula
'''
if call == 'action':
raise SaltCl... | [
"Return",
"available",
"OpenNebula",
"images",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L132-L160 | [
"def",
"avail_images",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_images function must be called with '",
"'-f or --function, or with the --list-images option'",
")",
"server",
",",
"user",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | avail_locations | Return available OpenNebula locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations opennebula
salt-cloud --function avail_locations opennebula
salt-cloud -f avail_locations opennebula | salt/cloud/clouds/opennebula.py | def avail_locations(call=None):
'''
Return available OpenNebula locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations opennebula
salt-cloud --function avail_locations opennebula
salt-cloud -f avail_locations opennebula
'''
if call == 'action':
... | def avail_locations(call=None):
'''
Return available OpenNebula locations.
CLI Example:
.. code-block:: bash
salt-cloud --list-locations opennebula
salt-cloud --function avail_locations opennebula
salt-cloud -f avail_locations opennebula
'''
if call == 'action':
... | [
"Return",
"available",
"OpenNebula",
"locations",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L163-L190 | [
"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.'",
")",
"server",
",",
"us... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_clusters | Returns a list of clusters in OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_clusters opennebula | salt/cloud/clouds/opennebula.py | def list_clusters(call=None):
'''
Returns a list of clusters in OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_clusters opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_clusters function must... | def list_clusters(call=None):
'''
Returns a list of clusters in OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_clusters opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_clusters function must... | [
"Returns",
"a",
"list",
"of",
"clusters",
"in",
"OpenNebula",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L212-L237 | [
"def",
"list_clusters",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_clusters function must be called with -f or --function.'",
")",
"server",
",",
"user",
",",
"password",
"=",
"_get_xml_rpc"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_datastores | Returns a list of data stores on OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_datastores opennebula | salt/cloud/clouds/opennebula.py | def list_datastores(call=None):
'''
Returns a list of data stores on OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_datastores opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_datastores func... | def list_datastores(call=None):
'''
Returns a list of data stores on OpenNebula.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_datastores opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_datastores func... | [
"Returns",
"a",
"list",
"of",
"data",
"stores",
"on",
"OpenNebula",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L240-L265 | [
"def",
"list_datastores",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_datastores function must be called with -f or --function.'",
")",
"server",
",",
"user",
",",
"password",
"=",
"_get_xml_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_security_groups | Lists all security groups available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_security_groups opennebula | salt/cloud/clouds/opennebula.py | def list_security_groups(call=None):
'''
Lists all security groups available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_security_groups opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
... | def list_security_groups(call=None):
'''
Lists all security groups available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_security_groups opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
... | [
"Lists",
"all",
"security",
"groups",
"available",
"to",
"the",
"user",
"and",
"the",
"user",
"s",
"groups",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L346-L371 | [
"def",
"list_security_groups",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_security_groups function must be called with -f or --function.'",
")",
"server",
",",
"user",
",",
"password",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_templates | Lists all templates available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_templates opennebula | salt/cloud/clouds/opennebula.py | def list_templates(call=None):
'''
Lists all templates available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_templates opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The li... | def list_templates(call=None):
'''
Lists all templates available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_templates opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The li... | [
"Lists",
"all",
"templates",
"available",
"to",
"the",
"user",
"and",
"the",
"user",
"s",
"groups",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L374-L399 | [
"def",
"list_templates",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_templates function must be called with -f or --function.'",
")",
"server",
",",
"user",
",",
"password",
"=",
"_get_xml_rp... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_vns | Lists all virtual networks available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_vns opennebula | salt/cloud/clouds/opennebula.py | def list_vns(call=None):
'''
Lists all virtual networks available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_vns opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_vn... | def list_vns(call=None):
'''
Lists all virtual networks available to the user and the user's groups.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f list_vns opennebula
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_vn... | [
"Lists",
"all",
"virtual",
"networks",
"available",
"to",
"the",
"user",
"and",
"the",
"user",
"s",
"groups",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L402-L427 | [
"def",
"list_vns",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_vns function must be called with -f or --function.'",
")",
"server",
",",
"user",
",",
"password",
"=",
"_get_xml_rpc",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | reboot | Reboot a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot my-vm | salt/cloud/clouds/opennebula.py | def reboot(name, call=None):
'''
Reboot a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be ... | def reboot(name, call=None):
'''
Reboot a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be ... | [
"Reboot",
"a",
"VM",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L430-L452 | [
"def",
"reboot",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The start action must be called with -a or --action.'",
")",
"log",
".",
"info",
"(",
"'Rebooting node %s'",
",",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | start | Start a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to start.
CLI Example:
.. code-block:: bash
salt-cloud -a start my-vm | salt/cloud/clouds/opennebula.py | def start(name, call=None):
'''
Start a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to start.
CLI Example:
.. code-block:: bash
salt-cloud -a start my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be call... | def start(name, call=None):
'''
Start a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to start.
CLI Example:
.. code-block:: bash
salt-cloud -a start my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be call... | [
"Start",
"a",
"VM",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L455-L477 | [
"def",
"start",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The start action must be called with -a or --action.'",
")",
"log",
".",
"info",
"(",
"'Starting node %s'",
",",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | stop | Stop a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to stop.
CLI Example:
.. code-block:: bash
salt-cloud -a stop my-vm | salt/cloud/clouds/opennebula.py | def stop(name, call=None):
'''
Stop a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to stop.
CLI Example:
.. code-block:: bash
salt-cloud -a stop my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be called w... | def stop(name, call=None):
'''
Stop a VM.
.. versionadded:: 2016.3.0
name
The name of the VM to stop.
CLI Example:
.. code-block:: bash
salt-cloud -a stop my-vm
'''
if call != 'action':
raise SaltCloudSystemExit(
'The start action must be called w... | [
"Stop",
"a",
"VM",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L480-L502 | [
"def",
"stop",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The start action must be called with -a or --action.'",
")",
"log",
".",
"info",
"(",
"'Stopping node %s'",
",",
"name",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_one_version | Returns the OpenNebula version.
.. versionadded:: 2016.3.5
CLI Example:
.. code-block:: bash
salt-cloud -f get_one_version one_provider_name | salt/cloud/clouds/opennebula.py | def get_one_version(kwargs=None, call=None):
'''
Returns the OpenNebula version.
.. versionadded:: 2016.3.5
CLI Example:
.. code-block:: bash
salt-cloud -f get_one_version one_provider_name
'''
if call == 'action':
raise SaltCloudSystemExit(
'The get_cluster_... | def get_one_version(kwargs=None, call=None):
'''
Returns the OpenNebula version.
.. versionadded:: 2016.3.5
CLI Example:
.. code-block:: bash
salt-cloud -f get_one_version one_provider_name
'''
if call == 'action':
raise SaltCloudSystemExit(
'The get_cluster_... | [
"Returns",
"the",
"OpenNebula",
"version",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L505-L529 | [
"def",
"get_one_version",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The get_cluster_id function must be called with -f or --function.'",
")",
"if",
"kwargs",
"is",
"Non... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_cluster_id | Returns a cluster's ID from the given cluster name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_cluster_id opennebula name=my-cluster-name | salt/cloud/clouds/opennebula.py | def get_cluster_id(kwargs=None, call=None):
'''
Returns a cluster's ID from the given cluster name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_cluster_id opennebula name=my-cluster-name
'''
if call == 'action':
raise SaltCloudSystemExit... | def get_cluster_id(kwargs=None, call=None):
'''
Returns a cluster's ID from the given cluster name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_cluster_id opennebula name=my-cluster-name
'''
if call == 'action':
raise SaltCloudSystemExit... | [
"Returns",
"a",
"cluster",
"s",
"ID",
"from",
"the",
"given",
"cluster",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L532-L565 | [
"def",
"get_cluster_id",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The get_cluster_id function must be called with -f or --function.'",
")",
"if",
"kwargs",
"is",
"None... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_datastore_id | Returns a data store's ID from the given data store name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_datastore_id opennebula name=my-datastore-name | salt/cloud/clouds/opennebula.py | def get_datastore_id(kwargs=None, call=None):
'''
Returns a data store's ID from the given data store name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_datastore_id opennebula name=my-datastore-name
'''
if call == 'action':
raise SaltClo... | def get_datastore_id(kwargs=None, call=None):
'''
Returns a data store's ID from the given data store name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_datastore_id opennebula name=my-datastore-name
'''
if call == 'action':
raise SaltClo... | [
"Returns",
"a",
"data",
"store",
"s",
"ID",
"from",
"the",
"given",
"data",
"store",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L568-L601 | [
"def",
"get_datastore_id",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The get_datastore_id function must be called with -f or --function.'",
")",
"if",
"kwargs",
"is",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.