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 | NetapiClient.local | Run :ref:`execution modules <all-salt.modules>` synchronously
See :py:meth:`salt.client.LocalClient.cmd` for all available
parameters.
Sends a command from the master to the targeted minions. This is the
same interface that Salt's own CLI uses. Note the ``arg`` and ``kwarg``
pa... | salt/netapi/__init__.py | def local(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` synchronously
See :py:meth:`salt.client.LocalClient.cmd` for all available
parameters.
Sends a command from the master to the targeted minions. This is the
same interface that Salt's o... | def local(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` synchronously
See :py:meth:`salt.client.LocalClient.cmd` for all available
parameters.
Sends a command from the master to the targeted minions. This is the
same interface that Salt's o... | [
"Run",
":",
"ref",
":",
"execution",
"modules",
"<all",
"-",
"salt",
".",
"modules",
">",
"synchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L94-L109 | [
"def",
"local",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"local",
"=",
"salt",
".",
"client",
".",
"get_local_client",
"(",
"mopts",
"=",
"self",
".",
"opts",
")",
"return",
"local",
".",
"cmd",
"(",
"*",
"args",
",",
"*"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.local_subset | Run :ref:`execution modules <all-salt.modules>` against subsets of minions
.. versionadded:: 2016.3.0
Wraps :py:meth:`salt.client.LocalClient.cmd_subset` | salt/netapi/__init__.py | def local_subset(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` against subsets of minions
.. versionadded:: 2016.3.0
Wraps :py:meth:`salt.client.LocalClient.cmd_subset`
'''
local = salt.client.get_local_client(mopts=self.opts)
retur... | def local_subset(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` against subsets of minions
.. versionadded:: 2016.3.0
Wraps :py:meth:`salt.client.LocalClient.cmd_subset`
'''
local = salt.client.get_local_client(mopts=self.opts)
retur... | [
"Run",
":",
"ref",
":",
"execution",
"modules",
"<all",
"-",
"salt",
".",
"modules",
">",
"against",
"subsets",
"of",
"minions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L111-L120 | [
"def",
"local_subset",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"local",
"=",
"salt",
".",
"client",
".",
"get_local_client",
"(",
"mopts",
"=",
"self",
".",
"opts",
")",
"return",
"local",
".",
"cmd_subset",
"(",
"*",
"args"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.local_batch | Run :ref:`execution modules <all-salt.modules>` against batches of minions
.. versionadded:: 0.8.4
Wraps :py:meth:`salt.client.LocalClient.cmd_batch`
:return: Returns the result from the exeuction module for each batch of
returns | salt/netapi/__init__.py | def local_batch(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` against batches of minions
.. versionadded:: 0.8.4
Wraps :py:meth:`salt.client.LocalClient.cmd_batch`
:return: Returns the result from the exeuction module for each batch of
... | def local_batch(self, *args, **kwargs):
'''
Run :ref:`execution modules <all-salt.modules>` against batches of minions
.. versionadded:: 0.8.4
Wraps :py:meth:`salt.client.LocalClient.cmd_batch`
:return: Returns the result from the exeuction module for each batch of
... | [
"Run",
":",
"ref",
":",
"execution",
"modules",
"<all",
"-",
"salt",
".",
"modules",
">",
"against",
"batches",
"of",
"minions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L122-L134 | [
"def",
"local_batch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"local",
"=",
"salt",
".",
"client",
".",
"get_local_client",
"(",
"mopts",
"=",
"self",
".",
"opts",
")",
"return",
"local",
".",
"cmd_batch",
"(",
"*",
"args",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.ssh | Run salt-ssh commands synchronously
Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`.
:return: Returns the result from the salt-ssh command | salt/netapi/__init__.py | def ssh(self, *args, **kwargs):
'''
Run salt-ssh commands synchronously
Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`.
:return: Returns the result from the salt-ssh command
'''
ssh_client = salt.client.ssh.client.SSHClient(mopts=self.opts,
... | def ssh(self, *args, **kwargs):
'''
Run salt-ssh commands synchronously
Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`.
:return: Returns the result from the salt-ssh command
'''
ssh_client = salt.client.ssh.client.SSHClient(mopts=self.opts,
... | [
"Run",
"salt",
"-",
"ssh",
"commands",
"synchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L136-L146 | [
"def",
"ssh",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ssh_client",
"=",
"salt",
".",
"client",
".",
"ssh",
".",
"client",
".",
"SSHClient",
"(",
"mopts",
"=",
"self",
".",
"opts",
",",
"disable_custom_roster",
"=",
"True",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.runner | Run `runner modules <all-salt.runners>` synchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Returns the result from the runner module | salt/netapi/__init__.py | def runner(self, fun, timeout=None, full_return=False, **kwargs):
'''
Run `runner modules <all-salt.runners>` synchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not suppor... | def runner(self, fun, timeout=None, full_return=False, **kwargs):
'''
Run `runner modules <all-salt.runners>` synchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not suppor... | [
"Run",
"runner",
"modules",
"<all",
"-",
"salt",
".",
"runners",
">",
"synchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L148-L161 | [
"def",
"runner",
"(",
"self",
",",
"fun",
",",
"timeout",
"=",
"None",
",",
"full_return",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'fun'",
"]",
"=",
"fun",
"runner",
"=",
"salt",
".",
"runner",
".",
"RunnerClient",
"(",
"se... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.runner_async | Run `runner modules <all-salt.runners>` asynchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not supported.
:return: event data and a job ID for the executed function. | salt/netapi/__init__.py | def runner_async(self, fun, **kwargs):
'''
Run `runner modules <all-salt.runners>` asynchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not supported.
:return: ev... | def runner_async(self, fun, **kwargs):
'''
Run `runner modules <all-salt.runners>` asynchronously
Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`.
Note that runner functions must be called using keyword arguments.
Positional arguments are not supported.
:return: ev... | [
"Run",
"runner",
"modules",
"<all",
"-",
"salt",
".",
"runners",
">",
"asynchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L163-L176 | [
"def",
"runner_async",
"(",
"self",
",",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'fun'",
"]",
"=",
"fun",
"runner",
"=",
"salt",
".",
"runner",
".",
"RunnerClient",
"(",
"self",
".",
"opts",
")",
"return",
"runner",
".",
"cmd_async"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.wheel | Run :ref:`wheel modules <all-salt.wheel>` synchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Returns the result from the wheel module | salt/netapi/__init__.py | def wheel(self, fun, **kwargs):
'''
Run :ref:`wheel modules <all-salt.wheel>` synchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Returns t... | def wheel(self, fun, **kwargs):
'''
Run :ref:`wheel modules <all-salt.wheel>` synchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Returns t... | [
"Run",
":",
"ref",
":",
"wheel",
"modules",
"<all",
"-",
"salt",
".",
"wheel",
">",
"synchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L178-L191 | [
"def",
"wheel",
"(",
"self",
",",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'fun'",
"]",
"=",
"fun",
"wheel",
"=",
"salt",
".",
"wheel",
".",
"WheelClient",
"(",
"self",
".",
"opts",
")",
"return",
"wheel",
".",
"cmd_sync",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NetapiClient.wheel_async | Run :ref:`wheel modules <all-salt.wheel>` asynchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Returns the result from the wheel module | salt/netapi/__init__.py | def wheel_async(self, fun, **kwargs):
'''
Run :ref:`wheel modules <all-salt.wheel>` asynchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Re... | def wheel_async(self, fun, **kwargs):
'''
Run :ref:`wheel modules <all-salt.wheel>` asynchronously
Wraps :py:meth:`salt.wheel.WheelClient.master_call`.
Note that wheel functions must be called using keyword arguments.
Positional arguments are not supported.
:return: Re... | [
"Run",
":",
"ref",
":",
"wheel",
"modules",
"<all",
"-",
"salt",
".",
"wheel",
">",
"asynchronously"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L193-L206 | [
"def",
"wheel_async",
"(",
"self",
",",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'fun'",
"]",
"=",
"fun",
"wheel",
"=",
"salt",
".",
"wheel",
".",
"WheelClient",
"(",
"self",
".",
"opts",
")",
"return",
"wheel",
".",
"cmd_async",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | find_json | Pass in a raw string and load the json when it starts. This allows for a
string to start with garbage and end with json but be cleanly loaded | salt/utils/json.py | def find_json(raw):
'''
Pass in a raw string and load the json when it starts. This allows for a
string to start with garbage and end with json but be cleanly loaded
'''
ret = {}
lines = __split(raw)
for ind, _ in enumerate(lines):
try:
working = '\n'.join(lines[ind:])
... | def find_json(raw):
'''
Pass in a raw string and load the json when it starts. This allows for a
string to start with garbage and end with json but be cleanly loaded
'''
ret = {}
lines = __split(raw)
for ind, _ in enumerate(lines):
try:
working = '\n'.join(lines[ind:])
... | [
"Pass",
"in",
"a",
"raw",
"string",
"and",
"load",
"the",
"json",
"when",
"it",
"starts",
".",
"This",
"allows",
"for",
"a",
"string",
"to",
"start",
"with",
"garbage",
"and",
"end",
"with",
"json",
"but",
"be",
"cleanly",
"loaded"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L32-L53 | [
"def",
"find_json",
"(",
"raw",
")",
":",
"ret",
"=",
"{",
"}",
"lines",
"=",
"__split",
"(",
"raw",
")",
"for",
"ind",
",",
"_",
"in",
"enumerate",
"(",
"lines",
")",
":",
"try",
":",
"working",
"=",
"'\\n'",
".",
"join",
"(",
"lines",
"[",
"i... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | import_json | Import a json module, starting with the quick ones and going down the list) | salt/utils/json.py | def import_json():
'''
Import a json module, starting with the quick ones and going down the list)
'''
for fast_json in ('ujson', 'yajl', 'json'):
try:
mod = __import__(fast_json)
log.trace('loaded %s json lib', fast_json)
return mod
except ImportError... | def import_json():
'''
Import a json module, starting with the quick ones and going down the list)
'''
for fast_json in ('ujson', 'yajl', 'json'):
try:
mod = __import__(fast_json)
log.trace('loaded %s json lib', fast_json)
return mod
except ImportError... | [
"Import",
"a",
"json",
"module",
"starting",
"with",
"the",
"quick",
"ones",
"and",
"going",
"down",
"the",
"list",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L56-L66 | [
"def",
"import_json",
"(",
")",
":",
"for",
"fast_json",
"in",
"(",
"'ujson'",
",",
"'yajl'",
",",
"'json'",
")",
":",
"try",
":",
"mod",
"=",
"__import__",
"(",
"fast_json",
")",
"log",
".",
"trace",
"(",
"'loaded %s json lib'",
",",
"fast_json",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | loads | .. versionadded:: 2018.3.0
Wraps json.loads and prevents a traceback in the event that a bytestring is
passed to the function. (Python < 3.6 cannot load bytestrings)
You can pass an alternate json module (loaded via import_json() above)
using the _json_module argument) | salt/utils/json.py | def loads(s, **kwargs):
'''
.. versionadded:: 2018.3.0
Wraps json.loads and prevents a traceback in the event that a bytestring is
passed to the function. (Python < 3.6 cannot load bytestrings)
You can pass an alternate json module (loaded via import_json() above)
using the _json_module argume... | def loads(s, **kwargs):
'''
.. versionadded:: 2018.3.0
Wraps json.loads and prevents a traceback in the event that a bytestring is
passed to the function. (Python < 3.6 cannot load bytestrings)
You can pass an alternate json module (loaded via import_json() above)
using the _json_module argume... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L81-L99 | [
"def",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
":",
"json_module",
"=",
"kwargs",
".",
"pop",
"(",
"'_json_module'",
",",
"json",
")",
"try",
":",
"return",
"json_module",
".",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
"except",
"Ty... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | dump | .. versionadded:: 2018.3.0
Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly
passed as True) for unicode compatibility. Note that setting it to True
will mess up any unicode characters, as they will be dumped as the string
literal version of the unicode code point.
On Pyth... | salt/utils/json.py | def dump(obj, fp, **kwargs):
'''
.. versionadded:: 2018.3.0
Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly
passed as True) for unicode compatibility. Note that setting it to True
will mess up any unicode characters, as they will be dumped as the string
literal versio... | def dump(obj, fp, **kwargs):
'''
.. versionadded:: 2018.3.0
Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly
passed as True) for unicode compatibility. Note that setting it to True
will mess up any unicode characters, as they will be dumped as the string
literal versio... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L102-L128 | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"*",
"*",
"kwargs",
")",
":",
"json_module",
"=",
"kwargs",
".",
"pop",
"(",
"'_json_module'",
",",
"json",
")",
"orig_enc_func",
"=",
"kwargs",
".",
"pop",
"(",
"'default'",
",",
"lambda",
"x",
":",
"x",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _user_mdata | User Metadata | salt/grains/mdata.py | def _user_mdata(mdata_list=None, mdata_get=None):
'''
User Metadata
'''
grains = {}
if not mdata_list:
mdata_list = salt.utils.path.which('mdata-list')
if not mdata_get:
mdata_get = salt.utils.path.which('mdata-get')
if not mdata_list or not mdata_get:
return grain... | def _user_mdata(mdata_list=None, mdata_get=None):
'''
User Metadata
'''
grains = {}
if not mdata_list:
mdata_list = salt.utils.path.which('mdata-list')
if not mdata_get:
mdata_get = salt.utils.path.which('mdata-get')
if not mdata_list or not mdata_get:
return grain... | [
"User",
"Metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L50-L77 | [
"def",
"_user_mdata",
"(",
"mdata_list",
"=",
"None",
",",
"mdata_get",
"=",
"None",
")",
":",
"grains",
"=",
"{",
"}",
"if",
"not",
"mdata_list",
":",
"mdata_list",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'mdata-list'",
")",
"if",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _sdc_mdata | SDC Metadata specified by there specs
https://eng.joyent.com/mdata/datadict.html | salt/grains/mdata.py | def _sdc_mdata(mdata_list=None, mdata_get=None):
'''
SDC Metadata specified by there specs
https://eng.joyent.com/mdata/datadict.html
'''
grains = {}
sdc_text_keys = [
'uuid',
'server_uuid',
'datacenter_name',
'hostname',
'dns_domain',
]
sdc_json_k... | def _sdc_mdata(mdata_list=None, mdata_get=None):
'''
SDC Metadata specified by there specs
https://eng.joyent.com/mdata/datadict.html
'''
grains = {}
sdc_text_keys = [
'uuid',
'server_uuid',
'datacenter_name',
'hostname',
'dns_domain',
]
sdc_json_k... | [
"SDC",
"Metadata",
"specified",
"by",
"there",
"specs",
"https",
":",
"//",
"eng",
".",
"joyent",
".",
"com",
"/",
"mdata",
"/",
"datadict",
".",
"html"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L80-L125 | [
"def",
"_sdc_mdata",
"(",
"mdata_list",
"=",
"None",
",",
"mdata_get",
"=",
"None",
")",
":",
"grains",
"=",
"{",
"}",
"sdc_text_keys",
"=",
"[",
"'uuid'",
",",
"'server_uuid'",
",",
"'datacenter_name'",
",",
"'hostname'",
",",
"'dns_domain'",
",",
"]",
"s... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _legacy_grains | Grains for backwards compatibility
Remove this function in Neon | salt/grains/mdata.py | def _legacy_grains(grains):
'''
Grains for backwards compatibility
Remove this function in Neon
'''
# parse legacy sdc grains
if 'mdata' in grains and 'sdc' in grains['mdata']:
if 'server_uuid' not in grains['mdata']['sdc'] or 'FAILURE' in grains['mdata']['sdc']['server_uuid']:
... | def _legacy_grains(grains):
'''
Grains for backwards compatibility
Remove this function in Neon
'''
# parse legacy sdc grains
if 'mdata' in grains and 'sdc' in grains['mdata']:
if 'server_uuid' not in grains['mdata']['sdc'] or 'FAILURE' in grains['mdata']['sdc']['server_uuid']:
... | [
"Grains",
"for",
"backwards",
"compatibility",
"Remove",
"this",
"function",
"in",
"Neon"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L128-L149 | [
"def",
"_legacy_grains",
"(",
"grains",
")",
":",
"# parse legacy sdc grains",
"if",
"'mdata'",
"in",
"grains",
"and",
"'sdc'",
"in",
"grains",
"[",
"'mdata'",
"]",
":",
"if",
"'server_uuid'",
"not",
"in",
"grains",
"[",
"'mdata'",
"]",
"[",
"'sdc'",
"]",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mdata | Provide grains from the SmartOS metadata | salt/grains/mdata.py | def mdata():
'''
Provide grains from the SmartOS metadata
'''
grains = {}
mdata_list = salt.utils.path.which('mdata-list')
mdata_get = salt.utils.path.which('mdata-get')
grains = salt.utils.dictupdate.update(grains, _user_mdata(mdata_list, mdata_get), merge_lists=True)
grains = salt.uti... | def mdata():
'''
Provide grains from the SmartOS metadata
'''
grains = {}
mdata_list = salt.utils.path.which('mdata-list')
mdata_get = salt.utils.path.which('mdata-get')
grains = salt.utils.dictupdate.update(grains, _user_mdata(mdata_list, mdata_get), merge_lists=True)
grains = salt.uti... | [
"Provide",
"grains",
"from",
"the",
"SmartOS",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L152-L165 | [
"def",
"mdata",
"(",
")",
":",
"grains",
"=",
"{",
"}",
"mdata_list",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'mdata-list'",
")",
"mdata_get",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'mdata-get'",
")",
"grains"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | xdg_config_dir | Check xdg locations for config files | salt/utils/xdg.py | def xdg_config_dir():
'''
Check xdg locations for config files
'''
xdg_config = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
xdg_config_directory = os.path.join(xdg_config, 'salt')
return xdg_config_directory | def xdg_config_dir():
'''
Check xdg locations for config files
'''
xdg_config = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
xdg_config_directory = os.path.join(xdg_config, 'salt')
return xdg_config_directory | [
"Check",
"xdg",
"locations",
"for",
"config",
"files"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/xdg.py#L9-L15 | [
"def",
"xdg_config_dir",
"(",
")",
":",
"xdg_config",
"=",
"os",
".",
"getenv",
"(",
"'XDG_CONFIG_HOME'",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.config'",
")",
")",
"xdg_config_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"xdg_config... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | topic_present | Ensure the SNS topic exists.
name
Name of the SNS topic.
subscriptions
List of SNS subscriptions.
Each subscription is a dictionary with a protocol and endpoint key:
.. code-block:: yaml
subscriptions:
- Protocol: https
Endpoint: https:/... | salt/states/boto3_sns.py | def topic_present(name, subscriptions=None, attributes=None,
region=None, key=None, keyid=None, profile=None):
'''
Ensure the SNS topic exists.
name
Name of the SNS topic.
subscriptions
List of SNS subscriptions.
Each subscription is a dictionary with a proto... | def topic_present(name, subscriptions=None, attributes=None,
region=None, key=None, keyid=None, profile=None):
'''
Ensure the SNS topic exists.
name
Name of the SNS topic.
subscriptions
List of SNS subscriptions.
Each subscription is a dictionary with a proto... | [
"Ensure",
"the",
"SNS",
"topic",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto3_sns.py#L75-L237 | [
"def",
"topic_present",
"(",
"name",
",",
"subscriptions",
"=",
"None",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | topic_absent | Ensure the named sns topic is deleted.
name
Name of the SNS topic.
unsubscribe
If True, unsubscribe all subcriptions to the SNS topic before
deleting the SNS topic
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used... | salt/states/boto3_sns.py | def topic_absent(name, unsubscribe=False, region=None, key=None, keyid=None, profile=None):
'''
Ensure the named sns topic is deleted.
name
Name of the SNS topic.
unsubscribe
If True, unsubscribe all subcriptions to the SNS topic before
deleting the SNS topic
region
... | def topic_absent(name, unsubscribe=False, region=None, key=None, keyid=None, profile=None):
'''
Ensure the named sns topic is deleted.
name
Name of the SNS topic.
unsubscribe
If True, unsubscribe all subcriptions to the SNS topic before
deleting the SNS topic
region
... | [
"Ensure",
"the",
"named",
"sns",
"topic",
"is",
"deleted",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto3_sns.py#L314-L386 | [
"def",
"topic_absent",
"(",
"name",
",",
"unsubscribe",
"=",
"False",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | start | Start the saltnado! | salt/netapi/rest_tornado/__init__.py | def start():
'''
Start the saltnado!
'''
mod_opts = __opts__.get(__virtualname__, {})
if 'num_processes' not in mod_opts:
mod_opts['num_processes'] = 1
if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True:
raise Exception((
'Tornado\'s debug imp... | def start():
'''
Start the saltnado!
'''
mod_opts = __opts__.get(__virtualname__, {})
if 'num_processes' not in mod_opts:
mod_opts['num_processes'] = 1
if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True:
raise Exception((
'Tornado\'s debug imp... | [
"Start",
"the",
"saltnado!"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/__init__.py#L87-L133 | [
"def",
"start",
"(",
")",
":",
"mod_opts",
"=",
"__opts__",
".",
"get",
"(",
"__virtualname__",
",",
"{",
"}",
")",
"if",
"'num_processes'",
"not",
"in",
"mod_opts",
":",
"mod_opts",
"[",
"'num_processes'",
"]",
"=",
"1",
"if",
"mod_opts",
"[",
"'num_pro... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_user | Checks if the named user and group are present on the minion | salt/states/file.py | def _check_user(user, group):
'''
Checks if the named user and group are present on the minion
'''
err = ''
if user:
uid = __salt__['file.user_to_uid'](user)
if uid == '':
err += 'User {0} is not available '.format(user)
if group:
gid = __salt__['file.group_to... | def _check_user(user, group):
'''
Checks if the named user and group are present on the minion
'''
err = ''
if user:
uid = __salt__['file.user_to_uid'](user)
if uid == '':
err += 'User {0} is not available '.format(user)
if group:
gid = __salt__['file.group_to... | [
"Checks",
"if",
"the",
"named",
"user",
"and",
"group",
"are",
"present",
"on",
"the",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L380-L393 | [
"def",
"_check_user",
"(",
"user",
",",
"group",
")",
":",
"err",
"=",
"''",
"if",
"user",
":",
"uid",
"=",
"__salt__",
"[",
"'file.user_to_uid'",
"]",
"(",
"user",
")",
"if",
"uid",
"==",
"''",
":",
"err",
"+=",
"'User {0} is not available '",
".",
"f... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _is_valid_relpath | Performs basic sanity checks on a relative path.
Requires POSIX-compatible paths (i.e. the kind obtained through
cp.list_master or other such calls).
Ensures that the path does not contain directory transversal, and
that it does not exceed a stated maximum depth (if specified). | salt/states/file.py | def _is_valid_relpath(
relpath,
maxdepth=None):
'''
Performs basic sanity checks on a relative path.
Requires POSIX-compatible paths (i.e. the kind obtained through
cp.list_master or other such calls).
Ensures that the path does not contain directory transversal, and
that it do... | def _is_valid_relpath(
relpath,
maxdepth=None):
'''
Performs basic sanity checks on a relative path.
Requires POSIX-compatible paths (i.e. the kind obtained through
cp.list_master or other such calls).
Ensures that the path does not contain directory transversal, and
that it do... | [
"Performs",
"basic",
"sanity",
"checks",
"on",
"a",
"relative",
"path",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L396-L420 | [
"def",
"_is_valid_relpath",
"(",
"relpath",
",",
"maxdepth",
"=",
"None",
")",
":",
"# Check relpath surrounded by slashes, so that `..` can be caught as",
"# a path component at the start, end, and in the middle of the path.",
"sep",
",",
"pardir",
"=",
"posixpath",
".",
"sep",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _salt_to_os_path | Converts a path from the form received via salt master to the OS's native
path format. | salt/states/file.py | def _salt_to_os_path(path):
'''
Converts a path from the form received via salt master to the OS's native
path format.
'''
return os.path.normpath(path.replace(posixpath.sep, os.path.sep)) | def _salt_to_os_path(path):
'''
Converts a path from the form received via salt master to the OS's native
path format.
'''
return os.path.normpath(path.replace(posixpath.sep, os.path.sep)) | [
"Converts",
"a",
"path",
"from",
"the",
"form",
"received",
"via",
"salt",
"master",
"to",
"the",
"OS",
"s",
"native",
"path",
"format",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L423-L428 | [
"def",
"_salt_to_os_path",
"(",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
".",
"replace",
"(",
"posixpath",
".",
"sep",
",",
"os",
".",
"path",
".",
"sep",
")",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _gen_recurse_managed_files | Generate the list of files managed by a recurse state | salt/states/file.py | def _gen_recurse_managed_files(
name,
source,
keep_symlinks=False,
include_pat=None,
exclude_pat=None,
maxdepth=None,
include_empty=False,
**kwargs):
'''
Generate the list of files managed by a recurse state
'''
# Convert a relative path g... | def _gen_recurse_managed_files(
name,
source,
keep_symlinks=False,
include_pat=None,
exclude_pat=None,
maxdepth=None,
include_empty=False,
**kwargs):
'''
Generate the list of files managed by a recurse state
'''
# Convert a relative path g... | [
"Generate",
"the",
"list",
"of",
"files",
"managed",
"by",
"a",
"recurse",
"state"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L431-L556 | [
"def",
"_gen_recurse_managed_files",
"(",
"name",
",",
"source",
",",
"keep_symlinks",
"=",
"False",
",",
"include_pat",
"=",
"None",
",",
"exclude_pat",
"=",
"None",
",",
"maxdepth",
"=",
"None",
",",
"include_empty",
"=",
"False",
",",
"*",
"*",
"kwargs",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _gen_keep_files | Generate the list of files that need to be kept when a dir based function
like directory or recurse has a clean. | salt/states/file.py | def _gen_keep_files(name, require, walk_d=None):
'''
Generate the list of files that need to be kept when a dir based function
like directory or recurse has a clean.
'''
def _is_child(path, directory):
'''
Check whether ``path`` is child of ``directory``
'''
path = os... | def _gen_keep_files(name, require, walk_d=None):
'''
Generate the list of files that need to be kept when a dir based function
like directory or recurse has a clean.
'''
def _is_child(path, directory):
'''
Check whether ``path`` is child of ``directory``
'''
path = os... | [
"Generate",
"the",
"list",
"of",
"files",
"that",
"need",
"to",
"be",
"kept",
"when",
"a",
"dir",
"based",
"function",
"like",
"directory",
"or",
"recurse",
"has",
"a",
"clean",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L559-L631 | [
"def",
"_gen_keep_files",
"(",
"name",
",",
"require",
",",
"walk_d",
"=",
"None",
")",
":",
"def",
"_is_child",
"(",
"path",
",",
"directory",
")",
":",
"'''\n Check whether ``path`` is child of ``directory``\n '''",
"path",
"=",
"os",
".",
"path",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _find_keep_files | Compile a list of valid keep files (and directories).
Used by _clean_dir() | salt/states/file.py | def _find_keep_files(root, keep):
'''
Compile a list of valid keep files (and directories).
Used by _clean_dir()
'''
real_keep = set()
real_keep.add(root)
if isinstance(keep, list):
for fn_ in keep:
if not os.path.isabs(fn_):
continue
fn_ = os.... | def _find_keep_files(root, keep):
'''
Compile a list of valid keep files (and directories).
Used by _clean_dir()
'''
real_keep = set()
real_keep.add(root)
if isinstance(keep, list):
for fn_ in keep:
if not os.path.isabs(fn_):
continue
fn_ = os.... | [
"Compile",
"a",
"list",
"of",
"valid",
"keep",
"files",
"(",
"and",
"directories",
")",
".",
"Used",
"by",
"_clean_dir",
"()"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L648-L667 | [
"def",
"_find_keep_files",
"(",
"root",
",",
"keep",
")",
":",
"real_keep",
"=",
"set",
"(",
")",
"real_keep",
".",
"add",
"(",
"root",
")",
"if",
"isinstance",
"(",
"keep",
",",
"list",
")",
":",
"for",
"fn_",
"in",
"keep",
":",
"if",
"not",
"os",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _clean_dir | Clean out all of the files and directories in a directory (root) while
preserving the files in a list (keep) and part of exclude_pat | salt/states/file.py | def _clean_dir(root, keep, exclude_pat):
'''
Clean out all of the files and directories in a directory (root) while
preserving the files in a list (keep) and part of exclude_pat
'''
root = os.path.normcase(root)
real_keep = _find_keep_files(root, keep)
removed = set()
def _delete_not_ke... | def _clean_dir(root, keep, exclude_pat):
'''
Clean out all of the files and directories in a directory (root) while
preserving the files in a list (keep) and part of exclude_pat
'''
root = os.path.normcase(root)
real_keep = _find_keep_files(root, keep)
removed = set()
def _delete_not_ke... | [
"Clean",
"out",
"all",
"of",
"the",
"files",
"and",
"directories",
"in",
"a",
"directory",
"(",
"root",
")",
"while",
"preserving",
"the",
"files",
"in",
"a",
"list",
"(",
"keep",
")",
"and",
"part",
"of",
"exclude_pat"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L670-L696 | [
"def",
"_clean_dir",
"(",
"root",
",",
"keep",
",",
"exclude_pat",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"normcase",
"(",
"root",
")",
"real_keep",
"=",
"_find_keep_files",
"(",
"root",
",",
"keep",
")",
"removed",
"=",
"set",
"(",
")",
"def... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_directory | Check what changes need to be made on a directory | salt/states/file.py | def _check_directory(name,
user=None,
group=None,
recurse=False,
mode=None,
file_mode=None,
clean=False,
require=False,
exclude_pat=None,
... | def _check_directory(name,
user=None,
group=None,
recurse=False,
mode=None,
file_mode=None,
clean=False,
require=False,
exclude_pat=None,
... | [
"Check",
"what",
"changes",
"need",
"to",
"be",
"made",
"on",
"a",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L705-L803 | [
"def",
"_check_directory",
"(",
"name",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"recurse",
"=",
"False",
",",
"mode",
"=",
"None",
",",
"file_mode",
"=",
"None",
",",
"clean",
"=",
"False",
",",
"require",
"=",
"False",
",",
"exclud... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_directory_win | Check what changes need to be made on a directory | salt/states/file.py | def _check_directory_win(name,
win_owner=None,
win_perms=None,
win_deny_perms=None,
win_inheritance=None,
win_perms_reset=None):
'''
Check what changes need to be made on a directory
... | def _check_directory_win(name,
win_owner=None,
win_perms=None,
win_deny_perms=None,
win_inheritance=None,
win_perms_reset=None):
'''
Check what changes need to be made on a directory
... | [
"Check",
"what",
"changes",
"need",
"to",
"be",
"made",
"on",
"a",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L806-L949 | [
"def",
"_check_directory_win",
"(",
"name",
",",
"win_owner",
"=",
"None",
",",
"win_perms",
"=",
"None",
",",
"win_deny_perms",
"=",
"None",
",",
"win_inheritance",
"=",
"None",
",",
"win_perms_reset",
"=",
"None",
")",
":",
"changes",
"=",
"{",
"}",
"if"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_dir_meta | Check the changes in directory metadata | salt/states/file.py | def _check_dir_meta(name,
user,
group,
mode,
follow_symlinks=False):
'''
Check the changes in directory metadata
'''
try:
stats = __salt__['file.stats'](name, None, follow_symlinks)
except CommandExecutionError:
... | def _check_dir_meta(name,
user,
group,
mode,
follow_symlinks=False):
'''
Check the changes in directory metadata
'''
try:
stats = __salt__['file.stats'](name, None, follow_symlinks)
except CommandExecutionError:
... | [
"Check",
"the",
"changes",
"in",
"directory",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L952-L982 | [
"def",
"_check_dir_meta",
"(",
"name",
",",
"user",
",",
"group",
",",
"mode",
",",
"follow_symlinks",
"=",
"False",
")",
":",
"try",
":",
"stats",
"=",
"__salt__",
"[",
"'file.stats'",
"]",
"(",
"name",
",",
"None",
",",
"follow_symlinks",
")",
"except"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_touch | Check to see if a file needs to be updated or created | salt/states/file.py | def _check_touch(name, atime, mtime):
'''
Check to see if a file needs to be updated or created
'''
ret = {
'result': None,
'comment': '',
'changes': {'new': name},
}
if not os.path.exists(name):
ret['comment'] = 'File {0} is set to be created'.format(name)
el... | def _check_touch(name, atime, mtime):
'''
Check to see if a file needs to be updated or created
'''
ret = {
'result': None,
'comment': '',
'changes': {'new': name},
}
if not os.path.exists(name):
ret['comment'] = 'File {0} is set to be created'.format(name)
el... | [
"Check",
"to",
"see",
"if",
"a",
"file",
"needs",
"to",
"be",
"updated",
"or",
"created"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L985-L1007 | [
"def",
"_check_touch",
"(",
"name",
",",
"atime",
",",
"mtime",
")",
":",
"ret",
"=",
"{",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"'new'",
":",
"name",
"}",
",",
"}",
"if",
"not",
"os",
".",
"path",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_symlink_ownership | Check if the symlink ownership matches the specified user and group | salt/states/file.py | def _check_symlink_ownership(path, user, group, win_owner):
'''
Check if the symlink ownership matches the specified user and group
'''
cur_user, cur_group = _get_symlink_ownership(path)
if salt.utils.platform.is_windows():
return win_owner == cur_user
else:
return (cur_user == u... | def _check_symlink_ownership(path, user, group, win_owner):
'''
Check if the symlink ownership matches the specified user and group
'''
cur_user, cur_group = _get_symlink_ownership(path)
if salt.utils.platform.is_windows():
return win_owner == cur_user
else:
return (cur_user == u... | [
"Check",
"if",
"the",
"symlink",
"ownership",
"matches",
"the",
"specified",
"user",
"and",
"group"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1021-L1029 | [
"def",
"_check_symlink_ownership",
"(",
"path",
",",
"user",
",",
"group",
",",
"win_owner",
")",
":",
"cur_user",
",",
"cur_group",
"=",
"_get_symlink_ownership",
"(",
"path",
")",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _set_symlink_ownership | Set the ownership of a symlink and return a boolean indicating
success/failure | salt/states/file.py | def _set_symlink_ownership(path, user, group, win_owner):
'''
Set the ownership of a symlink and return a boolean indicating
success/failure
'''
if salt.utils.platform.is_windows():
try:
salt.utils.win_dacl.set_owner(path, win_owner)
except CommandExecutionError:
... | def _set_symlink_ownership(path, user, group, win_owner):
'''
Set the ownership of a symlink and return a boolean indicating
success/failure
'''
if salt.utils.platform.is_windows():
try:
salt.utils.win_dacl.set_owner(path, win_owner)
except CommandExecutionError:
... | [
"Set",
"the",
"ownership",
"of",
"a",
"symlink",
"and",
"return",
"a",
"boolean",
"indicating",
"success",
"/",
"failure"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1032-L1047 | [
"def",
"_set_symlink_ownership",
"(",
"path",
",",
"user",
",",
"group",
",",
"win_owner",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"try",
":",
"salt",
".",
"utils",
".",
"win_dacl",
".",
"set_owner",
"("... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _symlink_check | Check the symlink function | salt/states/file.py | def _symlink_check(name, target, force, user, group, win_owner):
'''
Check the symlink function
'''
changes = {}
if not os.path.exists(name) and not __salt__['file.is_link'](name):
changes['new'] = name
return None, 'Symlink {0} to {1} is set for creation'.format(
name, t... | def _symlink_check(name, target, force, user, group, win_owner):
'''
Check the symlink function
'''
changes = {}
if not os.path.exists(name) and not __salt__['file.is_link'](name):
changes['new'] = name
return None, 'Symlink {0} to {1} is set for creation'.format(
name, t... | [
"Check",
"the",
"symlink",
"function"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1050-L1083 | [
"def",
"_symlink_check",
"(",
"name",
",",
"target",
",",
"force",
",",
"user",
",",
"group",
",",
"win_owner",
")",
":",
"changes",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"name",
")",
"and",
"not",
"__salt__",
"[",
"'fi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _unify_sources_and_hashes | Silly little function to give us a standard tuple list for sources and
source_hashes | salt/states/file.py | def _unify_sources_and_hashes(source=None, source_hash=None,
sources=None, source_hashes=None):
'''
Silly little function to give us a standard tuple list for sources and
source_hashes
'''
if sources is None:
sources = []
if source_hashes is None:
s... | def _unify_sources_and_hashes(source=None, source_hash=None,
sources=None, source_hashes=None):
'''
Silly little function to give us a standard tuple list for sources and
source_hashes
'''
if sources is None:
sources = []
if source_hashes is None:
s... | [
"Silly",
"little",
"function",
"to",
"give",
"us",
"a",
"standard",
"tuple",
"list",
"for",
"sources",
"and",
"source_hashes"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1104-L1128 | [
"def",
"_unify_sources_and_hashes",
"(",
"source",
"=",
"None",
",",
"source_hash",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"source_hashes",
"=",
"None",
")",
":",
"if",
"sources",
"is",
"None",
":",
"sources",
"=",
"[",
"]",
"if",
"source_hashes",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_template_texts | Iterate a list of sources and process them as templates.
Returns a list of 'chunks' containing the rendered templates. | salt/states/file.py | def _get_template_texts(source_list=None,
template='jinja',
defaults=None,
context=None,
**kwargs):
'''
Iterate a list of sources and process them as templates.
Returns a list of 'chunks' containing the rendered ... | def _get_template_texts(source_list=None,
template='jinja',
defaults=None,
context=None,
**kwargs):
'''
Iterate a list of sources and process them as templates.
Returns a list of 'chunks' containing the rendered ... | [
"Iterate",
"a",
"list",
"of",
"sources",
"and",
"process",
"them",
"as",
"templates",
".",
"Returns",
"a",
"list",
"of",
"chunks",
"containing",
"the",
"rendered",
"templates",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1131-L1189 | [
"def",
"_get_template_texts",
"(",
"source_list",
"=",
"None",
",",
"template",
"=",
"'jinja'",
",",
"defaults",
"=",
"None",
",",
"context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"'_get_template_texts'",
",",
"'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _validate_str_list | ensure ``arg`` is a list of strings | salt/states/file.py | def _validate_str_list(arg):
'''
ensure ``arg`` is a list of strings
'''
if isinstance(arg, six.binary_type):
ret = [salt.utils.stringutils.to_unicode(arg)]
elif isinstance(arg, six.string_types):
ret = [arg]
elif isinstance(arg, Iterable) and not isinstance(arg, Mapping):
... | def _validate_str_list(arg):
'''
ensure ``arg`` is a list of strings
'''
if isinstance(arg, six.binary_type):
ret = [salt.utils.stringutils.to_unicode(arg)]
elif isinstance(arg, six.string_types):
ret = [arg]
elif isinstance(arg, Iterable) and not isinstance(arg, Mapping):
... | [
"ensure",
"arg",
"is",
"a",
"list",
"of",
"strings"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1192-L1209 | [
"def",
"_validate_str_list",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"six",
".",
"binary_type",
")",
":",
"ret",
"=",
"[",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
"arg",
")",
"]",
"elif",
"isinstance",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _set_shortcut_ownership | Set the ownership of a shortcut and return a boolean indicating
success/failure | salt/states/file.py | def _set_shortcut_ownership(path, user):
'''
Set the ownership of a shortcut and return a boolean indicating
success/failure
'''
try:
__salt__['file.lchown'](path, user)
except OSError:
pass
return _check_shortcut_ownership(path, user) | def _set_shortcut_ownership(path, user):
'''
Set the ownership of a shortcut and return a boolean indicating
success/failure
'''
try:
__salt__['file.lchown'](path, user)
except OSError:
pass
return _check_shortcut_ownership(path, user) | [
"Set",
"the",
"ownership",
"of",
"a",
"shortcut",
"and",
"return",
"a",
"boolean",
"indicating",
"success",
"/",
"failure"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1224-L1233 | [
"def",
"_set_shortcut_ownership",
"(",
"path",
",",
"user",
")",
":",
"try",
":",
"__salt__",
"[",
"'file.lchown'",
"]",
"(",
"path",
",",
"user",
")",
"except",
"OSError",
":",
"pass",
"return",
"_check_shortcut_ownership",
"(",
"path",
",",
"user",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _shortcut_check | Check the shortcut function | salt/states/file.py | def _shortcut_check(name,
target,
arguments,
working_dir,
description,
icon_location,
force,
user):
'''
Check the shortcut function
'''
changes = {}
if not os.p... | def _shortcut_check(name,
target,
arguments,
working_dir,
description,
icon_location,
force,
user):
'''
Check the shortcut function
'''
changes = {}
if not os.p... | [
"Check",
"the",
"shortcut",
"function"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1236-L1294 | [
"def",
"_shortcut_check",
"(",
"name",
",",
"target",
",",
"arguments",
",",
"working_dir",
",",
"description",
",",
"icon_location",
",",
"force",
",",
"user",
")",
":",
"changes",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"na... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _makedirs | Helper function for creating directories when the ``makedirs`` option is set
to ``True``. Handles Unix and Windows based systems
.. versionadded:: 2017.7.8
Args:
name (str): The directory path to create
user (str): The linux user to own the directory
group (str): The linux group to... | salt/states/file.py | def _makedirs(name,
user=None,
group=None,
dir_mode=None,
win_owner=None,
win_perms=None,
win_deny_perms=None,
win_inheritance=None):
'''
Helper function for creating directories when the ``makedirs`` option is set... | def _makedirs(name,
user=None,
group=None,
dir_mode=None,
win_owner=None,
win_perms=None,
win_deny_perms=None,
win_inheritance=None):
'''
Helper function for creating directories when the ``makedirs`` option is set... | [
"Helper",
"function",
"for",
"creating",
"directories",
"when",
"the",
"makedirs",
"option",
"is",
"set",
"to",
"True",
".",
"Handles",
"Unix",
"and",
"Windows",
"based",
"systems"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1297-L1345 | [
"def",
"_makedirs",
"(",
"name",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"dir_mode",
"=",
"None",
",",
"win_owner",
"=",
"None",
",",
"win_perms",
"=",
"None",
",",
"win_deny_perms",
"=",
"None",
",",
"win_inheritance",
"=",
"None",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | symlink | Create a symbolic link (symlink, soft link)
If the file already exists and is a symlink pointing to any location other
than the specified target, the symlink will be replaced. If the symlink is
a regular file or directory then the state will return False. If the
regular file or directory is desired to ... | salt/states/file.py | def symlink(
name,
target,
force=False,
backupname=None,
makedirs=False,
user=None,
group=None,
copy_target_user=False,
copy_target_group=False,
mode=None,
win_owner=None,
win_perms=None,
win_deny_perms=None,
... | def symlink(
name,
target,
force=False,
backupname=None,
makedirs=False,
user=None,
group=None,
copy_target_user=False,
copy_target_group=False,
mode=None,
win_owner=None,
win_perms=None,
win_deny_perms=None,
... | [
"Create",
"a",
"symbolic",
"link",
"(",
"symlink",
"soft",
"link",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1348-L1714 | [
"def",
"symlink",
"(",
"name",
",",
"target",
",",
"force",
"=",
"False",
",",
"backupname",
"=",
"None",
",",
"makedirs",
"=",
"False",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"copy_target_user",
"=",
"False",
",",
"copy_target_group",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Make sure that the named file or directory is absent. If it exists, it will
be deleted. This will work to reverse any of the functions in the file
state module. If a directory is supplied, it will be recursively deleted.
name
The path which should be deleted | salt/states/file.py | def absent(name,
**kwargs):
'''
Make sure that the named file or directory is absent. If it exists, it will
be deleted. This will work to reverse any of the functions in the file
state module. If a directory is supplied, it will be recursively deleted.
name
The path which should ... | def absent(name,
**kwargs):
'''
Make sure that the named file or directory is absent. If it exists, it will
be deleted. This will work to reverse any of the functions in the file
state module. If a directory is supplied, it will be recursively deleted.
name
The path which should ... | [
"Make",
"sure",
"that",
"the",
"named",
"file",
"or",
"directory",
"is",
"absent",
".",
"If",
"it",
"exists",
"it",
"will",
"be",
"deleted",
".",
"This",
"will",
"work",
"to",
"reverse",
"any",
"of",
"the",
"functions",
"in",
"the",
"file",
"state",
"m... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1717-L1770 | [
"def",
"absent",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | tidied | Remove unwanted files based on specific criteria. Multiple criteria
are OR’d together, so a file that is too large but is not old enough
will still get tidied.
If neither age nor size is given all files which match a pattern in
matches will be removed.
name
The directory tree that should b... | salt/states/file.py | def tidied(name,
age=0,
matches=None,
rmdirs=False,
size=0,
**kwargs):
'''
Remove unwanted files based on specific criteria. Multiple criteria
are OR’d together, so a file that is too large but is not old enough
will still get tidied.
If neithe... | def tidied(name,
age=0,
matches=None,
rmdirs=False,
size=0,
**kwargs):
'''
Remove unwanted files based on specific criteria. Multiple criteria
are OR’d together, so a file that is too large but is not old enough
will still get tidied.
If neithe... | [
"Remove",
"unwanted",
"files",
"based",
"on",
"specific",
"criteria",
".",
"Multiple",
"criteria",
"are",
"OR’d",
"together",
"so",
"a",
"file",
"that",
"is",
"too",
"large",
"but",
"is",
"not",
"old",
"enough",
"will",
"still",
"get",
"tidied",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1773-L1889 | [
"def",
"tidied",
"(",
"name",
",",
"age",
"=",
"0",
",",
"matches",
"=",
"None",
",",
"rmdirs",
"=",
"False",
",",
"size",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | exists | Verify that the named file or directory is present or exists.
Ensures pre-requisites outside of Salt's purview
(e.g., keytabs, private keys, etc.) have been previously satisfied before
deployment.
This function does not create the file if it doesn't exist, it will return
an error.
name
... | salt/states/file.py | def exists(name,
**kwargs):
'''
Verify that the named file or directory is present or exists.
Ensures pre-requisites outside of Salt's purview
(e.g., keytabs, private keys, etc.) have been previously satisfied before
deployment.
This function does not create the file if it doesn't ex... | def exists(name,
**kwargs):
'''
Verify that the named file or directory is present or exists.
Ensures pre-requisites outside of Salt's purview
(e.g., keytabs, private keys, etc.) have been previously satisfied before
deployment.
This function does not create the file if it doesn't ex... | [
"Verify",
"that",
"the",
"named",
"file",
"or",
"directory",
"is",
"present",
"or",
"exists",
".",
"Ensures",
"pre",
"-",
"requisites",
"outside",
"of",
"Salt",
"s",
"purview",
"(",
"e",
".",
"g",
".",
"keytabs",
"private",
"keys",
"etc",
".",
")",
"ha... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1892-L1918 | [
"def",
"exists",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | managed | r'''
Manage a given file, this function allows for a file to be downloaded from
the salt master and potentially run through a templating system.
name
The location of the file to manage, as an absolute path.
source
The source file to download to the minion, this source file can be
... | salt/states/file.py | def managed(name,
source=None,
source_hash='',
source_hash_name=None,
keep_source=True,
user=None,
group=None,
mode=None,
attrs=None,
template=None,
makedirs=False,
dir_mode=None,
... | def managed(name,
source=None,
source_hash='',
source_hash_name=None,
keep_source=True,
user=None,
group=None,
mode=None,
attrs=None,
template=None,
makedirs=False,
dir_mode=None,
... | [
"r",
"Manage",
"a",
"given",
"file",
"this",
"function",
"allows",
"for",
"a",
"file",
"to",
"be",
"downloaded",
"from",
"the",
"salt",
"master",
"and",
"potentially",
"run",
"through",
"a",
"templating",
"system",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1945-L3062 | [
"def",
"managed",
"(",
"name",
",",
"source",
"=",
"None",
",",
"source_hash",
"=",
"''",
",",
"source_hash_name",
"=",
"None",
",",
"keep_source",
"=",
"True",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"attr... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_recurse_set | Converse *recurse* definition to a set of strings.
Raises TypeError or ValueError when *recurse* has wrong structure. | salt/states/file.py | def _get_recurse_set(recurse):
'''
Converse *recurse* definition to a set of strings.
Raises TypeError or ValueError when *recurse* has wrong structure.
'''
if not recurse:
return set()
if not isinstance(recurse, list):
raise TypeError('"recurse" must be formed as a list of stri... | def _get_recurse_set(recurse):
'''
Converse *recurse* definition to a set of strings.
Raises TypeError or ValueError when *recurse* has wrong structure.
'''
if not recurse:
return set()
if not isinstance(recurse, list):
raise TypeError('"recurse" must be formed as a list of stri... | [
"Converse",
"*",
"recurse",
"*",
"definition",
"to",
"a",
"set",
"of",
"strings",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3068-L3088 | [
"def",
"_get_recurse_set",
"(",
"recurse",
")",
":",
"if",
"not",
"recurse",
":",
"return",
"set",
"(",
")",
"if",
"not",
"isinstance",
"(",
"recurse",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"'\"recurse\" must be formed as a list of strings'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _depth_limited_walk | Walk the directory tree under root up till reaching max_depth.
With max_depth=None (default), do not limit depth. | salt/states/file.py | def _depth_limited_walk(top, max_depth=None):
'''
Walk the directory tree under root up till reaching max_depth.
With max_depth=None (default), do not limit depth.
'''
for root, dirs, files in salt.utils.path.os_walk(top):
if max_depth is not None:
rel_depth = root.count(os.path.... | def _depth_limited_walk(top, max_depth=None):
'''
Walk the directory tree under root up till reaching max_depth.
With max_depth=None (default), do not limit depth.
'''
for root, dirs, files in salt.utils.path.os_walk(top):
if max_depth is not None:
rel_depth = root.count(os.path.... | [
"Walk",
"the",
"directory",
"tree",
"under",
"root",
"up",
"till",
"reaching",
"max_depth",
".",
"With",
"max_depth",
"=",
"None",
"(",
"default",
")",
"do",
"not",
"limit",
"depth",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3091-L3101 | [
"def",
"_depth_limited_walk",
"(",
"top",
",",
"max_depth",
"=",
"None",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"salt",
".",
"utils",
".",
"path",
".",
"os_walk",
"(",
"top",
")",
":",
"if",
"max_depth",
"is",
"not",
"None",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | directory | r'''
Ensure that a named directory is present and has the right perms
name
The location to create or manage a directory, as an absolute path
user
The user to own the directory; this defaults to the user salt is
running as on the minion
group
The group ownership set for... | salt/states/file.py | def directory(name,
user=None,
group=None,
recurse=None,
max_depth=None,
dir_mode=None,
file_mode=None,
makedirs=False,
clean=False,
require=None,
exclude_pat=None,
f... | def directory(name,
user=None,
group=None,
recurse=None,
max_depth=None,
dir_mode=None,
file_mode=None,
makedirs=False,
clean=False,
require=None,
exclude_pat=None,
f... | [
"r",
"Ensure",
"that",
"a",
"named",
"directory",
"is",
"present",
"and",
"has",
"the",
"right",
"perms"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3104-L3638 | [
"def",
"directory",
"(",
"name",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"recurse",
"=",
"None",
",",
"max_depth",
"=",
"None",
",",
"dir_mode",
"=",
"None",
",",
"file_mode",
"=",
"None",
",",
"makedirs",
"=",
"False",
",",
"clean"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | recurse | Recurse through a subdirectory on the master and copy said subdirectory
over to the specified path.
name
The directory to set the recursion in
source
The source directory, this directory is located on the salt master file
server and is specified with the salt:// protocol. If the di... | salt/states/file.py | def recurse(name,
source,
keep_source=True,
clean=False,
require=None,
user=None,
group=None,
dir_mode=None,
file_mode=None,
sym_mode=None,
template=None,
context=None,
replace... | def recurse(name,
source,
keep_source=True,
clean=False,
require=None,
user=None,
group=None,
dir_mode=None,
file_mode=None,
sym_mode=None,
template=None,
context=None,
replace... | [
"Recurse",
"through",
"a",
"subdirectory",
"on",
"the",
"master",
"and",
"copy",
"said",
"subdirectory",
"over",
"to",
"the",
"specified",
"path",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3641-L4111 | [
"def",
"recurse",
"(",
"name",
",",
"source",
",",
"keep_source",
"=",
"True",
",",
"clean",
"=",
"False",
",",
"require",
"=",
"None",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"dir_mode",
"=",
"None",
",",
"file_mode",
"=",
"None",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | retention_schedule | Apply retention scheduling to backup storage directory.
.. versionadded:: 2016.11.0
:param name:
The filesystem path to the directory containing backups to be managed.
:param retain:
Delete the backups, except for the ones we want to keep.
The N below should be an integer but may ... | salt/states/file.py | def retention_schedule(name, retain, strptime_format=None, timezone=None):
'''
Apply retention scheduling to backup storage directory.
.. versionadded:: 2016.11.0
:param name:
The filesystem path to the directory containing backups to be managed.
:param retain:
Delete the backups,... | def retention_schedule(name, retain, strptime_format=None, timezone=None):
'''
Apply retention scheduling to backup storage directory.
.. versionadded:: 2016.11.0
:param name:
The filesystem path to the directory containing backups to be managed.
:param retain:
Delete the backups,... | [
"Apply",
"retention",
"scheduling",
"to",
"backup",
"storage",
"directory",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4114-L4303 | [
"def",
"retention_schedule",
"(",
"name",
",",
"retain",
",",
"strptime_format",
"=",
"None",
",",
"timezone",
"=",
"None",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | line | Line-based editing of a file.
.. versionadded:: 2015.8.0
:param name:
Filesystem path to the file to be edited.
:param content:
Content of the line. Allowed to be empty if mode=delete.
:param match:
Match the target line for an action by
a fragment of a string or regu... | salt/states/file.py | def line(name, content=None, match=None, mode=None, location=None,
before=None, after=None, show_changes=True, backup=False,
quiet=False, indent=True, create=False, user=None,
group=None, file_mode=None):
'''
Line-based editing of a file.
.. versionadded:: 2015.8.0
:param na... | def line(name, content=None, match=None, mode=None, location=None,
before=None, after=None, show_changes=True, backup=False,
quiet=False, indent=True, create=False, user=None,
group=None, file_mode=None):
'''
Line-based editing of a file.
.. versionadded:: 2015.8.0
:param na... | [
"Line",
"-",
"based",
"editing",
"of",
"a",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4306-L4475 | [
"def",
"line",
"(",
"name",
",",
"content",
"=",
"None",
",",
"match",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"location",
"=",
"None",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
",",
"show_changes",
"=",
"True",
",",
"backup",
"=",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | replace | r'''
Maintain an edit in a file.
.. versionadded:: 0.17.0
name
Filesystem path to the file to be edited. If a symlink is specified, it
will be resolved to its target.
pattern
A regular expression, to be matched using Python's
:py:func:`re.search`.
.. note::
... | salt/states/file.py | def replace(name,
pattern,
repl,
count=0,
flags=8,
bufsize=1,
append_if_not_found=False,
prepend_if_not_found=False,
not_found_content=None,
backup='.bak',
show_changes=True,
ignore_if_mis... | def replace(name,
pattern,
repl,
count=0,
flags=8,
bufsize=1,
append_if_not_found=False,
prepend_if_not_found=False,
not_found_content=None,
backup='.bak',
show_changes=True,
ignore_if_mis... | [
"r",
"Maintain",
"an",
"edit",
"in",
"a",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4478-L4676 | [
"def",
"replace",
"(",
"name",
",",
"pattern",
",",
"repl",
",",
"count",
"=",
"0",
",",
"flags",
"=",
"8",
",",
"bufsize",
"=",
"1",
",",
"append_if_not_found",
"=",
"False",
",",
"prepend_if_not_found",
"=",
"False",
",",
"not_found_content",
"=",
"Non... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | keyvalue | Key/Value based editing of a file.
.. versionadded:: Neon
This function differs from ``file.replace`` in that it is able to search for
keys, followed by a customizable separator, and replace the value with the
given value. Should the value be the same as the one already in the file, no
changes wil... | salt/states/file.py | def keyvalue(
name,
key=None,
value=None,
key_values=None,
separator="=",
append_if_not_found=False,
prepend_if_not_found=False,
search_only=False,
show_changes=True,
ignore_if_missing=False,
count=1,
uncomment=None,
... | def keyvalue(
name,
key=None,
value=None,
key_values=None,
separator="=",
append_if_not_found=False,
prepend_if_not_found=False,
search_only=False,
show_changes=True,
ignore_if_missing=False,
count=1,
uncomment=None,
... | [
"Key",
"/",
"Value",
"based",
"editing",
"of",
"a",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4679-L5036 | [
"def",
"keyvalue",
"(",
"name",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
",",
"key_values",
"=",
"None",
",",
"separator",
"=",
"\"=\"",
",",
"append_if_not_found",
"=",
"False",
",",
"prepend_if_not_found",
"=",
"False",
",",
"search_only",
"="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | blockreplace | Maintain an edit in a file in a zone delimited by two line markers
.. versionadded:: 2014.1.0
.. versionchanged:: 2017.7.5,2018.3.1
``append_newline`` argument added. Additionally, to improve
idempotence, if the string represented by ``marker_end`` is found in
the middle of the line, th... | salt/states/file.py | def blockreplace(
name,
marker_start='#-- start managed zone --',
marker_end='#-- end managed zone --',
source=None,
source_hash=None,
template='jinja',
sources=None,
source_hashes=None,
defaults=None,
context=None,
content='',
... | def blockreplace(
name,
marker_start='#-- start managed zone --',
marker_end='#-- end managed zone --',
source=None,
source_hash=None,
template='jinja',
sources=None,
source_hashes=None,
defaults=None,
context=None,
content='',
... | [
"Maintain",
"an",
"edit",
"in",
"a",
"file",
"in",
"a",
"zone",
"delimited",
"by",
"two",
"line",
"markers"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5039-L5352 | [
"def",
"blockreplace",
"(",
"name",
",",
"marker_start",
"=",
"'#-- start managed zone --'",
",",
"marker_end",
"=",
"'#-- end managed zone --'",
",",
"source",
"=",
"None",
",",
"source_hash",
"=",
"None",
",",
"template",
"=",
"'jinja'",
",",
"sources",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | comment | Comment out specified lines in a file.
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be commented;
this pattern will be wrapped in parenthesis and will move any
preceding/trailing ``^`` or ``$`` characters outside the p... | salt/states/file.py | def comment(name, regex, char='#', backup='.bak'):
'''
Comment out specified lines in a file.
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be commented;
this pattern will be wrapped in parenthesis and will move any
... | def comment(name, regex, char='#', backup='.bak'):
'''
Comment out specified lines in a file.
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be commented;
this pattern will be wrapped in parenthesis and will move any
... | [
"Comment",
"out",
"specified",
"lines",
"in",
"a",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5355-L5456 | [
"def",
"comment",
"(",
"name",
",",
"regex",
",",
"char",
"=",
"'#'",
",",
"backup",
"=",
"'.bak'",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | uncomment | Uncomment specified commented lines in a file
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be uncommented.
This regex should not include the comment character. A leading ``^``
character will be stripped for convenience... | salt/states/file.py | def uncomment(name, regex, char='#', backup='.bak'):
'''
Uncomment specified commented lines in a file
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be uncommented.
This regex should not include the comment character. A... | def uncomment(name, regex, char='#', backup='.bak'):
'''
Uncomment specified commented lines in a file
name
The full path to the file to be edited
regex
A regular expression used to find the lines that are to be uncommented.
This regex should not include the comment character. A... | [
"Uncomment",
"specified",
"commented",
"lines",
"in",
"a",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5459-L5561 | [
"def",
"uncomment",
"(",
"name",
",",
"regex",
",",
"char",
"=",
"'#'",
",",
"backup",
"=",
"'.bak'",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | append | Ensure that some text appears at the end of a file.
The text will not be appended if it already exists in the file.
A single string of text or a list of strings may be appended.
name
The location of the file to append to.
text
The text to be appended, which can be a single string or a... | salt/states/file.py | def append(name,
text=None,
makedirs=False,
source=None,
source_hash=None,
template='jinja',
sources=None,
source_hashes=None,
defaults=None,
context=None,
ignore_whitespace=True):
'''
Ensure that some ... | def append(name,
text=None,
makedirs=False,
source=None,
source_hash=None,
template='jinja',
sources=None,
source_hashes=None,
defaults=None,
context=None,
ignore_whitespace=True):
'''
Ensure that some ... | [
"Ensure",
"that",
"some",
"text",
"appears",
"at",
"the",
"end",
"of",
"a",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5564-L5836 | [
"def",
"append",
"(",
"name",
",",
"text",
"=",
"None",
",",
"makedirs",
"=",
"False",
",",
"source",
"=",
"None",
",",
"source_hash",
"=",
"None",
",",
"template",
"=",
"'jinja'",
",",
"sources",
"=",
"None",
",",
"source_hashes",
"=",
"None",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | patch | Ensure that a patch has been applied to the specified file or directory
.. versionchanged:: 2019.2.0
The ``hash`` and ``dry_run_first`` options are now ignored, as the
logic which determines whether or not the patch has already been
applied no longer requires them. Additionally, this state ... | salt/states/file.py | def patch(name,
source=None,
source_hash=None,
source_hash_name=None,
skip_verify=False,
template=None,
context=None,
defaults=None,
options='',
reject_file=None,
strip=None,
saltenv=None,
**kwargs):
... | def patch(name,
source=None,
source_hash=None,
source_hash_name=None,
skip_verify=False,
template=None,
context=None,
defaults=None,
options='',
reject_file=None,
strip=None,
saltenv=None,
**kwargs):
... | [
"Ensure",
"that",
"a",
"patch",
"has",
"been",
"applied",
"to",
"the",
"specified",
"file",
"or",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6145-L6566 | [
"def",
"patch",
"(",
"name",
",",
"source",
"=",
"None",
",",
"source_hash",
"=",
"None",
",",
"source_hash_name",
"=",
"None",
",",
"skip_verify",
"=",
"False",
",",
"template",
"=",
"None",
",",
"context",
"=",
"None",
",",
"defaults",
"=",
"None",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | touch | Replicate the 'nix "touch" command to create a new empty
file or update the atime and mtime of an existing file.
Note that if you just want to create a file and don't care about atime or
mtime, you should use ``file.managed`` instead, as it is more
feature-complete. (Just leave out the ``source``/``te... | salt/states/file.py | def touch(name, atime=None, mtime=None, makedirs=False):
'''
Replicate the 'nix "touch" command to create a new empty
file or update the atime and mtime of an existing file.
Note that if you just want to create a file and don't care about atime or
mtime, you should use ``file.managed`` instead, as ... | def touch(name, atime=None, mtime=None, makedirs=False):
'''
Replicate the 'nix "touch" command to create a new empty
file or update the atime and mtime of an existing file.
Note that if you just want to create a file and don't care about atime or
mtime, you should use ``file.managed`` instead, as ... | [
"Replicate",
"the",
"nix",
"touch",
"command",
"to",
"create",
"a",
"new",
"empty",
"file",
"or",
"update",
"the",
"atime",
"and",
"mtime",
"of",
"an",
"existing",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6569-L6641 | [
"def",
"touch",
"(",
"name",
",",
"atime",
"=",
"None",
",",
"mtime",
"=",
"None",
",",
"makedirs",
"=",
"False",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'change... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | copy_ | If the file defined by the ``source`` option exists on the minion, copy it
to the named path. The file will not be overwritten if it already exists,
unless the ``force`` option is set to ``True``.
.. note::
This state only copies files from one location on a minion to another
location on th... | salt/states/file.py | def copy_(name,
source,
force=False,
makedirs=False,
preserve=False,
user=None,
group=None,
mode=None,
subdir=False,
**kwargs):
'''
If the file defined by the ``source`` option exists on the minion, copy it
to the name... | def copy_(name,
source,
force=False,
makedirs=False,
preserve=False,
user=None,
group=None,
mode=None,
subdir=False,
**kwargs):
'''
If the file defined by the ``source`` option exists on the minion, copy it
to the name... | [
"If",
"the",
"file",
"defined",
"by",
"the",
"source",
"option",
"exists",
"on",
"the",
"minion",
"copy",
"it",
"to",
"the",
"named",
"path",
".",
"The",
"file",
"will",
"not",
"be",
"overwritten",
"if",
"it",
"already",
"exists",
"unless",
"the",
"force... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6644-L6849 | [
"def",
"copy_",
"(",
"name",
",",
"source",
",",
"force",
"=",
"False",
",",
"makedirs",
"=",
"False",
",",
"preserve",
"=",
"False",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"subdir",
"=",
"False",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | rename | If the source file exists on the system, rename it to the named file. The
named file will not be overwritten if it already exists unless the force
option is set to True.
name
The location of the file to rename to
source
The location of the file to move to the location specified with na... | salt/states/file.py | def rename(name, source, force=False, makedirs=False, **kwargs):
'''
If the source file exists on the system, rename it to the named file. The
named file will not be overwritten if it already exists unless the force
option is set to True.
name
The location of the file to rename to
sour... | def rename(name, source, force=False, makedirs=False, **kwargs):
'''
If the source file exists on the system, rename it to the named file. The
named file will not be overwritten if it already exists unless the force
option is set to True.
name
The location of the file to rename to
sour... | [
"If",
"the",
"source",
"file",
"exists",
"on",
"the",
"system",
"rename",
"it",
"to",
"the",
"named",
"file",
".",
"The",
"named",
"file",
"will",
"not",
"be",
"overwritten",
"if",
"it",
"already",
"exists",
"unless",
"the",
"force",
"option",
"is",
"set... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6852-L6942 | [
"def",
"rename",
"(",
"name",
",",
"source",
",",
"force",
"=",
"False",
",",
"makedirs",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name",
")",
"source",
"=",
"os",
".",
"path",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | accumulated | Prepare accumulator which can be used in template in file.managed state.
Accumulator dictionary becomes available in template. It can also be used
in file.blockreplace.
name
Accumulator name
filename
Filename which would receive this accumulator (see file.managed state
document... | salt/states/file.py | def accumulated(name, filename, text, **kwargs):
'''
Prepare accumulator which can be used in template in file.managed state.
Accumulator dictionary becomes available in template. It can also be used
in file.blockreplace.
name
Accumulator name
filename
Filename which would rece... | def accumulated(name, filename, text, **kwargs):
'''
Prepare accumulator which can be used in template in file.managed state.
Accumulator dictionary becomes available in template. It can also be used
in file.blockreplace.
name
Accumulator name
filename
Filename which would rece... | [
"Prepare",
"accumulator",
"which",
"can",
"be",
"used",
"in",
"template",
"in",
"file",
".",
"managed",
"state",
".",
"Accumulator",
"dictionary",
"becomes",
"available",
"in",
"template",
".",
"It",
"can",
"also",
"be",
"used",
"in",
"file",
".",
"blockrepl... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6945-L7046 | [
"def",
"accumulated",
"(",
"name",
",",
"filename",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"if",
"no... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | serialize | Serializes dataset and store it into managed file. Useful for sharing
simple configuration files.
name
The location of the file to create
dataset
The dataset that will be serialized
dataset_pillar
Operates like ``dataset``, but draws from a value stored in pillar,
usin... | salt/states/file.py | def serialize(name,
dataset=None,
dataset_pillar=None,
user=None,
group=None,
mode=None,
backup='',
makedirs=False,
show_changes=True,
create=True,
merge_if_exists=False,
... | def serialize(name,
dataset=None,
dataset_pillar=None,
user=None,
group=None,
mode=None,
backup='',
makedirs=False,
show_changes=True,
create=True,
merge_if_exists=False,
... | [
"Serializes",
"dataset",
"and",
"store",
"it",
"into",
"managed",
"file",
".",
"Useful",
"for",
"sharing",
"simple",
"configuration",
"files",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7049-L7426 | [
"def",
"serialize",
"(",
"name",
",",
"dataset",
"=",
"None",
",",
"dataset_pillar",
"=",
"None",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"backup",
"=",
"''",
",",
"makedirs",
"=",
"False",
",",
"show_chang... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mknod | Create a special file similar to the 'nix mknod command. The supported
device types are ``p`` (fifo pipe), ``c`` (character device), and ``b``
(block device). Provide the major and minor numbers when specifying a
character device or block device. A fifo pipe does not require this
information. The comman... | salt/states/file.py | def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'):
'''
Create a special file similar to the 'nix mknod command. The supported
device types are ``p`` (fifo pipe), ``c`` (character device), and ``b``
(block device). Provide the major and minor numbers when specifying a
chara... | def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'):
'''
Create a special file similar to the 'nix mknod command. The supported
device types are ``p`` (fifo pipe), ``c`` (character device), and ``b``
(block device). Provide the major and minor numbers when specifying a
chara... | [
"Create",
"a",
"special",
"file",
"similar",
"to",
"the",
"nix",
"mknod",
"command",
".",
"The",
"supported",
"device",
"types",
"are",
"p",
"(",
"fifo",
"pipe",
")",
"c",
"(",
"character",
"device",
")",
"and",
"b",
"(",
"block",
"device",
")",
".",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7429-L7640 | [
"def",
"mknod",
"(",
"name",
",",
"ntype",
",",
"major",
"=",
"0",
",",
"minor",
"=",
"0",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
",",
"mode",
"=",
"'0600'",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"name"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mod_run_check_cmd | Execute the check_cmd logic.
Return a result dict if ``check_cmd`` succeeds (check_cmd == 0)
otherwise return True | salt/states/file.py | def mod_run_check_cmd(cmd, filename, **check_cmd_opts):
'''
Execute the check_cmd logic.
Return a result dict if ``check_cmd`` succeeds (check_cmd == 0)
otherwise return True
'''
log.debug('running our check_cmd')
_cmd = '{0} {1}'.format(cmd, filename)
cret = __salt__['cmd.run_all'](_c... | def mod_run_check_cmd(cmd, filename, **check_cmd_opts):
'''
Execute the check_cmd logic.
Return a result dict if ``check_cmd`` succeeds (check_cmd == 0)
otherwise return True
'''
log.debug('running our check_cmd')
_cmd = '{0} {1}'.format(cmd, filename)
cret = __salt__['cmd.run_all'](_c... | [
"Execute",
"the",
"check_cmd",
"logic",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7643-L7667 | [
"def",
"mod_run_check_cmd",
"(",
"cmd",
",",
"filename",
",",
"*",
"*",
"check_cmd_opts",
")",
":",
"log",
".",
"debug",
"(",
"'running our check_cmd'",
")",
"_cmd",
"=",
"'{0} {1}'",
".",
"format",
"(",
"cmd",
",",
"filename",
")",
"cret",
"=",
"__salt__"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | decode | Decode an encoded file and write it to disk
.. versionadded:: 2016.3.0
name
Path of the file to be written.
encoded_data
The encoded file. Either this option or ``contents_pillar`` must be
specified.
contents_pillar
A Pillar path to the encoded file. Uses the same path ... | salt/states/file.py | def decode(name,
encoded_data=None,
contents_pillar=None,
encoding_type='base64',
checksum='md5'):
'''
Decode an encoded file and write it to disk
.. versionadded:: 2016.3.0
name
Path of the file to be written.
encoded_data
The encoded file. Either t... | def decode(name,
encoded_data=None,
contents_pillar=None,
encoding_type='base64',
checksum='md5'):
'''
Decode an encoded file and write it to disk
.. versionadded:: 2016.3.0
name
Path of the file to be written.
encoded_data
The encoded file. Either t... | [
"Decode",
"an",
"encoded",
"file",
"and",
"write",
"it",
"to",
"disk"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7670-L7779 | [
"def",
"decode",
"(",
"name",
",",
"encoded_data",
"=",
"None",
",",
"contents_pillar",
"=",
"None",
",",
"encoding_type",
"=",
"'base64'",
",",
"checksum",
"=",
"'md5'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | shortcut | Create a Windows shortcut
If the file already exists and is a shortcut pointing to any location other
than the specified target, the shortcut will be replaced. If it is
a regular file or directory then the state will return False. If the
regular file or directory is desired to be replaced with a shortc... | salt/states/file.py | def shortcut(
name,
target,
arguments=None,
working_dir=None,
description=None,
icon_location=None,
force=False,
backupname=None,
makedirs=False,
user=None,
**kwargs):
'''
Create a Windows shortcut
If the file already e... | def shortcut(
name,
target,
arguments=None,
working_dir=None,
description=None,
icon_location=None,
force=False,
backupname=None,
makedirs=False,
user=None,
**kwargs):
'''
Create a Windows shortcut
If the file already e... | [
"Create",
"a",
"Windows",
"shortcut"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7782-L8035 | [
"def",
"shortcut",
"(",
"name",
",",
"target",
",",
"arguments",
"=",
"None",
",",
"working_dir",
"=",
"None",
",",
"description",
"=",
"None",
",",
"icon_location",
"=",
"None",
",",
"force",
"=",
"False",
",",
"backupname",
"=",
"None",
",",
"makedirs"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cached | .. versionadded:: 2017.7.3
Ensures that a file is saved to the minion's cache. This state is primarily
invoked by other states to ensure that we do not re-download a source file
if we do not need to.
name
The URL of the file to be cached. To cache a file from an environment
other than ... | salt/states/file.py | def cached(name,
source_hash='',
source_hash_name=None,
skip_verify=False,
saltenv='base'):
'''
.. versionadded:: 2017.7.3
Ensures that a file is saved to the minion's cache. This state is primarily
invoked by other states to ensure that we do not re-download... | def cached(name,
source_hash='',
source_hash_name=None,
skip_verify=False,
saltenv='base'):
'''
.. versionadded:: 2017.7.3
Ensures that a file is saved to the minion's cache. This state is primarily
invoked by other states to ensure that we do not re-download... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"3"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L8038-L8313 | [
"def",
"cached",
"(",
"name",
",",
"source_hash",
"=",
"''",
",",
"source_hash_name",
"=",
"None",
",",
"skip_verify",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | not_cached | .. versionadded:: 2017.7.3
Ensures that a file is not present in the minion's cache, deleting it
if found. This state is primarily invoked by other states to ensure
that a fresh copy is fetched.
name
The URL of the file to be removed from cache. To remove a file from
cache in an enviro... | salt/states/file.py | def not_cached(name, saltenv='base'):
'''
.. versionadded:: 2017.7.3
Ensures that a file is not present in the minion's cache, deleting it
if found. This state is primarily invoked by other states to ensure
that a fresh copy is fetched.
name
The URL of the file to be removed from cache... | def not_cached(name, saltenv='base'):
'''
.. versionadded:: 2017.7.3
Ensures that a file is not present in the minion's cache, deleting it
if found. This state is primarily invoked by other states to ensure
that a fresh copy is fetched.
name
The URL of the file to be removed from cache... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"3"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L8316-L8375 | [
"def",
"not_cached",
"(",
"name",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
",",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
"}",
"try",
":",
"parsed",
"=",
"_urlpar... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | __render_script | Return the rendered script | salt/utils/cloud.py | def __render_script(path, vm_=None, opts=None, minion=''):
'''
Return the rendered script
'''
log.info('Rendering deploy script: %s', path)
try:
with salt.utils.files.fopen(path, 'r') as fp_:
template = Template(salt.utils.stringutils.to_unicode(fp_.read()))
return si... | def __render_script(path, vm_=None, opts=None, minion=''):
'''
Return the rendered script
'''
log.info('Rendering deploy script: %s', path)
try:
with salt.utils.files.fopen(path, 'r') as fp_:
template = Template(salt.utils.stringutils.to_unicode(fp_.read()))
return si... | [
"Return",
"the",
"rendered",
"script"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L128-L140 | [
"def",
"__render_script",
"(",
"path",
",",
"vm_",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"minion",
"=",
"''",
")",
":",
"log",
".",
"info",
"(",
"'Rendering deploy script: %s'",
",",
"path",
")",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | __ssh_gateway_config_dict | Return a dictionary with gateway options. The result is used
to provide arguments to __ssh_gateway_arguments method. | salt/utils/cloud.py | def __ssh_gateway_config_dict(gateway):
'''
Return a dictionary with gateway options. The result is used
to provide arguments to __ssh_gateway_arguments method.
'''
extended_kwargs = {}
if gateway:
extended_kwargs['ssh_gateway'] = gateway['ssh_gateway']
extended_kwargs['ssh_gatew... | def __ssh_gateway_config_dict(gateway):
'''
Return a dictionary with gateway options. The result is used
to provide arguments to __ssh_gateway_arguments method.
'''
extended_kwargs = {}
if gateway:
extended_kwargs['ssh_gateway'] = gateway['ssh_gateway']
extended_kwargs['ssh_gatew... | [
"Return",
"a",
"dictionary",
"with",
"gateway",
"options",
".",
"The",
"result",
"is",
"used",
"to",
"provide",
"arguments",
"to",
"__ssh_gateway_arguments",
"method",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L143-L154 | [
"def",
"__ssh_gateway_config_dict",
"(",
"gateway",
")",
":",
"extended_kwargs",
"=",
"{",
"}",
"if",
"gateway",
":",
"extended_kwargs",
"[",
"'ssh_gateway'",
"]",
"=",
"gateway",
"[",
"'ssh_gateway'",
"]",
"extended_kwargs",
"[",
"'ssh_gateway_key'",
"]",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | __ssh_gateway_arguments | Return ProxyCommand configuration string for ssh/scp command.
All gateway options should not include quotes (' or "). To support
future user configuration, please make sure to update the dictionary
from __ssh_gateway_config_dict and get_ssh_gateway_config (ec2.py) | salt/utils/cloud.py | def __ssh_gateway_arguments(kwargs):
'''
Return ProxyCommand configuration string for ssh/scp command.
All gateway options should not include quotes (' or "). To support
future user configuration, please make sure to update the dictionary
from __ssh_gateway_config_dict and get_ssh_gateway_config (e... | def __ssh_gateway_arguments(kwargs):
'''
Return ProxyCommand configuration string for ssh/scp command.
All gateway options should not include quotes (' or "). To support
future user configuration, please make sure to update the dictionary
from __ssh_gateway_config_dict and get_ssh_gateway_config (e... | [
"Return",
"ProxyCommand",
"configuration",
"string",
"for",
"ssh",
"/",
"scp",
"command",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L157-L198 | [
"def",
"__ssh_gateway_arguments",
"(",
"kwargs",
")",
":",
"extended_arguments",
"=",
"\"\"",
"ssh_gateway",
"=",
"kwargs",
".",
"get",
"(",
"'ssh_gateway'",
",",
"''",
")",
"ssh_gateway_port",
"=",
"22",
"if",
"':'",
"in",
"ssh_gateway",
":",
"ssh_gateway",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | os_script | Return the script as a string for the specific os | salt/utils/cloud.py | def os_script(os_, vm_=None, opts=None, minion=''):
'''
Return the script as a string for the specific os
'''
if minion:
minion = salt_config_to_yaml(minion)
if os.path.isabs(os_):
# The user provided an absolute path to the deploy script, let's use it
return __render_script... | def os_script(os_, vm_=None, opts=None, minion=''):
'''
Return the script as a string for the specific os
'''
if minion:
minion = salt_config_to_yaml(minion)
if os.path.isabs(os_):
# The user provided an absolute path to the deploy script, let's use it
return __render_script... | [
"Return",
"the",
"script",
"as",
"a",
"string",
"for",
"the",
"specific",
"os"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L208-L236 | [
"def",
"os_script",
"(",
"os_",
",",
"vm_",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"minion",
"=",
"''",
")",
":",
"if",
"minion",
":",
"minion",
"=",
"salt_config_to_yaml",
"(",
"minion",
")",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"os_",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | gen_keys | Generate Salt minion keys and return them as PEM file strings | salt/utils/cloud.py | def gen_keys(keysize=2048):
'''
Generate Salt minion keys and return them as PEM file strings
'''
# Mandate that keys are at least 2048 in size
if keysize < 2048:
keysize = 2048
tdir = tempfile.mkdtemp()
salt.crypt.gen_keys(tdir, 'minion', keysize)
priv_path = os.path.join(tdir,... | def gen_keys(keysize=2048):
'''
Generate Salt minion keys and return them as PEM file strings
'''
# Mandate that keys are at least 2048 in size
if keysize < 2048:
keysize = 2048
tdir = tempfile.mkdtemp()
salt.crypt.gen_keys(tdir, 'minion', keysize)
priv_path = os.path.join(tdir,... | [
"Generate",
"Salt",
"minion",
"keys",
"and",
"return",
"them",
"as",
"PEM",
"file",
"strings"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L239-L256 | [
"def",
"gen_keys",
"(",
"keysize",
"=",
"2048",
")",
":",
"# Mandate that keys are at least 2048 in size",
"if",
"keysize",
"<",
"2048",
":",
"keysize",
"=",
"2048",
"tdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"salt",
".",
"crypt",
".",
"gen_keys",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | accept_key | If the master config was available then we will have a pki_dir key in
the opts directory, this method places the pub key in the accepted
keys dir and removes it from the unaccepted keys dir if that is the case. | salt/utils/cloud.py | def accept_key(pki_dir, pub, id_):
'''
If the master config was available then we will have a pki_dir key in
the opts directory, this method places the pub key in the accepted
keys dir and removes it from the unaccepted keys dir if that is the case.
'''
for key_dir in 'minions', 'minions_pre', '... | def accept_key(pki_dir, pub, id_):
'''
If the master config was available then we will have a pki_dir key in
the opts directory, this method places the pub key in the accepted
keys dir and removes it from the unaccepted keys dir if that is the case.
'''
for key_dir in 'minions', 'minions_pre', '... | [
"If",
"the",
"master",
"config",
"was",
"available",
"then",
"we",
"will",
"have",
"a",
"pki_dir",
"key",
"in",
"the",
"opts",
"directory",
"this",
"method",
"places",
"the",
"pub",
"key",
"in",
"the",
"accepted",
"keys",
"dir",
"and",
"removes",
"it",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L259-L278 | [
"def",
"accept_key",
"(",
"pki_dir",
",",
"pub",
",",
"id_",
")",
":",
"for",
"key_dir",
"in",
"'minions'",
",",
"'minions_pre'",
",",
"'minions_rejected'",
":",
"key_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"key_dir",
")",
"if",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove_key | This method removes a specified key from the accepted keys dir | salt/utils/cloud.py | def remove_key(pki_dir, id_):
'''
This method removes a specified key from the accepted keys dir
'''
key = os.path.join(pki_dir, 'minions', id_)
if os.path.isfile(key):
os.remove(key)
log.debug('Deleted \'%s\'', key) | def remove_key(pki_dir, id_):
'''
This method removes a specified key from the accepted keys dir
'''
key = os.path.join(pki_dir, 'minions', id_)
if os.path.isfile(key):
os.remove(key)
log.debug('Deleted \'%s\'', key) | [
"This",
"method",
"removes",
"a",
"specified",
"key",
"from",
"the",
"accepted",
"keys",
"dir"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L281-L288 | [
"def",
"remove_key",
"(",
"pki_dir",
",",
"id_",
")",
":",
"key",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"'minions'",
",",
"id_",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"key",
")",
":",
"os",
".",
"remove",
"(",
"k... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | rename_key | Rename a key, when an instance has also been renamed | salt/utils/cloud.py | def rename_key(pki_dir, id_, new_id):
'''
Rename a key, when an instance has also been renamed
'''
oldkey = os.path.join(pki_dir, 'minions', id_)
newkey = os.path.join(pki_dir, 'minions', new_id)
if os.path.isfile(oldkey):
os.rename(oldkey, newkey) | def rename_key(pki_dir, id_, new_id):
'''
Rename a key, when an instance has also been renamed
'''
oldkey = os.path.join(pki_dir, 'minions', id_)
newkey = os.path.join(pki_dir, 'minions', new_id)
if os.path.isfile(oldkey):
os.rename(oldkey, newkey) | [
"Rename",
"a",
"key",
"when",
"an",
"instance",
"has",
"also",
"been",
"renamed"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L291-L298 | [
"def",
"rename_key",
"(",
"pki_dir",
",",
"id_",
",",
"new_id",
")",
":",
"oldkey",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"'minions'",
",",
"id_",
")",
"newkey",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"'minion... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | minion_config | Return a minion's configuration for the provided options and VM | salt/utils/cloud.py | def minion_config(opts, vm_):
'''
Return a minion's configuration for the provided options and VM
'''
# Don't start with a copy of the default minion opts; they're not always
# what we need. Some default options are Null, let's set a reasonable default
minion = {
'master': 'salt',
... | def minion_config(opts, vm_):
'''
Return a minion's configuration for the provided options and VM
'''
# Don't start with a copy of the default minion opts; they're not always
# what we need. Some default options are Null, let's set a reasonable default
minion = {
'master': 'salt',
... | [
"Return",
"a",
"minion",
"s",
"configuration",
"for",
"the",
"provided",
"options",
"and",
"VM"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L301-L344 | [
"def",
"minion_config",
"(",
"opts",
",",
"vm_",
")",
":",
"# Don't start with a copy of the default minion opts; they're not always",
"# what we need. Some default options are Null, let's set a reasonable default",
"minion",
"=",
"{",
"'master'",
":",
"'salt'",
",",
"'log_level'",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | master_config | Return a master's configuration for the provided options and VM | salt/utils/cloud.py | def master_config(opts, vm_):
'''
Return a master's configuration for the provided options and VM
'''
# Let's get a copy of the salt master default options
master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS)
# Some default options are Null, let's set a reasonable default
master.update(
... | def master_config(opts, vm_):
'''
Return a master's configuration for the provided options and VM
'''
# Let's get a copy of the salt master default options
master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS)
# Some default options are Null, let's set a reasonable default
master.update(
... | [
"Return",
"a",
"master",
"s",
"configuration",
"for",
"the",
"provided",
"options",
"and",
"VM"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L347-L369 | [
"def",
"master_config",
"(",
"opts",
",",
"vm_",
")",
":",
"# Let's get a copy of the salt master default options",
"master",
"=",
"copy",
".",
"deepcopy",
"(",
"salt",
".",
"config",
".",
"DEFAULT_MASTER_OPTS",
")",
"# Some default options are Null, let's set a reasonable ... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | salt_config_to_yaml | Return a salt configuration dictionary, master or minion, as a yaml dump | salt/utils/cloud.py | def salt_config_to_yaml(configuration, line_break='\n'):
'''
Return a salt configuration dictionary, master or minion, as a yaml dump
'''
return salt.utils.yaml.safe_dump(
configuration,
line_break=line_break,
default_flow_style=False) | def salt_config_to_yaml(configuration, line_break='\n'):
'''
Return a salt configuration dictionary, master or minion, as a yaml dump
'''
return salt.utils.yaml.safe_dump(
configuration,
line_break=line_break,
default_flow_style=False) | [
"Return",
"a",
"salt",
"configuration",
"dictionary",
"master",
"or",
"minion",
"as",
"a",
"yaml",
"dump"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L372-L379 | [
"def",
"salt_config_to_yaml",
"(",
"configuration",
",",
"line_break",
"=",
"'\\n'",
")",
":",
"return",
"salt",
".",
"utils",
".",
"yaml",
".",
"safe_dump",
"(",
"configuration",
",",
"line_break",
"=",
"line_break",
",",
"default_flow_style",
"=",
"False",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | bootstrap | This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call. | salt/utils/cloud.py | def bootstrap(vm_, opts=None):
'''
This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call.
'''
if opts is None:
opts = __opts__
deploy_config = salt.config.get_cloud_conf... | def bootstrap(vm_, opts=None):
'''
This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call.
'''
if opts is None:
opts = __opts__
deploy_config = salt.config.get_cloud_conf... | [
"This",
"is",
"the",
"primary",
"entry",
"point",
"for",
"logging",
"into",
"any",
"system",
"(",
"POSIX",
"or",
"Windows",
")",
"to",
"install",
"Salt",
".",
"It",
"will",
"make",
"the",
"decision",
"on",
"its",
"own",
"as",
"to",
"which",
"deploy",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L382-L668 | [
"def",
"bootstrap",
"(",
"vm_",
",",
"opts",
"=",
"None",
")",
":",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"__opts__",
"deploy_config",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
"(",
"'deploy'",
",",
"vm_",
",",
"opts",
",",
"de... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ssh_usernames | Return the ssh_usernames. Defaults to a built-in list of users for trying. | salt/utils/cloud.py | def ssh_usernames(vm_, opts, default_users=None):
'''
Return the ssh_usernames. Defaults to a built-in list of users for trying.
'''
if default_users is None:
default_users = ['root']
usernames = salt.config.get_cloud_config_value(
'ssh_username', vm_, opts
)
if not isinsta... | def ssh_usernames(vm_, opts, default_users=None):
'''
Return the ssh_usernames. Defaults to a built-in list of users for trying.
'''
if default_users is None:
default_users = ['root']
usernames = salt.config.get_cloud_config_value(
'ssh_username', vm_, opts
)
if not isinsta... | [
"Return",
"the",
"ssh_usernames",
".",
"Defaults",
"to",
"a",
"built",
"-",
"in",
"list",
"of",
"users",
"for",
"trying",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L671-L699 | [
"def",
"ssh_usernames",
"(",
"vm_",
",",
"opts",
",",
"default_users",
"=",
"None",
")",
":",
"if",
"default_users",
"is",
"None",
":",
"default_users",
"=",
"[",
"'root'",
"]",
"usernames",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_fun | Wait until a function finishes, or times out | salt/utils/cloud.py | def wait_for_fun(fun, timeout=900, **kwargs):
'''
Wait until a function finishes, or times out
'''
start = time.time()
log.debug('Attempting function %s', fun)
trycount = 0
while True:
trycount += 1
try:
response = fun(**kwargs)
if not isinstance(respo... | def wait_for_fun(fun, timeout=900, **kwargs):
'''
Wait until a function finishes, or times out
'''
start = time.time()
log.debug('Attempting function %s', fun)
trycount = 0
while True:
trycount += 1
try:
response = fun(**kwargs)
if not isinstance(respo... | [
"Wait",
"until",
"a",
"function",
"finishes",
"or",
"times",
"out"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L702-L721 | [
"def",
"wait_for_fun",
"(",
"fun",
",",
"timeout",
"=",
"900",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"log",
".",
"debug",
"(",
"'Attempting function %s'",
",",
"fun",
")",
"trycount",
"=",
"0",
"while",
"True... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_port | Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, depending on the base image. | salt/utils/cloud.py | def wait_for_port(host, port=22, timeout=900, gateway=None):
'''
Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, de... | def wait_for_port(host, port=22, timeout=900, gateway=None):
'''
Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, de... | [
"Wait",
"until",
"a",
"connection",
"to",
"the",
"specified",
"port",
"can",
"be",
"made",
"on",
"a",
"specified",
"host",
".",
"This",
"is",
"usually",
"port",
"22",
"(",
"for",
"SSH",
")",
"but",
"in",
"the",
"case",
"of",
"Windows",
"installations",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L724-L860 | [
"def",
"wait_for_port",
"(",
"host",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"gateway",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"# Assign test ports because if a gateway is defined",
"# we first want to test the gateway... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | run_winexe_command | Run a command remotly via the winexe executable | salt/utils/cloud.py | def run_winexe_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly via the winexe executable
'''
creds = "-U '{0}%{1}' //{2}".format(
username,
password,
host
)
logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format(
username,
... | def run_winexe_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly via the winexe executable
'''
creds = "-U '{0}%{1}' //{2}".format(
username,
password,
host
)
logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format(
username,
... | [
"Run",
"a",
"command",
"remotly",
"via",
"the",
"winexe",
"executable"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L938-L953 | [
"def",
"run_winexe_command",
"(",
"cmd",
",",
"args",
",",
"host",
",",
"username",
",",
"password",
",",
"port",
"=",
"445",
")",
":",
"creds",
"=",
"\"-U '{0}%{1}' //{2}\"",
".",
"format",
"(",
"username",
",",
"password",
",",
"host",
")",
"logging_cred... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | run_psexec_command | Run a command remotly using the psexec protocol | salt/utils/cloud.py | def run_psexec_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly using the psexec protocol
'''
if has_winexe() and not HAS_PSEXEC:
ret_code = run_winexe_command(cmd, args, host, username, password, port)
return None, None, ret_code
service_name = 'PS-E... | def run_psexec_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly using the psexec protocol
'''
if has_winexe() and not HAS_PSEXEC:
ret_code = run_winexe_command(cmd, args, host, username, password, port)
return None, None, ret_code
service_name = 'PS-E... | [
"Run",
"a",
"command",
"remotly",
"using",
"the",
"psexec",
"protocol"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L956-L973 | [
"def",
"run_psexec_command",
"(",
"cmd",
",",
"args",
",",
"host",
",",
"username",
",",
"password",
",",
"port",
"=",
"445",
")",
":",
"if",
"has_winexe",
"(",
")",
"and",
"not",
"HAS_PSEXEC",
":",
"ret_code",
"=",
"run_winexe_command",
"(",
"cmd",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_winexe | Wait until winexe connection can be established. | salt/utils/cloud.py | def wait_for_winexe(host, port, username, password, timeout=900):
'''
Wait until winexe connection can be established.
'''
start = time.time()
log.debug(
'Attempting winexe connection to host %s on port %s',
host, port
)
try_count = 0
while True:
try_count += 1
... | def wait_for_winexe(host, port, username, password, timeout=900):
'''
Wait until winexe connection can be established.
'''
start = time.time()
log.debug(
'Attempting winexe connection to host %s on port %s',
host, port
)
try_count = 0
while True:
try_count += 1
... | [
"Wait",
"until",
"winexe",
"connection",
"can",
"be",
"established",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L976-L1002 | [
"def",
"wait_for_winexe",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"log",
".",
"debug",
"(",
"'Attempting winexe connection to host %s on port %s'",
",",
"h... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_psexecsvc | Wait until psexec connection can be established. | salt/utils/cloud.py | def wait_for_psexecsvc(host, port, username, password, timeout=900):
'''
Wait until psexec connection can be established.
'''
if has_winexe() and not HAS_PSEXEC:
return wait_for_winexe(host, port, username, password, timeout)
start = time.time()
try_count = 0
while True:
try_... | def wait_for_psexecsvc(host, port, username, password, timeout=900):
'''
Wait until psexec connection can be established.
'''
if has_winexe() and not HAS_PSEXEC:
return wait_for_winexe(host, port, username, password, timeout)
start = time.time()
try_count = 0
while True:
try_... | [
"Wait",
"until",
"psexec",
"connection",
"can",
"be",
"established",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1005-L1031 | [
"def",
"wait_for_psexecsvc",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
")",
":",
"if",
"has_winexe",
"(",
")",
"and",
"not",
"HAS_PSEXEC",
":",
"return",
"wait_for_winexe",
"(",
"host",
",",
"port",
",",
"use... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_winrm | Wait until WinRM connection can be established. | salt/utils/cloud.py | def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True):
'''
Wait until WinRM connection can be established.
'''
# Ensure the winrm service is listening before attempting to connect
wait_for_port(host=host, port=port, timeout=timeout)
start = time.time()
l... | def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True):
'''
Wait until WinRM connection can be established.
'''
# Ensure the winrm service is listening before attempting to connect
wait_for_port(host=host, port=port, timeout=timeout)
start = time.time()
l... | [
"Wait",
"until",
"WinRM",
"connection",
"can",
"be",
"established",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1034-L1096 | [
"def",
"wait_for_winrm",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
",",
"use_ssl",
"=",
"True",
",",
"verify",
"=",
"True",
")",
":",
"# Ensure the winrm service is listening before attempting to connect",
"wait_for_port... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate_windows_cred_winexe | Check if the windows credentials are valid | salt/utils/cloud.py | def validate_windows_cred_winexe(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
cmd = "winexe -U '{0}%{1}' //{2} \"hostna... | def validate_windows_cred_winexe(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
cmd = "winexe -U '{0}%{1}' //{2} \"hostna... | [
"Check",
"if",
"the",
"windows",
"credentials",
"are",
"valid"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1099-L1121 | [
"def",
"validate_windows_cred_winexe",
"(",
"host",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"retries",
"=",
"10",
",",
"retry_delay",
"=",
"1",
")",
":",
"cmd",
"=",
"\"winexe -U '{0}%{1}' //{2} \\\"hostname\\\"\"",
".",
"format... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate_windows_cred | Check if the windows credentials are valid | salt/utils/cloud.py | def validate_windows_cred(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
for i in range(retries):
ret_code = 1
... | def validate_windows_cred(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
for i in range(retries):
ret_code = 1
... | [
"Check",
"if",
"the",
"windows",
"credentials",
"are",
"valid"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1124-L1143 | [
"def",
"validate_windows_cred",
"(",
"host",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"retries",
"=",
"10",
",",
"retry_delay",
"=",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"retries",
")",
":",
"ret_code",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wait_for_passwd | Wait until ssh connection can be accessed via password or ssh key | salt/utils/cloud.py | def wait_for_passwd(host, port=22, ssh_timeout=15, username='root',
password=None, key_filename=None, maxtries=15,
trysleep=1, display_ssh_output=True, gateway=None,
known_hosts_file='/dev/null', hard_timeout=None):
'''
Wait until ssh connection can be... | def wait_for_passwd(host, port=22, ssh_timeout=15, username='root',
password=None, key_filename=None, maxtries=15,
trysleep=1, display_ssh_output=True, gateway=None,
known_hosts_file='/dev/null', hard_timeout=None):
'''
Wait until ssh connection can be... | [
"Wait",
"until",
"ssh",
"connection",
"can",
"be",
"accessed",
"via",
"password",
"or",
"ssh",
"key"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1146-L1204 | [
"def",
"wait_for_passwd",
"(",
"host",
",",
"port",
"=",
"22",
",",
"ssh_timeout",
"=",
"15",
",",
"username",
"=",
"'root'",
",",
"password",
"=",
"None",
",",
"key_filename",
"=",
"None",
",",
"maxtries",
"=",
"15",
",",
"trysleep",
"=",
"1",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | deploy_windows | Copy the install files to a remote Windows box, and execute them | salt/utils/cloud.py | def deploy_windows(host,
port=445,
timeout=900,
username='Administrator',
password=None,
name=None,
sock_dir=None,
conf_file=None,
start_action=None,
... | def deploy_windows(host,
port=445,
timeout=900,
username='Administrator',
password=None,
name=None,
sock_dir=None,
conf_file=None,
start_action=None,
... | [
"Copy",
"the",
"install",
"files",
"to",
"a",
"remote",
"Windows",
"box",
"and",
"execute",
"them"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1207-L1408 | [
"def",
"deploy_windows",
"(",
"host",
",",
"port",
"=",
"445",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"name",
"=",
"None",
",",
"sock_dir",
"=",
"None",
",",
"conf_file",
"=",
"None",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | deploy_script | Copy a deploy script to a remote server, execute it, and remove it | salt/utils/cloud.py | def deploy_script(host,
port=22,
timeout=900,
username='root',
password=None,
key_filename=None,
script=None,
name=None,
sock_dir=None,
provider=None,
... | def deploy_script(host,
port=22,
timeout=900,
username='root',
password=None,
key_filename=None,
script=None,
name=None,
sock_dir=None,
provider=None,
... | [
"Copy",
"a",
"deploy",
"script",
"to",
"a",
"remote",
"server",
"execute",
"it",
"and",
"remove",
"it"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1411-L1887 | [
"def",
"deploy_script",
"(",
"host",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'root'",
",",
"password",
"=",
"None",
",",
"key_filename",
"=",
"None",
",",
"script",
"=",
"None",
",",
"name",
"=",
"None",
",",
"sock_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | run_inline_script | Run the inline script commands, one by one
:**kwargs: catch all other things we may get but don't actually need/use | salt/utils/cloud.py | def run_inline_script(host,
name=None,
port=22,
timeout=900,
username='root',
key_filename=None,
inline_script=None,
ssh_timeout=15,
display_ssh... | def run_inline_script(host,
name=None,
port=22,
timeout=900,
username='root',
key_filename=None,
inline_script=None,
ssh_timeout=15,
display_ssh... | [
"Run",
"the",
"inline",
"script",
"commands",
"one",
"by",
"one",
":",
"**",
"kwargs",
":",
"catch",
"all",
"other",
"things",
"we",
"may",
"get",
"but",
"don",
"t",
"actually",
"need",
"/",
"use"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1890-L1961 | [
"def",
"run_inline_script",
"(",
"host",
",",
"name",
"=",
"None",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'root'",
",",
"key_filename",
"=",
"None",
",",
"inline_script",
"=",
"None",
",",
"ssh_timeout",
"=",
"15",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | filter_event | Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag | salt/utils/cloud.py | def filter_event(tag, data, defaults):
'''
Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag
'''
ret = {}
keys = []
use_defaults = True
for ktag in __opts__.get('filter_events', {}):
if tag != kta... | def filter_event(tag, data, defaults):
'''
Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag
'''
ret = {}
keys = []
use_defaults = True
for ktag in __opts__.get('filter_events', {}):
if tag != kta... | [
"Accept",
"a",
"tag",
"a",
"dict",
"and",
"a",
"list",
"of",
"default",
"keys",
"to",
"return",
"from",
"the",
"dict",
"and",
"check",
"them",
"against",
"the",
"cloud",
"configuration",
"for",
"that",
"tag"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1964-L1994 | [
"def",
"filter_event",
"(",
"tag",
",",
"data",
",",
"defaults",
")",
":",
"ret",
"=",
"{",
"}",
"keys",
"=",
"[",
"]",
"use_defaults",
"=",
"True",
"for",
"ktag",
"in",
"__opts__",
".",
"get",
"(",
"'filter_events'",
",",
"{",
"}",
")",
":",
"if",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | fire_event | Fire deploy action | salt/utils/cloud.py | def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'):
'''
Fire deploy action
'''
event = salt.utils.event.get_event(
'master',
sock_dir,
transport,
listen=False)
try:
event.fire_event(msg, tag)
except ValueError:
# We're using at... | def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'):
'''
Fire deploy action
'''
event = salt.utils.event.get_event(
'master',
sock_dir,
transport,
listen=False)
try:
event.fire_event(msg, tag)
except ValueError:
# We're using at... | [
"Fire",
"deploy",
"action"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1997-L2019 | [
"def",
"fire_event",
"(",
"key",
",",
"msg",
",",
"tag",
",",
"sock_dir",
",",
"args",
"=",
"None",
",",
"transport",
"=",
"'zeromq'",
")",
":",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"get_event",
"(",
"'master'",
",",
"sock_dir",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | scp_file | Use scp or sftp to copy a file to a server | salt/utils/cloud.py | def scp_file(dest_path, contents=None, kwargs=None, local_file=None):
'''
Use scp or sftp to copy a file to a server
'''
file_to_upload = None
try:
if contents is not None:
try:
tmpfd, file_to_upload = tempfile.mkstemp()
os.write(tmpfd, contents)
... | def scp_file(dest_path, contents=None, kwargs=None, local_file=None):
'''
Use scp or sftp to copy a file to a server
'''
file_to_upload = None
try:
if contents is not None:
try:
tmpfd, file_to_upload = tempfile.mkstemp()
os.write(tmpfd, contents)
... | [
"Use",
"scp",
"or",
"sftp",
"to",
"copy",
"a",
"file",
"to",
"a",
"server"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2077-L2164 | [
"def",
"scp_file",
"(",
"dest_path",
",",
"contents",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"local_file",
"=",
"None",
")",
":",
"file_to_upload",
"=",
"None",
"try",
":",
"if",
"contents",
"is",
"not",
"None",
":",
"try",
":",
"tmpfd",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ssh_file | Copies a file to the remote SSH target using either sftp or scp, as
configured. | salt/utils/cloud.py | def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None):
'''
Copies a file to the remote SSH target using either sftp or scp, as
configured.
'''
if opts.get('file_transport', 'sftp') == 'sftp':
return sftp_file(dest_path, contents, kwargs, local_file)
return scp_file(d... | def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None):
'''
Copies a file to the remote SSH target using either sftp or scp, as
configured.
'''
if opts.get('file_transport', 'sftp') == 'sftp':
return sftp_file(dest_path, contents, kwargs, local_file)
return scp_file(d... | [
"Copies",
"a",
"file",
"to",
"the",
"remote",
"SSH",
"target",
"using",
"either",
"sftp",
"or",
"scp",
"as",
"configured",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2167-L2174 | [
"def",
"ssh_file",
"(",
"opts",
",",
"dest_path",
",",
"contents",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"local_file",
"=",
"None",
")",
":",
"if",
"opts",
".",
"get",
"(",
"'file_transport'",
",",
"'sftp'",
")",
"==",
"'sftp'",
":",
"return",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | win_cmd | Wrapper for commands to be run against Windows boxes | salt/utils/cloud.py | def win_cmd(command, **kwargs):
'''
Wrapper for commands to be run against Windows boxes
'''
logging_command = kwargs.get('logging_command', None)
try:
proc = NonBlockingPopen(
command,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIP... | def win_cmd(command, **kwargs):
'''
Wrapper for commands to be run against Windows boxes
'''
logging_command = kwargs.get('logging_command', None)
try:
proc = NonBlockingPopen(
command,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIP... | [
"Wrapper",
"for",
"commands",
"to",
"be",
"run",
"against",
"Windows",
"boxes"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2269-L2302 | [
"def",
"win_cmd",
"(",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"logging_command",
"=",
"kwargs",
".",
"get",
"(",
"'logging_command'",
",",
"None",
")",
"try",
":",
"proc",
"=",
"NonBlockingPopen",
"(",
"command",
",",
"shell",
"=",
"True",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.