repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/service.py | status | def status(name, sig=None):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to PID or empty
string is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the ser... | python | def status(name, sig=None):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to PID or empty
string is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the ser... | [
"def",
"status",
"(",
"name",
",",
"sig",
"=",
"None",
")",
":",
"if",
"sig",
":",
"return",
"__salt__",
"[",
"'status.pid'",
"]",
"(",
"sig",
")",
"contains_globbing",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'\\*|\\?|\\[.+\\]'",
",",
"name",
")"... | Return the status for a service.
If the name contains globbing, a dict mapping service name to PID or empty
string is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the service to check
sig (str): Signatu... | [
"Return",
"the",
"status",
"for",
"a",
"service",
".",
"If",
"the",
"name",
"contains",
"globbing",
"a",
"dict",
"mapping",
"service",
"name",
"to",
"PID",
"or",
"empty",
"string",
"is",
"returned",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/service.py#L125-L161 | train |
saltstack/salt | salt/modules/service.py | get_all | def get_all():
'''
Return a list of all available services
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
if not os.path.isdir(_GRAINMAP.get(__grains__.get('os'), '/etc/init.d')):
return []
return sorted(os.listdir(_GRAINMAP.get(__grains__.get('os'), '/etc/... | python | def get_all():
'''
Return a list of all available services
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
if not os.path.isdir(_GRAINMAP.get(__grains__.get('os'), '/etc/init.d')):
return []
return sorted(os.listdir(_GRAINMAP.get(__grains__.get('os'), '/etc/... | [
"def",
"get_all",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"_GRAINMAP",
".",
"get",
"(",
"__grains__",
".",
"get",
"(",
"'os'",
")",
",",
"'/etc/init.d'",
")",
")",
":",
"return",
"[",
"]",
"return",
"sorted",
"(",
"os",
... | Return a list of all available services
CLI Example:
.. code-block:: bash
salt '*' service.get_all | [
"Return",
"a",
"list",
"of",
"all",
"available",
"services"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/service.py#L207-L219 | train |
saltstack/salt | salt/pillar/neutron.py | _auth | def _auth(profile=None):
'''
Set up neutron credentials
'''
credentials = __salt__['config.option'](profile)
kwargs = {
'username': credentials['keystone.user'],
'password': credentials['keystone.password'],
'tenant_name': credentials['keystone.tenant'],
'auth_url': c... | python | def _auth(profile=None):
'''
Set up neutron credentials
'''
credentials = __salt__['config.option'](profile)
kwargs = {
'username': credentials['keystone.user'],
'password': credentials['keystone.password'],
'tenant_name': credentials['keystone.tenant'],
'auth_url': c... | [
"def",
"_auth",
"(",
"profile",
"=",
"None",
")",
":",
"credentials",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"profile",
")",
"kwargs",
"=",
"{",
"'username'",
":",
"credentials",
"[",
"'keystone.user'",
"]",
",",
"'password'",
":",
"credentials",... | Set up neutron credentials | [
"Set",
"up",
"neutron",
"credentials"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/neutron.py#L68-L82 | train |
saltstack/salt | salt/pillar/neutron.py | ext_pillar | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
conf):
'''
Check neutron for all data
'''
comps = conf.split()
profile = None
if comps[0]:
profile = comps[0]
conn = _auth(profile)
ret = {}
networks = conn.list_networks()
for netw... | python | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
conf):
'''
Check neutron for all data
'''
comps = conf.split()
profile = None
if comps[0]:
profile = comps[0]
conn = _auth(profile)
ret = {}
networks = conn.list_networks()
for netw... | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"# pylint: disable=W0613",
"conf",
")",
":",
"comps",
"=",
"conf",
".",
"split",
"(",
")",
"profile",
"=",
"None",
"if",
"comps",
"[",
"0",
"]",
":",
"profile",
"=",
"comps",
"[",
"0",
"]",
"... | Check neutron for all data | [
"Check",
"neutron",
"for",
"all",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/neutron.py#L85-L105 | train |
saltstack/salt | salt/states/mssql_database.py | present | def present(name, containment='NONE', options=None, **kwargs):
'''
Ensure that the named database is present with the specified options
name
The name of the database to manage
containment
Defaults to NONE
options
Can be a list of strings, a dictionary, or a list of dictionar... | python | def present(name, containment='NONE', options=None, **kwargs):
'''
Ensure that the named database is present with the specified options
name
The name of the database to manage
containment
Defaults to NONE
options
Can be a list of strings, a dictionary, or a list of dictionar... | [
"def",
"present",
"(",
"name",
",",
"containment",
"=",
"'NONE'",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'... | Ensure that the named database is present with the specified options
name
The name of the database to manage
containment
Defaults to NONE
options
Can be a list of strings, a dictionary, or a list of dictionaries | [
"Ensure",
"that",
"the",
"named",
"database",
"is",
"present",
"with",
"the",
"specified",
"options"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mssql_database.py#L36-L67 | train |
saltstack/salt | salt/fileclient.py | get_file_client | def get_file_client(opts, pillar=False):
'''
Read in the ``file_client`` option and return the correct type of file
server
'''
client = opts.get('file_client', 'remote')
if pillar and client == 'local':
client = 'pillar'
return {
'remote': RemoteClient,
'local': FSCli... | python | def get_file_client(opts, pillar=False):
'''
Read in the ``file_client`` option and return the correct type of file
server
'''
client = opts.get('file_client', 'remote')
if pillar and client == 'local':
client = 'pillar'
return {
'remote': RemoteClient,
'local': FSCli... | [
"def",
"get_file_client",
"(",
"opts",
",",
"pillar",
"=",
"False",
")",
":",
"client",
"=",
"opts",
".",
"get",
"(",
"'file_client'",
",",
"'remote'",
")",
"if",
"pillar",
"and",
"client",
"==",
"'local'",
":",
"client",
"=",
"'pillar'",
"return",
"{",
... | Read in the ``file_client`` option and return the correct type of file
server | [
"Read",
"in",
"the",
"file_client",
"option",
"and",
"return",
"the",
"correct",
"type",
"of",
"file",
"server"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L52-L64 | train |
saltstack/salt | salt/fileclient.py | decode_dict_keys_to_str | def decode_dict_keys_to_str(src):
'''
Convert top level keys from bytes to strings if possible.
This is necessary because Python 3 makes a distinction
between these types.
'''
if not six.PY3 or not isinstance(src, dict):
return src
output = {}
for key, val in six.iteritems(src):... | python | def decode_dict_keys_to_str(src):
'''
Convert top level keys from bytes to strings if possible.
This is necessary because Python 3 makes a distinction
between these types.
'''
if not six.PY3 or not isinstance(src, dict):
return src
output = {}
for key, val in six.iteritems(src):... | [
"def",
"decode_dict_keys_to_str",
"(",
"src",
")",
":",
"if",
"not",
"six",
".",
"PY3",
"or",
"not",
"isinstance",
"(",
"src",
",",
"dict",
")",
":",
"return",
"src",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
... | Convert top level keys from bytes to strings if possible.
This is necessary because Python 3 makes a distinction
between these types. | [
"Convert",
"top",
"level",
"keys",
"from",
"bytes",
"to",
"strings",
"if",
"possible",
".",
"This",
"is",
"necessary",
"because",
"Python",
"3",
"makes",
"a",
"distinction",
"between",
"these",
"types",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L67-L84 | train |
saltstack/salt | salt/fileclient.py | Client._check_proto | def _check_proto(self, path):
'''
Make sure that this path is intended for the salt master and trim it
'''
if not path.startswith('salt://'):
raise MinionError('Unsupported path: {0}'.format(path))
file_path, saltenv = salt.utils.url.parse(path)
return file_pa... | python | def _check_proto(self, path):
'''
Make sure that this path is intended for the salt master and trim it
'''
if not path.startswith('salt://'):
raise MinionError('Unsupported path: {0}'.format(path))
file_path, saltenv = salt.utils.url.parse(path)
return file_pa... | [
"def",
"_check_proto",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
".",
"startswith",
"(",
"'salt://'",
")",
":",
"raise",
"MinionError",
"(",
"'Unsupported path: {0}'",
".",
"format",
"(",
"path",
")",
")",
"file_path",
",",
"saltenv",
"=",
... | Make sure that this path is intended for the salt master and trim it | [
"Make",
"sure",
"that",
"this",
"path",
"is",
"intended",
"for",
"the",
"salt",
"master",
"and",
"trim",
"it"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L109-L116 | train |
saltstack/salt | salt/fileclient.py | Client._file_local_list | def _file_local_list(self, dest):
'''
Helper util to return a list of files in a directory
'''
if os.path.isdir(dest):
destdir = dest
else:
destdir = os.path.dirname(dest)
filelist = set()
for root, dirs, files in salt.utils.path.os_walk(... | python | def _file_local_list(self, dest):
'''
Helper util to return a list of files in a directory
'''
if os.path.isdir(dest):
destdir = dest
else:
destdir = os.path.dirname(dest)
filelist = set()
for root, dirs, files in salt.utils.path.os_walk(... | [
"def",
"_file_local_list",
"(",
"self",
",",
"dest",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dest",
")",
":",
"destdir",
"=",
"dest",
"else",
":",
"destdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"dest",
")",
"filelist",
"=",
... | Helper util to return a list of files in a directory | [
"Helper",
"util",
"to",
"return",
"a",
"list",
"of",
"files",
"in",
"a",
"directory"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L118-L134 | train |
saltstack/salt | salt/fileclient.py | Client._cache_loc | def _cache_loc(self, path, saltenv='base', cachedir=None):
'''
Return the local location to cache the file, cache dirs will be made
'''
cachedir = self.get_cachedir(cachedir)
dest = salt.utils.path.join(cachedir,
'files',
... | python | def _cache_loc(self, path, saltenv='base', cachedir=None):
'''
Return the local location to cache the file, cache dirs will be made
'''
cachedir = self.get_cachedir(cachedir)
dest = salt.utils.path.join(cachedir,
'files',
... | [
"def",
"_cache_loc",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
")",
":",
"cachedir",
"=",
"self",
".",
"get_cachedir",
"(",
"cachedir",
")",
"dest",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"join",
"("... | Return the local location to cache the file, cache dirs will be made | [
"Return",
"the",
"local",
"location",
"to",
"cache",
"the",
"file",
"cache",
"dirs",
"will",
"be",
"made"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L137-L160 | train |
saltstack/salt | salt/fileclient.py | Client.get_file | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Copies a file from the local files or master depending on
implementation
'''
rais... | python | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Copies a file from the local files or master depending on
implementation
'''
rais... | [
"def",
"get_file",
"(",
"self",
",",
"path",
",",
"dest",
"=",
"''",
",",
"makedirs",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
",",
"gzip",
"=",
"None",
",",
"cachedir",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | Copies a file from the local files or master depending on
implementation | [
"Copies",
"a",
"file",
"from",
"the",
"local",
"files",
"or",
"master",
"depending",
"on",
"implementation"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L169-L180 | train |
saltstack/salt | salt/fileclient.py | Client.cache_file | def cache_file(self, path, saltenv='base', cachedir=None, source_hash=None):
'''
Pull a file down from the file server and store it in the minion
file cache
'''
return self.get_url(
path, '', True, saltenv, cachedir=cachedir, source_hash=source_hash) | python | def cache_file(self, path, saltenv='base', cachedir=None, source_hash=None):
'''
Pull a file down from the file server and store it in the minion
file cache
'''
return self.get_url(
path, '', True, saltenv, cachedir=cachedir, source_hash=source_hash) | [
"def",
"cache_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
",",
"source_hash",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_url",
"(",
"path",
",",
"''",
",",
"True",
",",
"saltenv",
",",
"cached... | Pull a file down from the file server and store it in the minion
file cache | [
"Pull",
"a",
"file",
"down",
"from",
"the",
"file",
"server",
"and",
"store",
"it",
"in",
"the",
"minion",
"file",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L188-L194 | train |
saltstack/salt | salt/fileclient.py | Client.cache_files | def cache_files(self, paths, saltenv='base', cachedir=None):
'''
Download a list of files stored on the master and put them in the
minion file cache
'''
ret = []
if isinstance(paths, six.string_types):
paths = paths.split(',')
for path in paths:
... | python | def cache_files(self, paths, saltenv='base', cachedir=None):
'''
Download a list of files stored on the master and put them in the
minion file cache
'''
ret = []
if isinstance(paths, six.string_types):
paths = paths.split(',')
for path in paths:
... | [
"def",
"cache_files",
"(",
"self",
",",
"paths",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"paths",
",",
"six",
".",
"string_types",
")",
":",
"paths",
"=",
"paths",
".",
"... | Download a list of files stored on the master and put them in the
minion file cache | [
"Download",
"a",
"list",
"of",
"files",
"stored",
"on",
"the",
"master",
"and",
"put",
"them",
"in",
"the",
"minion",
"file",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L196-L206 | train |
saltstack/salt | salt/fileclient.py | Client.cache_master | def cache_master(self, saltenv='base', cachedir=None):
'''
Download and cache all files on a master in a specified environment
'''
ret = []
for path in self.file_list(saltenv):
ret.append(
self.cache_file(
salt.utils.url.create(path... | python | def cache_master(self, saltenv='base', cachedir=None):
'''
Download and cache all files on a master in a specified environment
'''
ret = []
for path in self.file_list(saltenv):
ret.append(
self.cache_file(
salt.utils.url.create(path... | [
"def",
"cache_master",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"file_list",
"(",
"saltenv",
")",
":",
"ret",
".",
"append",
"(",
"self",
".",
"cache... | Download and cache all files on a master in a specified environment | [
"Download",
"and",
"cache",
"all",
"files",
"on",
"a",
"master",
"in",
"a",
"specified",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L208-L218 | train |
saltstack/salt | salt/fileclient.py | Client.cache_dir | def cache_dir(self, path, saltenv='base', include_empty=False,
include_pat=None, exclude_pat=None, cachedir=None):
'''
Download all of the files in a subdir of the master
'''
ret = []
path = self._check_proto(salt.utils.data.decode(path))
# We want to m... | python | def cache_dir(self, path, saltenv='base', include_empty=False,
include_pat=None, exclude_pat=None, cachedir=None):
'''
Download all of the files in a subdir of the master
'''
ret = []
path = self._check_proto(salt.utils.data.decode(path))
# We want to m... | [
"def",
"cache_dir",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
",",
"include_empty",
"=",
"False",
",",
"include_pat",
"=",
"None",
",",
"exclude_pat",
"=",
"None",
",",
"cachedir",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"path",
"... | Download all of the files in a subdir of the master | [
"Download",
"all",
"of",
"the",
"files",
"in",
"a",
"subdir",
"of",
"the",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L220-L269 | train |
saltstack/salt | salt/fileclient.py | Client.cache_local_file | def cache_local_file(self, path, **kwargs):
'''
Cache a local file on the minion in the localfiles cache
'''
dest = os.path.join(self.opts['cachedir'], 'localfiles',
path.lstrip('/'))
destdir = os.path.dirname(dest)
if not os.path.isdir(destdi... | python | def cache_local_file(self, path, **kwargs):
'''
Cache a local file on the minion in the localfiles cache
'''
dest = os.path.join(self.opts['cachedir'], 'localfiles',
path.lstrip('/'))
destdir = os.path.dirname(dest)
if not os.path.isdir(destdi... | [
"def",
"cache_local_file",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'cachedir'",
"]",
",",
"'localfiles'",
",",
"path",
".",
"lstrip",
"(",
"'/'",
")",... | Cache a local file on the minion in the localfiles cache | [
"Cache",
"a",
"local",
"file",
"on",
"the",
"minion",
"in",
"the",
"localfiles",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L271-L283 | train |
saltstack/salt | salt/fileclient.py | Client.file_local_list | def file_local_list(self, saltenv='base'):
'''
List files in the local minion files and localfiles caches
'''
filesdest = os.path.join(self.opts['cachedir'], 'files', saltenv)
localfilesdest = os.path.join(self.opts['cachedir'], 'localfiles')
fdest = self._file_local_lis... | python | def file_local_list(self, saltenv='base'):
'''
List files in the local minion files and localfiles caches
'''
filesdest = os.path.join(self.opts['cachedir'], 'files', saltenv)
localfilesdest = os.path.join(self.opts['cachedir'], 'localfiles')
fdest = self._file_local_lis... | [
"def",
"file_local_list",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
")",
":",
"filesdest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'cachedir'",
"]",
",",
"'files'",
",",
"saltenv",
")",
"localfilesdest",
"=",
"os",
".",
... | List files in the local minion files and localfiles caches | [
"List",
"files",
"in",
"the",
"local",
"minion",
"files",
"and",
"localfiles",
"caches"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L285-L294 | train |
saltstack/salt | salt/fileclient.py | Client.is_cached | def is_cached(self, path, saltenv='base', cachedir=None):
'''
Returns the full path to a file if it is cached locally on the minion
otherwise returns a blank string
'''
if path.startswith('salt://'):
path, senv = salt.utils.url.parse(path)
if senv:
... | python | def is_cached(self, path, saltenv='base', cachedir=None):
'''
Returns the full path to a file if it is cached locally on the minion
otherwise returns a blank string
'''
if path.startswith('salt://'):
path, senv = salt.utils.url.parse(path)
if senv:
... | [
"def",
"is_cached",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'salt://'",
")",
":",
"path",
",",
"senv",
"=",
"salt",
".",
"utils",
".",
"url",
".",
"pars... | Returns the full path to a file if it is cached locally on the minion
otherwise returns a blank string | [
"Returns",
"the",
"full",
"path",
"to",
"a",
"file",
"if",
"it",
"is",
"cached",
"locally",
"on",
"the",
"minion",
"otherwise",
"returns",
"a",
"blank",
"string"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L314-L342 | train |
saltstack/salt | salt/fileclient.py | Client.cache_dest | def cache_dest(self, url, saltenv='base', cachedir=None):
'''
Return the expected cache location for the specified URL and
environment.
'''
proto = urlparse(url).scheme
if proto == '':
# Local file path
return url
if proto == 'salt':
... | python | def cache_dest(self, url, saltenv='base', cachedir=None):
'''
Return the expected cache location for the specified URL and
environment.
'''
proto = urlparse(url).scheme
if proto == '':
# Local file path
return url
if proto == 'salt':
... | [
"def",
"cache_dest",
"(",
"self",
",",
"url",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
")",
":",
"proto",
"=",
"urlparse",
"(",
"url",
")",
".",
"scheme",
"if",
"proto",
"==",
"''",
":",
"# Local file path",
"return",
"url",
"if",
... | Return the expected cache location for the specified URL and
environment. | [
"Return",
"the",
"expected",
"cache",
"location",
"for",
"the",
"specified",
"URL",
"and",
"environment",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L344-L365 | train |
saltstack/salt | salt/fileclient.py | Client.list_states | def list_states(self, saltenv):
'''
Return a list of all available sls modules on the master for a given
environment
'''
states = set()
for path in self.file_list(saltenv):
if salt.utils.platform.is_windows():
path = path.replace('\\', '/')
... | python | def list_states(self, saltenv):
'''
Return a list of all available sls modules on the master for a given
environment
'''
states = set()
for path in self.file_list(saltenv):
if salt.utils.platform.is_windows():
path = path.replace('\\', '/')
... | [
"def",
"list_states",
"(",
"self",
",",
"saltenv",
")",
":",
"states",
"=",
"set",
"(",
")",
"for",
"path",
"in",
"self",
".",
"file_list",
"(",
"saltenv",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"pa... | Return a list of all available sls modules on the master for a given
environment | [
"Return",
"a",
"list",
"of",
"all",
"available",
"sls",
"modules",
"on",
"the",
"master",
"for",
"a",
"given",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L367-L382 | train |
saltstack/salt | salt/fileclient.py | Client.get_state | def get_state(self, sls, saltenv, cachedir=None):
'''
Get a state file from the master and store it in the local minion
cache; return the location of the file
'''
if '.' in sls:
sls = sls.replace('.', '/')
sls_url = salt.utils.url.create(sls + '.sls')
... | python | def get_state(self, sls, saltenv, cachedir=None):
'''
Get a state file from the master and store it in the local minion
cache; return the location of the file
'''
if '.' in sls:
sls = sls.replace('.', '/')
sls_url = salt.utils.url.create(sls + '.sls')
... | [
"def",
"get_state",
"(",
"self",
",",
"sls",
",",
"saltenv",
",",
"cachedir",
"=",
"None",
")",
":",
"if",
"'.'",
"in",
"sls",
":",
"sls",
"=",
"sls",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"sls_url",
"=",
"salt",
".",
"utils",
".",
"url",
... | Get a state file from the master and store it in the local minion
cache; return the location of the file | [
"Get",
"a",
"state",
"file",
"from",
"the",
"master",
"and",
"store",
"it",
"in",
"the",
"local",
"minion",
"cache",
";",
"return",
"the",
"location",
"of",
"the",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L384-L397 | train |
saltstack/salt | salt/fileclient.py | Client.get_dir | def get_dir(self, path, dest='', saltenv='base', gzip=None,
cachedir=None):
'''
Get a directory recursively from the salt-master
'''
ret = []
# Strip trailing slash
path = self._check_proto(path).rstrip('/')
# Break up the path into a list containi... | python | def get_dir(self, path, dest='', saltenv='base', gzip=None,
cachedir=None):
'''
Get a directory recursively from the salt-master
'''
ret = []
# Strip trailing slash
path = self._check_proto(path).rstrip('/')
# Break up the path into a list containi... | [
"def",
"get_dir",
"(",
"self",
",",
"path",
",",
"dest",
"=",
"''",
",",
"saltenv",
"=",
"'base'",
",",
"gzip",
"=",
"None",
",",
"cachedir",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"# Strip trailing slash",
"path",
"=",
"self",
".",
"_check_pro... | Get a directory recursively from the salt-master | [
"Get",
"a",
"directory",
"recursively",
"from",
"the",
"salt",
"-",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L399-L456 | train |
saltstack/salt | salt/fileclient.py | Client.get_url | def get_url(self, url, dest, makedirs=False, saltenv='base',
no_cache=False, cachedir=None, source_hash=None):
'''
Get a single file from a URL.
'''
url_data = urlparse(url)
url_scheme = url_data.scheme
url_path = os.path.join(
url_data.net... | python | def get_url(self, url, dest, makedirs=False, saltenv='base',
no_cache=False, cachedir=None, source_hash=None):
'''
Get a single file from a URL.
'''
url_data = urlparse(url)
url_scheme = url_data.scheme
url_path = os.path.join(
url_data.net... | [
"def",
"get_url",
"(",
"self",
",",
"url",
",",
"dest",
",",
"makedirs",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
",",
"no_cache",
"=",
"False",
",",
"cachedir",
"=",
"None",
",",
"source_hash",
"=",
"None",
")",
":",
"url_data",
"=",
"urlparse",
... | Get a single file from a URL. | [
"Get",
"a",
"single",
"file",
"from",
"a",
"URL",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L458-L740 | train |
saltstack/salt | salt/fileclient.py | Client.get_template | def get_template(
self,
url,
dest,
template='jinja',
makedirs=False,
saltenv='base',
cachedir=None,
**kwargs):
'''
Cache a file then process it as a template
'''
if 'env' in kwargs:
... | python | def get_template(
self,
url,
dest,
template='jinja',
makedirs=False,
saltenv='base',
cachedir=None,
**kwargs):
'''
Cache a file then process it as a template
'''
if 'env' in kwargs:
... | [
"def",
"get_template",
"(",
"self",
",",
"url",
",",
"dest",
",",
"template",
"=",
"'jinja'",
",",
"makedirs",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
",",
"cachedir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'env'",
"in",
"kwargs"... | Cache a file then process it as a template | [
"Cache",
"a",
"file",
"then",
"process",
"it",
"as",
"a",
"template"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L742-L792 | train |
saltstack/salt | salt/fileclient.py | Client._extrn_path | def _extrn_path(self, url, saltenv, cachedir=None):
'''
Return the extrn_filepath for a given url
'''
url_data = urlparse(url)
if salt.utils.platform.is_windows():
netloc = salt.utils.path.sanitize_win_path(url_data.netloc)
else:
netloc = url_data.... | python | def _extrn_path(self, url, saltenv, cachedir=None):
'''
Return the extrn_filepath for a given url
'''
url_data = urlparse(url)
if salt.utils.platform.is_windows():
netloc = salt.utils.path.sanitize_win_path(url_data.netloc)
else:
netloc = url_data.... | [
"def",
"_extrn_path",
"(",
"self",
",",
"url",
",",
"saltenv",
",",
"cachedir",
"=",
"None",
")",
":",
"url_data",
"=",
"urlparse",
"(",
"url",
")",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"netloc",
"=",
"salt",... | Return the extrn_filepath for a given url | [
"Return",
"the",
"extrn_filepath",
"for",
"a",
"given",
"url"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L794-L826 | train |
saltstack/salt | salt/fileclient.py | PillarClient._find_file | def _find_file(self, path, saltenv='base'):
'''
Locate the file path
'''
fnd = {'path': '',
'rel': ''}
if salt.utils.url.is_escaped(path):
# The path arguments are escaped
path = salt.utils.url.unescape(path)
for root in self.opts['... | python | def _find_file(self, path, saltenv='base'):
'''
Locate the file path
'''
fnd = {'path': '',
'rel': ''}
if salt.utils.url.is_escaped(path):
# The path arguments are escaped
path = salt.utils.url.unescape(path)
for root in self.opts['... | [
"def",
"_find_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"fnd",
"=",
"{",
"'path'",
":",
"''",
",",
"'rel'",
":",
"''",
"}",
"if",
"salt",
".",
"utils",
".",
"url",
".",
"is_escaped",
"(",
"path",
")",
":",
"# The p... | Locate the file path | [
"Locate",
"the",
"file",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L833-L849 | train |
saltstack/salt | salt/fileclient.py | PillarClient.get_file | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Copies a file from the local files directory into :param:`dest`
gzip compression settings are ign... | python | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Copies a file from the local files directory into :param:`dest`
gzip compression settings are ign... | [
"def",
"get_file",
"(",
"self",
",",
"path",
",",
"dest",
"=",
"''",
",",
"makedirs",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
",",
"gzip",
"=",
"None",
",",
"cachedir",
"=",
"None",
")",
":",
"path",
"=",
"self",
".",
"_check_proto",
"(",
"pat... | Copies a file from the local files directory into :param:`dest`
gzip compression settings are ignored for local files | [
"Copies",
"a",
"file",
"from",
"the",
"local",
"files",
"directory",
"into",
":",
"param",
":",
"dest",
"gzip",
"compression",
"settings",
"are",
"ignored",
"for",
"local",
"files"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L851-L868 | train |
saltstack/salt | salt/fileclient.py | PillarClient.file_list | def file_list(self, saltenv='base', prefix=''):
'''
Return a list of files in the given environment
with optional relative prefix path to limit directory traversal
'''
ret = []
prefix = prefix.strip('/')
for path in self.opts['pillar_roots'].get(saltenv, []):
... | python | def file_list(self, saltenv='base', prefix=''):
'''
Return a list of files in the given environment
with optional relative prefix path to limit directory traversal
'''
ret = []
prefix = prefix.strip('/')
for path in self.opts['pillar_roots'].get(saltenv, []):
... | [
"def",
"file_list",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
",",
"prefix",
"=",
"''",
")",
":",
"ret",
"=",
"[",
"]",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
"'/'",
")",
"for",
"path",
"in",
"self",
".",
"opts",
"[",
"'pillar_roots'",
"]",
... | Return a list of files in the given environment
with optional relative prefix path to limit directory traversal | [
"Return",
"a",
"list",
"of",
"files",
"in",
"the",
"given",
"environment",
"with",
"optional",
"relative",
"prefix",
"path",
"to",
"limit",
"directory",
"traversal"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L870-L886 | train |
saltstack/salt | salt/fileclient.py | PillarClient.__get_file_path | def __get_file_path(self, path, saltenv='base'):
'''
Return either a file path or the result of a remote find_file call.
'''
try:
path = self._check_proto(path)
except MinionError as err:
# Local file path
if not os.path.isfile(path):
... | python | def __get_file_path(self, path, saltenv='base'):
'''
Return either a file path or the result of a remote find_file call.
'''
try:
path = self._check_proto(path)
except MinionError as err:
# Local file path
if not os.path.isfile(path):
... | [
"def",
"__get_file_path",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"try",
":",
"path",
"=",
"self",
".",
"_check_proto",
"(",
"path",
")",
"except",
"MinionError",
"as",
"err",
":",
"# Local file path",
"if",
"not",
"os",
".",
... | Return either a file path or the result of a remote find_file call. | [
"Return",
"either",
"a",
"file",
"path",
"or",
"the",
"result",
"of",
"a",
"remote",
"find_file",
"call",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L919-L935 | train |
saltstack/salt | salt/fileclient.py | PillarClient.hash_file | def hash_file(self, path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
'''
ret = {}
fnd = self.__get_file_path(path,... | python | def hash_file(self, path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
'''
ret = {}
fnd = self.__get_file_path(path,... | [
"def",
"hash_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"}",
"fnd",
"=",
"self",
".",
"__get_file_path",
"(",
"path",
",",
"saltenv",
")",
"if",
"fnd",
"is",
"None",
":",
"return",
"ret",
"try",
":",
... | Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file. | [
"Return",
"the",
"hash",
"of",
"a",
"file",
"to",
"get",
"the",
"hash",
"of",
"a",
"file",
"in",
"the",
"pillar_roots",
"prepend",
"the",
"path",
"with",
"salt",
":",
"//",
"<file",
"on",
"server",
">",
"otherwise",
"prepend",
"the",
"file",
"with",
"/... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L937-L958 | train |
saltstack/salt | salt/fileclient.py | PillarClient.hash_and_stat_file | def hash_and_stat_file(self, path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
Additionally, return the stat result of the file, o... | python | def hash_and_stat_file(self, path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
Additionally, return the stat result of the file, o... | [
"def",
"hash_and_stat_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"}",
"fnd",
"=",
"self",
".",
"__get_file_path",
"(",
"path",
",",
"saltenv",
")",
"if",
"fnd",
"is",
"None",
":",
"return",
"ret",
",",
... | Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
Additionally, return the stat result of the file, or None if no stat
results were found. | [
"Return",
"the",
"hash",
"of",
"a",
"file",
"to",
"get",
"the",
"hash",
"of",
"a",
"file",
"in",
"the",
"pillar_roots",
"prepend",
"the",
"path",
"with",
"salt",
":",
"//",
"<file",
"on",
"server",
">",
"otherwise",
"prepend",
"the",
"file",
"with",
"/... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L960-L989 | train |
saltstack/salt | salt/fileclient.py | PillarClient.envs | def envs(self):
'''
Return the available environments
'''
ret = []
for saltenv in self.opts['pillar_roots']:
ret.append(saltenv)
return ret | python | def envs(self):
'''
Return the available environments
'''
ret = []
for saltenv in self.opts['pillar_roots']:
ret.append(saltenv)
return ret | [
"def",
"envs",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"saltenv",
"in",
"self",
".",
"opts",
"[",
"'pillar_roots'",
"]",
":",
"ret",
".",
"append",
"(",
"saltenv",
")",
"return",
"ret"
] | Return the available environments | [
"Return",
"the",
"available",
"environments"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1003-L1010 | train |
saltstack/salt | salt/fileclient.py | RemoteClient._refresh_channel | def _refresh_channel(self):
'''
Reset the channel, in the event of an interruption
'''
self.channel = salt.transport.client.ReqChannel.factory(self.opts)
return self.channel | python | def _refresh_channel(self):
'''
Reset the channel, in the event of an interruption
'''
self.channel = salt.transport.client.ReqChannel.factory(self.opts)
return self.channel | [
"def",
"_refresh_channel",
"(",
"self",
")",
":",
"self",
".",
"channel",
"=",
"salt",
".",
"transport",
".",
"client",
".",
"ReqChannel",
".",
"factory",
"(",
"self",
".",
"opts",
")",
"return",
"self",
".",
"channel"
] | Reset the channel, in the event of an interruption | [
"Reset",
"the",
"channel",
"in",
"the",
"event",
"of",
"an",
"interruption"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1041-L1046 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.get_file | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Get a single file from the salt-master
path must be a salt server location, aka, salt://path/to/f... | python | def get_file(self,
path,
dest='',
makedirs=False,
saltenv='base',
gzip=None,
cachedir=None):
'''
Get a single file from the salt-master
path must be a salt server location, aka, salt://path/to/f... | [
"def",
"get_file",
"(",
"self",
",",
"path",
",",
"dest",
"=",
"''",
",",
"makedirs",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
",",
"gzip",
"=",
"None",
",",
"cachedir",
"=",
"None",
")",
":",
"path",
",",
"senv",
"=",
"salt",
".",
"utils",
"... | Get a single file from the salt-master
path must be a salt server location, aka, salt://path/to/file, if
dest is omitted, then the downloaded file will be placed in the minion
cache | [
"Get",
"a",
"single",
"file",
"from",
"the",
"salt",
"-",
"master",
"path",
"must",
"be",
"a",
"salt",
"server",
"location",
"aka",
"salt",
":",
"//",
"path",
"/",
"to",
"/",
"file",
"if",
"dest",
"is",
"omitted",
"then",
"the",
"downloaded",
"file",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1064-L1262 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.dir_list | def dir_list(self, saltenv='base', prefix=''):
'''
List the dirs on the master
'''
load = {'saltenv': saltenv,
'prefix': prefix,
'cmd': '_dir_list'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.s... | python | def dir_list(self, saltenv='base', prefix=''):
'''
List the dirs on the master
'''
load = {'saltenv': saltenv,
'prefix': prefix,
'cmd': '_dir_list'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.s... | [
"def",
"dir_list",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
",",
"prefix",
"=",
"''",
")",
":",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'prefix'",
":",
"prefix",
",",
"'cmd'",
":",
"'_dir_list'",
"}",
"return",
"salt",
".",
"utils",
"... | List the dirs on the master | [
"List",
"the",
"dirs",
"on",
"the",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1284-L1292 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.__hash_and_stat_file | def __hash_and_stat_file(self, path, saltenv='base'):
'''
Common code for hashing and stating files
'''
try:
path = self._check_proto(path)
except MinionError as err:
if not os.path.isfile(path):
log.warning(
'specified ... | python | def __hash_and_stat_file(self, path, saltenv='base'):
'''
Common code for hashing and stating files
'''
try:
path = self._check_proto(path)
except MinionError as err:
if not os.path.isfile(path):
log.warning(
'specified ... | [
"def",
"__hash_and_stat_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"try",
":",
"path",
"=",
"self",
".",
"_check_proto",
"(",
"path",
")",
"except",
"MinionError",
"as",
"err",
":",
"if",
"not",
"os",
".",
"path",
".",
... | Common code for hashing and stating files | [
"Common",
"code",
"for",
"hashing",
"and",
"stating",
"files"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1304-L1326 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.hash_and_stat_file | def hash_and_stat_file(self, path, saltenv='base'):
'''
The same as hash_file, but also return the file's mode, or None if no
mode data is present.
'''
hash_result = self.hash_file(path, saltenv)
try:
path = self._check_proto(path)
except MinionError a... | python | def hash_and_stat_file(self, path, saltenv='base'):
'''
The same as hash_file, but also return the file's mode, or None if no
mode data is present.
'''
hash_result = self.hash_file(path, saltenv)
try:
path = self._check_proto(path)
except MinionError a... | [
"def",
"hash_and_stat_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"hash_result",
"=",
"self",
".",
"hash_file",
"(",
"path",
",",
"saltenv",
")",
"try",
":",
"path",
"=",
"self",
".",
"_check_proto",
"(",
"path",
")",
"exc... | The same as hash_file, but also return the file's mode, or None if no
mode data is present. | [
"The",
"same",
"as",
"hash_file",
"but",
"also",
"return",
"the",
"file",
"s",
"mode",
"or",
"None",
"if",
"no",
"mode",
"data",
"is",
"present",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1336-L1360 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.list_env | def list_env(self, saltenv='base'):
'''
Return a list of the files in the file server's specified environment
'''
load = {'saltenv': saltenv,
'cmd': '_file_list'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.sen... | python | def list_env(self, saltenv='base'):
'''
Return a list of the files in the file server's specified environment
'''
load = {'saltenv': saltenv,
'cmd': '_file_list'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.sen... | [
"def",
"list_env",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
")",
":",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'cmd'",
":",
"'_file_list'",
"}",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"self",
".",
"channel",
"... | Return a list of the files in the file server's specified environment | [
"Return",
"a",
"list",
"of",
"the",
"files",
"in",
"the",
"file",
"server",
"s",
"specified",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1362-L1369 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.envs | def envs(self):
'''
Return a list of available environments
'''
load = {'cmd': '_file_envs'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.send(load) | python | def envs(self):
'''
Return a list of available environments
'''
load = {'cmd': '_file_envs'}
return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \
else self.channel.send(load) | [
"def",
"envs",
"(",
"self",
")",
":",
"load",
"=",
"{",
"'cmd'",
":",
"'_file_envs'",
"}",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"self",
".",
"channel",
".",
"send",
"(",
"load",
")",
")",
"if",
"six",
".",
"PY2",
"else... | Return a list of available environments | [
"Return",
"a",
"list",
"of",
"available",
"environments"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1371-L1377 | train |
saltstack/salt | salt/fileclient.py | RemoteClient.master_tops | def master_tops(self):
'''
Return the metadata derived from the master_tops system
'''
log.debug(
'The _ext_nodes master function has been renamed to _master_tops. '
'To ensure compatibility when using older Salt masters we will '
'continue to invoke t... | python | def master_tops(self):
'''
Return the metadata derived from the master_tops system
'''
log.debug(
'The _ext_nodes master function has been renamed to _master_tops. '
'To ensure compatibility when using older Salt masters we will '
'continue to invoke t... | [
"def",
"master_tops",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'The _ext_nodes master function has been renamed to _master_tops. '",
"'To ensure compatibility when using older Salt masters we will '",
"'continue to invoke the function as _ext_nodes until the '",
"'Magnesium releas... | Return the metadata derived from the master_tops system | [
"Return",
"the",
"metadata",
"derived",
"from",
"the",
"master_tops",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L1387-L1405 | train |
saltstack/salt | salt/states/saltsupport.py | SaltSupportState.check_destination | def check_destination(self, location, group):
'''
Check destination for the archives.
:return:
'''
# Pre-create destination, since rsync will
# put one file named as group
try:
destination = os.path.join(location, group)
if os.path.exists(d... | python | def check_destination(self, location, group):
'''
Check destination for the archives.
:return:
'''
# Pre-create destination, since rsync will
# put one file named as group
try:
destination = os.path.join(location, group)
if os.path.exists(d... | [
"def",
"check_destination",
"(",
"self",
",",
"location",
",",
"group",
")",
":",
"# Pre-create destination, since rsync will",
"# put one file named as group",
"try",
":",
"destination",
"=",
"os",
".",
"path",
".",
"join",
"(",
"location",
",",
"group",
")",
"if... | Check destination for the archives.
:return: | [
"Check",
"destination",
"for",
"the",
"archives",
".",
":",
"return",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/saltsupport.py#L96-L113 | train |
saltstack/salt | salt/states/saltsupport.py | SaltSupportState.collected | def collected(self, group, filename=None, host=None, location=None, move=True, all=True):
'''
Sync archives to a central place.
:param name:
:param group:
:param filename:
:param host:
:param location:
:param move:
:param all:
:return:
... | python | def collected(self, group, filename=None, host=None, location=None, move=True, all=True):
'''
Sync archives to a central place.
:param name:
:param group:
:param filename:
:param host:
:param location:
:param move:
:param all:
:return:
... | [
"def",
"collected",
"(",
"self",
",",
"group",
",",
"filename",
"=",
"None",
",",
"host",
"=",
"None",
",",
"location",
"=",
"None",
",",
"move",
"=",
"True",
",",
"all",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"'support.collected'",
... | Sync archives to a central place.
:param name:
:param group:
:param filename:
:param host:
:param location:
:param move:
:param all:
:return: | [
"Sync",
"archives",
"to",
"a",
"central",
"place",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/saltsupport.py#L115-L139 | train |
saltstack/salt | salt/states/saltsupport.py | SaltSupportState.taken | def taken(self, profile='default', pillar=None, archive=None, output='nested'):
'''
Takes minion support config data.
:param profile:
:param pillar:
:param archive:
:param output:
:return:
'''
ret = {
'name': 'support.taken',
... | python | def taken(self, profile='default', pillar=None, archive=None, output='nested'):
'''
Takes minion support config data.
:param profile:
:param pillar:
:param archive:
:param output:
:return:
'''
ret = {
'name': 'support.taken',
... | [
"def",
"taken",
"(",
"self",
",",
"profile",
"=",
"'default'",
",",
"pillar",
"=",
"None",
",",
"archive",
"=",
"None",
",",
"output",
"=",
"'nested'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"'support.taken'",
",",
"'changes'",
":",
"{",
"}",
",",... | Takes minion support config data.
:param profile:
:param pillar:
:param archive:
:param output:
:return: | [
"Takes",
"minion",
"support",
"config",
"data",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/saltsupport.py#L141-L168 | train |
saltstack/salt | salt/modules/vmctl.py | create_disk | def create_disk(name, size):
'''
Create a VMM disk with the specified `name` and `size`.
size:
Size in megabytes, or use a specifier such as M, G, T.
CLI Example:
.. code-block:: bash
salt '*' vmctl.create_disk /path/to/disk.img size=10G
'''
ret = False
cmd = 'vmctl c... | python | def create_disk(name, size):
'''
Create a VMM disk with the specified `name` and `size`.
size:
Size in megabytes, or use a specifier such as M, G, T.
CLI Example:
.. code-block:: bash
salt '*' vmctl.create_disk /path/to/disk.img size=10G
'''
ret = False
cmd = 'vmctl c... | [
"def",
"create_disk",
"(",
"name",
",",
"size",
")",
":",
"ret",
"=",
"False",
"cmd",
"=",
"'vmctl create {0} -s {1}'",
".",
"format",
"(",
"name",
",",
"size",
")",
"result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
... | Create a VMM disk with the specified `name` and `size`.
size:
Size in megabytes, or use a specifier such as M, G, T.
CLI Example:
.. code-block:: bash
salt '*' vmctl.create_disk /path/to/disk.img size=10G | [
"Create",
"a",
"VMM",
"disk",
"with",
"the",
"specified",
"name",
"and",
"size",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L50-L78 | train |
saltstack/salt | salt/modules/vmctl.py | load | def load(path):
'''
Load additional configuration from the specified file.
path
Path to the configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.load path=/etc/vm.switches.conf
'''
ret = False
cmd = 'vmctl load {0}'.format(path)
result = __salt__['... | python | def load(path):
'''
Load additional configuration from the specified file.
path
Path to the configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.load path=/etc/vm.switches.conf
'''
ret = False
cmd = 'vmctl load {0}'.format(path)
result = __salt__['... | [
"def",
"load",
"(",
"path",
")",
":",
"ret",
"=",
"False",
"cmd",
"=",
"'vmctl load {0}'",
".",
"format",
"(",
"path",
")",
"result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'trace'",
",",
"python_shell",
"="... | Load additional configuration from the specified file.
path
Path to the configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.load path=/etc/vm.switches.conf | [
"Load",
"additional",
"configuration",
"from",
"the",
"specified",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L81-L107 | train |
saltstack/salt | salt/modules/vmctl.py | reload | def reload():
'''
Remove all stopped VMs and reload configuration from the default configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.reload
'''
ret = False
cmd = 'vmctl reload'
result = __salt__['cmd.run_all'](cmd,
output... | python | def reload():
'''
Remove all stopped VMs and reload configuration from the default configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.reload
'''
ret = False
cmd = 'vmctl reload'
result = __salt__['cmd.run_all'](cmd,
output... | [
"def",
"reload",
"(",
")",
":",
"ret",
"=",
"False",
"cmd",
"=",
"'vmctl reload'",
"result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'trace'",
",",
"python_shell",
"=",
"False",
")",
"if",
"result",
"[",
"'re... | Remove all stopped VMs and reload configuration from the default configuration file.
CLI Example:
.. code-block:: bash
salt '*' vmctl.reload | [
"Remove",
"all",
"stopped",
"VMs",
"and",
"reload",
"configuration",
"from",
"the",
"default",
"configuration",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L110-L133 | train |
saltstack/salt | salt/modules/vmctl.py | reset | def reset(all=False, vms=False, switches=False):
'''
Reset the running state of VMM or a subsystem.
all:
Reset the running state.
switches:
Reset the configured switches.
vms:
Reset and terminate all VMs.
CLI Example:
.. code-block:: bash
salt '*' vmctl... | python | def reset(all=False, vms=False, switches=False):
'''
Reset the running state of VMM or a subsystem.
all:
Reset the running state.
switches:
Reset the configured switches.
vms:
Reset and terminate all VMs.
CLI Example:
.. code-block:: bash
salt '*' vmctl... | [
"def",
"reset",
"(",
"all",
"=",
"False",
",",
"vms",
"=",
"False",
",",
"switches",
"=",
"False",
")",
":",
"ret",
"=",
"False",
"cmd",
"=",
"[",
"'vmctl'",
",",
"'reset'",
"]",
"if",
"all",
":",
"cmd",
".",
"append",
"(",
"'all'",
")",
"elif",
... | Reset the running state of VMM or a subsystem.
all:
Reset the running state.
switches:
Reset the configured switches.
vms:
Reset and terminate all VMs.
CLI Example:
.. code-block:: bash
salt '*' vmctl.reset all=True | [
"Reset",
"the",
"running",
"state",
"of",
"VMM",
"or",
"a",
"subsystem",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L136-L177 | train |
saltstack/salt | salt/modules/vmctl.py | start | def start(name=None, id=None, bootpath=None, disk=None, disks=None, local_iface=False,
memory=None, nics=0, switch=None):
'''
Starts a VM defined by the specified parameters.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.... | python | def start(name=None, id=None, bootpath=None, disk=None, disks=None, local_iface=False,
memory=None, nics=0, switch=None):
'''
Starts a VM defined by the specified parameters.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.... | [
"def",
"start",
"(",
"name",
"=",
"None",
",",
"id",
"=",
"None",
",",
"bootpath",
"=",
"None",
",",
"disk",
"=",
"None",
",",
"disks",
"=",
"None",
",",
"local_iface",
"=",
"False",
",",
"memory",
"=",
"None",
",",
"nics",
"=",
"0",
",",
"switch... | Starts a VM defined by the specified parameters.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
bootpath:
Path to a kernel or BIOS image to load.
disk:
Path to a single disk to use.
disks:
List of mul... | [
"Starts",
"a",
"VM",
"defined",
"by",
"the",
"specified",
"parameters",
".",
"When",
"both",
"a",
"name",
"and",
"id",
"are",
"provided",
"the",
"id",
"is",
"ignored",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L180-L283 | train |
saltstack/salt | salt/modules/vmctl.py | status | def status(name=None, id=None):
'''
List VMs running on the host, or only the VM specified by ``id``. When
both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.status ... | python | def status(name=None, id=None):
'''
List VMs running on the host, or only the VM specified by ``id``. When
both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.status ... | [
"def",
"status",
"(",
"name",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"cmd",
"=",
"[",
"'vmctl'",
",",
"'status'",
"]",
"result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'tr... | List VMs running on the host, or only the VM specified by ``id``. When
both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.status # to list all VMs
salt '*' vmctl... | [
"List",
"VMs",
"running",
"on",
"the",
"host",
"or",
"only",
"the",
"VM",
"specified",
"by",
"id",
".",
"When",
"both",
"a",
"name",
"and",
"id",
"are",
"provided",
"the",
"id",
"is",
"ignored",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L286-L358 | train |
saltstack/salt | salt/modules/vmctl.py | stop | def stop(name=None, id=None):
'''
Stop (terminate) the VM identified by the given id or name.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.stop name=alpine
'... | python | def stop(name=None, id=None):
'''
Stop (terminate) the VM identified by the given id or name.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.stop name=alpine
'... | [
"def",
"stop",
"(",
"name",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"cmd",
"=",
"[",
"'vmctl'",
",",
"'stop'",
"]",
"if",
"not",
"(",
"name",
"or",
"id",
")",
":",
"raise",
"SaltInvocationError",
"(",
"'Must provide eit... | Stop (terminate) the VM identified by the given id or name.
When both a name and id are provided, the id is ignored.
name:
Name of the defined VM.
id:
VM id.
CLI Example:
.. code-block:: bash
salt '*' vmctl.stop name=alpine | [
"Stop",
"(",
"terminate",
")",
"the",
"VM",
"identified",
"by",
"the",
"given",
"id",
"or",
"name",
".",
"When",
"both",
"a",
"name",
"and",
"id",
"are",
"provided",
"the",
"id",
"is",
"ignored",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L361-L403 | train |
saltstack/salt | salt/modules/munin.py | run | def run(plugins):
'''
Run one or more named munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run uptime
salt '*' munin.run uptime,cpu,load,memory
'''
all_plugins = list_plugins()
if isinstance(plugins, six.string_types):
plugins = plugins.split(',')
... | python | def run(plugins):
'''
Run one or more named munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run uptime
salt '*' munin.run uptime,cpu,load,memory
'''
all_plugins = list_plugins()
if isinstance(plugins, six.string_types):
plugins = plugins.split(',')
... | [
"def",
"run",
"(",
"plugins",
")",
":",
"all_plugins",
"=",
"list_plugins",
"(",
")",
"if",
"isinstance",
"(",
"plugins",
",",
"six",
".",
"string_types",
")",
":",
"plugins",
"=",
"plugins",
".",
"split",
"(",
"','",
")",
"data",
"=",
"{",
"}",
"for... | Run one or more named munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run uptime
salt '*' munin.run uptime,cpu,load,memory | [
"Run",
"one",
"or",
"more",
"named",
"munin",
"plugins"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/munin.py#L33-L70 | train |
saltstack/salt | salt/modules/munin.py | run_all | def run_all():
'''
Run all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run_all
'''
plugins = list_plugins()
ret = {}
for plugin in plugins:
ret.update(run(plugin))
return ret | python | def run_all():
'''
Run all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run_all
'''
plugins = list_plugins()
ret = {}
for plugin in plugins:
ret.update(run(plugin))
return ret | [
"def",
"run_all",
"(",
")",
":",
"plugins",
"=",
"list_plugins",
"(",
")",
"ret",
"=",
"{",
"}",
"for",
"plugin",
"in",
"plugins",
":",
"ret",
".",
"update",
"(",
"run",
"(",
"plugin",
")",
")",
"return",
"ret"
] | Run all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.run_all | [
"Run",
"all",
"the",
"munin",
"plugins"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/munin.py#L73-L87 | train |
saltstack/salt | salt/modules/munin.py | list_plugins | def list_plugins():
'''
List all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.list_plugins
'''
pluginlist = os.listdir(PLUGINDIR)
ret = []
for plugin in pluginlist:
# Check if execute bit
statf = os.path.join(PLUGINDIR, plugin)
try... | python | def list_plugins():
'''
List all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.list_plugins
'''
pluginlist = os.listdir(PLUGINDIR)
ret = []
for plugin in pluginlist:
# Check if execute bit
statf = os.path.join(PLUGINDIR, plugin)
try... | [
"def",
"list_plugins",
"(",
")",
":",
"pluginlist",
"=",
"os",
".",
"listdir",
"(",
"PLUGINDIR",
")",
"ret",
"=",
"[",
"]",
"for",
"plugin",
"in",
"pluginlist",
":",
"# Check if execute bit",
"statf",
"=",
"os",
".",
"path",
".",
"join",
"(",
"PLUGINDIR"... | List all the munin plugins
CLI Example:
.. code-block:: bash
salt '*' munin.list_plugins | [
"List",
"all",
"the",
"munin",
"plugins"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/munin.py#L90-L111 | train |
saltstack/salt | salt/modules/kernelpkg_linux_yum.py | list_installed | def list_installed():
'''
Return a list of all installed kernels.
CLI Example:
.. code-block:: bash
salt '*' kernelpkg.list_installed
'''
result = __salt__['pkg.version'](_package_name(), versions_as_list=True)
if result is None:
return []
if six.PY2:
return s... | python | def list_installed():
'''
Return a list of all installed kernels.
CLI Example:
.. code-block:: bash
salt '*' kernelpkg.list_installed
'''
result = __salt__['pkg.version'](_package_name(), versions_as_list=True)
if result is None:
return []
if six.PY2:
return s... | [
"def",
"list_installed",
"(",
")",
":",
"result",
"=",
"__salt__",
"[",
"'pkg.version'",
"]",
"(",
"_package_name",
"(",
")",
",",
"versions_as_list",
"=",
"True",
")",
"if",
"result",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"six",
".",
"PY2",
":"... | Return a list of all installed kernels.
CLI Example:
.. code-block:: bash
salt '*' kernelpkg.list_installed | [
"Return",
"a",
"list",
"of",
"all",
"installed",
"kernels",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kernelpkg_linux_yum.py#L64-L81 | train |
saltstack/salt | salt/modules/kernelpkg_linux_yum.py | upgrade | def upgrade(reboot=False, at_time=None):
'''
Upgrade the kernel and optionally reboot the system.
reboot : False
Request a reboot if a new kernel is available.
at_time : immediate
Schedule the reboot at some point in the future. This argument
is ignored if ``reboot=False``. See... | python | def upgrade(reboot=False, at_time=None):
'''
Upgrade the kernel and optionally reboot the system.
reboot : False
Request a reboot if a new kernel is available.
at_time : immediate
Schedule the reboot at some point in the future. This argument
is ignored if ``reboot=False``. See... | [
"def",
"upgrade",
"(",
"reboot",
"=",
"False",
",",
"at_time",
"=",
"None",
")",
":",
"result",
"=",
"__salt__",
"[",
"'pkg.upgrade'",
"]",
"(",
"name",
"=",
"_package_name",
"(",
")",
")",
"_needs_reboot",
"=",
"needs_reboot",
"(",
")",
"ret",
"=",
"{... | Upgrade the kernel and optionally reboot the system.
reboot : False
Request a reboot if a new kernel is available.
at_time : immediate
Schedule the reboot at some point in the future. This argument
is ignored if ``reboot=False``. See
:py:func:`~salt.modules.system.reboot` for m... | [
"Upgrade",
"the",
"kernel",
"and",
"optionally",
"reboot",
"the",
"system",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kernelpkg_linux_yum.py#L138-L178 | train |
saltstack/salt | salt/modules/kernelpkg_linux_yum.py | remove | def remove(release):
'''
Remove a specific version of the kernel.
release
The release number of an installed kernel. This must be the entire release
number as returned by :py:func:`~salt.modules.kernelpkg_linux_yum.list_installed`,
not the package name.
CLI Example:
.. cod... | python | def remove(release):
'''
Remove a specific version of the kernel.
release
The release number of an installed kernel. This must be the entire release
number as returned by :py:func:`~salt.modules.kernelpkg_linux_yum.list_installed`,
not the package name.
CLI Example:
.. cod... | [
"def",
"remove",
"(",
"release",
")",
":",
"if",
"release",
"not",
"in",
"list_installed",
"(",
")",
":",
"raise",
"CommandExecutionError",
"(",
"'Kernel release \\'{0}\\' is not installed'",
".",
"format",
"(",
"release",
")",
")",
"if",
"release",
"==",
"activ... | Remove a specific version of the kernel.
release
The release number of an installed kernel. This must be the entire release
number as returned by :py:func:`~salt.modules.kernelpkg_linux_yum.list_installed`,
not the package name.
CLI Example:
.. code-block:: bash
salt '*' ... | [
"Remove",
"a",
"specific",
"version",
"of",
"the",
"kernel",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kernelpkg_linux_yum.py#L195-L246 | train |
saltstack/salt | salt/utils/cache.py | context_cache | def context_cache(func):
'''
A decorator to be used module functions which need to cache their
context.
To evaluate a __context__ and re-hydrate it if a given key
is empty or contains no items, pass a list of keys to evaulate.
'''
def context_cache_wrap(*args, **kwargs):
func_contex... | python | def context_cache(func):
'''
A decorator to be used module functions which need to cache their
context.
To evaluate a __context__ and re-hydrate it if a given key
is empty or contains no items, pass a list of keys to evaulate.
'''
def context_cache_wrap(*args, **kwargs):
func_contex... | [
"def",
"context_cache",
"(",
"func",
")",
":",
"def",
"context_cache_wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func_context",
"=",
"func",
".",
"__globals__",
"[",
"'__context__'",
"]",
"func_opts",
"=",
"func",
".",
"__globals__",
"[",
... | A decorator to be used module functions which need to cache their
context.
To evaluate a __context__ and re-hydrate it if a given key
is empty or contains no items, pass a list of keys to evaulate. | [
"A",
"decorator",
"to",
"be",
"used",
"module",
"functions",
"which",
"need",
"to",
"cache",
"their",
"context",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L344-L363 | train |
saltstack/salt | salt/utils/cache.py | CacheDict._enforce_ttl_key | def _enforce_ttl_key(self, key):
'''
Enforce the TTL to a specific key, delete if its past TTL
'''
if key not in self._key_cache_time or self._ttl == 0:
return
if time.time() - self._key_cache_time[key] > self._ttl:
del self._key_cache_time[key]
... | python | def _enforce_ttl_key(self, key):
'''
Enforce the TTL to a specific key, delete if its past TTL
'''
if key not in self._key_cache_time or self._ttl == 0:
return
if time.time() - self._key_cache_time[key] > self._ttl:
del self._key_cache_time[key]
... | [
"def",
"_enforce_ttl_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_key_cache_time",
"or",
"self",
".",
"_ttl",
"==",
"0",
":",
"return",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_key_cache_time",
"["... | Enforce the TTL to a specific key, delete if its past TTL | [
"Enforce",
"the",
"TTL",
"to",
"a",
"specific",
"key",
"delete",
"if",
"its",
"past",
"TTL"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L65-L73 | train |
saltstack/salt | salt/utils/cache.py | CacheDisk._enforce_ttl_key | def _enforce_ttl_key(self, key):
'''
Enforce the TTL to a specific key, delete if its past TTL
'''
if key not in self._key_cache_time or self._ttl == 0:
return
if time.time() - self._key_cache_time[key] > self._ttl:
del self._key_cache_time[key]
... | python | def _enforce_ttl_key(self, key):
'''
Enforce the TTL to a specific key, delete if its past TTL
'''
if key not in self._key_cache_time or self._ttl == 0:
return
if time.time() - self._key_cache_time[key] > self._ttl:
del self._key_cache_time[key]
... | [
"def",
"_enforce_ttl_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_key_cache_time",
"or",
"self",
".",
"_ttl",
"==",
"0",
":",
"return",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_key_cache_time",
"["... | Enforce the TTL to a specific key, delete if its past TTL | [
"Enforce",
"the",
"TTL",
"to",
"a",
"specific",
"key",
"delete",
"if",
"its",
"past",
"TTL"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L106-L114 | train |
saltstack/salt | salt/utils/cache.py | CacheDisk._read | def _read(self):
'''
Read in from disk
'''
if msgpack is None:
log.error('Cache cannot be read from the disk: msgpack is missing')
elif not os.path.exists(self._path):
log.debug('Cache path does not exist for reading: %s', self._path)
else:
... | python | def _read(self):
'''
Read in from disk
'''
if msgpack is None:
log.error('Cache cannot be read from the disk: msgpack is missing')
elif not os.path.exists(self._path):
log.debug('Cache path does not exist for reading: %s', self._path)
else:
... | [
"def",
"_read",
"(",
"self",
")",
":",
"if",
"msgpack",
"is",
"None",
":",
"log",
".",
"error",
"(",
"'Cache cannot be read from the disk: msgpack is missing'",
")",
"elif",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_path",
")",
":",
"log... | Read in from disk | [
"Read",
"in",
"from",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L172-L195 | train |
saltstack/salt | salt/utils/cache.py | CacheDisk.store | def store(self):
'''
Write content of the entire cache to disk
'''
if msgpack is None:
log.error('Cache cannot be stored on disk: msgpack is missing')
else:
# TODO Dir hashing?
try:
with salt.utils.files.fopen(self._path, 'wb+')... | python | def store(self):
'''
Write content of the entire cache to disk
'''
if msgpack is None:
log.error('Cache cannot be stored on disk: msgpack is missing')
else:
# TODO Dir hashing?
try:
with salt.utils.files.fopen(self._path, 'wb+')... | [
"def",
"store",
"(",
"self",
")",
":",
"if",
"msgpack",
"is",
"None",
":",
"log",
".",
"error",
"(",
"'Cache cannot be stored on disk: msgpack is missing'",
")",
"else",
":",
"# TODO Dir hashing?",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
... | Write content of the entire cache to disk | [
"Write",
"content",
"of",
"the",
"entire",
"cache",
"to",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L197-L213 | train |
saltstack/salt | salt/utils/cache.py | CacheCli.put_cache | def put_cache(self, minions):
'''
published the given minions to the ConCache
'''
self.cupd_out.send(self.serial.dumps(minions)) | python | def put_cache(self, minions):
'''
published the given minions to the ConCache
'''
self.cupd_out.send(self.serial.dumps(minions)) | [
"def",
"put_cache",
"(",
"self",
",",
"minions",
")",
":",
"self",
".",
"cupd_out",
".",
"send",
"(",
"self",
".",
"serial",
".",
"dumps",
"(",
"minions",
")",
")"
] | published the given minions to the ConCache | [
"published",
"the",
"given",
"minions",
"to",
"the",
"ConCache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L244-L248 | train |
saltstack/salt | salt/utils/cache.py | CacheCli.get_cached | def get_cached(self):
'''
queries the ConCache for a list of currently connected minions
'''
msg = self.serial.dumps('minions')
self.creq_out.send(msg)
min_list = self.serial.loads(self.creq_out.recv())
return min_list | python | def get_cached(self):
'''
queries the ConCache for a list of currently connected minions
'''
msg = self.serial.dumps('minions')
self.creq_out.send(msg)
min_list = self.serial.loads(self.creq_out.recv())
return min_list | [
"def",
"get_cached",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"serial",
".",
"dumps",
"(",
"'minions'",
")",
"self",
".",
"creq_out",
".",
"send",
"(",
"msg",
")",
"min_list",
"=",
"self",
".",
"serial",
".",
"loads",
"(",
"self",
".",
"creq... | queries the ConCache for a list of currently connected minions | [
"queries",
"the",
"ConCache",
"for",
"a",
"list",
"of",
"currently",
"connected",
"minions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L250-L257 | train |
saltstack/salt | salt/utils/cache.py | CacheRegex.sweep | def sweep(self):
'''
Sweep the cache and remove the outdated or least frequently
used entries
'''
if self.max_age < time.time() - self.timestamp:
self.clear()
self.timestamp = time.time()
else:
paterns = list(self.cache.values())
... | python | def sweep(self):
'''
Sweep the cache and remove the outdated or least frequently
used entries
'''
if self.max_age < time.time() - self.timestamp:
self.clear()
self.timestamp = time.time()
else:
paterns = list(self.cache.values())
... | [
"def",
"sweep",
"(",
"self",
")",
":",
"if",
"self",
".",
"max_age",
"<",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"timestamp",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"else",
"... | Sweep the cache and remove the outdated or least frequently
used entries | [
"Sweep",
"the",
"cache",
"and",
"remove",
"the",
"outdated",
"or",
"least",
"frequently",
"used",
"entries"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L286-L298 | train |
saltstack/salt | salt/utils/cache.py | CacheRegex.get | def get(self, pattern):
'''
Get a compiled regular expression object based on pattern and
cache it when it is not in the cache already
'''
try:
self.cache[pattern][0] += 1
return self.cache[pattern][1]
except KeyError:
pass
if l... | python | def get(self, pattern):
'''
Get a compiled regular expression object based on pattern and
cache it when it is not in the cache already
'''
try:
self.cache[pattern][0] += 1
return self.cache[pattern][1]
except KeyError:
pass
if l... | [
"def",
"get",
"(",
"self",
",",
"pattern",
")",
":",
"try",
":",
"self",
".",
"cache",
"[",
"pattern",
"]",
"[",
"0",
"]",
"+=",
"1",
"return",
"self",
".",
"cache",
"[",
"pattern",
"]",
"[",
"1",
"]",
"except",
"KeyError",
":",
"pass",
"if",
"... | Get a compiled regular expression object based on pattern and
cache it when it is not in the cache already | [
"Get",
"a",
"compiled",
"regular",
"expression",
"object",
"based",
"on",
"pattern",
"and",
"cache",
"it",
"when",
"it",
"is",
"not",
"in",
"the",
"cache",
"already"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L300-L315 | train |
saltstack/salt | salt/utils/cache.py | ContextCache.cache_context | def cache_context(self, context):
'''
Cache the given context to disk
'''
if not os.path.isdir(os.path.dirname(self.cache_path)):
os.mkdir(os.path.dirname(self.cache_path))
with salt.utils.files.fopen(self.cache_path, 'w+b') as cache:
self.serial.dump(cont... | python | def cache_context(self, context):
'''
Cache the given context to disk
'''
if not os.path.isdir(os.path.dirname(self.cache_path)):
os.mkdir(os.path.dirname(self.cache_path))
with salt.utils.files.fopen(self.cache_path, 'w+b') as cache:
self.serial.dump(cont... | [
"def",
"cache_context",
"(",
"self",
",",
"context",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"cache_path",
")",
")",
":",
"os",
".",
"mkdir",
"(",
"os",
".",
"path",
".",
... | Cache the given context to disk | [
"Cache",
"the",
"given",
"context",
"to",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L327-L334 | train |
saltstack/salt | salt/utils/cache.py | ContextCache.get_cache_context | def get_cache_context(self):
'''
Retrieve a context cache from disk
'''
with salt.utils.files.fopen(self.cache_path, 'rb') as cache:
return salt.utils.data.decode(self.serial.load(cache)) | python | def get_cache_context(self):
'''
Retrieve a context cache from disk
'''
with salt.utils.files.fopen(self.cache_path, 'rb') as cache:
return salt.utils.data.decode(self.serial.load(cache)) | [
"def",
"get_cache_context",
"(",
"self",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"self",
".",
"cache_path",
",",
"'rb'",
")",
"as",
"cache",
":",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"self"... | Retrieve a context cache from disk | [
"Retrieve",
"a",
"context",
"cache",
"from",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L336-L341 | train |
saltstack/salt | salt/utils/doc.py | strip_rst | def strip_rst(docs):
'''
Strip/replace reStructuredText directives in docstrings
'''
for func, docstring in six.iteritems(docs):
log.debug('Stripping docstring for %s', func)
if not docstring:
continue
docstring_new = docstring if six.PY3 else salt.utils.data.encode(d... | python | def strip_rst(docs):
'''
Strip/replace reStructuredText directives in docstrings
'''
for func, docstring in six.iteritems(docs):
log.debug('Stripping docstring for %s', func)
if not docstring:
continue
docstring_new = docstring if six.PY3 else salt.utils.data.encode(d... | [
"def",
"strip_rst",
"(",
"docs",
")",
":",
"for",
"func",
",",
"docstring",
"in",
"six",
".",
"iteritems",
"(",
"docs",
")",
":",
"log",
".",
"debug",
"(",
"'Stripping docstring for %s'",
",",
"func",
")",
"if",
"not",
"docstring",
":",
"continue",
"docs... | Strip/replace reStructuredText directives in docstrings | [
"Strip",
"/",
"replace",
"reStructuredText",
"directives",
"in",
"docstrings"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/doc.py#L16-L46 | train |
saltstack/salt | salt/utils/doc.py | parse_docstring | def parse_docstring(docstring):
'''
Parse a docstring into its parts.
Currently only parses dependencies, can be extended to parse whatever is
needed.
Parses into a dictionary:
{
'full': full docstring,
'deps': list of dependencies (empty list if none)
}
... | python | def parse_docstring(docstring):
'''
Parse a docstring into its parts.
Currently only parses dependencies, can be extended to parse whatever is
needed.
Parses into a dictionary:
{
'full': full docstring,
'deps': list of dependencies (empty list if none)
}
... | [
"def",
"parse_docstring",
"(",
"docstring",
")",
":",
"# First try with regex search for :depends:",
"ret",
"=",
"{",
"'full'",
":",
"docstring",
"}",
"regex",
"=",
"r'([ \\t]*):depends:[ \\t]+- (\\w+)[^\\n]*\\n(\\1[ \\t]+- (\\w+)[^\\n]*\\n)*'",
"match",
"=",
"re",
".",
"se... | Parse a docstring into its parts.
Currently only parses dependencies, can be extended to parse whatever is
needed.
Parses into a dictionary:
{
'full': full docstring,
'deps': list of dependencies (empty list if none)
} | [
"Parse",
"a",
"docstring",
"into",
"its",
"parts",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/doc.py#L49-L83 | train |
saltstack/salt | salt/states/boto_elasticache.py | present | def present(
name,
engine=None,
cache_node_type=None,
num_cache_nodes=None,
preferred_availability_zone=None,
port=None,
cache_parameter_group_name=None,
cache_security_group_names=None,
replication_group_id=None,
auto_minor_version_upgrade... | python | def present(
name,
engine=None,
cache_node_type=None,
num_cache_nodes=None,
preferred_availability_zone=None,
port=None,
cache_parameter_group_name=None,
cache_security_group_names=None,
replication_group_id=None,
auto_minor_version_upgrade... | [
"def",
"present",
"(",
"name",
",",
"engine",
"=",
"None",
",",
"cache_node_type",
"=",
"None",
",",
"num_cache_nodes",
"=",
"None",
",",
"preferred_availability_zone",
"=",
"None",
",",
"port",
"=",
"None",
",",
"cache_parameter_group_name",
"=",
"None",
",",... | Ensure the cache cluster exists.
name
Name of the cache cluster (cache cluster id).
engine
The name of the cache engine to be used for this cache cluster. Valid
values are memcached or redis.
cache_node_type
The compute and memory capacity of the nodes in the cache cluster... | [
"Ensure",
"the",
"cache",
"cluster",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elasticache.py#L100-L263 | train |
saltstack/salt | salt/states/boto_elasticache.py | subnet_group_present | def subnet_group_present(name, subnet_ids=None, subnet_names=None,
description=None, tags=None, region=None,
key=None, keyid=None, profile=None):
'''
Ensure ElastiCache subnet group exists.
.. versionadded:: 2015.8.0
name
The name for the Elast... | python | def subnet_group_present(name, subnet_ids=None, subnet_names=None,
description=None, tags=None, region=None,
key=None, keyid=None, profile=None):
'''
Ensure ElastiCache subnet group exists.
.. versionadded:: 2015.8.0
name
The name for the Elast... | [
"def",
"subnet_group_present",
"(",
"name",
",",
"subnet_ids",
"=",
"None",
",",
"subnet_names",
"=",
"None",
",",
"description",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
","... | Ensure ElastiCache subnet group exists.
.. versionadded:: 2015.8.0
name
The name for the ElastiCache subnet group. This value is stored as a lowercase string.
subnet_ids
A list of VPC subnet IDs for the cache subnet group. Exclusive with subnet_names.
subnet_names
A list of ... | [
"Ensure",
"ElastiCache",
"subnet",
"group",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elasticache.py#L266-L329 | train |
saltstack/salt | salt/states/boto_elasticache.py | creategroup | def creategroup(name, primary_cluster_id, replication_group_description, wait=None,
region=None, key=None, keyid=None, profile=None):
'''
Ensure the a replication group is create.
name
Name of replication group
wait
Waits for the group to be available
primary_clust... | python | def creategroup(name, primary_cluster_id, replication_group_description, wait=None,
region=None, key=None, keyid=None, profile=None):
'''
Ensure the a replication group is create.
name
Name of replication group
wait
Waits for the group to be available
primary_clust... | [
"def",
"creategroup",
"(",
"name",
",",
"primary_cluster_id",
",",
"replication_group_description",
",",
"wait",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=... | Ensure the a replication group is create.
name
Name of replication group
wait
Waits for the group to be available
primary_cluster_id
Name of the master cache node
replication_group_description
Description for the group
region
Region to connect to.
ke... | [
"Ensure",
"the",
"a",
"replication",
"group",
"is",
"create",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elasticache.py#L386-L438 | train |
saltstack/salt | salt/states/statuspage.py | _clear_dict | def _clear_dict(endpoint_props):
'''
Eliminates None entries from the features of the endpoint dict.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_val is not None
) | python | def _clear_dict(endpoint_props):
'''
Eliminates None entries from the features of the endpoint dict.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_val is not None
) | [
"def",
"_clear_dict",
"(",
"endpoint_props",
")",
":",
"return",
"dict",
"(",
"(",
"prop_name",
",",
"prop_val",
")",
"for",
"prop_name",
",",
"prop_val",
"in",
"six",
".",
"iteritems",
"(",
"endpoint_props",
")",
"if",
"prop_val",
"is",
"not",
"None",
")"... | Eliminates None entries from the features of the endpoint dict. | [
"Eliminates",
"None",
"entries",
"from",
"the",
"features",
"of",
"the",
"endpoint",
"dict",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L85-L93 | train |
saltstack/salt | salt/states/statuspage.py | _ignore_keys | def _ignore_keys(endpoint_props):
'''
Ignores some keys that might be different without any important info.
These keys are defined under _DO_NOT_COMPARE_FIELDS.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_name not in... | python | def _ignore_keys(endpoint_props):
'''
Ignores some keys that might be different without any important info.
These keys are defined under _DO_NOT_COMPARE_FIELDS.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_name not in... | [
"def",
"_ignore_keys",
"(",
"endpoint_props",
")",
":",
"return",
"dict",
"(",
"(",
"prop_name",
",",
"prop_val",
")",
"for",
"prop_name",
",",
"prop_val",
"in",
"six",
".",
"iteritems",
"(",
"endpoint_props",
")",
"if",
"prop_name",
"not",
"in",
"_DO_NOT_CO... | Ignores some keys that might be different without any important info.
These keys are defined under _DO_NOT_COMPARE_FIELDS. | [
"Ignores",
"some",
"keys",
"that",
"might",
"be",
"different",
"without",
"any",
"important",
"info",
".",
"These",
"keys",
"are",
"defined",
"under",
"_DO_NOT_COMPARE_FIELDS",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L96-L105 | train |
saltstack/salt | salt/states/statuspage.py | _unique | def _unique(list_of_dicts):
'''
Returns an unique list of dictionaries given a list that may contain duplicates.
'''
unique_list = []
for ele in list_of_dicts:
if ele not in unique_list:
unique_list.append(ele)
return unique_list | python | def _unique(list_of_dicts):
'''
Returns an unique list of dictionaries given a list that may contain duplicates.
'''
unique_list = []
for ele in list_of_dicts:
if ele not in unique_list:
unique_list.append(ele)
return unique_list | [
"def",
"_unique",
"(",
"list_of_dicts",
")",
":",
"unique_list",
"=",
"[",
"]",
"for",
"ele",
"in",
"list_of_dicts",
":",
"if",
"ele",
"not",
"in",
"unique_list",
":",
"unique_list",
".",
"append",
"(",
"ele",
")",
"return",
"unique_list"
] | Returns an unique list of dictionaries given a list that may contain duplicates. | [
"Returns",
"an",
"unique",
"list",
"of",
"dictionaries",
"given",
"a",
"list",
"that",
"may",
"contain",
"duplicates",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L108-L116 | train |
saltstack/salt | salt/states/statuspage.py | _clear_ignore | def _clear_ignore(endpoint_props):
'''
Both _clear_dict and _ignore_keys in a single iteration.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_name not in _DO_NOT_COMPARE_FIELDS and prop_val is not None
) | python | def _clear_ignore(endpoint_props):
'''
Both _clear_dict and _ignore_keys in a single iteration.
'''
return dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(endpoint_props)
if prop_name not in _DO_NOT_COMPARE_FIELDS and prop_val is not None
) | [
"def",
"_clear_ignore",
"(",
"endpoint_props",
")",
":",
"return",
"dict",
"(",
"(",
"prop_name",
",",
"prop_val",
")",
"for",
"prop_name",
",",
"prop_val",
"in",
"six",
".",
"iteritems",
"(",
"endpoint_props",
")",
"if",
"prop_name",
"not",
"in",
"_DO_NOT_C... | Both _clear_dict and _ignore_keys in a single iteration. | [
"Both",
"_clear_dict",
"and",
"_ignore_keys",
"in",
"a",
"single",
"iteration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L119-L127 | train |
saltstack/salt | salt/states/statuspage.py | _find_match | def _find_match(ele, lst):
'''
Find a matching element in a list.
'''
for _ele in lst:
for match_key in _MATCH_KEYS:
if _ele.get(match_key) == ele.get(match_key):
return ele | python | def _find_match(ele, lst):
'''
Find a matching element in a list.
'''
for _ele in lst:
for match_key in _MATCH_KEYS:
if _ele.get(match_key) == ele.get(match_key):
return ele | [
"def",
"_find_match",
"(",
"ele",
",",
"lst",
")",
":",
"for",
"_ele",
"in",
"lst",
":",
"for",
"match_key",
"in",
"_MATCH_KEYS",
":",
"if",
"_ele",
".",
"get",
"(",
"match_key",
")",
"==",
"ele",
".",
"get",
"(",
"match_key",
")",
":",
"return",
"... | Find a matching element in a list. | [
"Find",
"a",
"matching",
"element",
"in",
"a",
"list",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L140-L147 | train |
saltstack/salt | salt/states/statuspage.py | _update_on_fields | def _update_on_fields(prev_ele, new_ele):
'''
Return a dict with fields that differ between two dicts.
'''
fields_update = dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(new_ele)
if new_ele.get(prop_name) != prev_ele.get(prop_name) or prop_name in _MATCH_KEY... | python | def _update_on_fields(prev_ele, new_ele):
'''
Return a dict with fields that differ between two dicts.
'''
fields_update = dict(
(prop_name, prop_val)
for prop_name, prop_val in six.iteritems(new_ele)
if new_ele.get(prop_name) != prev_ele.get(prop_name) or prop_name in _MATCH_KEY... | [
"def",
"_update_on_fields",
"(",
"prev_ele",
",",
"new_ele",
")",
":",
"fields_update",
"=",
"dict",
"(",
"(",
"prop_name",
",",
"prop_val",
")",
"for",
"prop_name",
",",
"prop_val",
"in",
"six",
".",
"iteritems",
"(",
"new_ele",
")",
"if",
"new_ele",
".",... | Return a dict with fields that differ between two dicts. | [
"Return",
"a",
"dict",
"with",
"fields",
"that",
"differ",
"between",
"two",
"dicts",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L150-L165 | train |
saltstack/salt | salt/states/statuspage.py | _compute_diff | def _compute_diff(expected_endpoints, configured_endpoints):
'''
Compares configured endpoints with the expected configuration and returns the differences.
'''
new_endpoints = []
update_endpoints = []
remove_endpoints = []
ret = _compute_diff_ret()
# noth configured => configure with e... | python | def _compute_diff(expected_endpoints, configured_endpoints):
'''
Compares configured endpoints with the expected configuration and returns the differences.
'''
new_endpoints = []
update_endpoints = []
remove_endpoints = []
ret = _compute_diff_ret()
# noth configured => configure with e... | [
"def",
"_compute_diff",
"(",
"expected_endpoints",
",",
"configured_endpoints",
")",
":",
"new_endpoints",
"=",
"[",
"]",
"update_endpoints",
"=",
"[",
"]",
"remove_endpoints",
"=",
"[",
"]",
"ret",
"=",
"_compute_diff_ret",
"(",
")",
"# noth configured => configure... | Compares configured endpoints with the expected configuration and returns the differences. | [
"Compares",
"configured",
"endpoints",
"with",
"the",
"expected",
"configuration",
"and",
"returns",
"the",
"differences",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L168-L218 | train |
saltstack/salt | salt/states/statuspage.py | create | def create(name,
endpoint='incidents',
api_url=None,
page_id=None,
api_key=None,
api_version=None,
**kwargs):
'''
Insert a new entry under a specific endpoint.
endpoint: incidents
Insert under this specific endpoint.
page_id
... | python | def create(name,
endpoint='incidents',
api_url=None,
page_id=None,
api_key=None,
api_version=None,
**kwargs):
'''
Insert a new entry under a specific endpoint.
endpoint: incidents
Insert under this specific endpoint.
page_id
... | [
"def",
"create",
"(",
"name",
",",
"endpoint",
"=",
"'incidents'",
",",
"api_url",
"=",
"None",
",",
"page_id",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"api_version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"_default_ret",
... | Insert a new entry under a specific endpoint.
endpoint: incidents
Insert under this specific endpoint.
page_id
Page ID. Can also be specified in the config file.
api_key
API key. Can also be specified in the config file.
api_version: 1
API version. Can also be specifi... | [
"Insert",
"a",
"new",
"entry",
"under",
"a",
"specific",
"endpoint",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L225-L286 | train |
saltstack/salt | salt/states/statuspage.py | update | def update(name,
endpoint='incidents',
id=None,
api_url=None,
page_id=None,
api_key=None,
api_version=None,
**kwargs):
'''
Update attribute(s) of a specific endpoint.
id
The unique ID of the enpoint entry.
endpoint: i... | python | def update(name,
endpoint='incidents',
id=None,
api_url=None,
page_id=None,
api_key=None,
api_version=None,
**kwargs):
'''
Update attribute(s) of a specific endpoint.
id
The unique ID of the enpoint entry.
endpoint: i... | [
"def",
"update",
"(",
"name",
",",
"endpoint",
"=",
"'incidents'",
",",
"id",
"=",
"None",
",",
"api_url",
"=",
"None",
",",
"page_id",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"api_version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"r... | Update attribute(s) of a specific endpoint.
id
The unique ID of the enpoint entry.
endpoint: incidents
Endpoint name.
page_id
Page ID. Can also be specified in the config file.
api_key
API key. Can also be specified in the config file.
api_version: 1
API ... | [
"Update",
"attribute",
"(",
"s",
")",
"of",
"a",
"specific",
"endpoint",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L289-L356 | train |
saltstack/salt | salt/states/statuspage.py | delete | def delete(name,
endpoint='incidents',
id=None,
api_url=None,
page_id=None,
api_key=None,
api_version=None):
'''
Remove an entry from an endpoint.
endpoint: incidents
Request a specific endpoint.
page_id
Page ID. Can als... | python | def delete(name,
endpoint='incidents',
id=None,
api_url=None,
page_id=None,
api_key=None,
api_version=None):
'''
Remove an entry from an endpoint.
endpoint: incidents
Request a specific endpoint.
page_id
Page ID. Can als... | [
"def",
"delete",
"(",
"name",
",",
"endpoint",
"=",
"'incidents'",
",",
"id",
"=",
"None",
",",
"api_url",
"=",
"None",
",",
"page_id",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"api_version",
"=",
"None",
")",
":",
"ret",
"=",
"_default_ret",
"... | Remove an entry from an endpoint.
endpoint: incidents
Request a specific endpoint.
page_id
Page ID. Can also be specified in the config file.
api_key
API key. Can also be specified in the config file.
api_version: 1
API version. Can also be specified in the config fil... | [
"Remove",
"an",
"entry",
"from",
"an",
"endpoint",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L359-L414 | train |
saltstack/salt | salt/states/statuspage.py | managed | def managed(name,
config,
api_url=None,
page_id=None,
api_key=None,
api_version=None,
pace=_PACE,
allow_empty=False):
'''
Manage the StatusPage configuration.
config
Dictionary with the expected configuration of the... | python | def managed(name,
config,
api_url=None,
page_id=None,
api_key=None,
api_version=None,
pace=_PACE,
allow_empty=False):
'''
Manage the StatusPage configuration.
config
Dictionary with the expected configuration of the... | [
"def",
"managed",
"(",
"name",
",",
"config",
",",
"api_url",
"=",
"None",
",",
"page_id",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"api_version",
"=",
"None",
",",
"pace",
"=",
"_PACE",
",",
"allow_empty",
"=",
"False",
")",
":",
"complete_diff"... | Manage the StatusPage configuration.
config
Dictionary with the expected configuration of the StatusPage.
The main level keys of this dictionary represent the endpoint name.
If a certain endpoint does not exist in this structure, it will be ignored / not configured.
page_id
Pag... | [
"Manage",
"the",
"StatusPage",
"configuration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/statuspage.py#L417-L590 | train |
saltstack/salt | salt/states/splunk.py | present | def present(email, profile="splunk", **kwargs):
'''
Ensure a user is present
.. code-block:: yaml
ensure example test user 1:
splunk.user_present:
- realname: 'Example TestUser1'
- name: 'exampleuser'
- email: 'example@domain.com'
... | python | def present(email, profile="splunk", **kwargs):
'''
Ensure a user is present
.. code-block:: yaml
ensure example test user 1:
splunk.user_present:
- realname: 'Example TestUser1'
- name: 'exampleuser'
- email: 'example@domain.com'
... | [
"def",
"present",
"(",
"email",
",",
"profile",
"=",
"\"splunk\"",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
... | Ensure a user is present
.. code-block:: yaml
ensure example test user 1:
splunk.user_present:
- realname: 'Example TestUser1'
- name: 'exampleuser'
- email: 'example@domain.com'
- roles: ['user']
The following parameters are... | [
"Ensure",
"a",
"user",
"is",
"present"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/splunk.py#L26-L103 | train |
saltstack/salt | salt/states/splunk.py | absent | def absent(email, profile="splunk", **kwargs):
'''
Ensure a splunk user is absent
.. code-block:: yaml
ensure example test user 1:
splunk.absent:
- email: 'example@domain.com'
- name: 'exampleuser'
The following parameters are required:
email
... | python | def absent(email, profile="splunk", **kwargs):
'''
Ensure a splunk user is absent
.. code-block:: yaml
ensure example test user 1:
splunk.absent:
- email: 'example@domain.com'
- name: 'exampleuser'
The following parameters are required:
email
... | [
"def",
"absent",
"(",
"email",
",",
"profile",
"=",
"\"splunk\"",
",",
"*",
"*",
"kwargs",
")",
":",
"user_identity",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
")",
"ret",
"=",
"{",
"'name'",
":",
"user_identity",
",",
"'changes'",
":",
"{",
"}",
","... | Ensure a splunk user is absent
.. code-block:: yaml
ensure example test user 1:
splunk.absent:
- email: 'example@domain.com'
- name: 'exampleuser'
The following parameters are required:
email
This is the email of the user in splunk
name
... | [
"Ensure",
"a",
"splunk",
"user",
"is",
"absent"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/splunk.py#L106-L158 | train |
saltstack/salt | salt/states/keyboard.py | system | def system(name):
'''
Set the keyboard layout for the system
name
The keyboard layout to use
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if __salt__['keyboard.get_sys']() == name:
ret['result'] = True
ret['comme... | python | def system(name):
'''
Set the keyboard layout for the system
name
The keyboard layout to use
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if __salt__['keyboard.get_sys']() == name:
ret['result'] = True
ret['comme... | [
"def",
"system",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"__salt__",
"[",
"'keyboard.get_sys'",
"]",
"(",
")",
"==",
"name... | Set the keyboard layout for the system
name
The keyboard layout to use | [
"Set",
"the",
"keyboard",
"layout",
"for",
"the",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keyboard.py#L32-L58 | train |
saltstack/salt | salt/states/keyboard.py | xorg | def xorg(name):
'''
Set the keyboard layout for XOrg
layout
The keyboard layout to use
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if __salt__['keyboard.get_x']() == name:
ret['result'] = True
ret['comment'] = '... | python | def xorg(name):
'''
Set the keyboard layout for XOrg
layout
The keyboard layout to use
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if __salt__['keyboard.get_x']() == name:
ret['result'] = True
ret['comment'] = '... | [
"def",
"xorg",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"__salt__",
"[",
"'keyboard.get_x'",
"]",
"(",
")",
"==",
"name",
... | Set the keyboard layout for XOrg
layout
The keyboard layout to use | [
"Set",
"the",
"keyboard",
"layout",
"for",
"XOrg"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keyboard.py#L61-L87 | train |
saltstack/salt | salt/modules/win_service.py | _status_wait | def _status_wait(service_name, end_time, service_states):
'''
Helper function that will wait for the status of the service to match the
provided status before an end time expires. Used for service stop and start
.. versionadded:: 2017.7.9,2018.3.4
Args:
service_name (str):
The ... | python | def _status_wait(service_name, end_time, service_states):
'''
Helper function that will wait for the status of the service to match the
provided status before an end time expires. Used for service stop and start
.. versionadded:: 2017.7.9,2018.3.4
Args:
service_name (str):
The ... | [
"def",
"_status_wait",
"(",
"service_name",
",",
"end_time",
",",
"service_states",
")",
":",
"info_results",
"=",
"info",
"(",
"service_name",
")",
"while",
"info_results",
"[",
"'Status'",
"]",
"in",
"service_states",
"and",
"time",
".",
"time",
"(",
")",
... | Helper function that will wait for the status of the service to match the
provided status before an end time expires. Used for service stop and start
.. versionadded:: 2017.7.9,2018.3.4
Args:
service_name (str):
The name of the service
end_time (float):
A future ti... | [
"Helper",
"function",
"that",
"will",
"wait",
"for",
"the",
"status",
"of",
"the",
"service",
"to",
"match",
"the",
"provided",
"status",
"before",
"an",
"end",
"time",
"expires",
".",
"Used",
"for",
"service",
"stop",
"and",
"start"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L251-L293 | train |
saltstack/salt | salt/modules/win_service.py | _cmd_quote | def _cmd_quote(cmd):
r'''
Helper function to properly format the path to the binary for the service
Must be wrapped in double quotes to account for paths that have spaces. For
example:
``"C:\Program Files\Path\to\bin.exe"``
Args:
cmd (str): Full path to the binary
Returns:
... | python | def _cmd_quote(cmd):
r'''
Helper function to properly format the path to the binary for the service
Must be wrapped in double quotes to account for paths that have spaces. For
example:
``"C:\Program Files\Path\to\bin.exe"``
Args:
cmd (str): Full path to the binary
Returns:
... | [
"def",
"_cmd_quote",
"(",
"cmd",
")",
":",
"# Remove all single and double quotes from the beginning and the end",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'^(\\\\\"|\\').*|.*(\\\\\"|\\')$'",
")",
"while",
"pattern",
".",
"match",
"(",
"cmd",
")",
"is",
"not",
"Non... | r'''
Helper function to properly format the path to the binary for the service
Must be wrapped in double quotes to account for paths that have spaces. For
example:
``"C:\Program Files\Path\to\bin.exe"``
Args:
cmd (str): Full path to the binary
Returns:
str: Properly quoted pat... | [
"r",
"Helper",
"function",
"to",
"properly",
"format",
"the",
"path",
"to",
"the",
"binary",
"for",
"the",
"service",
"Must",
"be",
"wrapped",
"in",
"double",
"quotes",
"to",
"account",
"for",
"paths",
"that",
"have",
"spaces",
".",
"For",
"example",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L296-L317 | train |
saltstack/salt | salt/modules/win_service.py | get_enabled | def get_enabled():
'''
Return a list of enabled services. Enabled is defined as a service that is
marked to Auto Start.
Returns:
list: A list of enabled services
CLI Example:
.. code-block:: bash
salt '*' service.get_enabled
'''
raw_services = _get_services()
serv... | python | def get_enabled():
'''
Return a list of enabled services. Enabled is defined as a service that is
marked to Auto Start.
Returns:
list: A list of enabled services
CLI Example:
.. code-block:: bash
salt '*' service.get_enabled
'''
raw_services = _get_services()
serv... | [
"def",
"get_enabled",
"(",
")",
":",
"raw_services",
"=",
"_get_services",
"(",
")",
"services",
"=",
"set",
"(",
")",
"for",
"service",
"in",
"raw_services",
":",
"if",
"info",
"(",
"service",
"[",
"'ServiceName'",
"]",
")",
"[",
"'StartType'",
"]",
"in... | Return a list of enabled services. Enabled is defined as a service that is
marked to Auto Start.
Returns:
list: A list of enabled services
CLI Example:
.. code-block:: bash
salt '*' service.get_enabled | [
"Return",
"a",
"list",
"of",
"enabled",
"services",
".",
"Enabled",
"is",
"defined",
"as",
"a",
"service",
"that",
"is",
"marked",
"to",
"Auto",
"Start",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L320-L340 | train |
saltstack/salt | salt/modules/win_service.py | available | def available(name):
'''
Check if a service is available on the system.
Args:
name (str): The name of the service to check
Returns:
bool: ``True`` if the service is available, ``False`` otherwise
CLI Example:
.. code-block:: bash
salt '*' service.available <service n... | python | def available(name):
'''
Check if a service is available on the system.
Args:
name (str): The name of the service to check
Returns:
bool: ``True`` if the service is available, ``False`` otherwise
CLI Example:
.. code-block:: bash
salt '*' service.available <service n... | [
"def",
"available",
"(",
"name",
")",
":",
"for",
"service",
"in",
"get_all",
"(",
")",
":",
"if",
"name",
".",
"lower",
"(",
")",
"==",
"service",
".",
"lower",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | Check if a service is available on the system.
Args:
name (str): The name of the service to check
Returns:
bool: ``True`` if the service is available, ``False`` otherwise
CLI Example:
.. code-block:: bash
salt '*' service.available <service name> | [
"Check",
"if",
"a",
"service",
"is",
"available",
"on",
"the",
"system",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L366-L386 | train |
saltstack/salt | salt/modules/win_service.py | _get_services | def _get_services():
'''
Returns a list of all services on the system.
'''
handle_scm = win32service.OpenSCManager(
None, None, win32service.SC_MANAGER_ENUMERATE_SERVICE)
try:
services = win32service.EnumServicesStatusEx(handle_scm)
except AttributeError:
services = win3... | python | def _get_services():
'''
Returns a list of all services on the system.
'''
handle_scm = win32service.OpenSCManager(
None, None, win32service.SC_MANAGER_ENUMERATE_SERVICE)
try:
services = win32service.EnumServicesStatusEx(handle_scm)
except AttributeError:
services = win3... | [
"def",
"_get_services",
"(",
")",
":",
"handle_scm",
"=",
"win32service",
".",
"OpenSCManager",
"(",
"None",
",",
"None",
",",
"win32service",
".",
"SC_MANAGER_ENUMERATE_SERVICE",
")",
"try",
":",
"services",
"=",
"win32service",
".",
"EnumServicesStatusEx",
"(",
... | Returns a list of all services on the system. | [
"Returns",
"a",
"list",
"of",
"all",
"services",
"on",
"the",
"system",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L408-L422 | train |
saltstack/salt | salt/modules/win_service.py | get_all | def get_all():
'''
Return all installed services
Returns:
list: Returns a list of all services on the system.
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
services = _get_services()
ret = set()
for service in services:
ret.add(service['S... | python | def get_all():
'''
Return all installed services
Returns:
list: Returns a list of all services on the system.
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
services = _get_services()
ret = set()
for service in services:
ret.add(service['S... | [
"def",
"get_all",
"(",
")",
":",
"services",
"=",
"_get_services",
"(",
")",
"ret",
"=",
"set",
"(",
")",
"for",
"service",
"in",
"services",
":",
"ret",
".",
"add",
"(",
"service",
"[",
"'ServiceName'",
"]",
")",
"return",
"sorted",
"(",
"ret",
")"
... | Return all installed services
Returns:
list: Returns a list of all services on the system.
CLI Example:
.. code-block:: bash
salt '*' service.get_all | [
"Return",
"all",
"installed",
"services"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L425-L444 | train |
saltstack/salt | salt/modules/win_service.py | get_service_name | def get_service_name(*args):
'''
The Display Name is what is displayed in Windows when services.msc is
executed. Each Display Name has an associated Service Name which is the
actual name of the service. This function allows you to discover the
Service Name by returning a dictionary of Display Name... | python | def get_service_name(*args):
'''
The Display Name is what is displayed in Windows when services.msc is
executed. Each Display Name has an associated Service Name which is the
actual name of the service. This function allows you to discover the
Service Name by returning a dictionary of Display Name... | [
"def",
"get_service_name",
"(",
"*",
"args",
")",
":",
"raw_services",
"=",
"_get_services",
"(",
")",
"services",
"=",
"dict",
"(",
")",
"for",
"raw_service",
"in",
"raw_services",
":",
"if",
"args",
":",
"if",
"raw_service",
"[",
"'DisplayName'",
"]",
"i... | The Display Name is what is displayed in Windows when services.msc is
executed. Each Display Name has an associated Service Name which is the
actual name of the service. This function allows you to discover the
Service Name by returning a dictionary of Display Names and Service Names,
or filter by add... | [
"The",
"Display",
"Name",
"is",
"what",
"is",
"displayed",
"in",
"Windows",
"when",
"services",
".",
"msc",
"is",
"executed",
".",
"Each",
"Display",
"Name",
"has",
"an",
"associated",
"Service",
"Name",
"which",
"is",
"the",
"actual",
"name",
"of",
"the",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L447-L482 | train |
saltstack/salt | salt/modules/win_service.py | info | def info(name):
'''
Get information about a service on the system
Args:
name (str): The name of the service. This is not the display name. Use
``get_service_name`` to find the service name.
Returns:
dict: A dictionary containing information about the service.
CLI Examp... | python | def info(name):
'''
Get information about a service on the system
Args:
name (str): The name of the service. This is not the display name. Use
``get_service_name`` to find the service name.
Returns:
dict: A dictionary containing information about the service.
CLI Examp... | [
"def",
"info",
"(",
"name",
")",
":",
"try",
":",
"handle_scm",
"=",
"win32service",
".",
"OpenSCManager",
"(",
"None",
",",
"None",
",",
"win32service",
".",
"SC_MANAGER_CONNECT",
")",
"except",
"pywintypes",
".",
"error",
"as",
"exc",
":",
"raise",
"Comm... | Get information about a service on the system
Args:
name (str): The name of the service. This is not the display name. Use
``get_service_name`` to find the service name.
Returns:
dict: A dictionary containing information about the service.
CLI Example:
.. code-block:: bas... | [
"Get",
"information",
"about",
"a",
"service",
"on",
"the",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L485-L591 | train |
saltstack/salt | salt/modules/win_service.py | start | def start(name, timeout=90, with_deps=False, with_parents=False):
'''
Start the specified service.
.. warning::
You cannot start a disabled service in Windows. If the service is
disabled, it will be changed to ``Manual`` start.
Args:
name (str): The name of the service to start... | python | def start(name, timeout=90, with_deps=False, with_parents=False):
'''
Start the specified service.
.. warning::
You cannot start a disabled service in Windows. If the service is
disabled, it will be changed to ``Manual`` start.
Args:
name (str): The name of the service to start... | [
"def",
"start",
"(",
"name",
",",
"timeout",
"=",
"90",
",",
"with_deps",
"=",
"False",
",",
"with_parents",
"=",
"False",
")",
":",
"# Set the service to manual if disabled",
"if",
"disabled",
"(",
"name",
")",
":",
"modify",
"(",
"name",
",",
"start_type",... | Start the specified service.
.. warning::
You cannot start a disabled service in Windows. If the service is
disabled, it will be changed to ``Manual`` start.
Args:
name (str): The name of the service to start
timeout (int):
The time in seconds to wait for the servi... | [
"Start",
"the",
"specified",
"service",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L594-L653 | train |
saltstack/salt | salt/modules/win_service.py | stop | def stop(name, timeout=90, with_deps=False, with_parents=False):
'''
Stop the specified service
Args:
name (str): The name of the service to stop
timeout (int):
The time in seconds to wait for the service to stop before
returning. Default is 90 seconds
... | python | def stop(name, timeout=90, with_deps=False, with_parents=False):
'''
Stop the specified service
Args:
name (str): The name of the service to stop
timeout (int):
The time in seconds to wait for the service to stop before
returning. Default is 90 seconds
... | [
"def",
"stop",
"(",
"name",
",",
"timeout",
"=",
"90",
",",
"with_deps",
"=",
"False",
",",
"with_parents",
"=",
"False",
")",
":",
"ret",
"=",
"set",
"(",
")",
"services",
"=",
"ServiceDependencies",
"(",
"name",
",",
"get_all",
",",
"info",
")",
"s... | Stop the specified service
Args:
name (str): The name of the service to stop
timeout (int):
The time in seconds to wait for the service to stop before
returning. Default is 90 seconds
.. versionadded:: 2017.7.9,2018.3.4
with_deps (bool):
If... | [
"Stop",
"the",
"specified",
"service"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L656-L708 | train |
saltstack/salt | salt/modules/win_service.py | restart | def restart(name, timeout=90, with_deps=False, with_parents=False):
'''
Restart the named service. This issues a stop command followed by a start.
Args:
name: The name of the service to restart.
.. note::
If the name passed is ``salt-minion`` a scheduled task is
... | python | def restart(name, timeout=90, with_deps=False, with_parents=False):
'''
Restart the named service. This issues a stop command followed by a start.
Args:
name: The name of the service to restart.
.. note::
If the name passed is ``salt-minion`` a scheduled task is
... | [
"def",
"restart",
"(",
"name",
",",
"timeout",
"=",
"90",
",",
"with_deps",
"=",
"False",
",",
"with_parents",
"=",
"False",
")",
":",
"if",
"'salt-minion'",
"in",
"name",
":",
"create_win_salt_restart_task",
"(",
")",
"return",
"execute_salt_restart_task",
"(... | Restart the named service. This issues a stop command followed by a start.
Args:
name: The name of the service to restart.
.. note::
If the name passed is ``salt-minion`` a scheduled task is
created and executed to restart the salt-minion service.
timeo... | [
"Restart",
"the",
"named",
"service",
".",
"This",
"issues",
"a",
"stop",
"command",
"followed",
"by",
"a",
"start",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L711-L760 | train |
saltstack/salt | salt/modules/win_service.py | create_win_salt_restart_task | def create_win_salt_restart_task():
'''
Create a task in Windows task scheduler to enable restarting the salt-minion
Returns:
bool: ``True`` if successful, otherwise ``False``
CLI Example:
.. code-block:: bash
salt '*' service.create_win_salt_restart_task()
'''
cmd = 'cmd... | python | def create_win_salt_restart_task():
'''
Create a task in Windows task scheduler to enable restarting the salt-minion
Returns:
bool: ``True`` if successful, otherwise ``False``
CLI Example:
.. code-block:: bash
salt '*' service.create_win_salt_restart_task()
'''
cmd = 'cmd... | [
"def",
"create_win_salt_restart_task",
"(",
")",
":",
"cmd",
"=",
"'cmd'",
"args",
"=",
"'/c ping -n 3 127.0.0.1 && net stop salt-minion && net start '",
"'salt-minion'",
"return",
"__salt__",
"[",
"'task.create_task'",
"]",
"(",
"name",
"=",
"'restart-salt-minion'",
",",
... | Create a task in Windows task scheduler to enable restarting the salt-minion
Returns:
bool: ``True`` if successful, otherwise ``False``
CLI Example:
.. code-block:: bash
salt '*' service.create_win_salt_restart_task() | [
"Create",
"a",
"task",
"in",
"Windows",
"task",
"scheduler",
"to",
"enable",
"restarting",
"the",
"salt",
"-",
"minion"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L763-L787 | train |
saltstack/salt | salt/modules/win_service.py | status | def status(name, *args, **kwargs):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of th... | python | def status(name, *args, **kwargs):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of th... | [
"def",
"status",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"{",
"}",
"all_services",
"=",
"get_all",
"(",
")",
"contains_globbing",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'\\*|\\?|\\[.+\\]'",
",",
"name",
... | Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the service to check
Returns:
bool: ... | [
"Return",
"the",
"status",
"for",
"a",
"service",
".",
"If",
"the",
"name",
"contains",
"globbing",
"a",
"dict",
"mapping",
"service",
"name",
"to",
"True",
"/",
"False",
"values",
"is",
"returned",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_service.py#L806-L840 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.