partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _format_entrypoint_target | Makes a string describing the target of an EntryPoint object.
Base strongly on EntryPoint.__str__(). | salt/loader.py | def _format_entrypoint_target(ep):
'''
Makes a string describing the target of an EntryPoint object.
Base strongly on EntryPoint.__str__().
'''
s = ep.module_name
if ep.attrs:
s += ':' + '.'.join(ep.attrs)
return s | def _format_entrypoint_target(ep):
'''
Makes a string describing the target of an EntryPoint object.
Base strongly on EntryPoint.__str__().
'''
s = ep.module_name
if ep.attrs:
s += ':' + '.'.join(ep.attrs)
return s | [
"Makes",
"a",
"string",
"describing",
"the",
"target",
"of",
"an",
"EntryPoint",
"object",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L147-L156 | [
"def",
"_format_entrypoint_target",
"(",
"ep",
")",
":",
"s",
"=",
"ep",
".",
"module_name",
"if",
"ep",
".",
"attrs",
":",
"s",
"+=",
"':'",
"+",
"'.'",
".",
"join",
"(",
"ep",
".",
"attrs",
")",
"return",
"s"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | minion_mods | Load execution modules
Returns a dictionary of execution modules appropriate for the current
system by evaluating the __virtual__() function in each module.
:param dict opts: The Salt options dictionary
:param dict context: A Salt context that should be made present inside
... | salt/loader.py | def minion_mods(
opts,
context=None,
utils=None,
whitelist=None,
initial_load=False,
loaded_base_name=None,
notify=False,
static_modules=None,
proxy=None):
'''
Load execution modules
Returns a dictionary of execution modules appropriat... | def minion_mods(
opts,
context=None,
utils=None,
whitelist=None,
initial_load=False,
loaded_base_name=None,
notify=False,
static_modules=None,
proxy=None):
'''
Load execution modules
Returns a dictionary of execution modules appropriat... | [
"Load",
"execution",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L205-L287 | [
"def",
"minion_mods",
"(",
"opts",
",",
"context",
"=",
"None",
",",
"utils",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"initial_load",
"=",
"False",
",",
"loaded_base_name",
"=",
"None",
",",
"notify",
"=",
"False",
",",
"static_modules",
"=",
"N... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | raw_mod | Returns a single module loaded raw and bypassing the __virtual__ function
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
testmod = salt.loader.raw_mod(__opts__, 'test', None)
testmod['test.ping']() | salt/loader.py | def raw_mod(opts, name, functions, mod='modules'):
'''
Returns a single module loaded raw and bypassing the __virtual__ function
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
testmod = salt.loader.raw_... | def raw_mod(opts, name, functions, mod='modules'):
'''
Returns a single module loaded raw and bypassing the __virtual__ function
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
testmod = salt.loader.raw_... | [
"Returns",
"a",
"single",
"module",
"loaded",
"raw",
"and",
"bypassing",
"the",
"__virtual__",
"function"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L290-L315 | [
"def",
"raw_mod",
"(",
"opts",
",",
"name",
",",
"functions",
",",
"mod",
"=",
"'modules'",
")",
":",
"loader",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"mod",
",",
"'module'",
")",
",",
"opts",
",",
"tag",
"=",
"'rawmodule'",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | engines | Return the master services plugins | salt/loader.py | def engines(opts, functions, runners, utils, proxy=None):
'''
Return the master services plugins
'''
pack = {'__salt__': functions,
'__runners__': runners,
'__proxy__': proxy,
'__utils__': utils}
return LazyLoader(
_module_dirs(opts, 'engines'),
op... | def engines(opts, functions, runners, utils, proxy=None):
'''
Return the master services plugins
'''
pack = {'__salt__': functions,
'__runners__': runners,
'__proxy__': proxy,
'__utils__': utils}
return LazyLoader(
_module_dirs(opts, 'engines'),
op... | [
"Return",
"the",
"master",
"services",
"plugins"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L341-L354 | [
"def",
"engines",
"(",
"opts",
",",
"functions",
",",
"runners",
",",
"utils",
",",
"proxy",
"=",
"None",
")",
":",
"pack",
"=",
"{",
"'__salt__'",
":",
"functions",
",",
"'__runners__'",
":",
"runners",
",",
"'__proxy__'",
":",
"proxy",
",",
"'__utils__... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | proxy | Returns the proxy module for this salt-proxy-minion | salt/loader.py | def proxy(opts, functions=None, returners=None, whitelist=None, utils=None):
'''
Returns the proxy module for this salt-proxy-minion
'''
ret = LazyLoader(
_module_dirs(opts, 'proxy'),
opts,
tag='proxy',
pack={'__salt__': functions, '__ret__': returners, '__utils__': utils... | def proxy(opts, functions=None, returners=None, whitelist=None, utils=None):
'''
Returns the proxy module for this salt-proxy-minion
'''
ret = LazyLoader(
_module_dirs(opts, 'proxy'),
opts,
tag='proxy',
pack={'__salt__': functions, '__ret__': returners, '__utils__': utils... | [
"Returns",
"the",
"proxy",
"module",
"for",
"this",
"salt",
"-",
"proxy",
"-",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L357-L370 | [
"def",
"proxy",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"returners",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"utils",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'proxy'",
")",
",",
"opts... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | returners | Returns the returner modules | salt/loader.py | def returners(opts, functions, whitelist=None, context=None, proxy=None):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'returners', 'returner'),
opts,
tag='returner',
whitelist=whitelist,
pack={'__salt__': functions, '__context__': co... | def returners(opts, functions, whitelist=None, context=None, proxy=None):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'returners', 'returner'),
opts,
tag='returner',
whitelist=whitelist,
pack={'__salt__': functions, '__context__': co... | [
"Returns",
"the",
"returner",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L373-L383 | [
"def",
"returners",
"(",
"opts",
",",
"functions",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'returners'",
",",
"'returner'",
")",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | utils | Returns the utility modules | salt/loader.py | def utils(opts, whitelist=None, context=None, proxy=proxy):
'''
Returns the utility modules
'''
return LazyLoader(
_module_dirs(opts, 'utils', ext_type_dirs='utils_dirs'),
opts,
tag='utils',
whitelist=whitelist,
pack={'__context__': context, '__proxy__': proxy or ... | def utils(opts, whitelist=None, context=None, proxy=proxy):
'''
Returns the utility modules
'''
return LazyLoader(
_module_dirs(opts, 'utils', ext_type_dirs='utils_dirs'),
opts,
tag='utils',
whitelist=whitelist,
pack={'__context__': context, '__proxy__': proxy or ... | [
"Returns",
"the",
"utility",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L386-L396 | [
"def",
"utils",
"(",
"opts",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"proxy",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'utils'",
",",
"ext_type_dirs",
"=",
"'utils_dirs'",
")",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pillars | Returns the pillars modules | salt/loader.py | def pillars(opts, functions, context=None):
'''
Returns the pillars modules
'''
ret = LazyLoader(_module_dirs(opts, 'pillar'),
opts,
tag='pillar',
pack={'__salt__': functions,
'__context__': context,
... | def pillars(opts, functions, context=None):
'''
Returns the pillars modules
'''
ret = LazyLoader(_module_dirs(opts, 'pillar'),
opts,
tag='pillar',
pack={'__salt__': functions,
'__context__': context,
... | [
"Returns",
"the",
"pillars",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L399-L410 | [
"def",
"pillars",
"(",
"opts",
",",
"functions",
",",
"context",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'pillar'",
")",
",",
"opts",
",",
"tag",
"=",
"'pillar'",
",",
"pack",
"=",
"{",
"'__salt__'",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | tops | Returns the tops modules | salt/loader.py | def tops(opts):
'''
Returns the tops modules
'''
if 'master_tops' not in opts:
return {}
whitelist = list(opts['master_tops'].keys())
ret = LazyLoader(
_module_dirs(opts, 'tops', 'top'),
opts,
tag='top',
whitelist=whitelist,
)
return FilterDictWrap... | def tops(opts):
'''
Returns the tops modules
'''
if 'master_tops' not in opts:
return {}
whitelist = list(opts['master_tops'].keys())
ret = LazyLoader(
_module_dirs(opts, 'tops', 'top'),
opts,
tag='top',
whitelist=whitelist,
)
return FilterDictWrap... | [
"Returns",
"the",
"tops",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L413-L426 | [
"def",
"tops",
"(",
"opts",
")",
":",
"if",
"'master_tops'",
"not",
"in",
"opts",
":",
"return",
"{",
"}",
"whitelist",
"=",
"list",
"(",
"opts",
"[",
"'master_tops'",
"]",
".",
"keys",
"(",
")",
")",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wheels | Returns the wheels modules | salt/loader.py | def wheels(opts, whitelist=None, context=None):
'''
Returns the wheels modules
'''
if context is None:
context = {}
return LazyLoader(
_module_dirs(opts, 'wheel'),
opts,
tag='wheel',
whitelist=whitelist,
pack={'__context__': context},
) | def wheels(opts, whitelist=None, context=None):
'''
Returns the wheels modules
'''
if context is None:
context = {}
return LazyLoader(
_module_dirs(opts, 'wheel'),
opts,
tag='wheel',
whitelist=whitelist,
pack={'__context__': context},
) | [
"Returns",
"the",
"wheels",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L429-L441 | [
"def",
"wheels",
"(",
"opts",
",",
"whitelist",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'wheel'",
")",
",",
"opt... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | outputters | Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace | salt/loader.py | def outputters(opts):
'''
Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace
'''
ret = LazyLoader(
_module_dirs(opts, 'output', ext_type_dirs='outputter_dirs'),
opts,
ta... | def outputters(opts):
'''
Returns the outputters modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader instance, with only outputters present in the keyspace
'''
ret = LazyLoader(
_module_dirs(opts, 'output', ext_type_dirs='outputter_dirs'),
opts,
ta... | [
"Returns",
"the",
"outputters",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L444-L459 | [
"def",
"outputters",
"(",
"opts",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'output'",
",",
"ext_type_dirs",
"=",
"'outputter_dirs'",
")",
",",
"opts",
",",
"tag",
"=",
"'output'",
",",
")",
"wrapped_ret",
"=",
"FilterDict... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | auth | Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader | salt/loader.py | def auth(opts, whitelist=None):
'''
Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader
'''
return LazyLoader(
_module_dirs(opts, 'auth'),
opts,
tag='auth',
whitelist=whitelist,
pack={'__salt__': minion_mods(opts)},... | def auth(opts, whitelist=None):
'''
Returns the auth modules
:param dict opts: The Salt options dictionary
:returns: LazyLoader
'''
return LazyLoader(
_module_dirs(opts, 'auth'),
opts,
tag='auth',
whitelist=whitelist,
pack={'__salt__': minion_mods(opts)},... | [
"Returns",
"the",
"auth",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L488-L501 | [
"def",
"auth",
"(",
"opts",
",",
"whitelist",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'auth'",
")",
",",
"opts",
",",
"tag",
"=",
"'auth'",
",",
"whitelist",
"=",
"whitelist",
",",
"pack",
"=",
"{",
"'__... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | fileserver | Returns the file server modules | salt/loader.py | def fileserver(opts, backends):
'''
Returns the file server modules
'''
return LazyLoader(_module_dirs(opts, 'fileserver'),
opts,
tag='fileserver',
whitelist=backends,
pack={'__utils__': utils(opts)}) | def fileserver(opts, backends):
'''
Returns the file server modules
'''
return LazyLoader(_module_dirs(opts, 'fileserver'),
opts,
tag='fileserver',
whitelist=backends,
pack={'__utils__': utils(opts)}) | [
"Returns",
"the",
"file",
"server",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L504-L512 | [
"def",
"fileserver",
"(",
"opts",
",",
"backends",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'fileserver'",
")",
",",
"opts",
",",
"tag",
"=",
"'fileserver'",
",",
"whitelist",
"=",
"backends",
",",
"pack",
"=",
"{",
"'__u... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | roster | Returns the roster modules | salt/loader.py | def roster(opts, runner=None, utils=None, whitelist=None):
'''
Returns the roster modules
'''
return LazyLoader(
_module_dirs(opts, 'roster'),
opts,
tag='roster',
whitelist=whitelist,
pack={
'__runner__': runner,
'__utils__': utils,
... | def roster(opts, runner=None, utils=None, whitelist=None):
'''
Returns the roster modules
'''
return LazyLoader(
_module_dirs(opts, 'roster'),
opts,
tag='roster',
whitelist=whitelist,
pack={
'__runner__': runner,
'__utils__': utils,
... | [
"Returns",
"the",
"roster",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L515-L528 | [
"def",
"roster",
"(",
"opts",
",",
"runner",
"=",
"None",
",",
"utils",
"=",
"None",
",",
"whitelist",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'roster'",
")",
",",
"opts",
",",
"tag",
"=",
"'roster'",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | thorium | Load the thorium runtime modules | salt/loader.py | def thorium(opts, functions, runners):
'''
Load the thorium runtime modules
'''
pack = {'__salt__': functions, '__runner__': runners, '__context__': {}}
ret = LazyLoader(_module_dirs(opts, 'thorium'),
opts,
tag='thorium',
pack=pack)
ret.pack['__thorium__'] = r... | def thorium(opts, functions, runners):
'''
Load the thorium runtime modules
'''
pack = {'__salt__': functions, '__runner__': runners, '__context__': {}}
ret = LazyLoader(_module_dirs(opts, 'thorium'),
opts,
tag='thorium',
pack=pack)
ret.pack['__thorium__'] = r... | [
"Load",
"the",
"thorium",
"runtime",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L531-L541 | [
"def",
"thorium",
"(",
"opts",
",",
"functions",
",",
"runners",
")",
":",
"pack",
"=",
"{",
"'__salt__'",
":",
"functions",
",",
"'__runner__'",
":",
"runners",
",",
"'__context__'",
":",
"{",
"}",
"}",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"("... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | states | Returns the state modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.c... | salt/loader.py | def states(opts, functions, utils, serializers, whitelist=None, proxy=None, context=None):
'''
Returns the state modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
.... | def states(opts, functions, utils, serializers, whitelist=None, proxy=None, context=None):
'''
Returns the state modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
.... | [
"Returns",
"the",
"state",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L544-L574 | [
"def",
"states",
"(",
"opts",
",",
"functions",
",",
"utils",
",",
"serializers",
",",
"whitelist",
"=",
"None",
",",
"proxy",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"ret",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | beacons | Load the beacon modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values. | salt/loader.py | def beacons(opts, functions, context=None, proxy=None):
'''
Load the beacon modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
'''
return LazyLoader(
_mod... | def beacons(opts, functions, context=None, proxy=None):
'''
Load the beacon modules
:param dict opts: The Salt options dictionary
:param dict functions: A dictionary of minion modules, with module names as
keys and funcs as values.
'''
return LazyLoader(
_mod... | [
"Load",
"the",
"beacon",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L577-L591 | [
"def",
"beacons",
"(",
"opts",
",",
"functions",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'beacons'",
")",
",",
"opts",
",",
"tag",
"=",
"'beacons'",
",",
"pack",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | log_handlers | Returns the custom logging handler modules
:param dict opts: The Salt options dictionary | salt/loader.py | def log_handlers(opts):
'''
Returns the custom logging handler modules
:param dict opts: The Salt options dictionary
'''
ret = LazyLoader(
_module_dirs(
opts,
'log_handlers',
int_type='handlers',
base_path=os.path.join(SALT_BASE_PATH, 'log'),
... | def log_handlers(opts):
'''
Returns the custom logging handler modules
:param dict opts: The Salt options dictionary
'''
ret = LazyLoader(
_module_dirs(
opts,
'log_handlers',
int_type='handlers',
base_path=os.path.join(SALT_BASE_PATH, 'log'),
... | [
"Returns",
"the",
"custom",
"logging",
"handler",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L594-L610 | [
"def",
"log_handlers",
"(",
"opts",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'log_handlers'",
",",
"int_type",
"=",
"'handlers'",
",",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SALT_BASE_PATH",
",",
"'log'",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ssh_wrapper | Returns the custom logging handler modules | salt/loader.py | def ssh_wrapper(opts, functions=None, context=None):
'''
Returns the custom logging handler modules
'''
return LazyLoader(
_module_dirs(
opts,
'wrapper',
base_path=os.path.join(SALT_BASE_PATH, os.path.join('client', 'ssh')),
),
opts,
ta... | def ssh_wrapper(opts, functions=None, context=None):
'''
Returns the custom logging handler modules
'''
return LazyLoader(
_module_dirs(
opts,
'wrapper',
base_path=os.path.join(SALT_BASE_PATH, os.path.join('client', 'ssh')),
),
opts,
ta... | [
"Returns",
"the",
"custom",
"logging",
"handler",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L613-L631 | [
"def",
"ssh_wrapper",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'wrapper'",
",",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SALT_BASE_PA... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | render | Returns the render modules | salt/loader.py | def render(opts, functions, states=None, proxy=None, context=None):
'''
Returns the render modules
'''
if context is None:
context = {}
pack = {'__salt__': functions,
'__grains__': opts.get('grains', {}),
'__context__': context}
if states:
pack['__states... | def render(opts, functions, states=None, proxy=None, context=None):
'''
Returns the render modules
'''
if context is None:
context = {}
pack = {'__salt__': functions,
'__grains__': opts.get('grains', {}),
'__context__': context}
if states:
pack['__states... | [
"Returns",
"the",
"render",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L634-L666 | [
"def",
"render",
"(",
"opts",
",",
"functions",
",",
"states",
"=",
"None",
",",
"proxy",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"pack",
"=",
"{",
"'__salt__'",
":",
"functi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | grain_funcs | Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__) | salt/loader.py | def grain_funcs(opts, proxy=None):
'''
Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__)
'''
ret = LazyLoader(
... | def grain_funcs(opts, proxy=None):
'''
Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__)
'''
ret = LazyLoader(
... | [
"Returns",
"the",
"grain",
"functions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L669-L692 | [
"def",
"grain_funcs",
"(",
"opts",
",",
"proxy",
"=",
"None",
")",
":",
"ret",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'grains'",
",",
"'grain'",
",",
"ext_type_dirs",
"=",
"'grains_dirs'",
",",
")",
",",
"opts",
",",
"tag",
"=",
"'g... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _load_cached_grains | Returns the grains cached in cfn, or None if the cache is too old or is
corrupted. | salt/loader.py | def _load_cached_grains(opts, cfn):
'''
Returns the grains cached in cfn, or None if the cache is too old or is
corrupted.
'''
if not os.path.isfile(cfn):
log.debug('Grains cache file does not exist.')
return None
grains_cache_age = int(time.time() - os.path.getmtime(cfn))
i... | def _load_cached_grains(opts, cfn):
'''
Returns the grains cached in cfn, or None if the cache is too old or is
corrupted.
'''
if not os.path.isfile(cfn):
log.debug('Grains cache file does not exist.')
return None
grains_cache_age = int(time.time() - os.path.getmtime(cfn))
i... | [
"Returns",
"the",
"grains",
"cached",
"in",
"cfn",
"or",
"None",
"if",
"the",
"cache",
"is",
"too",
"old",
"or",
"is",
"corrupted",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L695-L729 | [
"def",
"_load_cached_grains",
"(",
"opts",
",",
"cfn",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"cfn",
")",
":",
"log",
".",
"debug",
"(",
"'Grains cache file does not exist.'",
")",
"return",
"None",
"grains_cache_age",
"=",
"int",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | grains | Return the functions for the dynamic grains and the values for the static
grains.
Since grains are computed early in the startup process, grains functions
do not have __salt__ or __proxy__ available. At proxy-minion startup,
this function is called with the proxymodule LazyLoader object so grains
... | salt/loader.py | def grains(opts, force_refresh=False, proxy=None):
'''
Return the functions for the dynamic grains and the values for the static
grains.
Since grains are computed early in the startup process, grains functions
do not have __salt__ or __proxy__ available. At proxy-minion startup,
this function ... | def grains(opts, force_refresh=False, proxy=None):
'''
Return the functions for the dynamic grains and the values for the static
grains.
Since grains are computed early in the startup process, grains functions
do not have __salt__ or __proxy__ available. At proxy-minion startup,
this function ... | [
"Return",
"the",
"functions",
"for",
"the",
"dynamic",
"grains",
"and",
"the",
"values",
"for",
"the",
"static",
"grains",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L732-L909 | [
"def",
"grains",
"(",
"opts",
",",
"force_refresh",
"=",
"False",
",",
"proxy",
"=",
"None",
")",
":",
"# Need to re-import salt.config, somehow it got lost when a minion is starting",
"import",
"salt",
".",
"config",
"# if we have no grains, lets try loading from disk (TODO: m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | call | Directly call a function inside a loader directory | salt/loader.py | def call(fun, **kwargs):
'''
Directly call a function inside a loader directory
'''
args = kwargs.get('args', [])
dirs = kwargs.get('dirs', [])
funcs = LazyLoader(
[os.path.join(SALT_BASE_PATH, 'modules')] + dirs,
None,
tag='modules',
virtual_enable=False,
)
... | def call(fun, **kwargs):
'''
Directly call a function inside a loader directory
'''
args = kwargs.get('args', [])
dirs = kwargs.get('dirs', [])
funcs = LazyLoader(
[os.path.join(SALT_BASE_PATH, 'modules')] + dirs,
None,
tag='modules',
virtual_enable=False,
)
... | [
"Directly",
"call",
"a",
"function",
"inside",
"a",
"loader",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L913-L926 | [
"def",
"call",
"(",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"kwargs",
".",
"get",
"(",
"'args'",
",",
"[",
"]",
")",
"dirs",
"=",
"kwargs",
".",
"get",
"(",
"'dirs'",
",",
"[",
"]",
")",
"funcs",
"=",
"LazyLoader",
"(",
"[",
"o... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | runner | Directly call a function inside a loader directory | salt/loader.py | def runner(opts, utils=None, context=None, whitelist=None):
'''
Directly call a function inside a loader directory
'''
if utils is None:
utils = {}
if context is None:
context = {}
ret = LazyLoader(
_module_dirs(opts, 'runners', 'runner', ext_type_dirs='runner_dirs'),
... | def runner(opts, utils=None, context=None, whitelist=None):
'''
Directly call a function inside a loader directory
'''
if utils is None:
utils = {}
if context is None:
context = {}
ret = LazyLoader(
_module_dirs(opts, 'runners', 'runner', ext_type_dirs='runner_dirs'),
... | [
"Directly",
"call",
"a",
"function",
"inside",
"a",
"loader",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L929-L946 | [
"def",
"runner",
"(",
"opts",
",",
"utils",
"=",
"None",
",",
"context",
"=",
"None",
",",
"whitelist",
"=",
"None",
")",
":",
"if",
"utils",
"is",
"None",
":",
"utils",
"=",
"{",
"}",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | sdb | Make a very small database call | salt/loader.py | def sdb(opts, functions=None, whitelist=None, utils=None):
'''
Make a very small database call
'''
if utils is None:
utils = {}
return LazyLoader(
_module_dirs(opts, 'sdb'),
opts,
tag='sdb',
pack={
'__sdb__': functions,
'__opts__': opt... | def sdb(opts, functions=None, whitelist=None, utils=None):
'''
Make a very small database call
'''
if utils is None:
utils = {}
return LazyLoader(
_module_dirs(opts, 'sdb'),
opts,
tag='sdb',
pack={
'__sdb__': functions,
'__opts__': opt... | [
"Make",
"a",
"very",
"small",
"database",
"call"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L960-L978 | [
"def",
"sdb",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"whitelist",
"=",
"None",
",",
"utils",
"=",
"None",
")",
":",
"if",
"utils",
"is",
"None",
":",
"utils",
"=",
"{",
"}",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pkgdb | Return modules for SPM's package database
.. versionadded:: 2015.8.0 | salt/loader.py | def pkgdb(opts):
'''
Return modules for SPM's package database
.. versionadded:: 2015.8.0
'''
return LazyLoader(
_module_dirs(
opts,
'pkgdb',
base_path=os.path.join(SALT_BASE_PATH, 'spm')
),
opts,
tag='pkgdb'
) | def pkgdb(opts):
'''
Return modules for SPM's package database
.. versionadded:: 2015.8.0
'''
return LazyLoader(
_module_dirs(
opts,
'pkgdb',
base_path=os.path.join(SALT_BASE_PATH, 'spm')
),
opts,
tag='pkgdb'
) | [
"Return",
"modules",
"for",
"SPM",
"s",
"package",
"database"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L981-L995 | [
"def",
"pkgdb",
"(",
"opts",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'pkgdb'",
",",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SALT_BASE_PATH",
",",
"'spm'",
")",
")",
",",
"opts",
",",
"tag",
"=",
"'pkg... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | clouds | Return the cloud functions | salt/loader.py | def clouds(opts):
'''
Return the cloud functions
'''
# Let's bring __active_provider_name__, defaulting to None, to all cloud
# drivers. This will get temporarily updated/overridden with a context
# manager when needed.
functions = LazyLoader(
_module_dirs(opts,
... | def clouds(opts):
'''
Return the cloud functions
'''
# Let's bring __active_provider_name__, defaulting to None, to all cloud
# drivers. This will get temporarily updated/overridden with a context
# manager when needed.
functions = LazyLoader(
_module_dirs(opts,
... | [
"Return",
"the",
"cloud",
"functions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1015-L1039 | [
"def",
"clouds",
"(",
"opts",
")",
":",
"# Let's bring __active_provider_name__, defaulting to None, to all cloud",
"# drivers. This will get temporarily updated/overridden with a context",
"# manager when needed.",
"functions",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | executors | Returns the executor modules | salt/loader.py | def executors(opts, functions=None, context=None, proxy=None):
'''
Returns the executor modules
'''
executors = LazyLoader(
_module_dirs(opts, 'executors', 'executor'),
opts,
tag='executor',
pack={'__salt__': functions, '__context__': context or {}, '__proxy__': proxy or ... | def executors(opts, functions=None, context=None, proxy=None):
'''
Returns the executor modules
'''
executors = LazyLoader(
_module_dirs(opts, 'executors', 'executor'),
opts,
tag='executor',
pack={'__salt__': functions, '__context__': context or {}, '__proxy__': proxy or ... | [
"Returns",
"the",
"executor",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1053-L1064 | [
"def",
"executors",
"(",
"opts",
",",
"functions",
"=",
"None",
",",
"context",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"executors",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'executors'",
",",
"'executor'",
")",
",",
"opts",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cache | Returns the returner modules | salt/loader.py | def cache(opts, serial):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'cache', 'cache'),
opts,
tag='cache',
pack={'__opts__': opts, '__context__': {'serial': serial}},
) | def cache(opts, serial):
'''
Returns the returner modules
'''
return LazyLoader(
_module_dirs(opts, 'cache', 'cache'),
opts,
tag='cache',
pack={'__opts__': opts, '__context__': {'serial': serial}},
) | [
"Returns",
"the",
"returner",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1067-L1076 | [
"def",
"cache",
"(",
"opts",
",",
"serial",
")",
":",
"return",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",",
"'cache'",
",",
"'cache'",
")",
",",
"opts",
",",
"tag",
"=",
"'cache'",
",",
"pack",
"=",
"{",
"'__opts__'",
":",
"opts",
",",
"'__c... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _inject_into_mod | Inject a variable into a module. This is used to inject "globals" like
``__salt__``, ``__pillar``, or ``grains``.
Instead of injecting the value directly, a ``ThreadLocalProxy`` is created.
If such a proxy is already present under the specified name, it is updated
with the new value. This update only a... | salt/loader.py | def _inject_into_mod(mod, name, value, force_lock=False):
'''
Inject a variable into a module. This is used to inject "globals" like
``__salt__``, ``__pillar``, or ``grains``.
Instead of injecting the value directly, a ``ThreadLocalProxy`` is created.
If such a proxy is already present under the sp... | def _inject_into_mod(mod, name, value, force_lock=False):
'''
Inject a variable into a module. This is used to inject "globals" like
``__salt__``, ``__pillar``, or ``grains``.
Instead of injecting the value directly, a ``ThreadLocalProxy`` is created.
If such a proxy is already present under the sp... | [
"Inject",
"a",
"variable",
"into",
"a",
"module",
".",
"This",
"is",
"used",
"to",
"inject",
"globals",
"like",
"__salt__",
"__pillar",
"or",
"grains",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1096-L1155 | [
"def",
"_inject_into_mod",
"(",
"mod",
",",
"name",
",",
"value",
",",
"force_lock",
"=",
"False",
")",
":",
"old_value",
"=",
"getattr",
"(",
"mod",
",",
"name",
",",
"None",
")",
"# We use a double-checked locking scheme in order to avoid taking the lock",
"# when... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | global_injector_decorator | Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject | salt/loader.py | def global_injector_decorator(inject_globals):
'''
Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject
'''
def inner_decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
... | def global_injector_decorator(inject_globals):
'''
Decorator used by the LazyLoader to inject globals into a function at
execute time.
globals
Dictionary with global variables to inject
'''
def inner_decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
... | [
"Decorator",
"used",
"by",
"the",
"LazyLoader",
"to",
"inject",
"globals",
"into",
"a",
"function",
"at",
"execute",
"time",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L2044-L2058 | [
"def",
"global_injector_decorator",
"(",
"inject_globals",
")",
":",
"def",
"inner_decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"salt",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader.missing_fun_string | Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False | salt/loader.py | def missing_fun_string(self, function_name):
'''
Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False
'''
mod_name = function_name.split('.')[0]
if mod_name in self.loaded_modules:
return '\'{0}\'... | def missing_fun_string(self, function_name):
'''
Return the error string for a missing function.
This can range from "not available' to "__virtual__" returned False
'''
mod_name = function_name.split('.')[0]
if mod_name in self.loaded_modules:
return '\'{0}\'... | [
"Return",
"the",
"error",
"string",
"for",
"a",
"missing",
"function",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1348-L1366 | [
"def",
"missing_fun_string",
"(",
"self",
",",
"function_name",
")",
":",
"mod_name",
"=",
"function_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"if",
"mod_name",
"in",
"self",
".",
"loaded_modules",
":",
"return",
"'\\'{0}\\' is not available.'",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._refresh_file_mapping | refresh the mapping of the FS on disk | salt/loader.py | def _refresh_file_mapping(self):
'''
refresh the mapping of the FS on disk
'''
# map of suffix to description for imp
if self.opts.get('cython_enable', True) is True:
try:
global pyximport
pyximport = __import__('pyximport') # pylint: ... | def _refresh_file_mapping(self):
'''
refresh the mapping of the FS on disk
'''
# map of suffix to description for imp
if self.opts.get('cython_enable', True) is True:
try:
global pyximport
pyximport = __import__('pyximport') # pylint: ... | [
"refresh",
"the",
"mapping",
"of",
"the",
"FS",
"on",
"disk"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1368-L1520 | [
"def",
"_refresh_file_mapping",
"(",
"self",
")",
":",
"# map of suffix to description for imp",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'cython_enable'",
",",
"True",
")",
"is",
"True",
":",
"try",
":",
"global",
"pyximport",
"pyximport",
"=",
"__import__"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader.clear | Clear the dict | salt/loader.py | def clear(self):
'''
Clear the dict
'''
with self._lock:
super(LazyLoader, self).clear() # clear the lazy loader
self.loaded_files = set()
self.missing_modules = {}
self.loaded_modules = {}
# if we have been loaded before, lets... | def clear(self):
'''
Clear the dict
'''
with self._lock:
super(LazyLoader, self).clear() # clear the lazy loader
self.loaded_files = set()
self.missing_modules = {}
self.loaded_modules = {}
# if we have been loaded before, lets... | [
"Clear",
"the",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1522-L1535 | [
"def",
"clear",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"super",
"(",
"LazyLoader",
",",
"self",
")",
".",
"clear",
"(",
")",
"# clear the lazy loader",
"self",
".",
"loaded_files",
"=",
"set",
"(",
")",
"self",
".",
"missing_modules",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader.__prep_mod_opts | Strip out of the opts any logger instance | salt/loader.py | def __prep_mod_opts(self, opts):
'''
Strip out of the opts any logger instance
'''
if '__grains__' not in self.pack:
grains = opts.get('grains', {})
if isinstance(grains, ThreadLocalProxy):
grains = ThreadLocalProxy.unproxy(grains)
se... | def __prep_mod_opts(self, opts):
'''
Strip out of the opts any logger instance
'''
if '__grains__' not in self.pack:
grains = opts.get('grains', {})
if isinstance(grains, ThreadLocalProxy):
grains = ThreadLocalProxy.unproxy(grains)
se... | [
"Strip",
"out",
"of",
"the",
"opts",
"any",
"logger",
"instance"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1537-L1564 | [
"def",
"__prep_mod_opts",
"(",
"self",
",",
"opts",
")",
":",
"if",
"'__grains__'",
"not",
"in",
"self",
".",
"pack",
":",
"grains",
"=",
"opts",
".",
"get",
"(",
"'grains'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"grains",
",",
"ThreadLocalProxy... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._iter_files | Iterate over all file_mapping files in order of closeness to mod_name | salt/loader.py | def _iter_files(self, mod_name):
'''
Iterate over all file_mapping files in order of closeness to mod_name
'''
# do we have an exact match?
if mod_name in self.file_mapping:
yield mod_name
# do we have a partial match?
for k in self.file_mapping:
... | def _iter_files(self, mod_name):
'''
Iterate over all file_mapping files in order of closeness to mod_name
'''
# do we have an exact match?
if mod_name in self.file_mapping:
yield mod_name
# do we have a partial match?
for k in self.file_mapping:
... | [
"Iterate",
"over",
"all",
"file_mapping",
"files",
"in",
"order",
"of",
"closeness",
"to",
"mod_name"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1566-L1582 | [
"def",
"_iter_files",
"(",
"self",
",",
"mod_name",
")",
":",
"# do we have an exact match?",
"if",
"mod_name",
"in",
"self",
".",
"file_mapping",
":",
"yield",
"mod_name",
"# do we have a partial match?",
"for",
"k",
"in",
"self",
".",
"file_mapping",
":",
"if",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._load | Load a single item if you have it | salt/loader.py | def _load(self, key):
'''
Load a single item if you have it
'''
# if the key doesn't have a '.' then it isn't valid for this mod dict
if not isinstance(key, six.string_types):
raise KeyError('The key must be a string.')
if '.' not in key:
raise Key... | def _load(self, key):
'''
Load a single item if you have it
'''
# if the key doesn't have a '.' then it isn't valid for this mod dict
if not isinstance(key, six.string_types):
raise KeyError('The key must be a string.')
if '.' not in key:
raise Key... | [
"Load",
"a",
"single",
"item",
"if",
"you",
"have",
"it"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1851-L1902 | [
"def",
"_load",
"(",
"self",
",",
"key",
")",
":",
"# if the key doesn't have a '.' then it isn't valid for this mod dict",
"if",
"not",
"isinstance",
"(",
"key",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"KeyError",
"(",
"'The key must be a string.'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._load_all | Load all of them | salt/loader.py | def _load_all(self):
'''
Load all of them
'''
with self._lock:
for name in self.file_mapping:
if name in self.loaded_files or name in self.missing_modules:
continue
self._load_module(name)
self.loaded = True | def _load_all(self):
'''
Load all of them
'''
with self._lock:
for name in self.file_mapping:
if name in self.loaded_files or name in self.missing_modules:
continue
self._load_module(name)
self.loaded = True | [
"Load",
"all",
"of",
"them"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1904-L1914 | [
"def",
"_load_all",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"for",
"name",
"in",
"self",
".",
"file_mapping",
":",
"if",
"name",
"in",
"self",
".",
"loaded_files",
"or",
"name",
"in",
"self",
".",
"missing_modules",
":",
"continue",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._apply_outputter | Apply the __outputter__ variable to the functions | salt/loader.py | def _apply_outputter(self, func, mod):
'''
Apply the __outputter__ variable to the functions
'''
if hasattr(mod, '__outputter__'):
outp = mod.__outputter__
if func.__name__ in outp:
func.__outputter__ = outp[func.__name__] | def _apply_outputter(self, func, mod):
'''
Apply the __outputter__ variable to the functions
'''
if hasattr(mod, '__outputter__'):
outp = mod.__outputter__
if func.__name__ in outp:
func.__outputter__ = outp[func.__name__] | [
"Apply",
"the",
"__outputter__",
"variable",
"to",
"the",
"functions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1921-L1928 | [
"def",
"_apply_outputter",
"(",
"self",
",",
"func",
",",
"mod",
")",
":",
"if",
"hasattr",
"(",
"mod",
",",
"'__outputter__'",
")",
":",
"outp",
"=",
"mod",
".",
"__outputter__",
"if",
"func",
".",
"__name__",
"in",
"outp",
":",
"func",
".",
"__output... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | LazyLoader._process_virtual | Given a loaded module and its default name determine its virtual name
This function returns a tuple. The first value will be either True or
False and will indicate if the module should be loaded or not (i.e. if
it threw and exception while processing its __virtual__ function). The
secon... | salt/loader.py | def _process_virtual(self, mod, module_name, virtual_func='__virtual__'):
'''
Given a loaded module and its default name determine its virtual name
This function returns a tuple. The first value will be either True or
False and will indicate if the module should be loaded or not (i.e. i... | def _process_virtual(self, mod, module_name, virtual_func='__virtual__'):
'''
Given a loaded module and its default name determine its virtual name
This function returns a tuple. The first value will be either True or
False and will indicate if the module should be loaded or not (i.e. i... | [
"Given",
"a",
"loaded",
"module",
"and",
"its",
"default",
"name",
"determine",
"its",
"virtual",
"name"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1930-L2041 | [
"def",
"_process_virtual",
"(",
"self",
",",
"mod",
",",
"module_name",
",",
"virtual_func",
"=",
"'__virtual__'",
")",
":",
"# The __virtual__ function will return either a True or False value.",
"# If it returns a True value it can also set a module level attribute",
"# named __vir... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get | Get an individual DMI string from SMBIOS info
string
The string to fetch. DMIdecode supports:
- ``bios-vendor``
- ``bios-version``
- ``bios-release-date``
- ``system-manufacturer``
- ``system-product-name``
- ``system-version``
- ``syste... | salt/modules/smbios.py | def get(string, clean=True):
'''
Get an individual DMI string from SMBIOS info
string
The string to fetch. DMIdecode supports:
- ``bios-vendor``
- ``bios-version``
- ``bios-release-date``
- ``system-manufacturer``
- ``system-product-name``
... | def get(string, clean=True):
'''
Get an individual DMI string from SMBIOS info
string
The string to fetch. DMIdecode supports:
- ``bios-vendor``
- ``bios-version``
- ``bios-release-date``
- ``system-manufacturer``
- ``system-product-name``
... | [
"Get",
"an",
"individual",
"DMI",
"string",
"from",
"SMBIOS",
"info"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L41-L89 | [
"def",
"get",
"(",
"string",
",",
"clean",
"=",
"True",
")",
":",
"val",
"=",
"_dmidecoder",
"(",
"'-s {0}'",
".",
"format",
"(",
"string",
")",
")",
".",
"strip",
"(",
")",
"# Cleanup possible comments in strings.",
"val",
"=",
"'\\n'",
".",
"join",
"("... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | records | Return DMI records from SMBIOS
type
Return only records of type(s)
The SMBIOS specification defines the following DMI types:
==== ======================================
Type Information
==== ======================================
0 BIOS
1 System
... | salt/modules/smbios.py | def records(rec_type=None, fields=None, clean=True):
'''
Return DMI records from SMBIOS
type
Return only records of type(s)
The SMBIOS specification defines the following DMI types:
==== ======================================
Type Information
==== ===============... | def records(rec_type=None, fields=None, clean=True):
'''
Return DMI records from SMBIOS
type
Return only records of type(s)
The SMBIOS specification defines the following DMI types:
==== ======================================
Type Information
==== ===============... | [
"Return",
"DMI",
"records",
"from",
"SMBIOS"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L92-L167 | [
"def",
"records",
"(",
"rec_type",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"clean",
"=",
"True",
")",
":",
"if",
"rec_type",
"is",
"None",
":",
"smbios",
"=",
"_dmi_parse",
"(",
"_dmidecoder",
"(",
")",
",",
"clean",
",",
"fields",
")",
"else",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dmi_parse | Structurize DMI records into a nice list
Optionally trash bogus entries and filter output | salt/modules/smbios.py | def _dmi_parse(data, clean=True, fields=None):
'''
Structurize DMI records into a nice list
Optionally trash bogus entries and filter output
'''
dmi = []
# Detect & split Handle records
dmi_split = re.compile('(handle [0-9]x[0-9a-f]+[^\n]+)\n', re.MULTILINE+re.IGNORECASE)
dmi_raw = iter... | def _dmi_parse(data, clean=True, fields=None):
'''
Structurize DMI records into a nice list
Optionally trash bogus entries and filter output
'''
dmi = []
# Detect & split Handle records
dmi_split = re.compile('(handle [0-9]x[0-9a-f]+[^\n]+)\n', re.MULTILINE+re.IGNORECASE)
dmi_raw = iter... | [
"Structurize",
"DMI",
"records",
"into",
"a",
"nice",
"list",
"Optionally",
"trash",
"bogus",
"entries",
"and",
"filter",
"output"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L170-L207 | [
"def",
"_dmi_parse",
"(",
"data",
",",
"clean",
"=",
"True",
",",
"fields",
"=",
"None",
")",
":",
"dmi",
"=",
"[",
"]",
"# Detect & split Handle records",
"dmi_split",
"=",
"re",
".",
"compile",
"(",
"'(handle [0-9]x[0-9a-f]+[^\\n]+)\\n'",
",",
"re",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dmi_data | Parse the raw DMIdecode output of a single handle
into a nice dict | salt/modules/smbios.py | def _dmi_data(dmi_raw, clean, fields):
'''
Parse the raw DMIdecode output of a single handle
into a nice dict
'''
dmi_data = {}
key = None
key_data = [None, []]
for line in dmi_raw:
if re.match(r'\t[^\s]+', line):
# Finish previous key
if key is not None:... | def _dmi_data(dmi_raw, clean, fields):
'''
Parse the raw DMIdecode output of a single handle
into a nice dict
'''
dmi_data = {}
key = None
key_data = [None, []]
for line in dmi_raw:
if re.match(r'\t[^\s]+', line):
# Finish previous key
if key is not None:... | [
"Parse",
"the",
"raw",
"DMIdecode",
"output",
"of",
"a",
"single",
"handle",
"into",
"a",
"nice",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L210-L259 | [
"def",
"_dmi_data",
"(",
"dmi_raw",
",",
"clean",
",",
"fields",
")",
":",
"dmi_data",
"=",
"{",
"}",
"key",
"=",
"None",
"key_data",
"=",
"[",
"None",
",",
"[",
"]",
"]",
"for",
"line",
"in",
"dmi_raw",
":",
"if",
"re",
".",
"match",
"(",
"r'\\t... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dmi_cast | Simple caster thingy for trying to fish out at least ints & lists from strings | salt/modules/smbios.py | def _dmi_cast(key, val, clean=True):
'''
Simple caster thingy for trying to fish out at least ints & lists from strings
'''
if clean and not _dmi_isclean(key, val):
return
elif not re.match(r'serial|part|asset|product', key, flags=re.IGNORECASE):
if ',' in val:
val = [el.... | def _dmi_cast(key, val, clean=True):
'''
Simple caster thingy for trying to fish out at least ints & lists from strings
'''
if clean and not _dmi_isclean(key, val):
return
elif not re.match(r'serial|part|asset|product', key, flags=re.IGNORECASE):
if ',' in val:
val = [el.... | [
"Simple",
"caster",
"thingy",
"for",
"trying",
"to",
"fish",
"out",
"at",
"least",
"ints",
"&",
"lists",
"from",
"strings"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L262-L277 | [
"def",
"_dmi_cast",
"(",
"key",
",",
"val",
",",
"clean",
"=",
"True",
")",
":",
"if",
"clean",
"and",
"not",
"_dmi_isclean",
"(",
"key",
",",
"val",
")",
":",
"return",
"elif",
"not",
"re",
".",
"match",
"(",
"r'serial|part|asset|product'",
",",
"key"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _dmidecoder | Call DMIdecode | salt/modules/smbios.py | def _dmidecoder(args=None):
'''
Call DMIdecode
'''
dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios'])
if not args:
out = salt.modules.cmdmod._run_quiet(dmidecoder)
else:
out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args))
return out | def _dmidecoder(args=None):
'''
Call DMIdecode
'''
dmidecoder = salt.utils.path.which_bin(['dmidecode', 'smbios'])
if not args:
out = salt.modules.cmdmod._run_quiet(dmidecoder)
else:
out = salt.modules.cmdmod._run_quiet('{0} {1}'.format(dmidecoder, args))
return out | [
"Call",
"DMIdecode"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smbios.py#L316-L327 | [
"def",
"_dmidecoder",
"(",
"args",
"=",
"None",
")",
":",
"dmidecoder",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which_bin",
"(",
"[",
"'dmidecode'",
",",
"'smbios'",
"]",
")",
"if",
"not",
"args",
":",
"out",
"=",
"salt",
".",
"modules",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltYamlSafeLoader.construct_mapping | Build the mapping for YAML | salt/utils/yamlloader.py | def construct_mapping(self, node, deep=False):
'''
Build the mapping for YAML
'''
if not isinstance(node, MappingNode):
raise ConstructorError(
None,
None,
'expected a mapping node, but found {0}'.format(node.id),
... | def construct_mapping(self, node, deep=False):
'''
Build the mapping for YAML
'''
if not isinstance(node, MappingNode):
raise ConstructorError(
None,
None,
'expected a mapping node, but found {0}'.format(node.id),
... | [
"Build",
"the",
"mapping",
"for",
"YAML"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L72-L105 | [
"def",
"construct_mapping",
"(",
"self",
",",
"node",
",",
"deep",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"MappingNode",
")",
":",
"raise",
"ConstructorError",
"(",
"None",
",",
"None",
",",
"'expected a mapping node, but found {0... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltYamlSafeLoader.construct_scalar | Verify integers and pass them in correctly is they are declared
as octal | salt/utils/yamlloader.py | def construct_scalar(self, node):
'''
Verify integers and pass them in correctly is they are declared
as octal
'''
if node.tag == 'tag:yaml.org,2002:int':
if node.value == '0':
pass
elif node.value.startswith('0') and not node.value.startsw... | def construct_scalar(self, node):
'''
Verify integers and pass them in correctly is they are declared
as octal
'''
if node.tag == 'tag:yaml.org,2002:int':
if node.value == '0':
pass
elif node.value.startswith('0') and not node.value.startsw... | [
"Verify",
"integers",
"and",
"pass",
"them",
"in",
"correctly",
"is",
"they",
"are",
"declared",
"as",
"octal"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/yamlloader.py#L107-L121 | [
"def",
"construct_scalar",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"tag",
"==",
"'tag:yaml.org,2002:int'",
":",
"if",
"node",
".",
"value",
"==",
"'0'",
":",
"pass",
"elif",
"node",
".",
"value",
".",
"startswith",
"(",
"'0'",
")",
"and"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ip_address | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Address or IPv6Address obje... | salt/ext/ipaddress.py | def ip_address(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An... | def ip_address(address):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP address. Either IPv4 or
IPv6 addresses may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L93-L120 | [
"def",
"ip_address",
"(",
"address",
")",
":",
"try",
":",
"return",
"IPv4Address",
"(",
"address",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6Address",
"(",
"address",
")",
"except",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ip_network | Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP network. Either IPv4 or
IPv6 networks may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns:
An IPv4Network or IPv6Network objec... | salt/ext/ipaddress.py | def ip_network(address, strict=True):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP network. Either IPv4 or
IPv6 networks may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns... | def ip_network(address, strict=True):
"""Take an IP string/int and return an object of the correct type.
Args:
address: A string or integer, the IP network. Either IPv4 or
IPv6 networks may be supplied; integers less than 2**32 will
be considered to be IPv4 by default.
Returns... | [
"Take",
"an",
"IP",
"string",
"/",
"int",
"and",
"return",
"an",
"object",
"of",
"the",
"correct",
"type",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L123-L150 | [
"def",
"ip_network",
"(",
"address",
",",
"strict",
"=",
"True",
")",
":",
"try",
":",
"return",
"IPv4Network",
"(",
"address",
",",
"strict",
")",
"except",
"(",
"AddressValueError",
",",
"NetmaskValueError",
")",
":",
"pass",
"try",
":",
"return",
"IPv6N... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _split_optional_netmask | Helper to split the netmask and raise AddressValueError if needed | salt/ext/ipaddress.py | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = str(address).split('/')
if len(addr) > 2:
raise AddressValueError("Only one '/' permitted in %r" % address)
return addr | [
"Helper",
"to",
"split",
"the",
"netmask",
"and",
"raise",
"AddressValueError",
"if",
"needed"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L224-L229 | [
"def",
"_split_optional_netmask",
"(",
"address",
")",
":",
"addr",
"=",
"str",
"(",
"address",
")",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"addr",
")",
">",
"2",
":",
"raise",
"AddressValueError",
"(",
"\"Only one '/' permitted in %r\"",
"%",
"a... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _count_righthand_zero_bits | Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number. | salt/ext/ipaddress.py | def _count_righthand_zero_bits(number, bits):
"""Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number.
"""
if number == 0:
return... | def _count_righthand_zero_bits(number, bits):
"""Count the number of zero bits on the right hand side.
Args:
number: an integer.
bits: maximum number of bits to count.
Returns:
The number of zero bits on the right hand side of the number.
"""
if number == 0:
return... | [
"Count",
"the",
"number",
"of",
"zero",
"bits",
"on",
"the",
"right",
"hand",
"side",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L251-L268 | [
"def",
"_count_righthand_zero_bits",
"(",
"number",
",",
"bits",
")",
":",
"if",
"number",
"==",
"0",
":",
"return",
"bits",
"for",
"i",
"in",
"range",
"(",
"bits",
")",
":",
"if",
"(",
"number",
">>",
"i",
")",
"&",
"1",
":",
"return",
"i",
"# All... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _collapse_addresses_recursive | Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collapse_addresses_recursive([ip1, ip2, ip3, ip4]) ->
... | salt/ext/ipaddress.py | def _collapse_addresses_recursive(addresses):
"""Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collaps... | def _collapse_addresses_recursive(addresses):
"""Loops through the addresses, collapsing concurrent netblocks.
Example:
ip1 = IPv4Network('192.0.2.0/26')
ip2 = IPv4Network('192.0.2.64/26')
ip3 = IPv4Network('192.0.2.128/26')
ip4 = IPv4Network('192.0.2.192/26')
_collaps... | [
"Loops",
"through",
"the",
"addresses",
"collapsing",
"concurrent",
"netblocks",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L327-L372 | [
"def",
"_collapse_addresses_recursive",
"(",
"addresses",
")",
":",
"while",
"True",
":",
"last_addr",
"=",
"None",
"ret_array",
"=",
"[",
"]",
"optimized",
"=",
"False",
"for",
"cur_addr",
"in",
"addresses",
":",
"if",
"not",
"ret_array",
":",
"last_addr",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | collapse_addresses | Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network or IPv6Network objects.
Returns:
... | salt/ext/ipaddress.py | def collapse_addresses(addresses):
"""Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network... | def collapse_addresses(addresses):
"""Collapse a list of IP objects.
Example:
collapse_addresses([IPv4Network('192.0.2.0/25'),
IPv4Network('192.0.2.128/25')]) ->
[IPv4Network('192.0.2.0/24')]
Args:
addresses: An iterator of IPv4Network... | [
"Collapse",
"a",
"list",
"of",
"IP",
"objects",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L375-L429 | [
"def",
"collapse_addresses",
"(",
"addresses",
")",
":",
"i",
"=",
"0",
"addrs",
"=",
"[",
"]",
"ips",
"=",
"[",
"]",
"nets",
"=",
"[",
"]",
"# split IP addresses and networks",
"for",
"ip",
"in",
"addresses",
":",
"if",
"isinstance",
"(",
"ip",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _IPAddressBase._prefix_from_ip_int | Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & ones | salt/ext/ipaddress.py | def _prefix_from_ip_int(self, ip_int):
"""Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & ... | def _prefix_from_ip_int(self, ip_int):
"""Return prefix length from the bitwise netmask.
Args:
ip_int: An integer, the netmask in expanded bitwise format
Returns:
An integer, the prefix length.
Raises:
ValueError: If the input intermingles zeroes & ... | [
"Return",
"prefix",
"length",
"from",
"the",
"bitwise",
"netmask",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L548-L570 | [
"def",
"_prefix_from_ip_int",
"(",
"self",
",",
"ip_int",
")",
":",
"trailing_zeroes",
"=",
"_count_righthand_zero_bits",
"(",
"ip_int",
",",
"self",
".",
"_max_prefixlen",
")",
"prefixlen",
"=",
"self",
".",
"_max_prefixlen",
"-",
"trailing_zeroes",
"leading_ones",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _IPAddressBase._prefix_from_prefix_string | Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask | salt/ext/ipaddress.py | def _prefix_from_prefix_string(self, prefixlen_str):
"""Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask... | def _prefix_from_prefix_string(self, prefixlen_str):
"""Return prefix length from a numeric string
Args:
prefixlen_str: The string to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask... | [
"Return",
"prefix",
"length",
"from",
"a",
"numeric",
"string"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L576-L598 | [
"def",
"_prefix_from_prefix_string",
"(",
"self",
",",
"prefixlen_str",
")",
":",
"# int allows a leading +/- as well as surrounding whitespace,",
"# so we ensure that isn't the case",
"if",
"not",
"_BaseV4",
".",
"_DECIMAL_DIGITS",
".",
"issuperset",
"(",
"prefixlen_str",
")",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _IPAddressBase._prefix_from_ip_string | Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmask/hostmask | salt/ext/ipaddress.py | def _prefix_from_ip_string(self, ip_str):
"""Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmas... | def _prefix_from_ip_string(self, ip_str):
"""Turn a netmask/hostmask string into a prefix length
Args:
ip_str: The netmask/hostmask to be converted
Returns:
An integer, the prefix length.
Raises:
NetmaskValueError: If the input is not a valid netmas... | [
"Turn",
"a",
"netmask",
"/",
"hostmask",
"string",
"into",
"a",
"prefix",
"length"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L600-L631 | [
"def",
"_prefix_from_ip_string",
"(",
"self",
",",
"ip_str",
")",
":",
"# Parse the netmask/hostmask like an IP address.",
"try",
":",
"ip_int",
"=",
"self",
".",
"_ip_int_from_string",
"(",
"ip_str",
")",
"except",
"AddressValueError",
":",
"self",
".",
"_report_inva... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseNetwork.subnets | The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
prefixlen_diff: An integer, the amount the prefix length
... | salt/ext/ipaddress.py | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
pre... | def subnets(self, prefixlen_diff=1, new_prefix=None):
"""The subnets which join to make the current subnet.
In the case that self contains only one IP
(self._prefixlen == 32 for IPv4 or self._prefixlen == 128
for IPv6), yield an iterator with just ourself.
Args:
pre... | [
"The",
"subnets",
"which",
"join",
"to",
"make",
"the",
"current",
"subnet",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L967-L1027 | [
"def",
"subnets",
"(",
"self",
",",
"prefixlen_diff",
"=",
"1",
",",
"new_prefix",
"=",
"None",
")",
":",
"if",
"self",
".",
"_prefixlen",
"==",
"self",
".",
"_max_prefixlen",
":",
"yield",
"self",
"return",
"if",
"new_prefix",
"is",
"not",
"None",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseNetwork.supernet | The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of 3, a supernet with a
/21 netmask is returned.
... | salt/ext/ipaddress.py | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of ... | def supernet(self, prefixlen_diff=1, new_prefix=None):
"""The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by. For example, given a
/24 network and a prefixlen_diff of ... | [
"The",
"supernet",
"containing",
"the",
"current",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1029-L1068 | [
"def",
"supernet",
"(",
"self",
",",
"prefixlen_diff",
"=",
"1",
",",
"new_prefix",
"=",
"None",
")",
":",
"if",
"self",
".",
"_prefixlen",
"==",
"0",
":",
"return",
"self",
"if",
"new_prefix",
"is",
"not",
"None",
":",
"if",
"new_prefix",
">",
"self",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseV4._ip_int_from_string | Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address. | salt/ext/ipaddress.py | def _ip_int_from_string(self, ip_str):
"""Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
... | def _ip_int_from_string(self, ip_str):
"""Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
... | [
"Turn",
"the",
"given",
"IP",
"string",
"into",
"an",
"integer",
"for",
"comparison",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1176-L1199 | [
"def",
"_ip_int_from_string",
"(",
"self",
",",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
":",
"raise",
"AddressValueError",
"(",
"'Address cannot be empty'",
")",
"octets",
"=",
"ip_str",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"octets",
")",
"!... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseV4._parse_octet | Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255]. | salt/ext/ipaddress.py | def _parse_octet(self, octet_str):
"""Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255].
"""
... | def _parse_octet(self, octet_str):
"""Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255].
"""
... | [
"Convert",
"a",
"decimal",
"octet",
"into",
"an",
"integer",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1201-L1235 | [
"def",
"_parse_octet",
"(",
"self",
",",
"octet_str",
")",
":",
"if",
"not",
"octet_str",
":",
"raise",
"ValueError",
"(",
"\"Empty octet not permitted\"",
")",
"# Whitelist the characters, since int() allows a lot of bizarre stuff.",
"if",
"not",
"self",
".",
"_DECIMAL_D... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseV4._is_valid_netmask | Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask. | salt/ext/ipaddress.py | def _is_valid_netmask(self, netmask):
"""Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask.
"""
mask = n... | def _is_valid_netmask(self, netmask):
"""Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask.
"""
mask = n... | [
"Verify",
"that",
"the",
"netmask",
"is",
"valid",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1249-L1278 | [
"def",
"_is_valid_netmask",
"(",
"self",
",",
"netmask",
")",
":",
"mask",
"=",
"netmask",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"mask",
")",
"==",
"4",
":",
"try",
":",
"for",
"x",
"in",
"mask",
":",
"if",
"int",
"(",
"x",
")",
"not... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | IPv4Address.is_private | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry. | salt/ext/ipaddress.py | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8')... | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8')... | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"private",
"networks",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1377-L1398 | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"(",
"self",
"in",
"IPv4Network",
"(",
"'0.0.0.0/8'",
")",
"or",
"self",
"in",
"IPv4Network",
"(",
"'10.0.0.0/8'",
")",
"or",
"self",
"in",
"IPv4Network",
"(",
"'127.0.0.0/8'",
")",
"or",
"self",
"in",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _BaseV6._explode_shorthand_ip_string | Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address. | salt/ext/ipaddress.py | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = str(self.network_address)
... | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = str(self.network_address)
... | [
"Expand",
"a",
"shortened",
"IPv6",
"address",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1847-L1869 | [
"def",
"_explode_shorthand_ip_string",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"IPv6Network",
")",
":",
"ip_str",
"=",
"str",
"(",
"self",
".",
"network_address",
")",
"elif",
"isinstance",
"(",
"self",
",",
"IPv6Interface",
")",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | IPv6Address.is_reserved | Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges. | salt/ext/ipaddress.py | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
"""
reserved_networks = [IPv6Network('::/8'), IPv6Network('100::/8'),
... | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
"""
reserved_networks = [IPv6Network('::/8'), IPv6Network('100::/8'),
... | [
"Test",
"if",
"the",
"address",
"is",
"otherwise",
"IETF",
"reserved",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1948-L1965 | [
"def",
"is_reserved",
"(",
"self",
")",
":",
"reserved_networks",
"=",
"[",
"IPv6Network",
"(",
"'::/8'",
")",
",",
"IPv6Network",
"(",
"'100::/8'",
")",
",",
"IPv6Network",
"(",
"'200::/7'",
")",
",",
"IPv6Network",
"(",
"'400::/6'",
")",
",",
"IPv6Network"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | IPv6Address.is_private | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry. | salt/ext/ipaddress.py | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
"""
return (self in IPv6Network('::1/128') or
self in IPv6Network('::/128') or
... | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
"""
return (self in IPv6Network('::1/128') or
self in IPv6Network('::/128') or
... | [
"Test",
"if",
"this",
"address",
"is",
"allocated",
"for",
"private",
"networks",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L1994-L2011 | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"(",
"self",
"in",
"IPv6Network",
"(",
"'::1/128'",
")",
"or",
"self",
"in",
"IPv6Network",
"(",
"'::/128'",
")",
"or",
"self",
"in",
"IPv6Network",
"(",
"'::ffff:0:0/96'",
")",
"or",
"self",
"in",
"I... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | IPv6Network.hosts | Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address. | salt/ext/ipaddress.py | def hosts(self):
"""Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
"""
network = int(self.network_address)
broadcast = int(self.broadcast_address)
for x in long_range(1, bro... | def hosts(self):
"""Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
"""
network = int(self.network_address)
broadcast = int(self.broadcast_address)
for x in long_range(1, bro... | [
"Generate",
"Iterator",
"over",
"usable",
"hosts",
"in",
"a",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/ipaddress.py#L2250-L2260 | [
"def",
"hosts",
"(",
"self",
")",
":",
"network",
"=",
"int",
"(",
"self",
".",
"network_address",
")",
"broadcast",
"=",
"int",
"(",
"self",
".",
"broadcast_address",
")",
"for",
"x",
"in",
"long_range",
"(",
"1",
",",
"broadcast",
"-",
"network",
"+"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _to_list | Convert snetinfo object to list | salt/beacons/network_info.py | def _to_list(obj):
'''
Convert snetinfo object to list
'''
ret = {}
for attr in __attrs:
if hasattr(obj, attr):
ret[attr] = getattr(obj, attr)
return ret | def _to_list(obj):
'''
Convert snetinfo object to list
'''
ret = {}
for attr in __attrs:
if hasattr(obj, attr):
ret[attr] = getattr(obj, attr)
return ret | [
"Convert",
"snetinfo",
"object",
"to",
"list"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L33-L42 | [
"def",
"_to_list",
"(",
"obj",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"attr",
"in",
"__attrs",
":",
"if",
"hasattr",
"(",
"obj",
",",
"attr",
")",
":",
"ret",
"[",
"attr",
"]",
"=",
"getattr",
"(",
"obj",
",",
"attr",
")",
"return",
"ret"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | validate | Validate the beacon configuration | salt/beacons/network_info.py | def validate(config):
'''
Validate the beacon configuration
'''
VALID_ITEMS = [
'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
'packets_recv', 'errin', 'errout', 'dropin',
'dropout'
]
# Configuration for load beacon should be a list of dicts
if not isinstance(c... | def validate(config):
'''
Validate the beacon configuration
'''
VALID_ITEMS = [
'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
'packets_recv', 'errin', 'errout', 'dropin',
'dropout'
]
# Configuration for load beacon should be a list of dicts
if not isinstance(c... | [
"Validate",
"the",
"beacon",
"configuration"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L51-L78 | [
"def",
"validate",
"(",
"config",
")",
":",
"VALID_ITEMS",
"=",
"[",
"'type'",
",",
"'bytes_sent'",
",",
"'bytes_recv'",
",",
"'packets_sent'",
",",
"'packets_recv'",
",",
"'errin'",
",",
"'errout'",
",",
"'dropin'",
",",
"'dropout'",
"]",
"# Configuration for l... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | beacon | Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
- interfaces:
... | salt/beacons/network_info.py | def beacon(config):
'''
Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
... | def beacon(config):
'''
Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
... | [
"Emit",
"the",
"network",
"statistics",
"of",
"this",
"host",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/network_info.py#L81-L166 | [
"def",
"beacon",
"(",
"config",
")",
":",
"ret",
"=",
"[",
"]",
"_config",
"=",
"{",
"}",
"list",
"(",
"map",
"(",
"_config",
".",
"update",
",",
"config",
")",
")",
"log",
".",
"debug",
"(",
"'psutil.net_io_counters %s'",
",",
"psutil",
".",
"net_io... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status | Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status | salt/modules/apcups.py | def status():
'''
Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status
'''
ret = {}
apcaccess = _check_apcaccess()
res = __salt__['cmd.run_all'](apcaccess)
retcode = res['retcode']
if retcode != 0:
ret['Error'] = 'Something with wron... | def status():
'''
Return apcaccess output
CLI Example:
.. code-block:: bash
salt '*' apcups.status
'''
ret = {}
apcaccess = _check_apcaccess()
res = __salt__['cmd.run_all'](apcaccess)
retcode = res['retcode']
if retcode != 0:
ret['Error'] = 'Something with wron... | [
"Return",
"apcaccess",
"output"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L42-L64 | [
"def",
"status",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"apcaccess",
"=",
"_check_apcaccess",
"(",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"apcaccess",
")",
"retcode",
"=",
"res",
"[",
"'retcode'",
"]",
"if",
"retcode",
"!=",
"0",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status_load | Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load | salt/modules/apcups.py | def status_load():
'''
Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load
'''
data = status()
if 'LOADPCT' in data:
load = data['LOADPCT'].split()
if load[1].lower() == 'percent':
return float(load[0])
return {'Error': 'Load ... | def status_load():
'''
Return load
CLI Example:
.. code-block:: bash
salt '*' apcups.status_load
'''
data = status()
if 'LOADPCT' in data:
load = data['LOADPCT'].split()
if load[1].lower() == 'percent':
return float(load[0])
return {'Error': 'Load ... | [
"Return",
"load"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L67-L83 | [
"def",
"status_load",
"(",
")",
":",
"data",
"=",
"status",
"(",
")",
"if",
"'LOADPCT'",
"in",
"data",
":",
"load",
"=",
"data",
"[",
"'LOADPCT'",
"]",
".",
"split",
"(",
")",
"if",
"load",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"==",
"'percent'"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status_charge | Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge | salt/modules/apcups.py | def status_charge():
'''
Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge
'''
data = status()
if 'BCHARGE' in data:
charge = data['BCHARGE'].split()
if charge[1].lower() == 'percent':
return float(charge[0])
ret... | def status_charge():
'''
Return battery charge
CLI Example:
.. code-block:: bash
salt '*' apcups.status_charge
'''
data = status()
if 'BCHARGE' in data:
charge = data['BCHARGE'].split()
if charge[1].lower() == 'percent':
return float(charge[0])
ret... | [
"Return",
"battery",
"charge"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apcups.py#L86-L102 | [
"def",
"status_charge",
"(",
")",
":",
"data",
"=",
"status",
"(",
")",
"if",
"'BCHARGE'",
"in",
"data",
":",
"charge",
"=",
"data",
"[",
"'BCHARGE'",
"]",
".",
"split",
"(",
")",
"if",
"charge",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"==",
"'per... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | coredump_configured | Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False`` to enable
or disable core dumps.
Note that ESXi requires that the core dump m... | salt/states/esxi.py | def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500):
'''
Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False``... | def coredump_configured(name, enabled, dump_ip, host_vnic='vmk0', dump_port=6500):
'''
Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False``... | [
"Ensures",
"a",
"host",
"s",
"core",
"dump",
"configuration",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L139-L274 | [
"def",
"coredump_configured",
"(",
"name",
",",
"enabled",
",",
"dump_ip",
",",
"host_vnic",
"=",
"'vmk0'",
",",
"dump_port",
"=",
"6500",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | password_present | Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
changes dictionary will always be populated.
The u... | salt/states/esxi.py | def password_present(name, password):
'''
Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
chang... | def password_present(name, password):
'''
Ensures the given password is set on the ESXi host. Passwords cannot be obtained from
host, so if a password is set in this state, the ``vsphere.update_host_password``
function will always run (except when using test=True functionality) and the state's
chang... | [
"Ensures",
"the",
"given",
"password",
"is",
"set",
"on",
"the",
"ESXi",
"host",
".",
"Passwords",
"cannot",
"be",
"obtained",
"from",
"host",
"so",
"if",
"a",
"password",
"is",
"set",
"in",
"this",
"state",
"the",
"vsphere",
".",
"update_host_password",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L277-L323 | [
"def",
"password_present",
"(",
"name",
",",
"password",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"'old'",
":",
"'unknown'",
",",
"'new'",
":",
"'********'",
"}",
",",
"'comment'",
":",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ntp_configured | Ensures a host's NTP server configuration such as setting NTP servers, ensuring the
NTP daemon is running or stopped, or restarting the NTP daemon for the ESXi host.
name
Name of the state.
service_running
Ensures the running state of the ntp daemon for the host. Boolean value where
... | salt/states/esxi.py | def ntp_configured(name,
service_running,
ntp_servers=None,
service_policy=None,
service_restart=False,
update_datetime=False):
'''
Ensures a host's NTP server configuration such as setting NTP servers, ensuring the
... | def ntp_configured(name,
service_running,
ntp_servers=None,
service_policy=None,
service_restart=False,
update_datetime=False):
'''
Ensures a host's NTP server configuration such as setting NTP servers, ensuring the
... | [
"Ensures",
"a",
"host",
"s",
"NTP",
"server",
"configuration",
"such",
"as",
"setting",
"NTP",
"servers",
"ensuring",
"the",
"NTP",
"daemon",
"is",
"running",
"or",
"stopped",
"or",
"restarting",
"the",
"NTP",
"daemon",
"for",
"the",
"ESXi",
"host",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L326-L497 | [
"def",
"ntp_configured",
"(",
"name",
",",
"service_running",
",",
"ntp_servers",
"=",
"None",
",",
"service_policy",
"=",
"None",
",",
"service_restart",
"=",
"False",
",",
"update_datetime",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vmotion_configured | Configures a host's VMotion properties such as enabling VMotion and setting
the device VirtualNic that VMotion will use.
name
Name of the state.
enabled
Ensures whether or not VMotion should be enabled on a host as a boolean
value where ``True`` indicates that VMotion should be ena... | salt/states/esxi.py | def vmotion_configured(name, enabled, device='vmk0'):
'''
Configures a host's VMotion properties such as enabling VMotion and setting
the device VirtualNic that VMotion will use.
name
Name of the state.
enabled
Ensures whether or not VMotion should be enabled on a host as a boolean... | def vmotion_configured(name, enabled, device='vmk0'):
'''
Configures a host's VMotion properties such as enabling VMotion and setting
the device VirtualNic that VMotion will use.
name
Name of the state.
enabled
Ensures whether or not VMotion should be enabled on a host as a boolean... | [
"Configures",
"a",
"host",
"s",
"VMotion",
"properties",
"such",
"as",
"enabling",
"VMotion",
"and",
"setting",
"the",
"device",
"VirtualNic",
"that",
"VMotion",
"will",
"use",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L500-L569 | [
"def",
"vmotion_configured",
"(",
"name",
",",
"enabled",
",",
"device",
"=",
"'vmk0'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"esxi_cmd",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vsan_configured | Configures a host's VSAN properties such as enabling or disabling VSAN, or
adding VSAN-eligible disks to the VSAN system for the host.
name
Name of the state.
enabled
Ensures whether or not VSAN should be enabled on a host as a boolean
value where ``True`` indicates that VSAN shoul... | salt/states/esxi.py | def vsan_configured(name, enabled, add_disks_to_vsan=False):
'''
Configures a host's VSAN properties such as enabling or disabling VSAN, or
adding VSAN-eligible disks to the VSAN system for the host.
name
Name of the state.
enabled
Ensures whether or not VSAN should be enabled on a... | def vsan_configured(name, enabled, add_disks_to_vsan=False):
'''
Configures a host's VSAN properties such as enabling or disabling VSAN, or
adding VSAN-eligible disks to the VSAN system for the host.
name
Name of the state.
enabled
Ensures whether or not VSAN should be enabled on a... | [
"Configures",
"a",
"host",
"s",
"VSAN",
"properties",
"such",
"as",
"enabling",
"or",
"disabling",
"VSAN",
"or",
"adding",
"VSAN",
"-",
"eligible",
"disks",
"to",
"the",
"VSAN",
"system",
"for",
"the",
"host",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L572-L666 | [
"def",
"vsan_configured",
"(",
"name",
",",
"enabled",
",",
"add_disks_to_vsan",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"esxi_cmd... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ssh_configured | Manage the SSH configuration for a host including whether or not SSH is running or
the presence of a given SSH key. Note: Only one ssh key can be uploaded for root.
Uploading a second key will replace any existing key.
name
Name of the state.
service_running
Ensures whether or not the ... | salt/states/esxi.py | def ssh_configured(name,
service_running,
ssh_key=None,
ssh_key_file=None,
service_policy=None,
service_restart=False,
certificate_verify=False):
'''
Manage the SSH configuration for a host includin... | def ssh_configured(name,
service_running,
ssh_key=None,
ssh_key_file=None,
service_policy=None,
service_restart=False,
certificate_verify=False):
'''
Manage the SSH configuration for a host includin... | [
"Manage",
"the",
"SSH",
"configuration",
"for",
"a",
"host",
"including",
"whether",
"or",
"not",
"SSH",
"is",
"running",
"or",
"the",
"presence",
"of",
"a",
"given",
"SSH",
"key",
".",
"Note",
":",
"Only",
"one",
"ssh",
"key",
"can",
"be",
"uploaded",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L669-L866 | [
"def",
"ssh_configured",
"(",
"name",
",",
"service_running",
",",
"ssh_key",
"=",
"None",
",",
"ssh_key_file",
"=",
"None",
",",
"service_policy",
"=",
"None",
",",
"service_restart",
"=",
"False",
",",
"certificate_verify",
"=",
"False",
")",
":",
"ret",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | syslog_configured | Ensures the specified syslog configuration parameters. By default,
this state will reset the syslog service after any new or changed
parameters are set successfully.
name
Name of the state.
syslog_configs
Name of parameter to set (corresponds to the command line switch for
esxc... | salt/states/esxi.py | def syslog_configured(name,
syslog_configs,
firewall=True,
reset_service=True,
reset_syslog_config=False,
reset_configs=None):
'''
Ensures the specified syslog configuration parameters. By default,
... | def syslog_configured(name,
syslog_configs,
firewall=True,
reset_service=True,
reset_syslog_config=False,
reset_configs=None):
'''
Ensures the specified syslog configuration parameters. By default,
... | [
"Ensures",
"the",
"specified",
"syslog",
"configuration",
"parameters",
".",
"By",
"default",
"this",
"state",
"will",
"reset",
"the",
"syslog",
"service",
"after",
"any",
"new",
"or",
"changed",
"parameters",
"are",
"set",
"successfully",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L869-L1025 | [
"def",
"syslog_configured",
"(",
"name",
",",
"syslog_configs",
",",
"firewall",
"=",
"True",
",",
"reset_service",
"=",
"True",
",",
"reset_syslog_config",
"=",
"False",
",",
"reset_configs",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | diskgroups_configured | Configures the disk groups to use for vsan.
This function will do the following:
1. Check whether or not all disks in the diskgroup spec exist, and raises
and errors if they do not.
2. Create diskgroups with the correct disk configurations if diskgroup
(identified by the cache disk canonica... | salt/states/esxi.py | def diskgroups_configured(name, diskgroups, erase_disks=False):
'''
Configures the disk groups to use for vsan.
This function will do the following:
1. Check whether or not all disks in the diskgroup spec exist, and raises
and errors if they do not.
2. Create diskgroups with the correct di... | def diskgroups_configured(name, diskgroups, erase_disks=False):
'''
Configures the disk groups to use for vsan.
This function will do the following:
1. Check whether or not all disks in the diskgroup spec exist, and raises
and errors if they do not.
2. Create diskgroups with the correct di... | [
"Configures",
"the",
"disk",
"groups",
"to",
"use",
"for",
"vsan",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L1030-L1300 | [
"def",
"diskgroups_configured",
"(",
"name",
",",
"diskgroups",
",",
"erase_disks",
"=",
"False",
")",
":",
"proxy_details",
"=",
"__salt__",
"[",
"'esxi.get_details'",
"]",
"(",
")",
"hostname",
"=",
"proxy_details",
"[",
"'host'",
"]",
"if",
"not",
"proxy_de... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | host_cache_configured | Configures the host cache used for swapping.
It will do the following:
1. Checks if backing disk exists
2. Creates the VMFS datastore if doesn't exist (datastore partition will be
created and use the entire disk)
3. Raises an error if ``dedicated_backing_disk`` is ``True`` and partitions
... | salt/states/esxi.py | def host_cache_configured(name, enabled, datastore, swap_size='100%',
dedicated_backing_disk=False,
erase_backing_disk=False):
'''
Configures the host cache used for swapping.
It will do the following:
1. Checks if backing disk exists
2. Creates... | def host_cache_configured(name, enabled, datastore, swap_size='100%',
dedicated_backing_disk=False,
erase_backing_disk=False):
'''
Configures the host cache used for swapping.
It will do the following:
1. Checks if backing disk exists
2. Creates... | [
"Configures",
"the",
"host",
"cache",
"used",
"for",
"swapping",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxi.py#L1305-L1594 | [
"def",
"host_cache_configured",
"(",
"name",
",",
"enabled",
",",
"datastore",
",",
"swap_size",
"=",
"'100%'",
",",
"dedicated_backing_disk",
"=",
"False",
",",
"erase_backing_disk",
"=",
"False",
")",
":",
"log",
".",
"trace",
"(",
"'enabled = %s'",
",",
"en... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | hostname | Ensures that the hostname is set to the specified value.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
hostname(str): The hostname of the server.
SLS Example:
.. code-block:: yaml
set_name:
cimc.hostname:
- hostname: foobar | salt/states/cimc.py | def hostname(name, hostname=None):
'''
Ensures that the hostname is set to the specified value.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
hostname(str): The hostname of the server.
SLS Example:
.. code-block:: yaml
set_name:
cimc.hos... | def hostname(name, hostname=None):
'''
Ensures that the hostname is set to the specified value.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
hostname(str): The hostname of the server.
SLS Example:
.. code-block:: yaml
set_name:
cimc.hos... | [
"Ensures",
"that",
"the",
"hostname",
"is",
"set",
"to",
"the",
"specified",
"value",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L46-L100 | [
"def",
"hostname",
"(",
"name",
",",
"hostname",
"=",
"None",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"current_name",
"=",
"__salt__",
"[",
"'cimc.get_hostname'",
"]",
"(",
")",
"req_change",
"=",
"False",
"try",
":",
"if",
"current_name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | logging_levels | Ensures that the logging levels are set on the device. The logging levels
must match the following options: emergency, alert, critical, error, warning,
notice, informational, debug.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
remote(str): The logging level for SYS... | salt/states/cimc.py | def logging_levels(name, remote=None, local=None):
'''
Ensures that the logging levels are set on the device. The logging levels
must match the following options: emergency, alert, critical, error, warning,
notice, informational, debug.
.. versionadded:: 2019.2.0
name: The name of the module f... | def logging_levels(name, remote=None, local=None):
'''
Ensures that the logging levels are set on the device. The logging levels
must match the following options: emergency, alert, critical, error, warning,
notice, informational, debug.
.. versionadded:: 2019.2.0
name: The name of the module f... | [
"Ensures",
"that",
"the",
"logging",
"levels",
"are",
"set",
"on",
"the",
"device",
".",
"The",
"logging",
"levels",
"must",
"match",
"the",
"following",
"options",
":",
"emergency",
"alert",
"critical",
"error",
"warning",
"notice",
"informational",
"debug",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L103-L165 | [
"def",
"logging_levels",
"(",
"name",
",",
"remote",
"=",
"None",
",",
"local",
"=",
"None",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"syslog_conf",
"=",
"__salt__",
"[",
"'cimc.get_syslog_settings'",
"]",
"(",
")",
"req_change",
"=",
"False... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ntp | Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four
NTP servers will be reviewed. Any entries past four will be ignored.
name: The name of the module function to execute.
servers(str, list): The IP address or FQDN of the NTP servers.
SLS... | salt/states/cimc.py | def ntp(name, servers):
'''
Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four
NTP servers will be reviewed. Any entries past four will be ignored.
name: The name of the module function to execute.
servers(str, list): The IP address ... | def ntp(name, servers):
'''
Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four
NTP servers will be reviewed. Any entries past four will be ignored.
name: The name of the module function to execute.
servers(str, list): The IP address ... | [
"Ensures",
"that",
"the",
"NTP",
"servers",
"are",
"configured",
".",
"Servers",
"are",
"provided",
"as",
"an",
"individual",
"string",
"or",
"list",
"format",
".",
"Only",
"four",
"NTP",
"servers",
"will",
"be",
"reviewed",
".",
"Any",
"entries",
"past",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L168-L247 | [
"def",
"ntp",
"(",
"name",
",",
"servers",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"ntp_servers",
"=",
"[",
"''",
",",
"''",
",",
"''",
",",
"''",
"]",
"# Parse our server arguments",
"if",
"isinstance",
"(",
"servers",
",",
"list",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | power_configuration | Ensures that the power configuration is configured on the system. This is
only available on some C-Series servers.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
policy(str): The action to be taken when chassis power is restored after
an unexpected power loss. This c... | salt/states/cimc.py | def power_configuration(name, policy=None, delayType=None, delayValue=None):
'''
Ensures that the power configuration is configured on the system. This is
only available on some C-Series servers.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
policy(str): The act... | def power_configuration(name, policy=None, delayType=None, delayValue=None):
'''
Ensures that the power configuration is configured on the system. This is
only available on some C-Series servers.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
policy(str): The act... | [
"Ensures",
"that",
"the",
"power",
"configuration",
"is",
"configured",
"on",
"the",
"system",
".",
"This",
"is",
"only",
"available",
"on",
"some",
"C",
"-",
"Series",
"servers",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L250-L348 | [
"def",
"power_configuration",
"(",
"name",
",",
"policy",
"=",
"None",
",",
"delayType",
"=",
"None",
",",
"delayValue",
"=",
"None",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"power_conf",
"=",
"__salt__",
"[",
"'cimc.get_power_configuration'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | syslog | Ensures that the syslog servers are set to the specified values. A value of None will be ignored.
name: The name of the module function to execute.
primary(str): The IP address or FQDN of the primary syslog server.
secondary(str): The IP address or FQDN of the secondary syslog server.
SLS Example:
... | salt/states/cimc.py | def syslog(name, primary=None, secondary=None):
'''
Ensures that the syslog servers are set to the specified values. A value of None will be ignored.
name: The name of the module function to execute.
primary(str): The IP address or FQDN of the primary syslog server.
secondary(str): The IP address... | def syslog(name, primary=None, secondary=None):
'''
Ensures that the syslog servers are set to the specified values. A value of None will be ignored.
name: The name of the module function to execute.
primary(str): The IP address or FQDN of the primary syslog server.
secondary(str): The IP address... | [
"Ensures",
"that",
"the",
"syslog",
"servers",
"are",
"set",
"to",
"the",
"specified",
"values",
".",
"A",
"value",
"of",
"None",
"will",
"be",
"ignored",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L351-L434 | [
"def",
"syslog",
"(",
"name",
",",
"primary",
"=",
"None",
",",
"secondary",
"=",
"None",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"conf",
"=",
"__salt__",
"[",
"'cimc.get_syslog'",
"]",
"(",
")",
"req_change",
"=",
"False",
"if",
"prima... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | user | Ensures that a user is configured on the device. Due to being unable to
verify the user password. This is a forced operation.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
id(int): The user ID slot on the device.
user(str): The username of the user.
priv(str):... | salt/states/cimc.py | def user(name, id='', user='', priv='', password='', status='active'):
'''
Ensures that a user is configured on the device. Due to being unable to
verify the user password. This is a forced operation.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
id(int): The us... | def user(name, id='', user='', priv='', password='', status='active'):
'''
Ensures that a user is configured on the device. Due to being unable to
verify the user password. This is a forced operation.
.. versionadded:: 2019.2.0
name: The name of the module function to execute.
id(int): The us... | [
"Ensures",
"that",
"a",
"user",
"is",
"configured",
"on",
"the",
"device",
".",
"Due",
"to",
"being",
"unable",
"to",
"verify",
"the",
"user",
"password",
".",
"This",
"is",
"a",
"forced",
"operation",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cimc.py#L437-L503 | [
"def",
"user",
"(",
"name",
",",
"id",
"=",
"''",
",",
"user",
"=",
"''",
",",
"priv",
"=",
"''",
",",
"password",
"=",
"''",
",",
"status",
"=",
"'active'",
")",
":",
"ret",
"=",
"_default_ret",
"(",
"name",
")",
"user_conf",
"=",
"__salt__",
"[... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | init | This function gets called when the proxy starts up. For
login
the protocol and port are cached. | salt/proxy/esxcluster.py | def init(opts):
'''
This function gets called when the proxy starts up. For
login
the protocol and port are cached.
'''
log.debug('Initting esxcluster proxy module in process %s', os.getpid())
log.debug('Validating esxcluster proxy input')
schema = EsxclusterProxySchema.serialize()
l... | def init(opts):
'''
This function gets called when the proxy starts up. For
login
the protocol and port are cached.
'''
log.debug('Initting esxcluster proxy module in process %s', os.getpid())
log.debug('Validating esxcluster proxy input')
schema = EsxclusterProxySchema.serialize()
l... | [
"This",
"function",
"gets",
"called",
"when",
"the",
"proxy",
"starts",
"up",
".",
"For",
"login",
"the",
"protocol",
"and",
"port",
"are",
"cached",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/esxcluster.py#L197-L257 | [
"def",
"init",
"(",
"opts",
")",
":",
"log",
".",
"debug",
"(",
"'Initting esxcluster proxy module in process %s'",
",",
"os",
".",
"getpid",
"(",
")",
")",
"log",
".",
"debug",
"(",
"'Validating esxcluster proxy input'",
")",
"schema",
"=",
"EsxclusterProxySchema... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | find_credentials | Cycle through all the possible credentials and return the first one that
works. | salt/proxy/esxcluster.py | def find_credentials():
'''
Cycle through all the possible credentials and return the first one that
works.
'''
# if the username and password were already found don't fo though the
# connection process again
if 'username' in DETAILS and 'password' in DETAILS:
return DETAILS['userna... | def find_credentials():
'''
Cycle through all the possible credentials and return the first one that
works.
'''
# if the username and password were already found don't fo though the
# connection process again
if 'username' in DETAILS and 'password' in DETAILS:
return DETAILS['userna... | [
"Cycle",
"through",
"all",
"the",
"possible",
"credentials",
"and",
"return",
"the",
"first",
"one",
"that",
"works",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/esxcluster.py#L281-L302 | [
"def",
"find_credentials",
"(",
")",
":",
"# if the username and password were already found don't fo though the",
"# connection process again",
"if",
"'username'",
"in",
"DETAILS",
"and",
"'password'",
"in",
"DETAILS",
":",
"return",
"DETAILS",
"[",
"'username'",
"]",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | targets | Return the targets from the flat yaml file, checks opts for location but
defaults to /etc/salt/roster | salt/roster/flat.py | def targets(tgt, tgt_type='glob', **kwargs):
'''
Return the targets from the flat yaml file, checks opts for location but
defaults to /etc/salt/roster
'''
template = get_roster_file(__opts__)
rend = salt.loader.render(__opts__, {})
raw = compile_template(template,
... | def targets(tgt, tgt_type='glob', **kwargs):
'''
Return the targets from the flat yaml file, checks opts for location but
defaults to /etc/salt/roster
'''
template = get_roster_file(__opts__)
rend = salt.loader.render(__opts__, {})
raw = compile_template(template,
... | [
"Return",
"the",
"targets",
"from",
"the",
"flat",
"yaml",
"file",
"checks",
"opts",
"for",
"location",
"but",
"defaults",
"to",
"/",
"etc",
"/",
"salt",
"/",
"roster"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/roster/flat.py#L18-L36 | [
"def",
"targets",
"(",
"tgt",
",",
"tgt_type",
"=",
"'glob'",
",",
"*",
"*",
"kwargs",
")",
":",
"template",
"=",
"get_roster_file",
"(",
"__opts__",
")",
"rend",
"=",
"salt",
".",
"loader",
".",
"render",
"(",
"__opts__",
",",
"{",
"}",
")",
"raw",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltKey.run | Execute salt-key | salt/cli/key.py | def run(self):
'''
Execute salt-key
'''
import salt.key
self.parse_args()
self.setup_logfile_logger()
verify_log(self.config)
key = salt.key.KeyCLI(self.config)
if check_user(self.config['user']):
key.run() | def run(self):
'''
Execute salt-key
'''
import salt.key
self.parse_args()
self.setup_logfile_logger()
verify_log(self.config)
key = salt.key.KeyCLI(self.config)
if check_user(self.config['user']):
key.run() | [
"Execute",
"salt",
"-",
"key"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/key.py#L14-L26 | [
"def",
"run",
"(",
"self",
")",
":",
"import",
"salt",
".",
"key",
"self",
".",
"parse_args",
"(",
")",
"self",
".",
"setup_logfile_logger",
"(",
")",
"verify_log",
"(",
"self",
".",
"config",
")",
"key",
"=",
"salt",
".",
"key",
".",
"KeyCLI",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get | Get a decrypted secret from the tISMd API | salt/sdb/tism.py | def get(key, service=None, profile=None): # pylint: disable=W0613
'''
Get a decrypted secret from the tISMd API
'''
if not profile.get('url') or not profile.get('token'):
raise SaltConfigurationError("url and/or token missing from the tism sdb profile")
request = {"token": profile['token'... | def get(key, service=None, profile=None): # pylint: disable=W0613
'''
Get a decrypted secret from the tISMd API
'''
if not profile.get('url') or not profile.get('token'):
raise SaltConfigurationError("url and/or token missing from the tism sdb profile")
request = {"token": profile['token'... | [
"Get",
"a",
"decrypted",
"secret",
"from",
"the",
"tISMd",
"API"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/tism.py#L53-L78 | [
"def",
"get",
"(",
"key",
",",
"service",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=W0613",
"if",
"not",
"profile",
".",
"get",
"(",
"'url'",
")",
"or",
"not",
"profile",
".",
"get",
"(",
"'token'",
")",
":",
"raise",
"Sa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ext_pillar | Execute queries against POSTGRES, merge and return as a dict | salt/pillar/postgres.py | def ext_pillar(minion_id,
pillar,
*args,
**kwargs):
'''
Execute queries against POSTGRES, merge and return as a dict
'''
return POSTGRESExtPillar().fetch(minion_id, pillar, *args, **kwargs) | def ext_pillar(minion_id,
pillar,
*args,
**kwargs):
'''
Execute queries against POSTGRES, merge and return as a dict
'''
return POSTGRESExtPillar().fetch(minion_id, pillar, *args, **kwargs) | [
"Execute",
"queries",
"against",
"POSTGRES",
"merge",
"and",
"return",
"as",
"a",
"dict"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/postgres.py#L112-L119 | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"POSTGRESExtPillar",
"(",
")",
".",
"fetch",
"(",
"minion_id",
",",
"pillar",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | POSTGRESExtPillar._get_cursor | Yield a POSTGRES cursor | salt/pillar/postgres.py | def _get_cursor(self):
'''
Yield a POSTGRES cursor
'''
_options = self._get_options()
conn = psycopg2.connect(host=_options['host'],
user=_options['user'],
password=_options['pass'],
d... | def _get_cursor(self):
'''
Yield a POSTGRES cursor
'''
_options = self._get_options()
conn = psycopg2.connect(host=_options['host'],
user=_options['user'],
password=_options['pass'],
d... | [
"Yield",
"a",
"POSTGRES",
"cursor"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/postgres.py#L85-L102 | [
"def",
"_get_cursor",
"(",
"self",
")",
":",
"_options",
"=",
"self",
".",
"_get_options",
"(",
")",
"conn",
"=",
"psycopg2",
".",
"connect",
"(",
"host",
"=",
"_options",
"[",
"'host'",
"]",
",",
"user",
"=",
"_options",
"[",
"'user'",
"]",
",",
"pa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | POSTGRESExtPillar.extract_queries | This function normalizes the config block into a set of queries we
can use. The return is a list of consistently laid out dicts. | salt/pillar/postgres.py | def extract_queries(self, args, kwargs):
'''
This function normalizes the config block into a set of queries we
can use. The return is a list of consistently laid out dicts.
'''
return super(POSTGRESExtPillar, self).extract_queries(args, kwargs) | def extract_queries(self, args, kwargs):
'''
This function normalizes the config block into a set of queries we
can use. The return is a list of consistently laid out dicts.
'''
return super(POSTGRESExtPillar, self).extract_queries(args, kwargs) | [
"This",
"function",
"normalizes",
"the",
"config",
"block",
"into",
"a",
"set",
"of",
"queries",
"we",
"can",
"use",
".",
"The",
"return",
"is",
"a",
"list",
"of",
"consistently",
"laid",
"out",
"dicts",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/postgres.py#L104-L109 | [
"def",
"extract_queries",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"super",
"(",
"POSTGRESExtPillar",
",",
"self",
")",
".",
"extract_queries",
"(",
"args",
",",
"kwargs",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_proc_cmdline | Returns the cmdline of a Process instance.
It's backward compatible with < 2.0 versions of psutil. | salt/modules/ps.py | def _get_proc_cmdline(proc):
'''
Returns the cmdline of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.cmdline() if PSUTIL2 else proc.cmdline)
except (psutil.NoSuchProcess, psutil.AccessDenied):
return [] | def _get_proc_cmdline(proc):
'''
Returns the cmdline of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.cmdline() if PSUTIL2 else proc.cmdline)
except (psutil.NoSuchProcess, psutil.AccessDenied):
return [] | [
"Returns",
"the",
"cmdline",
"of",
"a",
"Process",
"instance",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ps.py#L50-L59 | [
"def",
"_get_proc_cmdline",
"(",
"proc",
")",
":",
"try",
":",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"proc",
".",
"cmdline",
"(",
")",
"if",
"PSUTIL2",
"else",
"proc",
".",
"cmdline",
")",
"except",
"(",
"psutil",
".",
"NoS... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_proc_create_time | Returns the create_time of a Process instance.
It's backward compatible with < 2.0 versions of psutil. | salt/modules/ps.py | def _get_proc_create_time(proc):
'''
Returns the create_time of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.create_time() if PSUTIL2 else proc.create_time)
except (psutil.NoSuchProcess, psutil.AccessDenied):
... | def _get_proc_create_time(proc):
'''
Returns the create_time of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.create_time() if PSUTIL2 else proc.create_time)
except (psutil.NoSuchProcess, psutil.AccessDenied):
... | [
"Returns",
"the",
"create_time",
"of",
"a",
"Process",
"instance",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ps.py#L62-L71 | [
"def",
"_get_proc_create_time",
"(",
"proc",
")",
":",
"try",
":",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"proc",
".",
"create_time",
"(",
")",
"if",
"PSUTIL2",
"else",
"proc",
".",
"create_time",
")",
"except",
"(",
"psutil",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_proc_name | Returns the name of a Process instance.
It's backward compatible with < 2.0 versions of psutil. | salt/modules/ps.py | def _get_proc_name(proc):
'''
Returns the name of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.name() if PSUTIL2 else proc.name)
except (psutil.NoSuchProcess, psutil.AccessDenied):
return [] | def _get_proc_name(proc):
'''
Returns the name of a Process instance.
It's backward compatible with < 2.0 versions of psutil.
'''
try:
return salt.utils.data.decode(proc.name() if PSUTIL2 else proc.name)
except (psutil.NoSuchProcess, psutil.AccessDenied):
return [] | [
"Returns",
"the",
"name",
"of",
"a",
"Process",
"instance",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ps.py#L74-L83 | [
"def",
"_get_proc_name",
"(",
"proc",
")",
":",
"try",
":",
"return",
"salt",
".",
"utils",
".",
"data",
".",
"decode",
"(",
"proc",
".",
"name",
"(",
")",
"if",
"PSUTIL2",
"else",
"proc",
".",
"name",
")",
"except",
"(",
"psutil",
".",
"NoSuchProces... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.