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 | rebooted | Reboots VMs
.. versionadded:: 2016.3.0
:param name:
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, over... | salt/states/virt.py | def rebooted(name, connection=None, username=None, password=None):
'''
Reboots VMs
.. versionadded:: 2016.3.0
:param name:
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
... | def rebooted(name, connection=None, username=None, password=None):
'''
Reboots VMs
.. versionadded:: 2016.3.0
:param name:
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
... | [
"Reboots",
"VMs"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virt.py#L516-L536 | [
"def",
"rebooted",
"(",
"name",
",",
"connection",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"return",
"_virt_call",
"(",
"name",
",",
"'reboot'",
",",
"'rebooted'",
",",
"\"Machine has been rebooted\"",
",",
"connect... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | reverted | .. deprecated:: 2016.3.0
Reverts to the particular snapshot.
.. versionadded:: 2016.3.0
.. code-block:: yaml
domain_name:
virt.reverted:
- cleanup: True
domain_name_1:
virt.reverted:
- snapshot: snapshot_name
- cleanup: False | salt/states/virt.py | def reverted(name, snapshot=None, cleanup=False): # pylint: disable=redefined-outer-name
'''
.. deprecated:: 2016.3.0
Reverts to the particular snapshot.
.. versionadded:: 2016.3.0
.. code-block:: yaml
domain_name:
virt.reverted:
- cleanup: True
domain_nam... | def reverted(name, snapshot=None, cleanup=False): # pylint: disable=redefined-outer-name
'''
.. deprecated:: 2016.3.0
Reverts to the particular snapshot.
.. versionadded:: 2016.3.0
.. code-block:: yaml
domain_name:
virt.reverted:
- cleanup: True
domain_nam... | [
"..",
"deprecated",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virt.py#L580-L636 | [
"def",
"reverted",
"(",
"name",
",",
"snapshot",
"=",
"None",
",",
"cleanup",
"=",
"False",
")",
":",
"# pylint: disable=redefined-outer-name",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_running | Defines and starts a new network with specified arguments.
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overrid... | salt/states/virt.py | def network_running(name,
bridge,
forward,
vport=None,
tag=None,
autostart=True,
connection=None,
username=None,
password=None):
'''
Defines and starts ... | def network_running(name,
bridge,
forward,
vport=None,
tag=None,
autostart=True,
connection=None,
username=None,
password=None):
'''
Defines and starts ... | [
"Defines",
"and",
"starts",
"a",
"new",
"network",
"with",
"specified",
"arguments",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virt.py#L639-L709 | [
"def",
"network_running",
"(",
"name",
",",
"bridge",
",",
"forward",
",",
"vport",
"=",
"None",
",",
"tag",
"=",
"None",
",",
"autostart",
"=",
"True",
",",
"connection",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_running | Defines and starts a new pool with specified arguments.
.. versionadded:: 2019.2.0
:param ptype: libvirt pool type
:param target: full path to the target device or folder. (Default: ``None``)
:param permissions: target permissions. See the **Permissions definition**
section of the :py:func:`vi... | salt/states/virt.py | def pool_running(name,
ptype=None,
target=None,
permissions=None,
source=None,
transient=False,
autostart=True,
connection=None,
username=None,
password=None):
'''... | def pool_running(name,
ptype=None,
target=None,
permissions=None,
source=None,
transient=False,
autostart=True,
connection=None,
username=None,
password=None):
'''... | [
"Defines",
"and",
"starts",
"a",
"new",
"pool",
"with",
"specified",
"arguments",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virt.py#L712-L826 | [
"def",
"pool_running",
"(",
"name",
",",
"ptype",
"=",
"None",
",",
"target",
"=",
"None",
",",
"permissions",
"=",
"None",
",",
"source",
"=",
"None",
",",
"transient",
"=",
"False",
",",
"autostart",
"=",
"True",
",",
"connection",
"=",
"None",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status | Return ``True`` if service is running
name
the service's name
sig
signature to identify with ps
CLI Example:
.. code-block:: bash
salt '*' runit.status <service name> | salt/modules/runit.py | def status(name, sig=None):
'''
Return ``True`` if service is running
name
the service's name
sig
signature to identify with ps
CLI Example:
.. code-block:: bash
salt '*' runit.status <service name>
'''
if sig:
# usual way to do by others (debian_serv... | def status(name, sig=None):
'''
Return ``True`` if service is running
name
the service's name
sig
signature to identify with ps
CLI Example:
.. code-block:: bash
salt '*' runit.status <service name>
'''
if sig:
# usual way to do by others (debian_serv... | [
"Return",
"True",
"if",
"service",
"is",
"running"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L206-L240 | [
"def",
"status",
"(",
"name",
",",
"sig",
"=",
"None",
")",
":",
"if",
"sig",
":",
"# usual way to do by others (debian_service, netbsdservice).",
"# XXX probably does not work here (check 'runsv sshd' instead of 'sshd' ?)",
"return",
"bool",
"(",
"__salt__",
"[",
"'status.pi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _is_svc | Return ``True`` if directory <svc_path> is really a service:
file <svc_path>/run exists and is executable
svc_path
the (absolute) directory to check for compatibility | salt/modules/runit.py | def _is_svc(svc_path):
'''
Return ``True`` if directory <svc_path> is really a service:
file <svc_path>/run exists and is executable
svc_path
the (absolute) directory to check for compatibility
'''
run_file = os.path.join(svc_path, 'run')
if (os.path.exists(svc_path)
and os... | def _is_svc(svc_path):
'''
Return ``True`` if directory <svc_path> is really a service:
file <svc_path>/run exists and is executable
svc_path
the (absolute) directory to check for compatibility
'''
run_file = os.path.join(svc_path, 'run')
if (os.path.exists(svc_path)
and os... | [
"Return",
"True",
"if",
"directory",
"<svc_path",
">",
"is",
"really",
"a",
"service",
":",
"file",
"<svc_path",
">",
"/",
"run",
"exists",
"and",
"is",
"executable"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L243-L256 | [
"def",
"_is_svc",
"(",
"svc_path",
")",
":",
"run_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"svc_path",
",",
"'run'",
")",
"if",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"svc_path",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"ru... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status_autostart | Return ``True`` if service <name> is autostarted by sv
(file $service_folder/down does not exist)
NB: return ``False`` if the service is not enabled.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' runit.status_autostart <service name> | salt/modules/runit.py | def status_autostart(name):
'''
Return ``True`` if service <name> is autostarted by sv
(file $service_folder/down does not exist)
NB: return ``False`` if the service is not enabled.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' runit.status_autostart ... | def status_autostart(name):
'''
Return ``True`` if service <name> is autostarted by sv
(file $service_folder/down does not exist)
NB: return ``False`` if the service is not enabled.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' runit.status_autostart ... | [
"Return",
"True",
"if",
"service",
"<name",
">",
"is",
"autostarted",
"by",
"sv",
"(",
"file",
"$service_folder",
"/",
"down",
"does",
"not",
"exist",
")",
"NB",
":",
"return",
"False",
"if",
"the",
"service",
"is",
"not",
"enabled",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L259-L274 | [
"def",
"status_autostart",
"(",
"name",
")",
":",
"return",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"_service_path",
"(",
"name",
")",
",",
"'down'",
")",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_svc_broken_path | Return list of broken path(s) in SERVICE_DIR that match ``name``
A path is broken if it is a broken symlink or can not be a runit service
name
a glob for service name. default is '*'
CLI Example:
.. code-block:: bash
salt '*' runit.get_svc_broken_path <service name> | salt/modules/runit.py | def get_svc_broken_path(name='*'):
'''
Return list of broken path(s) in SERVICE_DIR that match ``name``
A path is broken if it is a broken symlink or can not be a runit service
name
a glob for service name. default is '*'
CLI Example:
.. code-block:: bash
salt '*' runit.get_... | def get_svc_broken_path(name='*'):
'''
Return list of broken path(s) in SERVICE_DIR that match ``name``
A path is broken if it is a broken symlink or can not be a runit service
name
a glob for service name. default is '*'
CLI Example:
.. code-block:: bash
salt '*' runit.get_... | [
"Return",
"list",
"of",
"broken",
"path",
"(",
"s",
")",
"in",
"SERVICE_DIR",
"that",
"match",
"name"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L277-L300 | [
"def",
"get_svc_broken_path",
"(",
"name",
"=",
"'*'",
")",
":",
"if",
"not",
"SERVICE_DIR",
":",
"raise",
"CommandExecutionError",
"(",
"'Could not find service directory.'",
")",
"ret",
"=",
"set",
"(",
")",
"for",
"el",
"in",
"glob",
".",
"glob",
"(",
"os... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_svc_avail_path | Add a path that may contain available services.
Return ``True`` if added (or already present), ``False`` on error.
path
directory to add to AVAIL_SVR_DIRS | salt/modules/runit.py | def add_svc_avail_path(path):
'''
Add a path that may contain available services.
Return ``True`` if added (or already present), ``False`` on error.
path
directory to add to AVAIL_SVR_DIRS
'''
if os.path.exists(path):
if path not in AVAIL_SVR_DIRS:
AVAIL_SVR_DIRS.app... | def add_svc_avail_path(path):
'''
Add a path that may contain available services.
Return ``True`` if added (or already present), ``False`` on error.
path
directory to add to AVAIL_SVR_DIRS
'''
if os.path.exists(path):
if path not in AVAIL_SVR_DIRS:
AVAIL_SVR_DIRS.app... | [
"Add",
"a",
"path",
"that",
"may",
"contain",
"available",
"services",
".",
"Return",
"True",
"if",
"added",
"(",
"or",
"already",
"present",
")",
"False",
"on",
"error",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L310-L322 | [
"def",
"add_svc_avail_path",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"if",
"path",
"not",
"in",
"AVAIL_SVR_DIRS",
":",
"AVAIL_SVR_DIRS",
".",
"append",
"(",
"path",
")",
"return",
"True",
"return",
"False"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_svc_path | Return a list of paths to services with ``name`` that have the specified ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service(s) that is not enabled
'ENABLED' : enabled service (whet... | salt/modules/runit.py | def _get_svc_path(name='*', status=None):
'''
Return a list of paths to services with ``name`` that have the specified ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service(s) that is ... | def _get_svc_path(name='*', status=None):
'''
Return a list of paths to services with ``name`` that have the specified ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service(s) that is ... | [
"Return",
"a",
"list",
"of",
"paths",
"to",
"services",
"with",
"name",
"that",
"have",
"the",
"specified",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L325-L374 | [
"def",
"_get_svc_path",
"(",
"name",
"=",
"'*'",
",",
"status",
"=",
"None",
")",
":",
"# This is the core routine to work with services, called by many",
"# other functions of this module.",
"#",
"# The name of a service is the \"apparent\" folder's name that contains its",
"# \"run... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_svc_list | Return list of services that have the specified service ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service that is not enabled
'ENABLED' : enabled service (whether started on boot ... | salt/modules/runit.py | def _get_svc_list(name='*', status=None):
'''
Return list of services that have the specified service ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service that is not enabled
... | def _get_svc_list(name='*', status=None):
'''
Return list of services that have the specified service ``status``
name
a glob for service name. default is '*'
status
None : all services (no filter, default choice)
'DISABLED' : available service that is not enabled
... | [
"Return",
"list",
"of",
"services",
"that",
"have",
"the",
"specified",
"service",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L377-L389 | [
"def",
"_get_svc_list",
"(",
"name",
"=",
"'*'",
",",
"status",
"=",
"None",
")",
":",
"return",
"sorted",
"(",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"el",
")",
"for",
"el",
"in",
"_get_svc_path",
"(",
"name",
",",
"status",
")",
"]",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_svc_alias | Returns the list of service's name that are aliased and their alias path(s) | salt/modules/runit.py | def get_svc_alias():
'''
Returns the list of service's name that are aliased and their alias path(s)
'''
ret = {}
for d in AVAIL_SVR_DIRS:
for el in glob.glob(os.path.join(d, '*')):
if not os.path.islink(el):
continue
psvc = os.readlink(el)
... | def get_svc_alias():
'''
Returns the list of service's name that are aliased and their alias path(s)
'''
ret = {}
for d in AVAIL_SVR_DIRS:
for el in glob.glob(os.path.join(d, '*')):
if not os.path.islink(el):
continue
psvc = os.readlink(el)
... | [
"Returns",
"the",
"list",
"of",
"service",
"s",
"name",
"that",
"are",
"aliased",
"and",
"their",
"alias",
"path",
"(",
"s",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L392-L409 | [
"def",
"get_svc_alias",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"d",
"in",
"AVAIL_SVR_DIRS",
":",
"for",
"el",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"'*'",
")",
")",
":",
"if",
"not",
"os",
".",
"p... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show | Show properties of one or more units/jobs or the manager
name
the service's name
CLI Example:
salt '*' service.show <service name> | salt/modules/runit.py | def show(name):
'''
Show properties of one or more units/jobs or the manager
name
the service's name
CLI Example:
salt '*' service.show <service name>
'''
ret = {}
ret['enabled'] = False
ret['disabled'] = True
ret['running'] = False
ret['service_path'] = None
... | def show(name):
'''
Show properties of one or more units/jobs or the manager
name
the service's name
CLI Example:
salt '*' service.show <service name>
'''
ret = {}
ret['enabled'] = False
ret['disabled'] = True
ret['running'] = False
ret['service_path'] = None
... | [
"Show",
"properties",
"of",
"one",
"or",
"more",
"units",
"/",
"jobs",
"or",
"the",
"manager"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L520-L553 | [
"def",
"show",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"}",
"ret",
"[",
"'enabled'",
"]",
"=",
"False",
"ret",
"[",
"'disabled'",
"]",
"=",
"True",
"ret",
"[",
"'running'",
"]",
"=",
"False",
"ret",
"[",
"'service_path'",
"]",
"=",
"None",
"ret",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | enable | Start service ``name`` at boot.
Returns ``True`` if operation is successful
name
the service's name
start : False
If ``True``, start the service once enabled.
CLI Example:
.. code-block:: bash
salt '*' service.enable <name> [start=True] | salt/modules/runit.py | def enable(name, start=False, **kwargs):
'''
Start service ``name`` at boot.
Returns ``True`` if operation is successful
name
the service's name
start : False
If ``True``, start the service once enabled.
CLI Example:
.. code-block:: bash
salt '*' service.enable <... | def enable(name, start=False, **kwargs):
'''
Start service ``name`` at boot.
Returns ``True`` if operation is successful
name
the service's name
start : False
If ``True``, start the service once enabled.
CLI Example:
.. code-block:: bash
salt '*' service.enable <... | [
"Start",
"service",
"name",
"at",
"boot",
".",
"Returns",
"True",
"if",
"operation",
"is",
"successful"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L556-L648 | [
"def",
"enable",
"(",
"name",
",",
"start",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# non-existent service",
"if",
"not",
"available",
"(",
"name",
")",
":",
"return",
"False",
"# if service is aliased, refuse to enable it",
"alias",
"=",
"get_svc_alia... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | disable | Don't start service ``name`` at boot
Returns ``True`` if operation is successful
name
the service's name
stop
if True, also stops the service
CLI Example:
.. code-block:: bash
salt '*' service.disable <name> [stop=True] | salt/modules/runit.py | def disable(name, stop=False, **kwargs):
'''
Don't start service ``name`` at boot
Returns ``True`` if operation is successful
name
the service's name
stop
if True, also stops the service
CLI Example:
.. code-block:: bash
salt '*' service.disable <name> [stop=True... | def disable(name, stop=False, **kwargs):
'''
Don't start service ``name`` at boot
Returns ``True`` if operation is successful
name
the service's name
stop
if True, also stops the service
CLI Example:
.. code-block:: bash
salt '*' service.disable <name> [stop=True... | [
"Don",
"t",
"start",
"service",
"name",
"at",
"boot",
"Returns",
"True",
"if",
"operation",
"is",
"successful"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L651-L687 | [
"def",
"disable",
"(",
"name",
",",
"stop",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# non-existent as registrered service",
"if",
"not",
"enabled",
"(",
"name",
")",
":",
"return",
"False",
"# down_file: file that prevent sv autostart",
"svc_realpath",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove | Remove the service <name> from system.
Returns ``True`` if operation is successful.
The service will be also stopped.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' service.remove <name> | salt/modules/runit.py | def remove(name):
'''
Remove the service <name> from system.
Returns ``True`` if operation is successful.
The service will be also stopped.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' service.remove <name>
'''
if not enabled(name):
... | def remove(name):
'''
Remove the service <name> from system.
Returns ``True`` if operation is successful.
The service will be also stopped.
name
the service's name
CLI Example:
.. code-block:: bash
salt '*' service.remove <name>
'''
if not enabled(name):
... | [
"Remove",
"the",
"service",
"<name",
">",
"from",
"system",
".",
"Returns",
"True",
"if",
"operation",
"is",
"successful",
".",
"The",
"service",
"will",
"be",
"also",
"stopped",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L690-L722 | [
"def",
"remove",
"(",
"name",
")",
":",
"if",
"not",
"enabled",
"(",
"name",
")",
":",
"return",
"False",
"svc_path",
"=",
"_service_path",
"(",
"name",
")",
"if",
"not",
"os",
".",
"path",
".",
"islink",
"(",
"svc_path",
")",
":",
"log",
".",
"err... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ext_pillar | Execute a command and read the output as YAML | salt/pillar/s3.py | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
bucket,
key=None,
keyid=None,
verify_ssl=True,
location=None,
multiple_env=False,
environment='base',
prefix='',
... | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
bucket,
key=None,
keyid=None,
verify_ssl=True,
location=None,
multiple_env=False,
environment='base',
prefix='',
... | [
"Execute",
"a",
"command",
"and",
"read",
"the",
"output",
"as",
"YAML"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L129-L189 | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"# pylint: disable=W0613",
"bucket",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"verify_ssl",
"=",
"True",
",",
"location",
"=",
"None",
",",
"multiple_env",
"=",
"False",
",",
"envir... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _init | Connect to S3 and download the metadata for each file in all buckets
specified and cache the data to disk. | salt/pillar/s3.py | def _init(creds, bucket, multiple_env, environment, prefix, s3_cache_expire):
'''
Connect to S3 and download the metadata for each file in all buckets
specified and cache the data to disk.
'''
cache_file = _get_buckets_cache_filename(bucket, prefix)
exp = time.time() - s3_cache_expire
# ch... | def _init(creds, bucket, multiple_env, environment, prefix, s3_cache_expire):
'''
Connect to S3 and download the metadata for each file in all buckets
specified and cache the data to disk.
'''
cache_file = _get_buckets_cache_filename(bucket, prefix)
exp = time.time() - s3_cache_expire
# ch... | [
"Connect",
"to",
"S3",
"and",
"download",
"the",
"metadata",
"for",
"each",
"file",
"in",
"all",
"buckets",
"specified",
"and",
"cache",
"the",
"data",
"to",
"disk",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L192-L225 | [
"def",
"_init",
"(",
"creds",
",",
"bucket",
",",
"multiple_env",
",",
"environment",
",",
"prefix",
",",
"s3_cache_expire",
")",
":",
"cache_file",
"=",
"_get_buckets_cache_filename",
"(",
"bucket",
",",
"prefix",
")",
"exp",
"=",
"time",
".",
"time",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_cache_dir | Get pillar cache directory. Initialize it if it does not exist. | salt/pillar/s3.py | def _get_cache_dir():
'''
Get pillar cache directory. Initialize it if it does not exist.
'''
cache_dir = os.path.join(__opts__['cachedir'], 'pillar_s3fs')
if not os.path.isdir(cache_dir):
log.debug('Initializing S3 Pillar Cache')
os.makedirs(cache_dir)
return cache_dir | def _get_cache_dir():
'''
Get pillar cache directory. Initialize it if it does not exist.
'''
cache_dir = os.path.join(__opts__['cachedir'], 'pillar_s3fs')
if not os.path.isdir(cache_dir):
log.debug('Initializing S3 Pillar Cache')
os.makedirs(cache_dir)
return cache_dir | [
"Get",
"pillar",
"cache",
"directory",
".",
"Initialize",
"it",
"if",
"it",
"does",
"not",
"exist",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L228-L239 | [
"def",
"_get_cache_dir",
"(",
")",
":",
"cache_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"__opts__",
"[",
"'cachedir'",
"]",
",",
"'pillar_s3fs'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"cache_dir",
")",
":",
"log",
".",
"debug... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_buckets_cache_filename | Return the filename of the cache for bucket contents.
Create the path if it does not exist. | salt/pillar/s3.py | def _get_buckets_cache_filename(bucket, prefix):
'''
Return the filename of the cache for bucket contents.
Create the path if it does not exist.
'''
cache_dir = _get_cache_dir()
if not os.path.exists(cache_dir):
os.makedirs(cache_dir)
return os.path.join(cache_dir, '{0}-{1}-files.c... | def _get_buckets_cache_filename(bucket, prefix):
'''
Return the filename of the cache for bucket contents.
Create the path if it does not exist.
'''
cache_dir = _get_cache_dir()
if not os.path.exists(cache_dir):
os.makedirs(cache_dir)
return os.path.join(cache_dir, '{0}-{1}-files.c... | [
"Return",
"the",
"filename",
"of",
"the",
"cache",
"for",
"bucket",
"contents",
".",
"Create",
"the",
"path",
"if",
"it",
"does",
"not",
"exist",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L256-L266 | [
"def",
"_get_buckets_cache_filename",
"(",
"bucket",
",",
"prefix",
")",
":",
"cache_dir",
"=",
"_get_cache_dir",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cache_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"cache_dir",
")",
"return",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _refresh_buckets_cache_file | Retrieve the content of all buckets and cache the metadata to the buckets
cache file | salt/pillar/s3.py | def _refresh_buckets_cache_file(creds, cache_file, multiple_env, environment, prefix):
'''
Retrieve the content of all buckets and cache the metadata to the buckets
cache file
'''
# helper s3 query function
def __get_s3_meta():
return __utils__['s3.query'](
key=creds.key,
... | def _refresh_buckets_cache_file(creds, cache_file, multiple_env, environment, prefix):
'''
Retrieve the content of all buckets and cache the metadata to the buckets
cache file
'''
# helper s3 query function
def __get_s3_meta():
return __utils__['s3.query'](
key=creds.key,
... | [
"Retrieve",
"the",
"content",
"of",
"all",
"buckets",
"and",
"cache",
"the",
"metadata",
"to",
"the",
"buckets",
"cache",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L269-L349 | [
"def",
"_refresh_buckets_cache_file",
"(",
"creds",
",",
"cache_file",
",",
"multiple_env",
",",
"environment",
",",
"prefix",
")",
":",
"# helper s3 query function",
"def",
"__get_s3_meta",
"(",
")",
":",
"return",
"__utils__",
"[",
"'s3.query'",
"]",
"(",
"key",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _read_buckets_cache_file | Return the contents of the buckets cache file | salt/pillar/s3.py | def _read_buckets_cache_file(cache_file):
'''
Return the contents of the buckets cache file
'''
log.debug('Reading buckets cache file')
with salt.utils.files.fopen(cache_file, 'rb') as fp_:
data = pickle.load(fp_)
return data | def _read_buckets_cache_file(cache_file):
'''
Return the contents of the buckets cache file
'''
log.debug('Reading buckets cache file')
with salt.utils.files.fopen(cache_file, 'rb') as fp_:
data = pickle.load(fp_)
return data | [
"Return",
"the",
"contents",
"of",
"the",
"buckets",
"cache",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L352-L362 | [
"def",
"_read_buckets_cache_file",
"(",
"cache_file",
")",
":",
"log",
".",
"debug",
"(",
"'Reading buckets cache file'",
")",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"cache_file",
",",
"'rb'",
")",
"as",
"fp_",
":",
"data",
"=",
"pi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _find_files | Looks for all the files in the S3 bucket cache metadata | salt/pillar/s3.py | def _find_files(metadata):
'''
Looks for all the files in the S3 bucket cache metadata
'''
ret = {}
for bucket, data in six.iteritems(metadata):
if bucket not in ret:
ret[bucket] = []
# grab the paths from the metadata
filePaths = [k['Key'] for k in data]
... | def _find_files(metadata):
'''
Looks for all the files in the S3 bucket cache metadata
'''
ret = {}
for bucket, data in six.iteritems(metadata):
if bucket not in ret:
ret[bucket] = []
# grab the paths from the metadata
filePaths = [k['Key'] for k in data]
... | [
"Looks",
"for",
"all",
"the",
"files",
"in",
"the",
"S3",
"bucket",
"cache",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L365-L381 | [
"def",
"_find_files",
"(",
"metadata",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"bucket",
",",
"data",
"in",
"six",
".",
"iteritems",
"(",
"metadata",
")",
":",
"if",
"bucket",
"not",
"in",
"ret",
":",
"ret",
"[",
"bucket",
"]",
"=",
"[",
"]",
"# g... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_file_from_s3 | Checks the local cache for the file, if it's old or missing go grab the
file from S3 and update the cache | salt/pillar/s3.py | def _get_file_from_s3(creds, metadata, saltenv, bucket, path,
cached_file_path):
'''
Checks the local cache for the file, if it's old or missing go grab the
file from S3 and update the cache
'''
# check the local cache...
if os.path.isfile(cached_file_path):
file_m... | def _get_file_from_s3(creds, metadata, saltenv, bucket, path,
cached_file_path):
'''
Checks the local cache for the file, if it's old or missing go grab the
file from S3 and update the cache
'''
# check the local cache...
if os.path.isfile(cached_file_path):
file_m... | [
"Checks",
"the",
"local",
"cache",
"for",
"the",
"file",
"if",
"it",
"s",
"old",
"or",
"missing",
"go",
"grab",
"the",
"file",
"from",
"S3",
"and",
"update",
"the",
"cache"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/s3.py#L398-L432 | [
"def",
"_get_file_from_s3",
"(",
"creds",
",",
"metadata",
",",
"saltenv",
",",
"bucket",
",",
"path",
",",
"cached_file_path",
")",
":",
"# check the local cache...",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"cached_file_path",
")",
":",
"file_meta",
"=",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _arg2opt | Turn a pass argument into the correct option | salt/modules/logadm.py | def _arg2opt(arg):
'''
Turn a pass argument into the correct option
'''
res = [o for o, a in option_toggles.items() if a == arg]
res += [o for o, a in option_flags.items() if a == arg]
return res[0] if res else None | def _arg2opt(arg):
'''
Turn a pass argument into the correct option
'''
res = [o for o, a in option_toggles.items() if a == arg]
res += [o for o, a in option_flags.items() if a == arg]
return res[0] if res else None | [
"Turn",
"a",
"pass",
"argument",
"into",
"the",
"correct",
"option"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L61-L67 | [
"def",
"_arg2opt",
"(",
"arg",
")",
":",
"res",
"=",
"[",
"o",
"for",
"o",
",",
"a",
"in",
"option_toggles",
".",
"items",
"(",
")",
"if",
"a",
"==",
"arg",
"]",
"res",
"+=",
"[",
"o",
"for",
"o",
",",
"a",
"in",
"option_flags",
".",
"items",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_conf | Parse a logadm configuration file. | salt/modules/logadm.py | def _parse_conf(conf_file=default_conf):
'''
Parse a logadm configuration file.
'''
ret = {}
with salt.utils.files.fopen(conf_file, 'r') as ifile:
for line in ifile:
line = salt.utils.stringutils.to_unicode(line).strip()
if not line:
continue
... | def _parse_conf(conf_file=default_conf):
'''
Parse a logadm configuration file.
'''
ret = {}
with salt.utils.files.fopen(conf_file, 'r') as ifile:
for line in ifile:
line = salt.utils.stringutils.to_unicode(line).strip()
if not line:
continue
... | [
"Parse",
"a",
"logadm",
"configuration",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L70-L84 | [
"def",
"_parse_conf",
"(",
"conf_file",
"=",
"default_conf",
")",
":",
"ret",
"=",
"{",
"}",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"conf_file",
",",
"'r'",
")",
"as",
"ifile",
":",
"for",
"line",
"in",
"ifile",
":",
"line",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_options | Parse a logadm options string | salt/modules/logadm.py | def _parse_options(entry, options, include_unset=True):
'''
Parse a logadm options string
'''
log_cfg = {}
options = shlex.split(options)
if not options:
return None
## identifier is entry or log?
if entry.startswith('/'):
log_cfg['log_file'] = entry
else:
lo... | def _parse_options(entry, options, include_unset=True):
'''
Parse a logadm options string
'''
log_cfg = {}
options = shlex.split(options)
if not options:
return None
## identifier is entry or log?
if entry.startswith('/'):
log_cfg['log_file'] = entry
else:
lo... | [
"Parse",
"a",
"logadm",
"options",
"string"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L87-L152 | [
"def",
"_parse_options",
"(",
"entry",
",",
"options",
",",
"include_unset",
"=",
"True",
")",
":",
"log_cfg",
"=",
"{",
"}",
"options",
"=",
"shlex",
".",
"split",
"(",
"options",
")",
"if",
"not",
"options",
":",
"return",
"None",
"## identifier is entry... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show_conf | Show configuration
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
name : string
optional show only a single entry
CLI Example:
.. code-block:: bash
salt '*' logadm.show_conf
salt '*' logadm.show_conf name=/var/log/syslog | salt/modules/logadm.py | def show_conf(conf_file=default_conf, name=None):
'''
Show configuration
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
name : string
optional show only a single entry
CLI Example:
.. code-block:: bash
salt '*' logadm.show_conf
salt '*' l... | def show_conf(conf_file=default_conf, name=None):
'''
Show configuration
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
name : string
optional show only a single entry
CLI Example:
.. code-block:: bash
salt '*' logadm.show_conf
salt '*' l... | [
"Show",
"configuration"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L155-L179 | [
"def",
"show_conf",
"(",
"conf_file",
"=",
"default_conf",
",",
"name",
"=",
"None",
")",
":",
"cfg",
"=",
"_parse_conf",
"(",
"conf_file",
")",
"# filter",
"if",
"name",
"and",
"name",
"in",
"cfg",
":",
"return",
"{",
"name",
":",
"cfg",
"[",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_conf | Show parsed configuration
.. versionadded:: 2018.3.0
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
log_file : string
optional show only one log file
include_unset : boolean
include unset flags in output
CLI Example:
.. code-block:: bash
... | salt/modules/logadm.py | def list_conf(conf_file=default_conf, log_file=None, include_unset=False):
'''
Show parsed configuration
.. versionadded:: 2018.3.0
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
log_file : string
optional show only one log file
include_unset : boolean
... | def list_conf(conf_file=default_conf, log_file=None, include_unset=False):
'''
Show parsed configuration
.. versionadded:: 2018.3.0
conf_file : string
path to logadm.conf, defaults to /etc/logadm.conf
log_file : string
optional show only one log file
include_unset : boolean
... | [
"Show",
"parsed",
"configuration"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L182-L217 | [
"def",
"list_conf",
"(",
"conf_file",
"=",
"default_conf",
",",
"log_file",
"=",
"None",
",",
"include_unset",
"=",
"False",
")",
":",
"cfg",
"=",
"_parse_conf",
"(",
"conf_file",
")",
"cfg_parsed",
"=",
"{",
"}",
"## parse all options",
"for",
"entry",
"in"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show_args | Show which arguments map to which flags and options.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' logadm.show_args | salt/modules/logadm.py | def show_args():
'''
Show which arguments map to which flags and options.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' logadm.show_args
'''
mapping = {'flags': {}, 'options': {}}
for flag, arg in option_toggles.items():
mapping['flags'][flag] ... | def show_args():
'''
Show which arguments map to which flags and options.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' logadm.show_args
'''
mapping = {'flags': {}, 'options': {}}
for flag, arg in option_toggles.items():
mapping['flags'][flag] ... | [
"Show",
"which",
"arguments",
"map",
"to",
"which",
"flags",
"and",
"options",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L221-L239 | [
"def",
"show_args",
"(",
")",
":",
"mapping",
"=",
"{",
"'flags'",
":",
"{",
"}",
",",
"'options'",
":",
"{",
"}",
"}",
"for",
"flag",
",",
"arg",
"in",
"option_toggles",
".",
"items",
"(",
")",
":",
"mapping",
"[",
"'flags'",
"]",
"[",
"flag",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | rotate | Set up pattern for logging.
name : string
alias for entryname
pattern : string
alias for log_file
conf_file : string
optional path to alternative configuration file
kwargs : boolean|string|int
optional additional flags and parameters
.. note::
``name`` and `... | salt/modules/logadm.py | def rotate(name, pattern=None, conf_file=default_conf, **kwargs):
'''
Set up pattern for logging.
name : string
alias for entryname
pattern : string
alias for log_file
conf_file : string
optional path to alternative configuration file
kwargs : boolean|string|int
... | def rotate(name, pattern=None, conf_file=default_conf, **kwargs):
'''
Set up pattern for logging.
name : string
alias for entryname
pattern : string
alias for log_file
conf_file : string
optional path to alternative configuration file
kwargs : boolean|string|int
... | [
"Set",
"up",
"pattern",
"for",
"logging",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L242-L323 | [
"def",
"rotate",
"(",
"name",
",",
"pattern",
"=",
"None",
",",
"conf_file",
"=",
"default_conf",
",",
"*",
"*",
"kwargs",
")",
":",
"## cleanup kwargs",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove | Remove log pattern from logadm
CLI Example:
.. code-block:: bash
salt '*' logadm.remove myapplog | salt/modules/logadm.py | def remove(name, conf_file=default_conf):
'''
Remove log pattern from logadm
CLI Example:
.. code-block:: bash
salt '*' logadm.remove myapplog
'''
command = "logadm -f {0} -r {1}".format(conf_file, name)
result = __salt__['cmd.run_all'](command, python_shell=False)
if result['re... | def remove(name, conf_file=default_conf):
'''
Remove log pattern from logadm
CLI Example:
.. code-block:: bash
salt '*' logadm.remove myapplog
'''
command = "logadm -f {0} -r {1}".format(conf_file, name)
result = __salt__['cmd.run_all'](command, python_shell=False)
if result['re... | [
"Remove",
"log",
"pattern",
"from",
"logadm"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/logadm.py#L326-L343 | [
"def",
"remove",
"(",
"name",
",",
"conf_file",
"=",
"default_conf",
")",
":",
"command",
"=",
"\"logadm -f {0} -r {1}\"",
".",
"format",
"(",
"conf_file",
",",
"name",
")",
"result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"command",
",",
"python_s... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_encodings | return a list of string encodings to try | salt/utils/locales.py | def get_encodings():
'''
return a list of string encodings to try
'''
encodings = [__salt_system_encoding__]
try:
sys_enc = sys.getdefaultencoding()
except ValueError: # system encoding is nonstandard or malformed
sys_enc = None
if sys_enc and sys_enc not in encodings:
... | def get_encodings():
'''
return a list of string encodings to try
'''
encodings = [__salt_system_encoding__]
try:
sys_enc = sys.getdefaultencoding()
except ValueError: # system encoding is nonstandard or malformed
sys_enc = None
if sys_enc and sys_enc not in encodings:
... | [
"return",
"a",
"list",
"of",
"string",
"encodings",
"to",
"try"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/locales.py#L16-L33 | [
"def",
"get_encodings",
"(",
")",
":",
"encodings",
"=",
"[",
"__salt_system_encoding__",
"]",
"try",
":",
"sys_enc",
"=",
"sys",
".",
"getdefaultencoding",
"(",
")",
"except",
"ValueError",
":",
"# system encoding is nonstandard or malformed",
"sys_enc",
"=",
"None... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | split_locale | Split a locale specifier. The general format is
language[_territory][.codeset][@modifier] [charmap]
For example:
ca_ES.UTF-8@valencia UTF-8 | salt/utils/locales.py | def split_locale(loc):
'''
Split a locale specifier. The general format is
language[_territory][.codeset][@modifier] [charmap]
For example:
ca_ES.UTF-8@valencia UTF-8
'''
def split(st, char):
'''
Split a string `st` once by `char`; always return a two-element list
... | def split_locale(loc):
'''
Split a locale specifier. The general format is
language[_territory][.codeset][@modifier] [charmap]
For example:
ca_ES.UTF-8@valencia UTF-8
'''
def split(st, char):
'''
Split a string `st` once by `char`; always return a two-element list
... | [
"Split",
"a",
"locale",
"specifier",
".",
"The",
"general",
"format",
"is"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/locales.py#L58-L83 | [
"def",
"split_locale",
"(",
"loc",
")",
":",
"def",
"split",
"(",
"st",
",",
"char",
")",
":",
"'''\n Split a string `st` once by `char`; always return a two-element list\n even if the second element is empty.\n '''",
"split_st",
"=",
"st",
".",
"split",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | join_locale | Join a locale specifier split in the format returned by split_locale. | salt/utils/locales.py | def join_locale(comps):
'''
Join a locale specifier split in the format returned by split_locale.
'''
loc = comps['language']
if comps.get('territory'):
loc += '_' + comps['territory']
if comps.get('codeset'):
loc += '.' + comps['codeset']
if comps.get('modifier'):
lo... | def join_locale(comps):
'''
Join a locale specifier split in the format returned by split_locale.
'''
loc = comps['language']
if comps.get('territory'):
loc += '_' + comps['territory']
if comps.get('codeset'):
loc += '.' + comps['codeset']
if comps.get('modifier'):
lo... | [
"Join",
"a",
"locale",
"specifier",
"split",
"in",
"the",
"format",
"returned",
"by",
"split_locale",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/locales.py#L86-L99 | [
"def",
"join_locale",
"(",
"comps",
")",
":",
"loc",
"=",
"comps",
"[",
"'language'",
"]",
"if",
"comps",
".",
"get",
"(",
"'territory'",
")",
":",
"loc",
"+=",
"'_'",
"+",
"comps",
"[",
"'territory'",
"]",
"if",
"comps",
".",
"get",
"(",
"'codeset'"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | normalize_locale | Format a locale specifier according to the format returned by `locale -a`. | salt/utils/locales.py | def normalize_locale(loc):
'''
Format a locale specifier according to the format returned by `locale -a`.
'''
comps = split_locale(loc)
comps['territory'] = comps['territory'].upper()
comps['codeset'] = comps['codeset'].lower().replace('-', '')
comps['charmap'] = ''
return join_locale(co... | def normalize_locale(loc):
'''
Format a locale specifier according to the format returned by `locale -a`.
'''
comps = split_locale(loc)
comps['territory'] = comps['territory'].upper()
comps['codeset'] = comps['codeset'].lower().replace('-', '')
comps['charmap'] = ''
return join_locale(co... | [
"Format",
"a",
"locale",
"specifier",
"according",
"to",
"the",
"format",
"returned",
"by",
"locale",
"-",
"a",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/locales.py#L102-L110 | [
"def",
"normalize_locale",
"(",
"loc",
")",
":",
"comps",
"=",
"split_locale",
"(",
"loc",
")",
"comps",
"[",
"'territory'",
"]",
"=",
"comps",
"[",
"'territory'",
"]",
".",
"upper",
"(",
")",
"comps",
"[",
"'codeset'",
"]",
"=",
"comps",
"[",
"'codese... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _remove_dots | Remove dots from the given data structure | salt/returners/mongo_return.py | def _remove_dots(src):
'''
Remove dots from the given data structure
'''
output = {}
for key, val in six.iteritems(src):
if isinstance(val, dict):
val = _remove_dots(val)
output[key.replace('.', '-')] = val
return output | def _remove_dots(src):
'''
Remove dots from the given data structure
'''
output = {}
for key, val in six.iteritems(src):
if isinstance(val, dict):
val = _remove_dots(val)
output[key.replace('.', '-')] = val
return output | [
"Remove",
"dots",
"from",
"the",
"given",
"data",
"structure"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L96-L105 | [
"def",
"_remove_dots",
"(",
"src",
")",
":",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"src",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"val",
"=",
"_remove_dots",
"(",
"val",
")... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_conn | Return a mongodb connection object | salt/returners/mongo_return.py | def _get_conn(ret):
'''
Return a mongodb connection object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
db_ = _options.get('db')
user = _options.get('user')
password = _options.get('password')
indexes = _options.get('indexes', False)
... | def _get_conn(ret):
'''
Return a mongodb connection object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
db_ = _options.get('db')
user = _options.get('user')
password = _options.get('password')
indexes = _options.get('indexes', False)
... | [
"Return",
"a",
"mongodb",
"connection",
"object"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L127-L165 | [
"def",
"_get_conn",
"(",
"ret",
")",
":",
"_options",
"=",
"_get_options",
"(",
"ret",
")",
"host",
"=",
"_options",
".",
"get",
"(",
"'host'",
")",
"port",
"=",
"_options",
".",
"get",
"(",
"'port'",
")",
"db_",
"=",
"_options",
".",
"get",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_jid | Return the return information associated with a jid | salt/returners/mongo_return.py | def get_jid(jid):
'''
Return the return information associated with a jid
'''
conn, mdb = _get_conn(ret=None)
ret = {}
rdata = mdb.saltReturns.find({'jid': jid}, {'_id': 0})
if rdata:
for data in rdata:
minion = data['minion']
# return data in the format {<min... | def get_jid(jid):
'''
Return the return information associated with a jid
'''
conn, mdb = _get_conn(ret=None)
ret = {}
rdata = mdb.saltReturns.find({'jid': jid}, {'_id': 0})
if rdata:
for data in rdata:
minion = data['minion']
# return data in the format {<min... | [
"Return",
"the",
"return",
"information",
"associated",
"with",
"a",
"jid"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L203-L215 | [
"def",
"get_jid",
"(",
"jid",
")",
":",
"conn",
",",
"mdb",
"=",
"_get_conn",
"(",
"ret",
"=",
"None",
")",
"ret",
"=",
"{",
"}",
"rdata",
"=",
"mdb",
".",
"saltReturns",
".",
"find",
"(",
"{",
"'jid'",
":",
"jid",
"}",
",",
"{",
"'_id'",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_fun | Return the most recent jobs that have executed the named function | salt/returners/mongo_return.py | def get_fun(fun):
'''
Return the most recent jobs that have executed the named function
'''
conn, mdb = _get_conn(ret=None)
ret = {}
rdata = mdb.saltReturns.find_one({'fun': fun}, {'_id': 0})
if rdata:
ret = rdata
return ret | def get_fun(fun):
'''
Return the most recent jobs that have executed the named function
'''
conn, mdb = _get_conn(ret=None)
ret = {}
rdata = mdb.saltReturns.find_one({'fun': fun}, {'_id': 0})
if rdata:
ret = rdata
return ret | [
"Return",
"the",
"most",
"recent",
"jobs",
"that",
"have",
"executed",
"the",
"named",
"function"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L218-L227 | [
"def",
"get_fun",
"(",
"fun",
")",
":",
"conn",
",",
"mdb",
"=",
"_get_conn",
"(",
"ret",
"=",
"None",
")",
"ret",
"=",
"{",
"}",
"rdata",
"=",
"mdb",
".",
"saltReturns",
".",
"find_one",
"(",
"{",
"'fun'",
":",
"fun",
"}",
",",
"{",
"'_id'",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _cert_file | Return expected path of a Let's Encrypt live cert | salt/modules/acme.py | def _cert_file(name, cert_type):
'''
Return expected path of a Let's Encrypt live cert
'''
return os.path.join(LE_LIVE, name, '{0}.pem'.format(cert_type)) | def _cert_file(name, cert_type):
'''
Return expected path of a Let's Encrypt live cert
'''
return os.path.join(LE_LIVE, name, '{0}.pem'.format(cert_type)) | [
"Return",
"expected",
"path",
"of",
"a",
"Let",
"s",
"Encrypt",
"live",
"cert"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L64-L68 | [
"def",
"_cert_file",
"(",
"name",
",",
"cert_type",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"LE_LIVE",
",",
"name",
",",
"'{0}.pem'",
".",
"format",
"(",
"cert_type",
")",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _expires | Return the expiry date of a cert
:return datetime object of expiry date | salt/modules/acme.py | def _expires(name):
'''
Return the expiry date of a cert
:return datetime object of expiry date
'''
cert_file = _cert_file(name, 'cert')
# Use the salt module if available
if 'tls.cert_info' in __salt__:
expiry = __salt__['tls.cert_info'](cert_file)['not_after']
# Cobble it toge... | def _expires(name):
'''
Return the expiry date of a cert
:return datetime object of expiry date
'''
cert_file = _cert_file(name, 'cert')
# Use the salt module if available
if 'tls.cert_info' in __salt__:
expiry = __salt__['tls.cert_info'](cert_file)['not_after']
# Cobble it toge... | [
"Return",
"the",
"expiry",
"date",
"of",
"a",
"cert"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L71-L89 | [
"def",
"_expires",
"(",
"name",
")",
":",
"cert_file",
"=",
"_cert_file",
"(",
"name",
",",
"'cert'",
")",
"# Use the salt module if available",
"if",
"'tls.cert_info'",
"in",
"__salt__",
":",
"expiry",
"=",
"__salt__",
"[",
"'tls.cert_info'",
"]",
"(",
"cert_fi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _renew_by | Date before a certificate should be renewed
:param name: Common Name of the certificate (DNS name of certificate)
:param window: days before expiry date to renew
:return datetime object of first renewal date | salt/modules/acme.py | def _renew_by(name, window=None):
'''
Date before a certificate should be renewed
:param name: Common Name of the certificate (DNS name of certificate)
:param window: days before expiry date to renew
:return datetime object of first renewal date
'''
expiry = _expires(name)
if window is ... | def _renew_by(name, window=None):
'''
Date before a certificate should be renewed
:param name: Common Name of the certificate (DNS name of certificate)
:param window: days before expiry date to renew
:return datetime object of first renewal date
'''
expiry = _expires(name)
if window is ... | [
"Date",
"before",
"a",
"certificate",
"should",
"be",
"renewed"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L92-L104 | [
"def",
"_renew_by",
"(",
"name",
",",
"window",
"=",
"None",
")",
":",
"expiry",
"=",
"_expires",
"(",
"name",
")",
"if",
"window",
"is",
"not",
"None",
":",
"expiry",
"=",
"expiry",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"window",
")",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cert | Obtain/renew a certificate from an ACME CA, probably Let's Encrypt.
:param name: Common Name of the certificate (DNS name of certificate)
:param aliases: subjectAltNames (Additional DNS names on certificate)
:param email: e-mail address for interaction with ACME provider
:param webroot: True or a full ... | salt/modules/acme.py | def cert(name,
aliases=None,
email=None,
webroot=None,
test_cert=False,
renew=None,
keysize=None,
server=None,
owner='root',
group='root',
mode='0640',
certname=None,
preferred_challenges=None,
tls_sni_0... | def cert(name,
aliases=None,
email=None,
webroot=None,
test_cert=False,
renew=None,
keysize=None,
server=None,
owner='root',
group='root',
mode='0640',
certname=None,
preferred_challenges=None,
tls_sni_0... | [
"Obtain",
"/",
"renew",
"a",
"certificate",
"from",
"an",
"ACME",
"CA",
"probably",
"Let",
"s",
"Encrypt",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L107-L258 | [
"def",
"cert",
"(",
"name",
",",
"aliases",
"=",
"None",
",",
"email",
"=",
"None",
",",
"webroot",
"=",
"None",
",",
"test_cert",
"=",
"False",
",",
"renew",
"=",
"None",
",",
"keysize",
"=",
"None",
",",
"server",
"=",
"None",
",",
"owner",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | info | Return information about a certificate
.. note::
Will output tls.cert_info if that's available, or OpenSSL text if not
:param name: CommonName of cert
CLI example:
.. code-block:: bash
salt 'gitlab.example.com' acme.info dev.example.com | salt/modules/acme.py | def info(name):
'''
Return information about a certificate
.. note::
Will output tls.cert_info if that's available, or OpenSSL text if not
:param name: CommonName of cert
CLI example:
.. code-block:: bash
salt 'gitlab.example.com' acme.info dev.example.com
'''
cert_f... | def info(name):
'''
Return information about a certificate
.. note::
Will output tls.cert_info if that's available, or OpenSSL text if not
:param name: CommonName of cert
CLI example:
.. code-block:: bash
salt 'gitlab.example.com' acme.info dev.example.com
'''
cert_f... | [
"Return",
"information",
"about",
"a",
"certificate"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L274-L300 | [
"def",
"info",
"(",
"name",
")",
":",
"cert_file",
"=",
"_cert_file",
"(",
"name",
",",
"'cert'",
")",
"# Use the salt module if available",
"if",
"'tls.cert_info'",
"in",
"__salt__",
":",
"cert_info",
"=",
"__salt__",
"[",
"'tls.cert_info'",
"]",
"(",
"cert_fil... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | needs_renewal | Check if a certificate needs renewal
:param name: CommonName of cert
:param window: Window in days to renew earlier or True/force to just return True
Code example:
.. code-block:: python
if __salt__['acme.needs_renewal']('dev.example.com'):
__salt__['acme.cert']('dev.example.com'... | salt/modules/acme.py | def needs_renewal(name, window=None):
'''
Check if a certificate needs renewal
:param name: CommonName of cert
:param window: Window in days to renew earlier or True/force to just return True
Code example:
.. code-block:: python
if __salt__['acme.needs_renewal']('dev.example.com'):
... | def needs_renewal(name, window=None):
'''
Check if a certificate needs renewal
:param name: CommonName of cert
:param window: Window in days to renew earlier or True/force to just return True
Code example:
.. code-block:: python
if __salt__['acme.needs_renewal']('dev.example.com'):
... | [
"Check",
"if",
"a",
"certificate",
"needs",
"renewal"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/acme.py#L344-L363 | [
"def",
"needs_renewal",
"(",
"name",
",",
"window",
"=",
"None",
")",
":",
"if",
"window",
"is",
"not",
"None",
"and",
"window",
"in",
"(",
"'force'",
",",
"'Force'",
",",
"True",
")",
":",
"return",
"True",
"return",
"_renew_by",
"(",
"name",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _analyse_overview_field | Split the field in drbd-overview | salt/modules/drbd.py | def _analyse_overview_field(content):
'''
Split the field in drbd-overview
'''
if "(" in content:
# Output like "Connected(2*)" or "UpToDate(2*)"
return content.split("(")[0], content.split("(")[0]
elif "/" in content:
# Output like "Primar/Second" or "UpToDa/UpToDa"
... | def _analyse_overview_field(content):
'''
Split the field in drbd-overview
'''
if "(" in content:
# Output like "Connected(2*)" or "UpToDate(2*)"
return content.split("(")[0], content.split("(")[0]
elif "/" in content:
# Output like "Primar/Second" or "UpToDa/UpToDa"
... | [
"Split",
"the",
"field",
"in",
"drbd",
"-",
"overview"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L13-L24 | [
"def",
"_analyse_overview_field",
"(",
"content",
")",
":",
"if",
"\"(\"",
"in",
"content",
":",
"# Output like \"Connected(2*)\" or \"UpToDate(2*)\"",
"return",
"content",
".",
"split",
"(",
"\"(\"",
")",
"[",
"0",
"]",
",",
"content",
".",
"split",
"(",
"\"(\"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _count_spaces_startswith | Count the number of spaces before the first character | salt/modules/drbd.py | def _count_spaces_startswith(line):
'''
Count the number of spaces before the first character
'''
if line.split('#')[0].strip() == "":
return None
spaces = 0
for i in line:
if i.isspace():
spaces += 1
else:
return spaces | def _count_spaces_startswith(line):
'''
Count the number of spaces before the first character
'''
if line.split('#')[0].strip() == "":
return None
spaces = 0
for i in line:
if i.isspace():
spaces += 1
else:
return spaces | [
"Count",
"the",
"number",
"of",
"spaces",
"before",
"the",
"first",
"character"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L27-L39 | [
"def",
"_count_spaces_startswith",
"(",
"line",
")",
":",
"if",
"line",
".",
"split",
"(",
"'#'",
")",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"==",
"\"\"",
":",
"return",
"None",
"spaces",
"=",
"0",
"for",
"i",
"in",
"line",
":",
"if",
"i",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _analyse_status_type | Figure out the sections in drbdadm status | salt/modules/drbd.py | def _analyse_status_type(line):
'''
Figure out the sections in drbdadm status
'''
spaces = _count_spaces_startswith(line)
if spaces is None:
return ''
switch = {
0: 'RESOURCE',
2: {' disk:': 'LOCALDISK', ' role:': 'PEERNODE', ' connection:': 'PEERNODE'},
4: {' p... | def _analyse_status_type(line):
'''
Figure out the sections in drbdadm status
'''
spaces = _count_spaces_startswith(line)
if spaces is None:
return ''
switch = {
0: 'RESOURCE',
2: {' disk:': 'LOCALDISK', ' role:': 'PEERNODE', ' connection:': 'PEERNODE'},
4: {' p... | [
"Figure",
"out",
"the",
"sections",
"in",
"drbdadm",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L42-L67 | [
"def",
"_analyse_status_type",
"(",
"line",
")",
":",
"spaces",
"=",
"_count_spaces_startswith",
"(",
"line",
")",
"if",
"spaces",
"is",
"None",
":",
"return",
"''",
"switch",
"=",
"{",
"0",
":",
"'RESOURCE'",
",",
"2",
":",
"{",
"' disk:'",
":",
"'LOCAL... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _add_res | Analyse the line of local resource of ``drbdadm status`` | salt/modules/drbd.py | def _add_res(line):
'''
Analyse the line of local resource of ``drbdadm status``
'''
global resource
fields = line.strip().split()
if resource:
ret.append(resource)
resource = {}
resource["resource name"] = fields[0]
resource["local role"] = fields[1].split(":")[1]
... | def _add_res(line):
'''
Analyse the line of local resource of ``drbdadm status``
'''
global resource
fields = line.strip().split()
if resource:
ret.append(resource)
resource = {}
resource["resource name"] = fields[0]
resource["local role"] = fields[1].split(":")[1]
... | [
"Analyse",
"the",
"line",
"of",
"local",
"resource",
"of",
"drbdadm",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L70-L84 | [
"def",
"_add_res",
"(",
"line",
")",
":",
"global",
"resource",
"fields",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"if",
"resource",
":",
"ret",
".",
"append",
"(",
"resource",
")",
"resource",
"=",
"{",
"}",
"resource",
"[",
"\... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _add_volume | Analyse the line of volumes of ``drbdadm status`` | salt/modules/drbd.py | def _add_volume(line):
'''
Analyse the line of volumes of ``drbdadm status``
'''
section = _analyse_status_type(line)
fields = line.strip().split()
volume = {}
for field in fields:
volume[field.split(':')[0]] = field.split(':')[1]
if section == 'LOCALDISK':
resource['lo... | def _add_volume(line):
'''
Analyse the line of volumes of ``drbdadm status``
'''
section = _analyse_status_type(line)
fields = line.strip().split()
volume = {}
for field in fields:
volume[field.split(':')[0]] = field.split(':')[1]
if section == 'LOCALDISK':
resource['lo... | [
"Analyse",
"the",
"line",
"of",
"volumes",
"of",
"drbdadm",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L87-L102 | [
"def",
"_add_volume",
"(",
"line",
")",
":",
"section",
"=",
"_analyse_status_type",
"(",
"line",
")",
"fields",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"volume",
"=",
"{",
"}",
"for",
"field",
"in",
"fields",
":",
"volume",
"[",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _add_peernode | Analyse the line of peer nodes of ``drbdadm status`` | salt/modules/drbd.py | def _add_peernode(line):
'''
Analyse the line of peer nodes of ``drbdadm status``
'''
global lastpnodevolumes
fields = line.strip().split()
peernode = {}
peernode["peernode name"] = fields[0]
#Could be role or connection:
peernode[fields[1].split(":")[0]] = fields[1].split(":")[1]
... | def _add_peernode(line):
'''
Analyse the line of peer nodes of ``drbdadm status``
'''
global lastpnodevolumes
fields = line.strip().split()
peernode = {}
peernode["peernode name"] = fields[0]
#Could be role or connection:
peernode[fields[1].split(":")[0]] = fields[1].split(":")[1]
... | [
"Analyse",
"the",
"line",
"of",
"peer",
"nodes",
"of",
"drbdadm",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L105-L119 | [
"def",
"_add_peernode",
"(",
"line",
")",
":",
"global",
"lastpnodevolumes",
"fields",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"peernode",
"=",
"{",
"}",
"peernode",
"[",
"\"peernode name\"",
"]",
"=",
"fields",
"[",
"0",
"]",
"#Co... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _line_parser | Call action for different lines | salt/modules/drbd.py | def _line_parser(line):
'''
Call action for different lines
'''
section = _analyse_status_type(line)
fields = line.strip().split()
switch = {
'': _empty,
'RESOURCE': _add_res,
'PEERNODE': _add_peernode,
'LOCALDISK': _add_volume,
'PEERDISK': _add_volume,
... | def _line_parser(line):
'''
Call action for different lines
'''
section = _analyse_status_type(line)
fields = line.strip().split()
switch = {
'': _empty,
'RESOURCE': _add_res,
'PEERNODE': _add_peernode,
'LOCALDISK': _add_volume,
'PEERDISK': _add_volume,
... | [
"Call",
"action",
"for",
"different",
"lines"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L137-L154 | [
"def",
"_line_parser",
"(",
"line",
")",
":",
"section",
"=",
"_analyse_status_type",
"(",
"line",
")",
"fields",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"switch",
"=",
"{",
"''",
":",
"_empty",
",",
"'RESOURCE'",
":",
"_add_res",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | overview | Show status of the DRBD devices, support two nodes only.
drbd-overview is removed since drbd-utils-9.6.0,
use status instead.
CLI Example:
.. code-block:: bash
salt '*' drbd.overview | salt/modules/drbd.py | def overview():
'''
Show status of the DRBD devices, support two nodes only.
drbd-overview is removed since drbd-utils-9.6.0,
use status instead.
CLI Example:
.. code-block:: bash
salt '*' drbd.overview
'''
cmd = 'drbd-overview'
for line in __salt__['cmd.run'](cmd).splitli... | def overview():
'''
Show status of the DRBD devices, support two nodes only.
drbd-overview is removed since drbd-utils-9.6.0,
use status instead.
CLI Example:
.. code-block:: bash
salt '*' drbd.overview
'''
cmd = 'drbd-overview'
for line in __salt__['cmd.run'](cmd).splitli... | [
"Show",
"status",
"of",
"the",
"DRBD",
"devices",
"support",
"two",
"nodes",
"only",
".",
"drbd",
"-",
"overview",
"is",
"removed",
"since",
"drbd",
"-",
"utils",
"-",
"9",
".",
"6",
".",
"0",
"use",
"status",
"instead",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L157-L228 | [
"def",
"overview",
"(",
")",
":",
"cmd",
"=",
"'drbd-overview'",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
".",
"splitlines",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"fields",
"=",
"line",
".",
"strip",
"(",
")",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | status | Using drbdadm to show status of the DRBD devices,
available in the latest drbd9.
Support multiple nodes, multiple volumes.
:type name: str
:param name:
Resource name.
:return: drbd status of resource.
:rtype: list(dict(res))
CLI Example:
.. code-block:: bash
salt '*'... | salt/modules/drbd.py | def status(name='all'):
'''
Using drbdadm to show status of the DRBD devices,
available in the latest drbd9.
Support multiple nodes, multiple volumes.
:type name: str
:param name:
Resource name.
:return: drbd status of resource.
:rtype: list(dict(res))
CLI Example:
..... | def status(name='all'):
'''
Using drbdadm to show status of the DRBD devices,
available in the latest drbd9.
Support multiple nodes, multiple volumes.
:type name: str
:param name:
Resource name.
:return: drbd status of resource.
:rtype: list(dict(res))
CLI Example:
..... | [
"Using",
"drbdadm",
"to",
"show",
"status",
"of",
"the",
"DRBD",
"devices",
"available",
"in",
"the",
"latest",
"drbd9",
".",
"Support",
"multiple",
"nodes",
"multiple",
"volumes",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L237-L283 | [
"def",
"status",
"(",
"name",
"=",
"'all'",
")",
":",
"# Initialize for multiple times test cases",
"global",
"ret",
"global",
"resource",
"ret",
"=",
"[",
"]",
"resource",
"=",
"{",
"}",
"cmd",
"=",
"[",
"'drbdadm'",
",",
"'status'",
"]",
"cmd",
".",
"app... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_return_code_powershell | return from the input string the return code of the powershell command | salt/modules/rdp.py | def _parse_return_code_powershell(string):
'''
return from the input string the return code of the powershell command
'''
regex = re.search(r'ReturnValue\s*: (\d*)', string)
if not regex:
return (False, 'Could not parse PowerShell return code.')
else:
return int(regex.group(1)) | def _parse_return_code_powershell(string):
'''
return from the input string the return code of the powershell command
'''
regex = re.search(r'ReturnValue\s*: (\d*)', string)
if not regex:
return (False, 'Could not parse PowerShell return code.')
else:
return int(regex.group(1)) | [
"return",
"from",
"the",
"input",
"string",
"the",
"return",
"code",
"of",
"the",
"powershell",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L34-L43 | [
"def",
"_parse_return_code_powershell",
"(",
"string",
")",
":",
"regex",
"=",
"re",
".",
"search",
"(",
"r'ReturnValue\\s*: (\\d*)'",
",",
"string",
")",
"if",
"not",
"regex",
":",
"return",
"(",
"False",
",",
"'Could not parse PowerShell return code.'",
")",
"el... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _psrdp | Create a Win32_TerminalServiceSetting WMI Object as $RDP and execute the
command cmd returns the STDOUT of the command | salt/modules/rdp.py | def _psrdp(cmd):
'''
Create a Win32_TerminalServiceSetting WMI Object as $RDP and execute the
command cmd returns the STDOUT of the command
'''
rdp = ('$RDP = Get-WmiObject -Class Win32_TerminalServiceSetting '
'-Namespace root\\CIMV2\\TerminalServices -Computer . '
'-Authentic... | def _psrdp(cmd):
'''
Create a Win32_TerminalServiceSetting WMI Object as $RDP and execute the
command cmd returns the STDOUT of the command
'''
rdp = ('$RDP = Get-WmiObject -Class Win32_TerminalServiceSetting '
'-Namespace root\\CIMV2\\TerminalServices -Computer . '
'-Authentic... | [
"Create",
"a",
"Win32_TerminalServiceSetting",
"WMI",
"Object",
"as",
"$RDP",
"and",
"execute",
"the",
"command",
"cmd",
"returns",
"the",
"STDOUT",
"of",
"the",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L46-L55 | [
"def",
"_psrdp",
"(",
"cmd",
")",
":",
"rdp",
"=",
"(",
"'$RDP = Get-WmiObject -Class Win32_TerminalServiceSetting '",
"'-Namespace root\\\\CIMV2\\\\TerminalServices -Computer . '",
"'-Authentication 6 -ErrorAction Stop'",
")",
"return",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_sessions | List information about the sessions.
.. versionadded:: 2016.11.0
:param logged_in_users_only: If True, only return sessions with users logged in.
:return: A list containing dictionaries of session information.
CLI Example:
.. code-block:: bash
salt '*' rdp.list_sessions | salt/modules/rdp.py | def list_sessions(logged_in_users_only=False):
'''
List information about the sessions.
.. versionadded:: 2016.11.0
:param logged_in_users_only: If True, only return sessions with users logged in.
:return: A list containing dictionaries of session information.
CLI Example:
.. code-block:... | def list_sessions(logged_in_users_only=False):
'''
List information about the sessions.
.. versionadded:: 2016.11.0
:param logged_in_users_only: If True, only return sessions with users logged in.
:return: A list containing dictionaries of session information.
CLI Example:
.. code-block:... | [
"List",
"information",
"about",
"the",
"sessions",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L104-L151 | [
"def",
"list_sessions",
"(",
"logged_in_users_only",
"=",
"False",
")",
":",
"ret",
"=",
"list",
"(",
")",
"server",
"=",
"win32ts",
".",
"WTS_CURRENT_SERVER_HANDLE",
"protocols",
"=",
"{",
"win32ts",
".",
"WTS_PROTOCOL_TYPE_CONSOLE",
":",
"'console'",
",",
"win... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_session | Get information about a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A dictionary of session information.
CLI Example:
.. code-block:: bash
salt '*' rdp.get_session session_id
salt '*' rdp.get_session 99 | salt/modules/rdp.py | def get_session(session_id):
'''
Get information about a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A dictionary of session information.
CLI Example:
.. code-block:: bash
salt '*' rdp.get_session session_id
salt '*' r... | def get_session(session_id):
'''
Get information about a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A dictionary of session information.
CLI Example:
.. code-block:: bash
salt '*' rdp.get_session session_id
salt '*' r... | [
"Get",
"information",
"about",
"a",
"session",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L155-L181 | [
"def",
"get_session",
"(",
"session_id",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"sessions",
"=",
"list_sessions",
"(",
")",
"session",
"=",
"[",
"item",
"for",
"item",
"in",
"sessions",
"if",
"item",
"[",
"'session_id'",
"]",
"==",
"session_id",
"]",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | disconnect_session | Disconnect a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the disconnect succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.disconnect_session session_id
salt '*' rdp.disconnect_session 99 | salt/modules/rdp.py | def disconnect_session(session_id):
'''
Disconnect a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the disconnect succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.disconnect_session session... | def disconnect_session(session_id):
'''
Disconnect a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the disconnect succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.disconnect_session session... | [
"Disconnect",
"a",
"session",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L185-L207 | [
"def",
"disconnect_session",
"(",
"session_id",
")",
":",
"try",
":",
"win32ts",
".",
"WTSDisconnectSession",
"(",
"win32ts",
".",
"WTS_CURRENT_SERVER_HANDLE",
",",
"session_id",
",",
"True",
")",
"except",
"PyWinError",
"as",
"error",
":",
"_LOG",
".",
"error",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | logoff_session | Initiate the logoff of a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the logoff succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.logoff_session session_id
salt '*' rdp.logoff_session 99 | salt/modules/rdp.py | def logoff_session(session_id):
'''
Initiate the logoff of a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the logoff succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.logoff_session session... | def logoff_session(session_id):
'''
Initiate the logoff of a session.
.. versionadded:: 2016.11.0
:param session_id: The numeric Id of the session.
:return: A boolean representing whether the logoff succeeded.
CLI Example:
.. code-block:: bash
salt '*' rdp.logoff_session session... | [
"Initiate",
"the",
"logoff",
"of",
"a",
"session",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rdp.py#L211-L233 | [
"def",
"logoff_session",
"(",
"session_id",
")",
":",
"try",
":",
"win32ts",
".",
"WTSLogoffSession",
"(",
"win32ts",
".",
"WTS_CURRENT_SERVER_HANDLE",
",",
"session_id",
",",
"True",
")",
"except",
"PyWinError",
"as",
"error",
":",
"_LOG",
".",
"error",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | envs | Return the available fileserver environments. If no backend is provided,
then the environments for all configured backends will be returned.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
If all passed backends start with a minus si... | salt/runners/fileserver.py | def envs(backend=None, sources=False):
'''
Return the available fileserver environments. If no backend is provided,
then the environments for all configured backends will be returned.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
... | def envs(backend=None, sources=False):
'''
Return the available fileserver environments. If no backend is provided,
then the environments for all configured backends will be returned.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
... | [
"Return",
"the",
"available",
"fileserver",
"environments",
".",
"If",
"no",
"backend",
"is",
"provided",
"then",
"the",
"environments",
"for",
"all",
"configured",
"backends",
"will",
"be",
"returned",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L11-L39 | [
"def",
"envs",
"(",
"backend",
"=",
"None",
",",
"sources",
"=",
"False",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"return",
"sorted",
"(",
"fileserver",
".",
"envs",
"(",
"back",
"=",
"backend",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | clear_file_list_cache | .. versionadded:: 2016.11.0
The Salt fileserver caches the files/directories/symlinks for each
fileserver backend and environment as they are requested. This is done to
help the fileserver scale better. Without this caching, when
hundreds/thousands of minions simultaneously ask the master what files ar... | salt/runners/fileserver.py | def clear_file_list_cache(saltenv=None, backend=None):
'''
.. versionadded:: 2016.11.0
The Salt fileserver caches the files/directories/symlinks for each
fileserver backend and environment as they are requested. This is done to
help the fileserver scale better. Without this caching, when
hundre... | def clear_file_list_cache(saltenv=None, backend=None):
'''
.. versionadded:: 2016.11.0
The Salt fileserver caches the files/directories/symlinks for each
fileserver backend and environment as they are requested. This is done to
help the fileserver scale better. Without this caching, when
hundre... | [
"..",
"versionadded",
"::",
"2016",
".",
"11",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L42-L147 | [
"def",
"clear_file_list_cache",
"(",
"saltenv",
"=",
"None",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | file_list | Return a list of files from the salt fileserver
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded from the ... | salt/runners/fileserver.py | def file_list(saltenv='base', backend=None):
'''
Return a list of files from the salt fileserver
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``... | def file_list(saltenv='base', backend=None):
'''
Return a list of files from the salt fileserver
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``... | [
"Return",
"a",
"list",
"of",
"files",
"from",
"the",
"salt",
"fileserver"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L150-L193 | [
"def",
"file_list",
"(",
"saltenv",
"=",
"'base'",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":",
"back... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | symlink_list | Return a list of symlinked files and dirs
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded from the enable... | salt/runners/fileserver.py | def symlink_list(saltenv='base', backend=None):
'''
Return a list of symlinked files and dirs
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), ... | def symlink_list(saltenv='base', backend=None):
'''
Return a list of symlinked files and dirs
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), ... | [
"Return",
"a",
"list",
"of",
"symlinked",
"files",
"and",
"dirs"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L196-L239 | [
"def",
"symlink_list",
"(",
"saltenv",
"=",
"'base'",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":",
"b... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | dir_list | Return a list of directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded fro... | salt/runners/fileserver.py | def dir_list(saltenv='base', backend=None):
'''
Return a list of directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (... | def dir_list(saltenv='base', backend=None):
'''
Return a list of directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (... | [
"Return",
"a",
"list",
"of",
"directories",
"in",
"the",
"given",
"environment"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L242-L285 | [
"def",
"dir_list",
"(",
"saltenv",
"=",
"'base'",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":",
"backe... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | empty_dir_list | .. versionadded:: 2015.5.0
Return a list of empty directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these... | salt/runners/fileserver.py | def empty_dir_list(saltenv='base', backend=None):
'''
.. versionadded:: 2015.5.0
Return a list of empty directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
... | def empty_dir_list(saltenv='base', backend=None):
'''
.. versionadded:: 2015.5.0
Return a list of empty directories in the given environment
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L288-L322 | [
"def",
"empty_dir_list",
"(",
"saltenv",
"=",
"'base'",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | update | Update the fileserver cache. If no backend is provided, then the cache for
all configured backends will be updated.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
If all passed backends start with a minus sign (``-``), then these
... | salt/runners/fileserver.py | def update(backend=None):
'''
Update the fileserver cache. If no backend is provided, then the cache for
all configured backends will be updated.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
If all passed backends start wi... | def update(backend=None):
'''
Update the fileserver cache. If no backend is provided, then the cache for
all configured backends will be updated.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.5.0
If all passed backends start wi... | [
"Update",
"the",
"fileserver",
"cache",
".",
"If",
"no",
"backend",
"is",
"provided",
"then",
"the",
"cache",
"for",
"all",
"configured",
"backends",
"will",
"be",
"updated",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L325-L353 | [
"def",
"update",
"(",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"fileserver",
".",
"update",
"(",
"back",
"=",
"backend",
")",
"return",
"True"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | clear_cache | .. versionadded:: 2015.5.0
Clear the fileserver cache from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). Executing this runner with no arguments will
clear the cache for all enabled VCS fileserver backends, but this
... | salt/runners/fileserver.py | def clear_cache(backend=None):
'''
.. versionadded:: 2015.5.0
Clear the fileserver cache from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). Executing this runner with no arguments will
clear the cache for all ... | def clear_cache(backend=None):
'''
.. versionadded:: 2015.5.0
Clear the fileserver cache from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). Executing this runner with no arguments will
clear the cache for all ... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L356-L391 | [
"def",
"clear_cache",
"(",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"cleared",
",",
"errors",
"=",
"fileserver",
".",
"clear_cache",
"(",
"back",
"=",
"backend",
")",
"ret",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | clear_lock | .. versionadded:: 2015.5.0
Clear the fileserver update lock from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). This should only need to be done if a fileserver
update was interrupted and a remote is not updating (gene... | salt/runners/fileserver.py | def clear_lock(backend=None, remote=None):
'''
.. versionadded:: 2015.5.0
Clear the fileserver update lock from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). This should only need to be done if a fileserver
up... | def clear_lock(backend=None, remote=None):
'''
.. versionadded:: 2015.5.0
Clear the fileserver update lock from VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`). This should only need to be done if a fileserver
up... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L394-L432 | [
"def",
"clear_lock",
"(",
"backend",
"=",
"None",
",",
"remote",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"cleared",
",",
"errors",
"=",
"fileserver",
".",
"clear_lock",
"(",
"back",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | lock | .. versionadded:: 2015.5.0
Set a fileserver update lock for VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`).
.. note::
This will only operate on enabled backends (those configured in
:conf_master:`files... | salt/runners/fileserver.py | def lock(backend=None, remote=None):
'''
.. versionadded:: 2015.5.0
Set a fileserver update lock for VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`).
.. note::
This will only operate on enabled backends... | def lock(backend=None, remote=None):
'''
.. versionadded:: 2015.5.0
Set a fileserver update lock for VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`).
.. note::
This will only operate on enabled backends... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L435-L474 | [
"def",
"lock",
"(",
"backend",
"=",
"None",
",",
"remote",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"locked",
",",
"errors",
"=",
"fileserver",
".",
"lock",
"(",
"back",
"=",
"backend... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | KeyCLI.run | Run the logic for saltkey | salt/key.py | def run(self):
'''
Run the logic for saltkey
'''
self._update_opts()
cmd = self.opts['fun']
veri = None
ret = None
try:
if cmd in ('accept', 'reject', 'delete'):
ret = self._run_cmd('name_match')
if not isinstan... | def run(self):
'''
Run the logic for saltkey
'''
self._update_opts()
cmd = self.opts['fun']
veri = None
ret = None
try:
if cmd in ('accept', 'reject', 'delete'):
ret = self._run_cmd('name_match')
if not isinstan... | [
"Run",
"the",
"logic",
"for",
"saltkey"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L228-L284 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_update_opts",
"(",
")",
"cmd",
"=",
"self",
".",
"opts",
"[",
"'fun'",
"]",
"veri",
"=",
"None",
"ret",
"=",
"None",
"try",
":",
"if",
"cmd",
"in",
"(",
"'accept'",
",",
"'reject'",
",",
"'delet... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key._check_minions_directories | Return the minion keys directory paths | salt/key.py | def _check_minions_directories(self):
'''
Return the minion keys directory paths
'''
minions_accepted = os.path.join(self.opts['pki_dir'], self.ACC)
minions_pre = os.path.join(self.opts['pki_dir'], self.PEND)
minions_rejected = os.path.join(self.opts['pki_dir'],
... | def _check_minions_directories(self):
'''
Return the minion keys directory paths
'''
minions_accepted = os.path.join(self.opts['pki_dir'], self.ACC)
minions_pre = os.path.join(self.opts['pki_dir'], self.PEND)
minions_rejected = os.path.join(self.opts['pki_dir'],
... | [
"Return",
"the",
"minion",
"keys",
"directory",
"paths"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L314-L325 | [
"def",
"_check_minions_directories",
"(",
"self",
")",
":",
"minions_accepted",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"self",
".",
"ACC",
")",
"minions_pre",
"=",
"os",
".",
"path",
".",
"join",
"(",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.gen_keys | Generate minion RSA public keypair | salt/key.py | def gen_keys(self, keydir=None, keyname=None, keysize=None, user=None):
'''
Generate minion RSA public keypair
'''
keydir, keyname, keysize, user = self._get_key_attrs(keydir, keyname,
keysize, user)
salt.crypt.gen_keys... | def gen_keys(self, keydir=None, keyname=None, keysize=None, user=None):
'''
Generate minion RSA public keypair
'''
keydir, keyname, keysize, user = self._get_key_attrs(keydir, keyname,
keysize, user)
salt.crypt.gen_keys... | [
"Generate",
"minion",
"RSA",
"public",
"keypair"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L343-L350 | [
"def",
"gen_keys",
"(",
"self",
",",
"keydir",
"=",
"None",
",",
"keyname",
"=",
"None",
",",
"keysize",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"keydir",
",",
"keyname",
",",
"keysize",
",",
"user",
"=",
"self",
".",
"_get_key_attrs",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.gen_signature | Generate master public-key-signature | salt/key.py | def gen_signature(self, privkey, pubkey, sig_path):
'''
Generate master public-key-signature
'''
return salt.crypt.gen_signature(privkey,
pubkey,
sig_path,
self.passphr... | def gen_signature(self, privkey, pubkey, sig_path):
'''
Generate master public-key-signature
'''
return salt.crypt.gen_signature(privkey,
pubkey,
sig_path,
self.passphr... | [
"Generate",
"master",
"public",
"-",
"key",
"-",
"signature"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L352-L359 | [
"def",
"gen_signature",
"(",
"self",
",",
"privkey",
",",
"pubkey",
",",
"sig_path",
")",
":",
"return",
"salt",
".",
"crypt",
".",
"gen_signature",
"(",
"privkey",
",",
"pubkey",
",",
"sig_path",
",",
"self",
".",
"passphrase",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.gen_keys_signature | Generate master public-key-signature | salt/key.py | def gen_keys_signature(self, priv, pub, signature_path, auto_create=False, keysize=None):
'''
Generate master public-key-signature
'''
# check given pub-key
if pub:
if not os.path.isfile(pub):
return 'Public-key {0} does not exist'.format(pub)
... | def gen_keys_signature(self, priv, pub, signature_path, auto_create=False, keysize=None):
'''
Generate master public-key-signature
'''
# check given pub-key
if pub:
if not os.path.isfile(pub):
return 'Public-key {0} does not exist'.format(pub)
... | [
"Generate",
"master",
"public",
"-",
"key",
"-",
"signature"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L361-L416 | [
"def",
"gen_keys_signature",
"(",
"self",
",",
"priv",
",",
"pub",
",",
"signature_path",
",",
"auto_create",
"=",
"False",
",",
"keysize",
"=",
"None",
")",
":",
"# check given pub-key",
"if",
"pub",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.check_minion_cache | Check the minion cache to make sure that old minion data is cleared
Optionally, pass in a list of minions which should have their caches
preserved. To preserve all caches, set __opts__['preserve_minion_cache'] | salt/key.py | def check_minion_cache(self, preserve_minions=None):
'''
Check the minion cache to make sure that old minion data is cleared
Optionally, pass in a list of minions which should have their caches
preserved. To preserve all caches, set __opts__['preserve_minion_cache']
'''
... | def check_minion_cache(self, preserve_minions=None):
'''
Check the minion cache to make sure that old minion data is cleared
Optionally, pass in a list of minions which should have their caches
preserved. To preserve all caches, set __opts__['preserve_minion_cache']
'''
... | [
"Check",
"the",
"minion",
"cache",
"to",
"make",
"sure",
"that",
"old",
"minion",
"data",
"is",
"cleared"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L418-L448 | [
"def",
"check_minion_cache",
"(",
"self",
",",
"preserve_minions",
"=",
"None",
")",
":",
"if",
"preserve_minions",
"is",
"None",
":",
"preserve_minions",
"=",
"[",
"]",
"keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"minions",
"=",
"[",
"]",
"for",
"k... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.check_master | Log if the master is not running
:rtype: bool
:return: Whether or not the master is running | salt/key.py | def check_master(self):
'''
Log if the master is not running
:rtype: bool
:return: Whether or not the master is running
'''
if not os.path.exists(
os.path.join(
self.opts['sock_dir'],
'publish_pull.ipc'
... | def check_master(self):
'''
Log if the master is not running
:rtype: bool
:return: Whether or not the master is running
'''
if not os.path.exists(
os.path.join(
self.opts['sock_dir'],
'publish_pull.ipc'
... | [
"Log",
"if",
"the",
"master",
"is",
"not",
"running"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L450-L464 | [
"def",
"check_master",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'sock_dir'",
"]",
",",
"'publish_pull.ipc'",
")",
")",
":",
"return",
"False",
"return",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.name_match | Accept a glob which to match the of a key and return the key's location | salt/key.py | def name_match(self, match, full=False):
'''
Accept a glob which to match the of a key and return the key's location
'''
if full:
matches = self.all_keys()
else:
matches = self.list_keys()
ret = {}
if ',' in match and isinstance(match, six.... | def name_match(self, match, full=False):
'''
Accept a glob which to match the of a key and return the key's location
'''
if full:
matches = self.all_keys()
else:
matches = self.list_keys()
ret = {}
if ',' in match and isinstance(match, six.... | [
"Accept",
"a",
"glob",
"which",
"to",
"match",
"the",
"of",
"a",
"key",
"and",
"return",
"the",
"key",
"s",
"location"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L466-L490 | [
"def",
"name_match",
"(",
"self",
",",
"match",
",",
"full",
"=",
"False",
")",
":",
"if",
"full",
":",
"matches",
"=",
"self",
".",
"all_keys",
"(",
")",
"else",
":",
"matches",
"=",
"self",
".",
"list_keys",
"(",
")",
"ret",
"=",
"{",
"}",
"if"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.dict_match | Accept a dictionary of keys and return the current state of the
specified keys | salt/key.py | def dict_match(self, match_dict):
'''
Accept a dictionary of keys and return the current state of the
specified keys
'''
ret = {}
cur_keys = self.list_keys()
for status, keys in six.iteritems(match_dict):
for key in salt.utils.data.sorted_ignorecase(ke... | def dict_match(self, match_dict):
'''
Accept a dictionary of keys and return the current state of the
specified keys
'''
ret = {}
cur_keys = self.list_keys()
for status, keys in six.iteritems(match_dict):
for key in salt.utils.data.sorted_ignorecase(ke... | [
"Accept",
"a",
"dictionary",
"of",
"keys",
"and",
"return",
"the",
"current",
"state",
"of",
"the",
"specified",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L492-L504 | [
"def",
"dict_match",
"(",
"self",
",",
"match_dict",
")",
":",
"ret",
"=",
"{",
"}",
"cur_keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"for",
"status",
",",
"keys",
"in",
"six",
".",
"iteritems",
"(",
"match_dict",
")",
":",
"for",
"key",
"in",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.local_keys | Return a dict of local keys | salt/key.py | def local_keys(self):
'''
Return a dict of local keys
'''
ret = {'local': []}
for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(self.opts['pki_dir'])):
if fn_.endswith('.pub') or fn_.endswith('.pem'):
path = os.path.join(self.opts['pki_dir'], fn_... | def local_keys(self):
'''
Return a dict of local keys
'''
ret = {'local': []}
for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(self.opts['pki_dir'])):
if fn_.endswith('.pub') or fn_.endswith('.pem'):
path = os.path.join(self.opts['pki_dir'], fn_... | [
"Return",
"a",
"dict",
"of",
"local",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L506-L516 | [
"def",
"local_keys",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"'local'",
":",
"[",
"]",
"}",
"for",
"fn_",
"in",
"salt",
".",
"utils",
".",
"data",
".",
"sorted_ignorecase",
"(",
"os",
".",
"listdir",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.list_keys | Return a dict of managed keys and what the key status are | salt/key.py | def list_keys(self):
'''
Return a dict of managed keys and what the key status are
'''
key_dirs = self._check_minions_directories()
ret = {}
for dir_ in key_dirs:
if dir_ is None:
continue
ret[os.path.basename(dir_)] = []
... | def list_keys(self):
'''
Return a dict of managed keys and what the key status are
'''
key_dirs = self._check_minions_directories()
ret = {}
for dir_ in key_dirs:
if dir_ is None:
continue
ret[os.path.basename(dir_)] = []
... | [
"Return",
"a",
"dict",
"of",
"managed",
"keys",
"and",
"what",
"the",
"key",
"status",
"are"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L518-L540 | [
"def",
"list_keys",
"(",
"self",
")",
":",
"key_dirs",
"=",
"self",
".",
"_check_minions_directories",
"(",
")",
"ret",
"=",
"{",
"}",
"for",
"dir_",
"in",
"key_dirs",
":",
"if",
"dir_",
"is",
"None",
":",
"continue",
"ret",
"[",
"os",
".",
"path",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.all_keys | Merge managed keys with local keys | salt/key.py | def all_keys(self):
'''
Merge managed keys with local keys
'''
keys = self.list_keys()
keys.update(self.local_keys())
return keys | def all_keys(self):
'''
Merge managed keys with local keys
'''
keys = self.list_keys()
keys.update(self.local_keys())
return keys | [
"Merge",
"managed",
"keys",
"with",
"local",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L542-L548 | [
"def",
"all_keys",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"keys",
".",
"update",
"(",
"self",
".",
"local_keys",
"(",
")",
")",
"return",
"keys"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.list_status | Return a dict of managed keys under a named status | salt/key.py | def list_status(self, match):
'''
Return a dict of managed keys under a named status
'''
acc, pre, rej, den = self._check_minions_directories()
ret = {}
if match.startswith('acc'):
ret[os.path.basename(acc)] = []
for fn_ in salt.utils.data.sorted_i... | def list_status(self, match):
'''
Return a dict of managed keys under a named status
'''
acc, pre, rej, den = self._check_minions_directories()
ret = {}
if match.startswith('acc'):
ret[os.path.basename(acc)] = []
for fn_ in salt.utils.data.sorted_i... | [
"Return",
"a",
"dict",
"of",
"managed",
"keys",
"under",
"a",
"named",
"status"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L550-L582 | [
"def",
"list_status",
"(",
"self",
",",
"match",
")",
":",
"acc",
",",
"pre",
",",
"rej",
",",
"den",
"=",
"self",
".",
"_check_minions_directories",
"(",
")",
"ret",
"=",
"{",
"}",
"if",
"match",
".",
"startswith",
"(",
"'acc'",
")",
":",
"ret",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.key_str | Return the specified public key or keys based on a glob | salt/key.py | def key_str(self, match):
'''
Return the specified public key or keys based on a glob
'''
ret = {}
for status, keys in six.iteritems(self.name_match(match)):
ret[status] = {}
for key in salt.utils.data.sorted_ignorecase(keys):
path = os.pat... | def key_str(self, match):
'''
Return the specified public key or keys based on a glob
'''
ret = {}
for status, keys in six.iteritems(self.name_match(match)):
ret[status] = {}
for key in salt.utils.data.sorted_ignorecase(keys):
path = os.pat... | [
"Return",
"the",
"specified",
"public",
"key",
"or",
"keys",
"based",
"on",
"a",
"glob"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L584-L596 | [
"def",
"key_str",
"(",
"self",
",",
"match",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"status",
",",
"keys",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"name_match",
"(",
"match",
")",
")",
":",
"ret",
"[",
"status",
"]",
"=",
"{",
"}",
"fo... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.accept | Accept public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match_dict". | salt/key.py | def accept(self, match=None, match_dict=None, include_rejected=False, include_denied=False):
'''
Accept public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match_dict".
'''
if match is not None:
matches = self.nam... | def accept(self, match=None, match_dict=None, include_rejected=False, include_denied=False):
'''
Accept public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match_dict".
'''
if match is not None:
matches = self.nam... | [
"Accept",
"public",
"keys",
".",
"If",
"match",
"is",
"passed",
"it",
"is",
"evaluated",
"as",
"a",
"glob",
".",
"Pre",
"-",
"gathered",
"matches",
"can",
"also",
"be",
"passed",
"via",
"match_dict",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L612-L651 | [
"def",
"accept",
"(",
"self",
",",
"match",
"=",
"None",
",",
"match_dict",
"=",
"None",
",",
"include_rejected",
"=",
"False",
",",
"include_denied",
"=",
"False",
")",
":",
"if",
"match",
"is",
"not",
"None",
":",
"matches",
"=",
"self",
".",
"name_m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.accept_all | Accept all keys in pre | salt/key.py | def accept_all(self):
'''
Accept all keys in pre
'''
keys = self.list_keys()
for key in keys[self.PEND]:
try:
shutil.move(
os.path.join(
self.opts['pki_dir'],
self.PEND,
... | def accept_all(self):
'''
Accept all keys in pre
'''
keys = self.list_keys()
for key in keys[self.PEND]:
try:
shutil.move(
os.path.join(
self.opts['pki_dir'],
self.PEND,
... | [
"Accept",
"all",
"keys",
"in",
"pre"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L653-L677 | [
"def",
"accept_all",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"for",
"key",
"in",
"keys",
"[",
"self",
".",
"PEND",
"]",
":",
"try",
":",
"shutil",
".",
"move",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.delete_key | Delete public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match_dict".
To preserve the master caches of minions who are matched, set preserve_minions | salt/key.py | def delete_key(self,
match=None,
match_dict=None,
preserve_minions=None,
revoke_auth=False):
'''
Delete public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match... | def delete_key(self,
match=None,
match_dict=None,
preserve_minions=None,
revoke_auth=False):
'''
Delete public keys. If "match" is passed, it is evaluated as a glob.
Pre-gathered matches can also be passed via "match... | [
"Delete",
"public",
"keys",
".",
"If",
"match",
"is",
"passed",
"it",
"is",
"evaluated",
"as",
"a",
"glob",
".",
"Pre",
"-",
"gathered",
"matches",
"can",
"also",
"be",
"passed",
"via",
"match_dict",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L679-L729 | [
"def",
"delete_key",
"(",
"self",
",",
"match",
"=",
"None",
",",
"match_dict",
"=",
"None",
",",
"preserve_minions",
"=",
"None",
",",
"revoke_auth",
"=",
"False",
")",
":",
"if",
"match",
"is",
"not",
"None",
":",
"matches",
"=",
"self",
".",
"name_m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.delete_den | Delete all denied keys | salt/key.py | def delete_den(self):
'''
Delete all denied keys
'''
keys = self.list_keys()
for status, keys in six.iteritems(self.list_keys()):
for key in keys[self.DEN]:
try:
os.remove(os.path.join(self.opts['pki_dir'], status, key))
... | def delete_den(self):
'''
Delete all denied keys
'''
keys = self.list_keys()
for status, keys in six.iteritems(self.list_keys()):
for key in keys[self.DEN]:
try:
os.remove(os.path.join(self.opts['pki_dir'], status, key))
... | [
"Delete",
"all",
"denied",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L731-L748 | [
"def",
"delete_den",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"for",
"status",
",",
"keys",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"list_keys",
"(",
")",
")",
":",
"for",
"key",
"in",
"keys",
"[",
"self",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.delete_all | Delete all keys | salt/key.py | def delete_all(self):
'''
Delete all keys
'''
for status, keys in six.iteritems(self.list_keys()):
for key in keys:
try:
os.remove(os.path.join(self.opts['pki_dir'], status, key))
eload = {'result': True,
... | def delete_all(self):
'''
Delete all keys
'''
for status, keys in six.iteritems(self.list_keys()):
for key in keys:
try:
os.remove(os.path.join(self.opts['pki_dir'], status, key))
eload = {'result': True,
... | [
"Delete",
"all",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L750-L768 | [
"def",
"delete_all",
"(",
"self",
")",
":",
"for",
"status",
",",
"keys",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"list_keys",
"(",
")",
")",
":",
"for",
"key",
"in",
"keys",
":",
"try",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.reject_all | Reject all keys in pre | salt/key.py | def reject_all(self):
'''
Reject all keys in pre
'''
keys = self.list_keys()
for key in keys[self.PEND]:
try:
shutil.move(
os.path.join(
self.opts['pki_dir'],
self.PEND,
... | def reject_all(self):
'''
Reject all keys in pre
'''
keys = self.list_keys()
for key in keys[self.PEND]:
try:
shutil.move(
os.path.join(
self.opts['pki_dir'],
self.PEND,
... | [
"Reject",
"all",
"keys",
"in",
"pre"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L814-L841 | [
"def",
"reject_all",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"list_keys",
"(",
")",
"for",
"key",
"in",
"keys",
"[",
"self",
".",
"PEND",
"]",
":",
"try",
":",
"shutil",
".",
"move",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.finger | Return the fingerprint for a specified key | salt/key.py | def finger(self, match, hash_type=None):
'''
Return the fingerprint for a specified key
'''
if hash_type is None:
hash_type = __opts__['hash_type']
matches = self.name_match(match, True)
ret = {}
for status, keys in six.iteritems(matches):
... | def finger(self, match, hash_type=None):
'''
Return the fingerprint for a specified key
'''
if hash_type is None:
hash_type = __opts__['hash_type']
matches = self.name_match(match, True)
ret = {}
for status, keys in six.iteritems(matches):
... | [
"Return",
"the",
"fingerprint",
"for",
"a",
"specified",
"key"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L843-L860 | [
"def",
"finger",
"(",
"self",
",",
"match",
",",
"hash_type",
"=",
"None",
")",
":",
"if",
"hash_type",
"is",
"None",
":",
"hash_type",
"=",
"__opts__",
"[",
"'hash_type'",
"]",
"matches",
"=",
"self",
".",
"name_match",
"(",
"match",
",",
"True",
")",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Key.finger_all | Return fingerprints for all keys | salt/key.py | def finger_all(self, hash_type=None):
'''
Return fingerprints for all keys
'''
if hash_type is None:
hash_type = __opts__['hash_type']
ret = {}
for status, keys in six.iteritems(self.all_keys()):
ret[status] = {}
for key in keys:
... | def finger_all(self, hash_type=None):
'''
Return fingerprints for all keys
'''
if hash_type is None:
hash_type = __opts__['hash_type']
ret = {}
for status, keys in six.iteritems(self.all_keys()):
ret[status] = {}
for key in keys:
... | [
"Return",
"fingerprints",
"for",
"all",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L862-L878 | [
"def",
"finger_all",
"(",
"self",
",",
"hash_type",
"=",
"None",
")",
":",
"if",
"hash_type",
"is",
"None",
":",
"hash_type",
"=",
"__opts__",
"[",
"'hash_type'",
"]",
"ret",
"=",
"{",
"}",
"for",
"status",
",",
"keys",
"in",
"six",
".",
"iteritems",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | __catalina_home | Tomcat paths differ depending on packaging | salt/modules/tomcat.py | def __catalina_home():
'''
Tomcat paths differ depending on packaging
'''
locations = ['/usr/share/tomcat*', '/opt/tomcat']
for location in locations:
folders = glob.glob(location)
if folders:
for catalina_home in folders:
if os.path.isdir(catalina_home + ... | def __catalina_home():
'''
Tomcat paths differ depending on packaging
'''
locations = ['/usr/share/tomcat*', '/opt/tomcat']
for location in locations:
folders = glob.glob(location)
if folders:
for catalina_home in folders:
if os.path.isdir(catalina_home + ... | [
"Tomcat",
"paths",
"differ",
"depending",
"on",
"packaging"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L119-L130 | [
"def",
"__catalina_home",
"(",
")",
":",
"locations",
"=",
"[",
"'/usr/share/tomcat*'",
",",
"'/opt/tomcat'",
"]",
"for",
"location",
"in",
"locations",
":",
"folders",
"=",
"glob",
".",
"glob",
"(",
"location",
")",
"if",
"folders",
":",
"for",
"catalina_ho... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_credentials | Get the username and password from opts, grains, or pillar | salt/modules/tomcat.py | def _get_credentials():
'''
Get the username and password from opts, grains, or pillar
'''
ret = {
'user': False,
'passwd': False
}
# Loop through opts, grains, and pillar
# Return the first acceptable configuration found
for item in ret:
for struct in [__opts__,... | def _get_credentials():
'''
Get the username and password from opts, grains, or pillar
'''
ret = {
'user': False,
'passwd': False
}
# Loop through opts, grains, and pillar
# Return the first acceptable configuration found
for item in ret:
for struct in [__opts__,... | [
"Get",
"the",
"username",
"and",
"password",
"from",
"opts",
"grains",
"or",
"pillar"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L133-L156 | [
"def",
"_get_credentials",
"(",
")",
":",
"ret",
"=",
"{",
"'user'",
":",
"False",
",",
"'passwd'",
":",
"False",
"}",
"# Loop through opts, grains, and pillar",
"# Return the first acceptable configuration found",
"for",
"item",
"in",
"ret",
":",
"for",
"struct",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _auth | returns a authentication handler.
Get user & password from grains, if are not set default to
modules.config.option
If user & pass are missing return False | salt/modules/tomcat.py | def _auth(uri):
'''
returns a authentication handler.
Get user & password from grains, if are not set default to
modules.config.option
If user & pass are missing return False
'''
user, password = _get_credentials()
if user is False or password is False:
return False
basic ... | def _auth(uri):
'''
returns a authentication handler.
Get user & password from grains, if are not set default to
modules.config.option
If user & pass are missing return False
'''
user, password = _get_credentials()
if user is False or password is False:
return False
basic ... | [
"returns",
"a",
"authentication",
"handler",
".",
"Get",
"user",
"&",
"password",
"from",
"grains",
"if",
"are",
"not",
"set",
"default",
"to",
"modules",
".",
"config",
".",
"option"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L159-L178 | [
"def",
"_auth",
"(",
"uri",
")",
":",
"user",
",",
"password",
"=",
"_get_credentials",
"(",
")",
"if",
"user",
"is",
"False",
"or",
"password",
"is",
"False",
":",
"return",
"False",
"basic",
"=",
"_HTTPBasicAuthHandler",
"(",
")",
"basic",
".",
"add_pa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | extract_war_version | Extract the version from the war file name. There does not seem to be a
standard for encoding the version into the `war file name`_
.. _`war file name`: https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
Examples:
.. code-block:: bash
/path/salt-2015.8.6.war -> 2015.8.6
/pa... | salt/modules/tomcat.py | def extract_war_version(war):
'''
Extract the version from the war file name. There does not seem to be a
standard for encoding the version into the `war file name`_
.. _`war file name`: https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
Examples:
.. code-block:: bash
/path... | def extract_war_version(war):
'''
Extract the version from the war file name. There does not seem to be a
standard for encoding the version into the `war file name`_
.. _`war file name`: https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
Examples:
.. code-block:: bash
/path... | [
"Extract",
"the",
"version",
"from",
"the",
"war",
"file",
"name",
".",
"There",
"does",
"not",
"seem",
"to",
"be",
"a",
"standard",
"for",
"encoding",
"the",
"version",
"into",
"the",
"war",
"file",
"name",
"_"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L181-L198 | [
"def",
"extract_war_version",
"(",
"war",
")",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"war",
")",
"war_package",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"basename",
")",
"[",
"0",
"]",
"# remove '.war'",
"version",
"=",
"r... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _wget | A private function used to issue the command to tomcat via the manager
webapp
cmd
the command to execute
url
The URL of the server manager webapp (example:
http://localhost:8080/manager)
opts
a dict of arguments
timeout
timeout for HTTP request
Return... | salt/modules/tomcat.py | def _wget(cmd, opts=None, url='http://localhost:8080/manager', timeout=180):
'''
A private function used to issue the command to tomcat via the manager
webapp
cmd
the command to execute
url
The URL of the server manager webapp (example:
http://localhost:8080/manager)
o... | def _wget(cmd, opts=None, url='http://localhost:8080/manager', timeout=180):
'''
A private function used to issue the command to tomcat via the manager
webapp
cmd
the command to execute
url
The URL of the server manager webapp (example:
http://localhost:8080/manager)
o... | [
"A",
"private",
"function",
"used",
"to",
"issue",
"the",
"command",
"to",
"tomcat",
"via",
"the",
"manager",
"webapp"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L201-L265 | [
"def",
"_wget",
"(",
"cmd",
",",
"opts",
"=",
"None",
",",
"url",
"=",
"'http://localhost:8080/manager'",
",",
"timeout",
"=",
"180",
")",
":",
"ret",
"=",
"{",
"'res'",
":",
"True",
",",
"'msg'",
":",
"[",
"]",
"}",
"# prepare authentication",
"auth",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _simple_cmd | Simple command wrapper to commands that need only a path option | salt/modules/tomcat.py | def _simple_cmd(cmd, app, url='http://localhost:8080/manager', timeout=180):
'''
Simple command wrapper to commands that need only a path option
'''
try:
opts = {
'path': app,
'version': ls(url)[app]['version']
}
return '\n'.join(_wget(cmd, opts, url, tim... | def _simple_cmd(cmd, app, url='http://localhost:8080/manager', timeout=180):
'''
Simple command wrapper to commands that need only a path option
'''
try:
opts = {
'path': app,
'version': ls(url)[app]['version']
}
return '\n'.join(_wget(cmd, opts, url, tim... | [
"Simple",
"command",
"wrapper",
"to",
"commands",
"that",
"need",
"only",
"a",
"path",
"option"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L268-L280 | [
"def",
"_simple_cmd",
"(",
"cmd",
",",
"app",
",",
"url",
"=",
"'http://localhost:8080/manager'",
",",
"timeout",
"=",
"180",
")",
":",
"try",
":",
"opts",
"=",
"{",
"'path'",
":",
"app",
",",
"'version'",
":",
"ls",
"(",
"url",
")",
"[",
"app",
"]",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ls | list all the deployed webapps
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request
CLI Examples:
.. code-block:: bash
salt '*' tomcat.ls
salt '*' tomcat.ls http://localhost:8080/manager | salt/modules/tomcat.py | def ls(url='http://localhost:8080/manager', timeout=180):
'''
list all the deployed webapps
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request
CLI Examples:
.. code-block:: bash
salt '*' tomcat.ls
sa... | def ls(url='http://localhost:8080/manager', timeout=180):
'''
list all the deployed webapps
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request
CLI Examples:
.. code-block:: bash
salt '*' tomcat.ls
sa... | [
"list",
"all",
"the",
"deployed",
"webapps"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L324-L358 | [
"def",
"ls",
"(",
"url",
"=",
"'http://localhost:8080/manager'",
",",
"timeout",
"=",
"180",
")",
":",
"ret",
"=",
"{",
"}",
"data",
"=",
"_wget",
"(",
"'list'",
",",
"''",
",",
"url",
",",
"timeout",
"=",
"timeout",
")",
"if",
"data",
"[",
"'res'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.