repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/pyenv.py | versions | def versions(runas=None):
'''
List the installed versions of python.
CLI Example:
.. code-block:: bash
salt '*' pyenv.versions
'''
ret = _pyenv_exec('versions', '--bare', runas=runas)
return [] if ret is False else ret.splitlines() | python | def versions(runas=None):
'''
List the installed versions of python.
CLI Example:
.. code-block:: bash
salt '*' pyenv.versions
'''
ret = _pyenv_exec('versions', '--bare', runas=runas)
return [] if ret is False else ret.splitlines() | [
"def",
"versions",
"(",
"runas",
"=",
"None",
")",
":",
"ret",
"=",
"_pyenv_exec",
"(",
"'versions'",
",",
"'--bare'",
",",
"runas",
"=",
"runas",
")",
"return",
"[",
"]",
"if",
"ret",
"is",
"False",
"else",
"ret",
".",
"splitlines",
"(",
")"
] | List the installed versions of python.
CLI Example:
.. code-block:: bash
salt '*' pyenv.versions | [
"List",
"the",
"installed",
"versions",
"of",
"python",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pyenv.py#L209-L220 | train |
saltstack/salt | salt/modules/pyenv.py | default | def default(python=None, runas=None):
'''
Returns or sets the currently defined default python.
python=None
The version to set as the default. Should match one of the versions
listed by :mod:`pyenv.versions <salt.modules.pyenv.versions>`. Leave
blank to return the current default.
... | python | def default(python=None, runas=None):
'''
Returns or sets the currently defined default python.
python=None
The version to set as the default. Should match one of the versions
listed by :mod:`pyenv.versions <salt.modules.pyenv.versions>`. Leave
blank to return the current default.
... | [
"def",
"default",
"(",
"python",
"=",
"None",
",",
"runas",
"=",
"None",
")",
":",
"if",
"python",
":",
"_pyenv_exec",
"(",
"'global'",
",",
"python",
",",
"runas",
"=",
"runas",
")",
"return",
"True",
"else",
":",
"ret",
"=",
"_pyenv_exec",
"(",
"'g... | Returns or sets the currently defined default python.
python=None
The version to set as the default. Should match one of the versions
listed by :mod:`pyenv.versions <salt.modules.pyenv.versions>`. Leave
blank to return the current default.
CLI Example:
.. code-block:: bash
... | [
"Returns",
"or",
"sets",
"the",
"currently",
"defined",
"default",
"python",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pyenv.py#L223-L244 | train |
saltstack/salt | salt/modules/pyenv.py | do | def do(cmdline=None, runas=None):
'''
Execute a python command with pyenv's shims from the user or the system.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do 'gem list bundler'
salt '*' pyenv.do 'gem list bundler' deploy
'''
path = _pyenv_path(runas)
cmd_split = cmdli... | python | def do(cmdline=None, runas=None):
'''
Execute a python command with pyenv's shims from the user or the system.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do 'gem list bundler'
salt '*' pyenv.do 'gem list bundler' deploy
'''
path = _pyenv_path(runas)
cmd_split = cmdli... | [
"def",
"do",
"(",
"cmdline",
"=",
"None",
",",
"runas",
"=",
"None",
")",
":",
"path",
"=",
"_pyenv_path",
"(",
"runas",
")",
"cmd_split",
"=",
"cmdline",
".",
"split",
"(",
")",
"quoted_line",
"=",
"''",
"for",
"cmd",
"in",
"cmd_split",
":",
"quoted... | Execute a python command with pyenv's shims from the user or the system.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do 'gem list bundler'
salt '*' pyenv.do 'gem list bundler' deploy | [
"Execute",
"a",
"python",
"command",
"with",
"pyenv",
"s",
"shims",
"from",
"the",
"user",
"or",
"the",
"system",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pyenv.py#L281-L307 | train |
saltstack/salt | salt/modules/pyenv.py | do_with_python | def do_with_python(python, cmdline, runas=None):
'''
Execute a python command with pyenv's shims using a specific python version.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler'
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler' deplo... | python | def do_with_python(python, cmdline, runas=None):
'''
Execute a python command with pyenv's shims using a specific python version.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler'
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler' deplo... | [
"def",
"do_with_python",
"(",
"python",
",",
"cmdline",
",",
"runas",
"=",
"None",
")",
":",
"if",
"python",
":",
"cmd",
"=",
"'PYENV_VERSION={0} {1}'",
".",
"format",
"(",
"python",
",",
"cmdline",
")",
"else",
":",
"cmd",
"=",
"cmdline",
"return",
"do"... | Execute a python command with pyenv's shims using a specific python version.
CLI Example:
.. code-block:: bash
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler'
salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler' deploy | [
"Execute",
"a",
"python",
"command",
"with",
"pyenv",
"s",
"shims",
"using",
"a",
"specific",
"python",
"version",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pyenv.py#L310-L326 | train |
saltstack/salt | salt/states/boto_rds.py | present | def present(name,
allocated_storage,
db_instance_class,
engine,
master_username,
master_user_password,
db_name=None,
storage_type=None,
db_security_groups=None,
vpc_security_group_ids=None,
vpc_securi... | python | def present(name,
allocated_storage,
db_instance_class,
engine,
master_username,
master_user_password,
db_name=None,
storage_type=None,
db_security_groups=None,
vpc_security_group_ids=None,
vpc_securi... | [
"def",
"present",
"(",
"name",
",",
"allocated_storage",
",",
"db_instance_class",
",",
"engine",
",",
"master_username",
",",
"master_user_password",
",",
"db_name",
"=",
"None",
",",
"storage_type",
"=",
"None",
",",
"db_security_groups",
"=",
"None",
",",
"vp... | Ensure RDS instance exists.
name
Name of the RDS state definition.
allocated_storage
The amount of storage (in gigabytes) to be initially allocated for the
database instance.
db_instance_class
The compute and memory capacity of the Amazon RDS DB instance.
engine
... | [
"Ensure",
"RDS",
"instance",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_rds.py#L94-L361 | train |
saltstack/salt | salt/states/boto_rds.py | replica_present | def replica_present(name, source, db_instance_class=None,
availability_zone=None, port=None,
auto_minor_version_upgrade=None, iops=None,
option_group_name=None, publicly_accessible=None,
tags=None, region=None, key=None, keyid=None,
... | python | def replica_present(name, source, db_instance_class=None,
availability_zone=None, port=None,
auto_minor_version_upgrade=None, iops=None,
option_group_name=None, publicly_accessible=None,
tags=None, region=None, key=None, keyid=None,
... | [
"def",
"replica_present",
"(",
"name",
",",
"source",
",",
"db_instance_class",
"=",
"None",
",",
"availability_zone",
"=",
"None",
",",
"port",
"=",
"None",
",",
"auto_minor_version_upgrade",
"=",
"None",
",",
"iops",
"=",
"None",
",",
"option_group_name",
"=... | Ensure RDS replica exists.
.. code-block:: yaml
Ensure myrds replica RDS exists:
boto_rds.create_replica:
- name: myreplica
- source: mydb | [
"Ensure",
"RDS",
"replica",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_rds.py#L364-L428 | train |
saltstack/salt | salt/states/boto_rds.py | subnet_group_present | def subnet_group_present(name, description, subnet_ids=None, subnet_names=None,
tags=None, region=None, key=None, keyid=None,
profile=None):
'''
Ensure DB subnet group exists.
name
The name for the DB subnet group. This value is stored as a lowercas... | python | def subnet_group_present(name, description, subnet_ids=None, subnet_names=None,
tags=None, region=None, key=None, keyid=None,
profile=None):
'''
Ensure DB subnet group exists.
name
The name for the DB subnet group. This value is stored as a lowercas... | [
"def",
"subnet_group_present",
"(",
"name",
",",
"description",
",",
"subnet_ids",
"=",
"None",
",",
"subnet_names",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
... | Ensure DB subnet group exists.
name
The name for the DB subnet group. This value is stored as a lowercase string.
subnet_ids
A list of the EC2 Subnet IDs for the DB subnet group.
Either subnet_ids or subnet_names must be provided.
subnet_names
A list of The EC2 Subnet name... | [
"Ensure",
"DB",
"subnet",
"group",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_rds.py#L431-L523 | train |
saltstack/salt | salt/states/boto_rds.py | absent | def absent(name, skip_final_snapshot=None, final_db_snapshot_identifier=None,
tags=None, wait_for_deletion=True, timeout=180,
region=None, key=None, keyid=None, profile=None):
'''
Ensure RDS instance is absent.
name
Name of the RDS instance.
skip_final_snapshot
Wh... | python | def absent(name, skip_final_snapshot=None, final_db_snapshot_identifier=None,
tags=None, wait_for_deletion=True, timeout=180,
region=None, key=None, keyid=None, profile=None):
'''
Ensure RDS instance is absent.
name
Name of the RDS instance.
skip_final_snapshot
Wh... | [
"def",
"absent",
"(",
"name",
",",
"skip_final_snapshot",
"=",
"None",
",",
"final_db_snapshot_identifier",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"wait_for_deletion",
"=",
"True",
",",
"timeout",
"=",
"180",
",",
"region",
"=",
"None",
",",
"key",
"=... | Ensure RDS instance is absent.
name
Name of the RDS instance.
skip_final_snapshot
Whether a final db snapshot is created before the instance is deleted.
If True, no snapshot is created.
If False, a snapshot is created before deleting the instance.
final_db_snapshot_identif... | [
"Ensure",
"RDS",
"instance",
"is",
"absent",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_rds.py#L526-L595 | train |
saltstack/salt | salt/states/boto_rds.py | parameter_present | def parameter_present(name, db_parameter_group_family, description, parameters=None,
apply_method="pending-reboot", tags=None, region=None, key=None, keyid=None, profile=None):
'''
Ensure DB parameter group exists and update parameters.
name
The name for the parameter group.
... | python | def parameter_present(name, db_parameter_group_family, description, parameters=None,
apply_method="pending-reboot", tags=None, region=None, key=None, keyid=None, profile=None):
'''
Ensure DB parameter group exists and update parameters.
name
The name for the parameter group.
... | [
"def",
"parameter_present",
"(",
"name",
",",
"db_parameter_group_family",
",",
"description",
",",
"parameters",
"=",
"None",
",",
"apply_method",
"=",
"\"pending-reboot\"",
",",
"tags",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
... | Ensure DB parameter group exists and update parameters.
name
The name for the parameter group.
db_parameter_group_family
The DB parameter group family name. A
DB parameter group can be associated with one and only one DB
parameter group family, and can be applied only to a DB i... | [
"Ensure",
"DB",
"parameter",
"group",
"exists",
"and",
"update",
"parameters",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_rds.py#L627-L734 | train |
saltstack/salt | salt/utils/find.py | _parse_interval | def _parse_interval(value):
'''
Convert an interval string like 1w3d6h into the number of seconds, time
resolution (1 unit of the smallest specified time unit) and the modifier(
'+', '-', or '').
w = week
d = day
h = hour
m = minute
s = second
'''
match = ... | python | def _parse_interval(value):
'''
Convert an interval string like 1w3d6h into the number of seconds, time
resolution (1 unit of the smallest specified time unit) and the modifier(
'+', '-', or '').
w = week
d = day
h = hour
m = minute
s = second
'''
match = ... | [
"def",
"_parse_interval",
"(",
"value",
")",
":",
"match",
"=",
"_INTERVAL_REGEX",
".",
"match",
"(",
"six",
".",
"text_type",
"(",
"value",
")",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invalid time interval: \\'{0}\\''",
".",
"f... | Convert an interval string like 1w3d6h into the number of seconds, time
resolution (1 unit of the smallest specified time unit) and the modifier(
'+', '-', or '').
w = week
d = day
h = hour
m = minute
s = second | [
"Convert",
"an",
"interval",
"string",
"like",
"1w3d6h",
"into",
"the",
"number",
"of",
"seconds",
"time",
"resolution",
"(",
"1",
"unit",
"of",
"the",
"smallest",
"specified",
"time",
"unit",
")",
"and",
"the",
"modifier",
"(",
"+",
"-",
"or",
")",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/find.py#L152-L179 | train |
saltstack/salt | salt/utils/find.py | find | def find(path, options):
'''
WRITEME
'''
finder = Finder(options)
for path in finder.find(path):
yield path | python | def find(path, options):
'''
WRITEME
'''
finder = Finder(options)
for path in finder.find(path):
yield path | [
"def",
"find",
"(",
"path",
",",
"options",
")",
":",
"finder",
"=",
"Finder",
"(",
"options",
")",
"for",
"path",
"in",
"finder",
".",
"find",
"(",
"path",
")",
":",
"yield",
"path"
] | WRITEME | [
"WRITEME"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/find.py#L697-L703 | train |
saltstack/salt | salt/utils/find.py | Finder.find | def find(self, path):
'''
Generate filenames in path that satisfy criteria specified in
the constructor.
This method is a generator and should be repeatedly called
until there are no more results.
'''
if self.mindepth < 1:
dirpath, name = os.path.split... | python | def find(self, path):
'''
Generate filenames in path that satisfy criteria specified in
the constructor.
This method is a generator and should be repeatedly called
until there are no more results.
'''
if self.mindepth < 1:
dirpath, name = os.path.split... | [
"def",
"find",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"mindepth",
"<",
"1",
":",
"dirpath",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"match",
",",
"fstat",
"=",
"self",
".",
"_check_criteria",
"(",
"dir... | Generate filenames in path that satisfy criteria specified in
the constructor.
This method is a generator and should be repeatedly called
until there are no more results. | [
"Generate",
"filenames",
"in",
"path",
"that",
"satisfy",
"criteria",
"specified",
"in",
"the",
"constructor",
".",
"This",
"method",
"is",
"a",
"generator",
"and",
"should",
"be",
"repeatedly",
"called",
"until",
"there",
"are",
"no",
"more",
"results",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/find.py#L632-L658 | train |
saltstack/salt | salt/modules/pagerduty.py | list_services | def list_services(profile=None, api_key=None):
'''
List services belonging to this account
CLI Example:
salt myminion pagerduty.list_services my-pagerduty-account
'''
return salt.utils.pagerduty.list_items(
'services',
'name',
__salt__['config.option'](profile),
... | python | def list_services(profile=None, api_key=None):
'''
List services belonging to this account
CLI Example:
salt myminion pagerduty.list_services my-pagerduty-account
'''
return salt.utils.pagerduty.list_items(
'services',
'name',
__salt__['config.option'](profile),
... | [
"def",
"list_services",
"(",
"profile",
"=",
"None",
",",
"api_key",
"=",
"None",
")",
":",
"return",
"salt",
".",
"utils",
".",
"pagerduty",
".",
"list_items",
"(",
"'services'",
",",
"'name'",
",",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"profile",... | List services belonging to this account
CLI Example:
salt myminion pagerduty.list_services my-pagerduty-account | [
"List",
"services",
"belonging",
"to",
"this",
"account"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pagerduty.py#L37-L51 | train |
saltstack/salt | salt/modules/pagerduty.py | create_event | def create_event(service_key=None, description=None, details=None,
incident_key=None, profile=None):
'''
Create an event in PagerDuty. Designed for use in states.
CLI Example:
.. code-block:: yaml
salt myminion pagerduty.create_event <service_key> <description> <details> \
... | python | def create_event(service_key=None, description=None, details=None,
incident_key=None, profile=None):
'''
Create an event in PagerDuty. Designed for use in states.
CLI Example:
.. code-block:: yaml
salt myminion pagerduty.create_event <service_key> <description> <details> \
... | [
"def",
"create_event",
"(",
"service_key",
"=",
"None",
",",
"description",
"=",
"None",
",",
"details",
"=",
"None",
",",
"incident_key",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"trigger_url",
"=",
"'https://events.pagerduty.com/generic/2010-04-15/cre... | Create an event in PagerDuty. Designed for use in states.
CLI Example:
.. code-block:: yaml
salt myminion pagerduty.create_event <service_key> <description> <details> \
profile=my-pagerduty-account
The following parameters are required:
service_key
This key can be found by u... | [
"Create",
"an",
"event",
"in",
"PagerDuty",
".",
"Designed",
"for",
"use",
"in",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pagerduty.py#L149-L197 | train |
saltstack/salt | salt/states/win_certutil.py | add_store | def add_store(name, store, saltenv='base'):
'''
Store a certificate to the given store
name
The certificate to store, this can use local paths
or salt:// paths
store
The store to add the certificate to
saltenv
The salt environment to use, this is ignored if a local... | python | def add_store(name, store, saltenv='base'):
'''
Store a certificate to the given store
name
The certificate to store, this can use local paths
or salt:// paths
store
The store to add the certificate to
saltenv
The salt environment to use, this is ignored if a local... | [
"def",
"add_store",
"(",
"name",
",",
"store",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"cert_file",
"=",
"__sa... | Store a certificate to the given store
name
The certificate to store, this can use local paths
or salt:// paths
store
The store to add the certificate to
saltenv
The salt environment to use, this is ignored if a local
path is specified | [
"Store",
"a",
"certificate",
"to",
"the",
"given",
"store"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_certutil.py#L34-L73 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.master_call | def master_call(self, **kwargs):
'''
Execute a function through the master network interface.
'''
load = kwargs
load['cmd'] = self.client
channel = salt.transport.client.ReqChannel.factory(self.opts,
crypt='clear'... | python | def master_call(self, **kwargs):
'''
Execute a function through the master network interface.
'''
load = kwargs
load['cmd'] = self.client
channel = salt.transport.client.ReqChannel.factory(self.opts,
crypt='clear'... | [
"def",
"master_call",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"load",
"=",
"kwargs",
"load",
"[",
"'cmd'",
"]",
"=",
"self",
".",
"client",
"channel",
"=",
"salt",
".",
"transport",
".",
"client",
".",
"ReqChannel",
".",
"factory",
"(",
"self... | Execute a function through the master network interface. | [
"Execute",
"a",
"function",
"through",
"the",
"master",
"network",
"interface",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L139-L155 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.cmd_sync | def cmd_sync(self, low, timeout=None, full_return=False):
'''
Execute a runner function synchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:... | python | def cmd_sync(self, low, timeout=None, full_return=False):
'''
Execute a runner function synchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:... | [
"def",
"cmd_sync",
"(",
"self",
",",
"low",
",",
"timeout",
"=",
"None",
",",
"full_return",
"=",
"False",
")",
":",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"get_master_event",
"(",
"self",
".",
"opts",
",",
"self",
".",
"opts",
"[",
... | Execute a runner function synchronously; eauth is respected
This function requires that :conf_master:`external_auth` is configured
and the user is authorized to execute runner functions: (``@runner``).
.. code-block:: python
runner.eauth_sync({
'fun': 'jobs.list_jo... | [
"Execute",
"a",
"runner",
"function",
"synchronously",
";",
"eauth",
"is",
"respected"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L157-L185 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.cmd | def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):
'''
Execute a function
.. code-block:: python
>>> opts = salt.config.master_config('/etc/salt/master')
>>> runner = salt.runner.RunnerClient(opts)
>>> runner.cmd('j... | python | def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):
'''
Execute a function
.. code-block:: python
>>> opts = salt.config.master_config('/etc/salt/master')
>>> runner = salt.runner.RunnerClient(opts)
>>> runner.cmd('j... | [
"def",
"cmd",
"(",
"self",
",",
"fun",
",",
"arg",
"=",
"None",
",",
"pub_data",
"=",
"None",
",",
"kwarg",
"=",
"None",
",",
"print_event",
"=",
"True",
",",
"full_return",
"=",
"False",
")",
":",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"tup... | Execute a function
.. code-block:: python
>>> opts = salt.config.master_config('/etc/salt/master')
>>> runner = salt.runner.RunnerClient(opts)
>>> runner.cmd('jobs.list_jobs', [])
{
'20131219215650131543': {
'Arguments': [300]... | [
"Execute",
"a",
"function"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L187-L249 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.store_job | def store_job(self):
'''
Helper that allows us to turn off storing jobs for different classes
that may incorporate this mixin.
'''
try:
class_name = self.__class__.__name__.lower()
except AttributeError:
log.warning(
'Unable to dete... | python | def store_job(self):
'''
Helper that allows us to turn off storing jobs for different classes
that may incorporate this mixin.
'''
try:
class_name = self.__class__.__name__.lower()
except AttributeError:
log.warning(
'Unable to dete... | [
"def",
"store_job",
"(",
"self",
")",
":",
"try",
":",
"class_name",
"=",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
"except",
"AttributeError",
":",
"log",
".",
"warning",
"(",
"'Unable to determine class name'",
",",
"exc_info_on_logl... | Helper that allows us to turn off storing jobs for different classes
that may incorporate this mixin. | [
"Helper",
"that",
"allows",
"us",
"to",
"turn",
"off",
"storing",
"jobs",
"for",
"different",
"classes",
"that",
"may",
"incorporate",
"this",
"mixin",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L258-L277 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.low | def low(self, fun, low, print_event=True, full_return=False):
'''
Execute a function from low data
Low data includes:
required:
- fun: the name of the function to run
optional:
- arg: a list of args to pass to fun
- kwarg: k... | python | def low(self, fun, low, print_event=True, full_return=False):
'''
Execute a function from low data
Low data includes:
required:
- fun: the name of the function to run
optional:
- arg: a list of args to pass to fun
- kwarg: k... | [
"def",
"low",
"(",
"self",
",",
"fun",
",",
"low",
",",
"print_event",
"=",
"True",
",",
"full_return",
"=",
"False",
")",
":",
"# fire the mminion loading (if not already done) here",
"# this is not to clutter the output with the module loading",
"# if we have a high debug l... | Execute a function from low data
Low data includes:
required:
- fun: the name of the function to run
optional:
- arg: a list of args to pass to fun
- kwarg: kwargs for fun
- __user__: user who is running the command
... | [
"Execute",
"a",
"function",
"from",
"low",
"data",
"Low",
"data",
"includes",
":",
"required",
":",
"-",
"fun",
":",
"the",
"name",
"of",
"the",
"function",
"to",
"run",
"optional",
":",
"-",
"arg",
":",
"a",
"list",
"of",
"args",
"to",
"pass",
"to",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L279-L444 | train |
saltstack/salt | salt/client/mixins.py | SyncClientMixin.get_docs | def get_docs(self, arg=None):
'''
Return a dictionary of functions and the inline documentation for each
'''
if arg:
if '*' in arg:
target_mod = arg
_use_fnmatch = True
else:
target_mod = arg + '.' if not arg.endswit... | python | def get_docs(self, arg=None):
'''
Return a dictionary of functions and the inline documentation for each
'''
if arg:
if '*' in arg:
target_mod = arg
_use_fnmatch = True
else:
target_mod = arg + '.' if not arg.endswit... | [
"def",
"get_docs",
"(",
"self",
",",
"arg",
"=",
"None",
")",
":",
"if",
"arg",
":",
"if",
"'*'",
"in",
"arg",
":",
"target_mod",
"=",
"arg",
"_use_fnmatch",
"=",
"True",
"else",
":",
"target_mod",
"=",
"arg",
"+",
"'.'",
"if",
"not",
"arg",
".",
... | Return a dictionary of functions and the inline documentation for each | [
"Return",
"a",
"dictionary",
"of",
"functions",
"and",
"the",
"inline",
"documentation",
"for",
"each"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L446-L468 | train |
saltstack/salt | salt/client/mixins.py | AsyncClientMixin.asynchronous | def asynchronous(self, fun, low, user='UNKNOWN', pub=None):
'''
Execute the function in a multiprocess and return the event tag to use
to watch for the return
'''
async_pub = pub if pub is not None else self._gen_async_pub()
proc = salt.utils.process.SignalHandlingMultip... | python | def asynchronous(self, fun, low, user='UNKNOWN', pub=None):
'''
Execute the function in a multiprocess and return the event tag to use
to watch for the return
'''
async_pub = pub if pub is not None else self._gen_async_pub()
proc = salt.utils.process.SignalHandlingMultip... | [
"def",
"asynchronous",
"(",
"self",
",",
"fun",
",",
"low",
",",
"user",
"=",
"'UNKNOWN'",
",",
"pub",
"=",
"None",
")",
":",
"async_pub",
"=",
"pub",
"if",
"pub",
"is",
"not",
"None",
"else",
"self",
".",
"_gen_async_pub",
"(",
")",
"proc",
"=",
"... | Execute the function in a multiprocess and return the event tag to use
to watch for the return | [
"Execute",
"the",
"function",
"in",
"a",
"multiprocess",
"and",
"return",
"the",
"event",
"tag",
"to",
"use",
"to",
"watch",
"for",
"the",
"return"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L525-L540 | train |
saltstack/salt | salt/client/mixins.py | AsyncClientMixin.print_async_event | def print_async_event(self, suffix, event):
'''
Print all of the events with the prefix 'tag'
'''
if not isinstance(event, dict):
return
# if we are "quiet", don't print
if self.opts.get('quiet', False):
return
# some suffixes we don't wa... | python | def print_async_event(self, suffix, event):
'''
Print all of the events with the prefix 'tag'
'''
if not isinstance(event, dict):
return
# if we are "quiet", don't print
if self.opts.get('quiet', False):
return
# some suffixes we don't wa... | [
"def",
"print_async_event",
"(",
"self",
",",
"suffix",
",",
"event",
")",
":",
"if",
"not",
"isinstance",
"(",
"event",
",",
"dict",
")",
":",
"return",
"# if we are \"quiet\", don't print",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'quiet'",
",",
"Fal... | Print all of the events with the prefix 'tag' | [
"Print",
"all",
"of",
"the",
"events",
"with",
"the",
"prefix",
"tag"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/mixins.py#L542-L575 | train |
saltstack/salt | doc/_ext/shorturls.py | write_urls_index | def write_urls_index(app, exc):
'''
Generate a JSON file to serve as an index for short-URL lookups
'''
inventory = os.path.join(app.builder.outdir, 'objects.inv')
objects = sphinx.ext.intersphinx.fetch_inventory(app, DOCS_URL, inventory)
with open(os.path.join(app.builder.outdir, 'shorturls.js... | python | def write_urls_index(app, exc):
'''
Generate a JSON file to serve as an index for short-URL lookups
'''
inventory = os.path.join(app.builder.outdir, 'objects.inv')
objects = sphinx.ext.intersphinx.fetch_inventory(app, DOCS_URL, inventory)
with open(os.path.join(app.builder.outdir, 'shorturls.js... | [
"def",
"write_urls_index",
"(",
"app",
",",
"exc",
")",
":",
"inventory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app",
".",
"builder",
".",
"outdir",
",",
"'objects.inv'",
")",
"objects",
"=",
"sphinx",
".",
"ext",
".",
"intersphinx",
".",
"fetch_i... | Generate a JSON file to serve as an index for short-URL lookups | [
"Generate",
"a",
"JSON",
"file",
"to",
"serve",
"as",
"an",
"index",
"for",
"short",
"-",
"URL",
"lookups"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/_ext/shorturls.py#L11-L19 | train |
saltstack/salt | salt/utils/mac_utils.py | execute_return_success | def execute_return_success(cmd):
'''
Executes the passed command. Returns True if successful
:param str cmd: The command to run
:return: True if successful, otherwise False
:rtype: bool
:raises: Error if command fails or is not supported
'''
ret = _run_all(cmd)
if ret['retcode']... | python | def execute_return_success(cmd):
'''
Executes the passed command. Returns True if successful
:param str cmd: The command to run
:return: True if successful, otherwise False
:rtype: bool
:raises: Error if command fails or is not supported
'''
ret = _run_all(cmd)
if ret['retcode']... | [
"def",
"execute_return_success",
"(",
"cmd",
")",
":",
"ret",
"=",
"_run_all",
"(",
"cmd",
")",
"if",
"ret",
"[",
"'retcode'",
"]",
"!=",
"0",
"or",
"'not supported'",
"in",
"ret",
"[",
"'stdout'",
"]",
".",
"lower",
"(",
")",
":",
"msg",
"=",
"'Comm... | Executes the passed command. Returns True if successful
:param str cmd: The command to run
:return: True if successful, otherwise False
:rtype: bool
:raises: Error if command fails or is not supported | [
"Executes",
"the",
"passed",
"command",
".",
"Returns",
"True",
"if",
"successful"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L144-L165 | train |
saltstack/salt | salt/utils/mac_utils.py | execute_return_result | def execute_return_result(cmd):
'''
Executes the passed command. Returns the standard out if successful
:param str cmd: The command to run
:return: The standard out of the command if successful, otherwise returns
an error
:rtype: str
:raises: Error if command fails or is not supported
... | python | def execute_return_result(cmd):
'''
Executes the passed command. Returns the standard out if successful
:param str cmd: The command to run
:return: The standard out of the command if successful, otherwise returns
an error
:rtype: str
:raises: Error if command fails or is not supported
... | [
"def",
"execute_return_result",
"(",
"cmd",
")",
":",
"ret",
"=",
"_run_all",
"(",
"cmd",
")",
"if",
"ret",
"[",
"'retcode'",
"]",
"!=",
"0",
"or",
"'not supported'",
"in",
"ret",
"[",
"'stdout'",
"]",
".",
"lower",
"(",
")",
":",
"msg",
"=",
"'Comma... | Executes the passed command. Returns the standard out if successful
:param str cmd: The command to run
:return: The standard out of the command if successful, otherwise returns
an error
:rtype: str
:raises: Error if command fails or is not supported | [
"Executes",
"the",
"passed",
"command",
".",
"Returns",
"the",
"standard",
"out",
"if",
"successful"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L168-L189 | train |
saltstack/salt | salt/utils/mac_utils.py | validate_enabled | def validate_enabled(enabled):
'''
Helper function to validate the enabled parameter. Boolean values are
converted to "on" and "off". String values are checked to make sure they are
either "on" or "off"/"yes" or "no". Integer ``0`` will return "off". All
other integers will return "on"
:param e... | python | def validate_enabled(enabled):
'''
Helper function to validate the enabled parameter. Boolean values are
converted to "on" and "off". String values are checked to make sure they are
either "on" or "off"/"yes" or "no". Integer ``0`` will return "off". All
other integers will return "on"
:param e... | [
"def",
"validate_enabled",
"(",
"enabled",
")",
":",
"if",
"isinstance",
"(",
"enabled",
",",
"six",
".",
"string_types",
")",
":",
"if",
"enabled",
".",
"lower",
"(",
")",
"not",
"in",
"[",
"'on'",
",",
"'off'",
",",
"'yes'",
",",
"'no'",
"]",
":",
... | Helper function to validate the enabled parameter. Boolean values are
converted to "on" and "off". String values are checked to make sure they are
either "on" or "off"/"yes" or "no". Integer ``0`` will return "off". All
other integers will return "on"
:param enabled: Enabled can be boolean True or Fals... | [
"Helper",
"function",
"to",
"validate",
"the",
"enabled",
"parameter",
".",
"Boolean",
"values",
"are",
"converted",
"to",
"on",
"and",
"off",
".",
"String",
"values",
"are",
"checked",
"to",
"make",
"sure",
"they",
"are",
"either",
"on",
"or",
"off",
"/",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L213-L236 | train |
saltstack/salt | salt/utils/mac_utils.py | confirm_updated | def confirm_updated(value, check_fun, normalize_ret=False, wait=5):
'''
Wait up to ``wait`` seconds for a system parameter to be changed before
deciding it hasn't changed.
:param str value: The value indicating a successful change
:param function check_fun: The function whose return is compared wi... | python | def confirm_updated(value, check_fun, normalize_ret=False, wait=5):
'''
Wait up to ``wait`` seconds for a system parameter to be changed before
deciding it hasn't changed.
:param str value: The value indicating a successful change
:param function check_fun: The function whose return is compared wi... | [
"def",
"confirm_updated",
"(",
"value",
",",
"check_fun",
",",
"normalize_ret",
"=",
"False",
",",
"wait",
"=",
"5",
")",
":",
"for",
"i",
"in",
"range",
"(",
"wait",
")",
":",
"state",
"=",
"validate_enabled",
"(",
"check_fun",
"(",
")",
")",
"if",
... | Wait up to ``wait`` seconds for a system parameter to be changed before
deciding it hasn't changed.
:param str value: The value indicating a successful change
:param function check_fun: The function whose return is compared with
``value``
:param bool normalize_ret: Whether to normalize the re... | [
"Wait",
"up",
"to",
"wait",
"seconds",
"for",
"a",
"system",
"parameter",
"to",
"be",
"changed",
"before",
"deciding",
"it",
"hasn",
"t",
"changed",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L239-L260 | train |
saltstack/salt | salt/utils/mac_utils.py | launchctl | def launchctl(sub_cmd, *args, **kwargs):
'''
Run a launchctl command and raise an error if it fails
Args: additional args are passed to launchctl
sub_cmd (str): Sub command supplied to launchctl
Kwargs: passed to ``cmd.run_all``
return_stdout (bool): A keyword argument. If true return ... | python | def launchctl(sub_cmd, *args, **kwargs):
'''
Run a launchctl command and raise an error if it fails
Args: additional args are passed to launchctl
sub_cmd (str): Sub command supplied to launchctl
Kwargs: passed to ``cmd.run_all``
return_stdout (bool): A keyword argument. If true return ... | [
"def",
"launchctl",
"(",
"sub_cmd",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get return type",
"return_stdout",
"=",
"kwargs",
".",
"pop",
"(",
"'return_stdout'",
",",
"False",
")",
"# Construct command",
"cmd",
"=",
"[",
"'launchctl'",
",",
... | Run a launchctl command and raise an error if it fails
Args: additional args are passed to launchctl
sub_cmd (str): Sub command supplied to launchctl
Kwargs: passed to ``cmd.run_all``
return_stdout (bool): A keyword argument. If true return the stdout of
the launchctl command
... | [
"Run",
"a",
"launchctl",
"command",
"and",
"raise",
"an",
"error",
"if",
"it",
"fails"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L263-L309 | train |
saltstack/salt | salt/utils/mac_utils.py | _available_services | def _available_services(refresh=False):
'''
This is a helper function for getting the available macOS services.
The strategy is to look through the known system locations for
launchd plist files, parse them, and use their information for
populating the list of services. Services can run without a p... | python | def _available_services(refresh=False):
'''
This is a helper function for getting the available macOS services.
The strategy is to look through the known system locations for
launchd plist files, parse them, and use their information for
populating the list of services. Services can run without a p... | [
"def",
"_available_services",
"(",
"refresh",
"=",
"False",
")",
":",
"try",
":",
"if",
"__context__",
"[",
"'available_services'",
"]",
"and",
"not",
"refresh",
":",
"log",
".",
"debug",
"(",
"'Found context for available services.'",
")",
"__context__",
"[",
"... | This is a helper function for getting the available macOS services.
The strategy is to look through the known system locations for
launchd plist files, parse them, and use their information for
populating the list of services. Services can run without a plist
file present, but normally services which h... | [
"This",
"is",
"a",
"helper",
"function",
"for",
"getting",
"the",
"available",
"macOS",
"services",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L312-L417 | train |
saltstack/salt | salt/utils/mac_utils.py | console_user | def console_user(username=False):
'''
Gets the UID or Username of the current console user.
:return: The uid or username of the console user.
:param bool username: Whether to return the username of the console
user instead of the UID. Defaults to False
:rtype: Interger of the UID, or a string... | python | def console_user(username=False):
'''
Gets the UID or Username of the current console user.
:return: The uid or username of the console user.
:param bool username: Whether to return the username of the console
user instead of the UID. Defaults to False
:rtype: Interger of the UID, or a string... | [
"def",
"console_user",
"(",
"username",
"=",
"False",
")",
":",
"try",
":",
"# returns the 'st_uid' stat from the /dev/console file.",
"uid",
"=",
"os",
".",
"stat",
"(",
"'/dev/console'",
")",
"[",
"4",
"]",
"except",
"(",
"OSError",
",",
"IndexError",
")",
"... | Gets the UID or Username of the current console user.
:return: The uid or username of the console user.
:param bool username: Whether to return the username of the console
user instead of the UID. Defaults to False
:rtype: Interger of the UID, or a string of the username.
Raises:
Command... | [
"Gets",
"the",
"UID",
"or",
"Username",
"of",
"the",
"current",
"console",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mac_utils.py#L441-L472 | train |
saltstack/salt | salt/states/pkgrepo.py | managed | def managed(name, ppa=None, **kwargs):
'''
This state manages software package repositories. Currently, :mod:`yum
<salt.modules.yumpkg>`, :mod:`apt <salt.modules.aptpkg>`, and :mod:`zypper
<salt.modules.zypper>` repositories are supported.
**YUM/DNF/ZYPPER-BASED SYSTEMS**
.. note::
One... | python | def managed(name, ppa=None, **kwargs):
'''
This state manages software package repositories. Currently, :mod:`yum
<salt.modules.yumpkg>`, :mod:`apt <salt.modules.aptpkg>`, and :mod:`zypper
<salt.modules.zypper>` repositories are supported.
**YUM/DNF/ZYPPER-BASED SYSTEMS**
.. note::
One... | [
"def",
"managed",
"(",
"name",
",",
"ppa",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'refresh_db'",
"in",
"kwargs",
":",
"salt",
".",
"utils",
".",
"versions",
".",
"warn_until",
"(",
"'Neon'",
",",
"'The \\'refresh_db\\' argument to \\'pkg.mod_... | This state manages software package repositories. Currently, :mod:`yum
<salt.modules.yumpkg>`, :mod:`apt <salt.modules.aptpkg>`, and :mod:`zypper
<salt.modules.zypper>` repositories are supported.
**YUM/DNF/ZYPPER-BASED SYSTEMS**
.. note::
One of ``baseurl`` or ``mirrorlist`` below is required... | [
"This",
"state",
"manages",
"software",
"package",
"repositories",
".",
"Currently",
":",
"mod",
":",
"yum",
"<salt",
".",
"modules",
".",
"yumpkg",
">",
":",
"mod",
":",
"apt",
"<salt",
".",
"modules",
".",
"aptpkg",
">",
"and",
":",
"mod",
":",
"zypp... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pkgrepo.py#L112-L535 | train |
saltstack/salt | salt/states/pkgrepo.py | absent | def absent(name, **kwargs):
'''
This function deletes the specified repo on the system, if it exists. It
is essentially a wrapper around pkg.del_repo.
name
The name of the package repo, as it would be referred to when running
the regular package manager commands.
**UBUNTU-SPECIFIC ... | python | def absent(name, **kwargs):
'''
This function deletes the specified repo on the system, if it exists. It
is essentially a wrapper around pkg.del_repo.
name
The name of the package repo, as it would be referred to when running
the regular package manager commands.
**UBUNTU-SPECIFIC ... | [
"def",
"absent",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"'ppa'",
"in",
"kwargs",
"and",
"__gra... | This function deletes the specified repo on the system, if it exists. It
is essentially a wrapper around pkg.del_repo.
name
The name of the package repo, as it would be referred to when running
the regular package manager commands.
**UBUNTU-SPECIFIC OPTIONS**
ppa
On Ubuntu, yo... | [
"This",
"function",
"deletes",
"the",
"specified",
"repo",
"on",
"the",
"system",
"if",
"it",
"exists",
".",
"It",
"is",
"essentially",
"a",
"wrapper",
"around",
"pkg",
".",
"del_repo",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pkgrepo.py#L538-L653 | train |
saltstack/salt | salt/pillar/foreman.py | ext_pillar | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
key=None,
only=()):
'''
Read pillar data from Foreman via its API.
'''
url = __opts__['foreman.url']
user = __opts__['foreman.user']
password = __opts__['foreman.password']
api = __opts__[... | python | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
key=None,
only=()):
'''
Read pillar data from Foreman via its API.
'''
url = __opts__['foreman.url']
user = __opts__['foreman.user']
password = __opts__['foreman.password']
api = __opts__[... | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"pillar",
",",
"# pylint: disable=W0613",
"key",
"=",
"None",
",",
"only",
"=",
"(",
")",
")",
":",
"url",
"=",
"__opts__",
"[",
"'foreman.url'",
"]",
"user",
"=",
"__opts__",
"[",
"'foreman.user'",
"]",
"passwor... | Read pillar data from Foreman via its API. | [
"Read",
"pillar",
"data",
"from",
"Foreman",
"via",
"its",
"API",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/foreman.py#L81-L141 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | create_table | def create_table(table_name, region=None, key=None, keyid=None, profile=None,
read_capacity_units=None, write_capacity_units=None,
hash_key=None, hash_key_data_type=None, range_key=None,
range_key_data_type=None, local_indexes=None,
global_indexes=None... | python | def create_table(table_name, region=None, key=None, keyid=None, profile=None,
read_capacity_units=None, write_capacity_units=None,
hash_key=None, hash_key_data_type=None, range_key=None,
range_key_data_type=None, local_indexes=None,
global_indexes=None... | [
"def",
"create_table",
"(",
"table_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"read_capacity_units",
"=",
"None",
",",
"write_capacity_units",
"=",
"None",
",",
"hash_key",
"=",
... | Creates a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.create_table table_name /
region=us-east-1 /
hash_key=id /
hash_key_data_type=N /
range_key=created_at /
range_key_data_type=N /
read_capacity_units=1 /
writ... | [
"Creates",
"a",
"DynamoDB",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L85-L161 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | exists | def exists(table_name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a table exists.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.exists table_name region=us-east-1
'''
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=... | python | def exists(table_name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a table exists.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.exists table_name region=us-east-1
'''
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=... | [
"def",
"exists",
"(",
"table_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
... | Check to see if a table exists.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.exists table_name region=us-east-1 | [
"Check",
"to",
"see",
"if",
"a",
"table",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L164-L182 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | delete | def delete(table_name, region=None, key=None, keyid=None, profile=None):
'''
Delete a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.delete table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table ... | python | def delete(table_name, region=None, key=None, keyid=None, profile=None):
'''
Delete a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.delete table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table ... | [
"def",
"delete",
"(",
"table_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid",... | Delete a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.delete table_name region=us-east-1 | [
"Delete",
"a",
"DynamoDB",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L185-L208 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | update | def update(table_name, throughput=None, global_indexes=None,
region=None, key=None, keyid=None, profile=None):
'''
Update a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.update table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, prof... | python | def update(table_name, throughput=None, global_indexes=None,
region=None, key=None, keyid=None, profile=None):
'''
Update a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.update table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, prof... | [
"def",
"update",
"(",
"table_name",
",",
"throughput",
"=",
"None",
",",
"global_indexes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"... | Update a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.update table_name region=us-east-1 | [
"Update",
"a",
"DynamoDB",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L211-L222 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | create_global_secondary_index | def create_global_secondary_index(table_name, global_index, region=None,
key=None, keyid=None, profile=None):
'''
Creates a single global secondary index on a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.create_global_secondary... | python | def create_global_secondary_index(table_name, global_index, region=None,
key=None, keyid=None, profile=None):
'''
Creates a single global secondary index on a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.create_global_secondary... | [
"def",
"create_global_secondary_index",
"(",
"table_name",
",",
"global_index",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
... | Creates a single global secondary index on a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.create_global_secondary_index table_name /
index_name | [
"Creates",
"a",
"single",
"global",
"secondary",
"index",
"on",
"a",
"DynamoDB",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L225-L238 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | update_global_secondary_index | def update_global_secondary_index(table_name, global_indexes, region=None,
key=None, keyid=None, profile=None):
'''
Updates the throughput of the given global secondary indexes.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.update_global_second... | python | def update_global_secondary_index(table_name, global_indexes, region=None,
key=None, keyid=None, profile=None):
'''
Updates the throughput of the given global secondary indexes.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.update_global_second... | [
"def",
"update_global_secondary_index",
"(",
"table_name",
",",
"global_indexes",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",... | Updates the throughput of the given global secondary indexes.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.update_global_secondary_index table_name /
indexes | [
"Updates",
"the",
"throughput",
"of",
"the",
"given",
"global",
"secondary",
"indexes",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L241-L254 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | describe | def describe(table_name, region=None, key=None, keyid=None, profile=None):
'''
Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table = Table(table_name, ... | python | def describe(table_name, region=None, key=None, keyid=None, profile=None):
'''
Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table = Table(table_name, ... | [
"def",
"describe",
"(",
"table_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid... | Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1 | [
"Describe",
"a",
"DynamoDB",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L257-L267 | train |
saltstack/salt | salt/modules/boto_dynamodb.py | extract_index | def extract_index(index_data, global_index=False):
'''
Instantiates and returns an AllIndex object given a valid index
configuration
CLI Example:
salt myminion boto_dynamodb.extract_index index
'''
parsed_data = {}
keys = []
for key, value in six.iteritems(index_data):
... | python | def extract_index(index_data, global_index=False):
'''
Instantiates and returns an AllIndex object given a valid index
configuration
CLI Example:
salt myminion boto_dynamodb.extract_index index
'''
parsed_data = {}
keys = []
for key, value in six.iteritems(index_data):
... | [
"def",
"extract_index",
"(",
"index_data",
",",
"global_index",
"=",
"False",
")",
":",
"parsed_data",
"=",
"{",
"}",
"keys",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"index_data",
")",
":",
"for",
"item",
"in",
... | Instantiates and returns an AllIndex object given a valid index
configuration
CLI Example:
salt myminion boto_dynamodb.extract_index index | [
"Instantiates",
"and",
"returns",
"an",
"AllIndex",
"object",
"given",
"a",
"valid",
"index",
"configuration"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L270-L353 | train |
saltstack/salt | salt/modules/cpan.py | install | def install(module):
'''
Install a Perl module from CPAN
CLI Example:
.. code-block:: bash
salt '*' cpan.install Template::Alloy
'''
ret = {
'old': None,
'new': None,
}
old_info = show(module)
cmd = 'cpan -i {0}'.format(module)
out = __salt__['cmd.run... | python | def install(module):
'''
Install a Perl module from CPAN
CLI Example:
.. code-block:: bash
salt '*' cpan.install Template::Alloy
'''
ret = {
'old': None,
'new': None,
}
old_info = show(module)
cmd = 'cpan -i {0}'.format(module)
out = __salt__['cmd.run... | [
"def",
"install",
"(",
"module",
")",
":",
"ret",
"=",
"{",
"'old'",
":",
"None",
",",
"'new'",
":",
"None",
",",
"}",
"old_info",
"=",
"show",
"(",
"module",
")",
"cmd",
"=",
"'cpan -i {0}'",
".",
"format",
"(",
"module",
")",
"out",
"=",
"__salt_... | Install a Perl module from CPAN
CLI Example:
.. code-block:: bash
salt '*' cpan.install Template::Alloy | [
"Install",
"a",
"Perl",
"module",
"from",
"CPAN"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L35-L63 | train |
saltstack/salt | salt/modules/cpan.py | remove | def remove(module, details=False):
'''
Attempt to remove a Perl module that was installed from CPAN. Because the
``cpan`` command doesn't actually support "uninstall"-like functionality,
this function will attempt to do what it can, with what it has from CPAN.
Until this function is declared stable... | python | def remove(module, details=False):
'''
Attempt to remove a Perl module that was installed from CPAN. Because the
``cpan`` command doesn't actually support "uninstall"-like functionality,
this function will attempt to do what it can, with what it has from CPAN.
Until this function is declared stable... | [
"def",
"remove",
"(",
"module",
",",
"details",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'old'",
":",
"None",
",",
"'new'",
":",
"None",
",",
"}",
"info",
"=",
"show",
"(",
"module",
")",
"if",
"'error'",
"in",
"info",
":",
"return",
"{",
"'erro... | Attempt to remove a Perl module that was installed from CPAN. Because the
``cpan`` command doesn't actually support "uninstall"-like functionality,
this function will attempt to do what it can, with what it has from CPAN.
Until this function is declared stable, USE AT YOUR OWN RISK!
CLI Example:
... | [
"Attempt",
"to",
"remove",
"a",
"Perl",
"module",
"that",
"was",
"installed",
"from",
"CPAN",
".",
"Because",
"the",
"cpan",
"command",
"doesn",
"t",
"actually",
"support",
"uninstall",
"-",
"like",
"functionality",
"this",
"function",
"will",
"attempt",
"to",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L66-L130 | train |
saltstack/salt | salt/modules/cpan.py | list_ | def list_():
'''
List installed Perl modules, and the version installed
CLI Example:
.. code-block:: bash
salt '*' cpan.list
'''
ret = {}
cmd = 'cpan -l'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
comps = line.split()
ret[comps[0]] = comps... | python | def list_():
'''
List installed Perl modules, and the version installed
CLI Example:
.. code-block:: bash
salt '*' cpan.list
'''
ret = {}
cmd = 'cpan -l'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
comps = line.split()
ret[comps[0]] = comps... | [
"def",
"list_",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"cmd",
"=",
"'cpan -l'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"out",
":",
"comps",
"=",
"line",
".",
"split",
"(",
... | List installed Perl modules, and the version installed
CLI Example:
.. code-block:: bash
salt '*' cpan.list | [
"List",
"installed",
"Perl",
"modules",
"and",
"the",
"version",
"installed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L133-L149 | train |
saltstack/salt | salt/modules/cpan.py | show | def show(module):
'''
Show information about a specific Perl module
CLI Example:
.. code-block:: bash
salt '*' cpan.show Template::Alloy
'''
ret = {}
ret['name'] = module
# This section parses out details from CPAN, if possible
cmd = 'cpan -D {0}'.format(module)
out =... | python | def show(module):
'''
Show information about a specific Perl module
CLI Example:
.. code-block:: bash
salt '*' cpan.show Template::Alloy
'''
ret = {}
ret['name'] = module
# This section parses out details from CPAN, if possible
cmd = 'cpan -D {0}'.format(module)
out =... | [
"def",
"show",
"(",
"module",
")",
":",
"ret",
"=",
"{",
"}",
"ret",
"[",
"'name'",
"]",
"=",
"module",
"# This section parses out details from CPAN, if possible",
"cmd",
"=",
"'cpan -D {0}'",
".",
"format",
"(",
"module",
")",
"out",
"=",
"__salt__",
"[",
"... | Show information about a specific Perl module
CLI Example:
.. code-block:: bash
salt '*' cpan.show Template::Alloy | [
"Show",
"information",
"about",
"a",
"specific",
"Perl",
"module"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L152-L214 | train |
saltstack/salt | salt/modules/cpan.py | show_config | def show_config():
'''
Return a dict of CPAN configuration values
CLI Example:
.. code-block:: bash
salt '*' cpan.show_config
'''
ret = {}
cmd = 'cpan -J'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
if '=>' not in line:
# TODO: Some opt... | python | def show_config():
'''
Return a dict of CPAN configuration values
CLI Example:
.. code-block:: bash
salt '*' cpan.show_config
'''
ret = {}
cmd = 'cpan -J'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
if '=>' not in line:
# TODO: Some opt... | [
"def",
"show_config",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"cmd",
"=",
"'cpan -J'",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"out",
":",
"if",
"'=>'",
"not",
"in",
"line",
"... | Return a dict of CPAN configuration values
CLI Example:
.. code-block:: bash
salt '*' cpan.show_config | [
"Return",
"a",
"dict",
"of",
"CPAN",
"configuration",
"values"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cpan.py#L217-L238 | train |
saltstack/salt | salt/cache/mysql_cache.py | run_query | def run_query(conn, query, retries=3):
'''
Get a cursor and run a query. Reconnect up to `retries` times if
needed.
Returns: cursor, affected rows counter
Raises: SaltCacheError, AttributeError, OperationalError
'''
try:
cur = conn.cursor()
out = cur.execute(query)
re... | python | def run_query(conn, query, retries=3):
'''
Get a cursor and run a query. Reconnect up to `retries` times if
needed.
Returns: cursor, affected rows counter
Raises: SaltCacheError, AttributeError, OperationalError
'''
try:
cur = conn.cursor()
out = cur.execute(query)
re... | [
"def",
"run_query",
"(",
"conn",
",",
"query",
",",
"retries",
"=",
"3",
")",
":",
"try",
":",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"out",
"=",
"cur",
".",
"execute",
"(",
"query",
")",
"return",
"cur",
",",
"out",
"except",
"(",
"Attribu... | Get a cursor and run a query. Reconnect up to `retries` times if
needed.
Returns: cursor, affected rows counter
Raises: SaltCacheError, AttributeError, OperationalError | [
"Get",
"a",
"cursor",
"and",
"run",
"a",
"query",
".",
"Reconnect",
"up",
"to",
"retries",
"times",
"if",
"needed",
".",
"Returns",
":",
"cursor",
"affected",
"rows",
"counter",
"Raises",
":",
"SaltCacheError",
"AttributeError",
"OperationalError"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L92-L118 | train |
saltstack/salt | salt/cache/mysql_cache.py | _create_table | def _create_table():
'''
Create table if needed
'''
# Explicitely check if the table already exists as the library logs a
# warning on CREATE TABLE
query = """SELECT COUNT(TABLE_NAME) FROM information_schema.tables
WHERE table_schema = '{0}' AND table_name = '{1}'""".format(
... | python | def _create_table():
'''
Create table if needed
'''
# Explicitely check if the table already exists as the library logs a
# warning on CREATE TABLE
query = """SELECT COUNT(TABLE_NAME) FROM information_schema.tables
WHERE table_schema = '{0}' AND table_name = '{1}'""".format(
... | [
"def",
"_create_table",
"(",
")",
":",
"# Explicitely check if the table already exists as the library logs a",
"# warning on CREATE TABLE",
"query",
"=",
"\"\"\"SELECT COUNT(TABLE_NAME) FROM information_schema.tables\n WHERE table_schema = '{0}' AND table_name = '{1}'\"\"\"",
".",
"for... | Create table if needed | [
"Create",
"table",
"if",
"needed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L121-L146 | train |
saltstack/salt | salt/cache/mysql_cache.py | _init_client | def _init_client():
"""Initialize connection and create table if needed
"""
if client is not None:
return
global _mysql_kwargs, _table_name
_mysql_kwargs = {
'host': __opts__.get('mysql.host', '127.0.0.1'),
'user': __opts__.get('mysql.user', None),
'passwd': __opts__... | python | def _init_client():
"""Initialize connection and create table if needed
"""
if client is not None:
return
global _mysql_kwargs, _table_name
_mysql_kwargs = {
'host': __opts__.get('mysql.host', '127.0.0.1'),
'user': __opts__.get('mysql.user', None),
'passwd': __opts__... | [
"def",
"_init_client",
"(",
")",
":",
"if",
"client",
"is",
"not",
"None",
":",
"return",
"global",
"_mysql_kwargs",
",",
"_table_name",
"_mysql_kwargs",
"=",
"{",
"'host'",
":",
"__opts__",
".",
"get",
"(",
"'mysql.host'",
",",
"'127.0.0.1'",
")",
",",
"'... | Initialize connection and create table if needed | [
"Initialize",
"connection",
"and",
"create",
"table",
"if",
"needed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L149-L176 | train |
saltstack/salt | salt/cache/mysql_cache.py | store | def store(bank, key, data):
'''
Store a key value.
'''
_init_client()
data = __context__['serial'].dumps(data)
query = b"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', " \
b"'{3}')".format(_table_name,
bank,
key,
... | python | def store(bank, key, data):
'''
Store a key value.
'''
_init_client()
data = __context__['serial'].dumps(data)
query = b"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', " \
b"'{3}')".format(_table_name,
bank,
key,
... | [
"def",
"store",
"(",
"bank",
",",
"key",
",",
"data",
")",
":",
"_init_client",
"(",
")",
"data",
"=",
"__context__",
"[",
"'serial'",
"]",
".",
"dumps",
"(",
"data",
")",
"query",
"=",
"b\"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', \"",
"b\"'{... | Store a key value. | [
"Store",
"a",
"key",
"value",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L179-L196 | train |
saltstack/salt | salt/cache/mysql_cache.py | fetch | def fetch(bank, key):
'''
Fetch a key value.
'''
_init_client()
query = "SELECT data FROM {0} WHERE bank='{1}' AND etcd_key='{2}'".format(
_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
if r is None:
return {}
return __con... | python | def fetch(bank, key):
'''
Fetch a key value.
'''
_init_client()
query = "SELECT data FROM {0} WHERE bank='{1}' AND etcd_key='{2}'".format(
_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
if r is None:
return {}
return __con... | [
"def",
"fetch",
"(",
"bank",
",",
"key",
")",
":",
"_init_client",
"(",
")",
"query",
"=",
"\"SELECT data FROM {0} WHERE bank='{1}' AND etcd_key='{2}'\"",
".",
"format",
"(",
"_table_name",
",",
"bank",
",",
"key",
")",
"cur",
",",
"_",
"=",
"run_query",
"(",
... | Fetch a key value. | [
"Fetch",
"a",
"key",
"value",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L199-L211 | train |
saltstack/salt | salt/cache/mysql_cache.py | flush | def flush(bank, key=None):
'''
Remove the key from the cache bank with all the key content.
'''
_init_client()
query = "DELETE FROM {0} WHERE bank='{1}'".format(_table_name, bank)
if key is not None:
query += " AND etcd_key='{0}'".format(key)
cur, _ = run_query(client, query)
cu... | python | def flush(bank, key=None):
'''
Remove the key from the cache bank with all the key content.
'''
_init_client()
query = "DELETE FROM {0} WHERE bank='{1}'".format(_table_name, bank)
if key is not None:
query += " AND etcd_key='{0}'".format(key)
cur, _ = run_query(client, query)
cu... | [
"def",
"flush",
"(",
"bank",
",",
"key",
"=",
"None",
")",
":",
"_init_client",
"(",
")",
"query",
"=",
"\"DELETE FROM {0} WHERE bank='{1}'\"",
".",
"format",
"(",
"_table_name",
",",
"bank",
")",
"if",
"key",
"is",
"not",
"None",
":",
"query",
"+=",
"\"... | Remove the key from the cache bank with all the key content. | [
"Remove",
"the",
"key",
"from",
"the",
"cache",
"bank",
"with",
"all",
"the",
"key",
"content",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L214-L224 | train |
saltstack/salt | salt/cache/mysql_cache.py | ls | def ls(bank):
'''
Return an iterable object containing all entries stored in the specified
bank.
'''
_init_client()
query = "SELECT etcd_key FROM {0} WHERE bank='{1}'".format(
_table_name, bank)
cur, _ = run_query(client, query)
out = [row[0] for row in cur.fetchall()]
cur.cl... | python | def ls(bank):
'''
Return an iterable object containing all entries stored in the specified
bank.
'''
_init_client()
query = "SELECT etcd_key FROM {0} WHERE bank='{1}'".format(
_table_name, bank)
cur, _ = run_query(client, query)
out = [row[0] for row in cur.fetchall()]
cur.cl... | [
"def",
"ls",
"(",
"bank",
")",
":",
"_init_client",
"(",
")",
"query",
"=",
"\"SELECT etcd_key FROM {0} WHERE bank='{1}'\"",
".",
"format",
"(",
"_table_name",
",",
"bank",
")",
"cur",
",",
"_",
"=",
"run_query",
"(",
"client",
",",
"query",
")",
"out",
"=... | Return an iterable object containing all entries stored in the specified
bank. | [
"Return",
"an",
"iterable",
"object",
"containing",
"all",
"entries",
"stored",
"in",
"the",
"specified",
"bank",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L227-L238 | train |
saltstack/salt | salt/cache/mysql_cache.py | contains | def contains(bank, key):
'''
Checks if the specified bank contains the specified key.
'''
_init_client()
query = "SELECT COUNT(data) FROM {0} WHERE bank='{1}' " \
"AND etcd_key='{2}'".format(_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
... | python | def contains(bank, key):
'''
Checks if the specified bank contains the specified key.
'''
_init_client()
query = "SELECT COUNT(data) FROM {0} WHERE bank='{1}' " \
"AND etcd_key='{2}'".format(_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
... | [
"def",
"contains",
"(",
"bank",
",",
"key",
")",
":",
"_init_client",
"(",
")",
"query",
"=",
"\"SELECT COUNT(data) FROM {0} WHERE bank='{1}' \"",
"\"AND etcd_key='{2}'\"",
".",
"format",
"(",
"_table_name",
",",
"bank",
",",
"key",
")",
"cur",
",",
"_",
"=",
... | Checks if the specified bank contains the specified key. | [
"Checks",
"if",
"the",
"specified",
"bank",
"contains",
"the",
"specified",
"key",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/mysql_cache.py#L241-L251 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.new | def new(self):
'''
Create a new database and opens it.
:return:
'''
dbname = self._label()
self.db_path = os.path.join(self.path, dbname)
if not os.path.exists(self.db_path):
os.makedirs(self.db_path)
self._opened = True
self.list_tabl... | python | def new(self):
'''
Create a new database and opens it.
:return:
'''
dbname = self._label()
self.db_path = os.path.join(self.path, dbname)
if not os.path.exists(self.db_path):
os.makedirs(self.db_path)
self._opened = True
self.list_tabl... | [
"def",
"new",
"(",
"self",
")",
":",
"dbname",
"=",
"self",
".",
"_label",
"(",
")",
"self",
".",
"db_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"dbname",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
... | Create a new database and opens it.
:return: | [
"Create",
"a",
"new",
"database",
"and",
"opens",
"it",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L76-L89 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.purge | def purge(self, dbid):
'''
Purge the database.
:param dbid:
:return:
'''
db_path = os.path.join(self.path, dbid)
if os.path.exists(db_path):
shutil.rmtree(db_path, ignore_errors=True)
return True
return False | python | def purge(self, dbid):
'''
Purge the database.
:param dbid:
:return:
'''
db_path = os.path.join(self.path, dbid)
if os.path.exists(db_path):
shutil.rmtree(db_path, ignore_errors=True)
return True
return False | [
"def",
"purge",
"(",
"self",
",",
"dbid",
")",
":",
"db_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"dbid",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"db_path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"db_... | Purge the database.
:param dbid:
:return: | [
"Purge",
"the",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L91-L102 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.flush | def flush(self, table):
'''
Flush table.
:param table:
:return:
'''
table_path = os.path.join(self.db_path, table)
if os.path.exists(table_path):
os.unlink(table_path) | python | def flush(self, table):
'''
Flush table.
:param table:
:return:
'''
table_path = os.path.join(self.db_path, table)
if os.path.exists(table_path):
os.unlink(table_path) | [
"def",
"flush",
"(",
"self",
",",
"table",
")",
":",
"table_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"db_path",
",",
"table",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"table_path",
")",
":",
"os",
".",
"unlink",
"(",... | Flush table.
:param table:
:return: | [
"Flush",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L104-L113 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.list | def list(self):
'''
List all the databases on the given path.
:return:
'''
databases = []
for dbname in os.listdir(self.path):
databases.append(dbname)
return list(reversed(sorted(databases))) | python | def list(self):
'''
List all the databases on the given path.
:return:
'''
databases = []
for dbname in os.listdir(self.path):
databases.append(dbname)
return list(reversed(sorted(databases))) | [
"def",
"list",
"(",
"self",
")",
":",
"databases",
"=",
"[",
"]",
"for",
"dbname",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"path",
")",
":",
"databases",
".",
"append",
"(",
"dbname",
")",
"return",
"list",
"(",
"reversed",
"(",
"sorted",
"("... | List all the databases on the given path.
:return: | [
"List",
"all",
"the",
"databases",
"on",
"the",
"given",
"path",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L115-L124 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.list_tables | def list_tables(self):
'''
Load existing tables and their descriptions.
:return:
'''
if not self._tables:
for table_name in os.listdir(self.db_path):
self._tables[table_name] = self._load_table(table_name)
return self._tables.keys() | python | def list_tables(self):
'''
Load existing tables and their descriptions.
:return:
'''
if not self._tables:
for table_name in os.listdir(self.db_path):
self._tables[table_name] = self._load_table(table_name)
return self._tables.keys() | [
"def",
"list_tables",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_tables",
":",
"for",
"table_name",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"db_path",
")",
":",
"self",
".",
"_tables",
"[",
"table_name",
"]",
"=",
"self",
".",
"_load_ta... | Load existing tables and their descriptions.
:return: | [
"Load",
"existing",
"tables",
"and",
"their",
"descriptions",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L126-L136 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.open | def open(self, dbname=None):
'''
Open database from the path with the name or latest.
If there are no yet databases, create a new implicitly.
:return:
'''
databases = self.list()
if self.is_closed():
self.db_path = os.path.join(self.path, dbname or (d... | python | def open(self, dbname=None):
'''
Open database from the path with the name or latest.
If there are no yet databases, create a new implicitly.
:return:
'''
databases = self.list()
if self.is_closed():
self.db_path = os.path.join(self.path, dbname or (d... | [
"def",
"open",
"(",
"self",
",",
"dbname",
"=",
"None",
")",
":",
"databases",
"=",
"self",
".",
"list",
"(",
")",
"if",
"self",
".",
"is_closed",
"(",
")",
":",
"self",
".",
"db_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"pa... | Open database from the path with the name or latest.
If there are no yet databases, create a new implicitly.
:return: | [
"Open",
"database",
"from",
"the",
"path",
"with",
"the",
"name",
"or",
"latest",
".",
"If",
"there",
"are",
"no",
"yet",
"databases",
"create",
"a",
"new",
"implicitly",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L142-L154 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.create_table_from_object | def create_table_from_object(self, obj):
'''
Create a table from the object.
NOTE: This method doesn't stores anything.
:param obj:
:return:
'''
get_type = lambda item: str(type(item)).split("'")[1]
if not os.path.exists(os.path.join(self.db_path, obj._TA... | python | def create_table_from_object(self, obj):
'''
Create a table from the object.
NOTE: This method doesn't stores anything.
:param obj:
:return:
'''
get_type = lambda item: str(type(item)).split("'")[1]
if not os.path.exists(os.path.join(self.db_path, obj._TA... | [
"def",
"create_table_from_object",
"(",
"self",
",",
"obj",
")",
":",
"get_type",
"=",
"lambda",
"item",
":",
"str",
"(",
"type",
"(",
"item",
")",
")",
".",
"split",
"(",
"\"'\"",
")",
"[",
"1",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | Create a table from the object.
NOTE: This method doesn't stores anything.
:param obj:
:return: | [
"Create",
"a",
"table",
"from",
"the",
"object",
".",
"NOTE",
":",
"This",
"method",
"doesn",
"t",
"stores",
"anything",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L172-L185 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.store | def store(self, obj, distinct=False):
'''
Store an object in the table.
:param obj: An object to store
:param distinct: Store object only if there is none identical of such.
If at least one field is different, store it.
:return:
'''
if d... | python | def store(self, obj, distinct=False):
'''
Store an object in the table.
:param obj: An object to store
:param distinct: Store object only if there is none identical of such.
If at least one field is different, store it.
:return:
'''
if d... | [
"def",
"store",
"(",
"self",
",",
"obj",
",",
"distinct",
"=",
"False",
")",
":",
"if",
"distinct",
":",
"fields",
"=",
"dict",
"(",
"zip",
"(",
"self",
".",
"_tables",
"[",
"obj",
".",
"_TABLE",
"]",
".",
"keys",
"(",
")",
",",
"obj",
".",
"_s... | Store an object in the table.
:param obj: An object to store
:param distinct: Store object only if there is none identical of such.
If at least one field is different, store it.
:return: | [
"Store",
"an",
"object",
"in",
"the",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L187-L203 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.update | def update(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Update object(s) in the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
updated = False
objects = list()
for _obj in se... | python | def update(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Update object(s) in the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
updated = False
objects = list()
for _obj in se... | [
"def",
"update",
"(",
"self",
",",
"obj",
",",
"matches",
"=",
"None",
",",
"mt",
"=",
"None",
",",
"lt",
"=",
"None",
",",
"eq",
"=",
"None",
")",
":",
"updated",
"=",
"False",
"objects",
"=",
"list",
"(",
")",
"for",
"_obj",
"in",
"self",
"."... | Update object(s) in the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: | [
"Update",
"object",
"(",
"s",
")",
"in",
"the",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L205-L229 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.delete | def delete(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Delete object from the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
deleted = False
objects = list()
for _obj in sel... | python | def delete(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Delete object from the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
deleted = False
objects = list()
for _obj in sel... | [
"def",
"delete",
"(",
"self",
",",
"obj",
",",
"matches",
"=",
"None",
",",
"mt",
"=",
"None",
",",
"lt",
"=",
"None",
",",
"eq",
"=",
"None",
")",
":",
"deleted",
"=",
"False",
"objects",
"=",
"list",
"(",
")",
"for",
"_obj",
"in",
"self",
"."... | Delete object from the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: | [
"Delete",
"object",
"from",
"the",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L231-L255 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.__criteria | def __criteria(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Returns True if object is aligned to the criteria.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: Boolean
'''
# Fail matcher if "less than"
... | python | def __criteria(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Returns True if object is aligned to the criteria.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: Boolean
'''
# Fail matcher if "less than"
... | [
"def",
"__criteria",
"(",
"self",
",",
"obj",
",",
"matches",
"=",
"None",
",",
"mt",
"=",
"None",
",",
"lt",
"=",
"None",
",",
"eq",
"=",
"None",
")",
":",
"# Fail matcher if \"less than\"",
"for",
"field",
",",
"value",
"in",
"(",
"mt",
"or",
"{",
... | Returns True if object is aligned to the criteria.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: Boolean | [
"Returns",
"True",
"if",
"object",
"is",
"aligned",
"to",
"the",
"criteria",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L263-L294 | train |
saltstack/salt | salt/modules/inspectlib/fsdb.py | CsvDB.get | def get(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Get objects from the table.
:param table_name:
:param matches: Regexp.
:param mt: More than.
:param lt: Less than.
:param eq: Equals.
:return:
'''
objects = []
with g... | python | def get(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Get objects from the table.
:param table_name:
:param matches: Regexp.
:param mt: More than.
:param lt: Less than.
:param eq: Equals.
:return:
'''
objects = []
with g... | [
"def",
"get",
"(",
"self",
",",
"obj",
",",
"matches",
"=",
"None",
",",
"mt",
"=",
"None",
",",
"lt",
"=",
"None",
",",
"eq",
"=",
"None",
")",
":",
"objects",
"=",
"[",
"]",
"with",
"gzip",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
... | Get objects from the table.
:param table_name:
:param matches: Regexp.
:param mt: More than.
:param lt: Less than.
:param eq: Equals.
:return: | [
"Get",
"objects",
"from",
"the",
"table",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L296-L320 | train |
saltstack/salt | salt/runners/event.py | send | def send(tag, data=None):
'''
Send an event with the given tag and data.
This is useful for sending events directly to the master from the shell
with salt-run. It is also quite useful for sending events in orchestration
states where the ``fire_event`` requisite isn't sufficient because it does
... | python | def send(tag, data=None):
'''
Send an event with the given tag and data.
This is useful for sending events directly to the master from the shell
with salt-run. It is also quite useful for sending events in orchestration
states where the ``fire_event`` requisite isn't sufficient because it does
... | [
"def",
"send",
"(",
"tag",
",",
"data",
"=",
"None",
")",
":",
"data",
"=",
"data",
"or",
"{",
"}",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"get_master_event",
"(",
"__opts__",
",",
"__opts__",
"[",
"'sock_dir'",
"]",
",",
"listen",
... | Send an event with the given tag and data.
This is useful for sending events directly to the master from the shell
with salt-run. It is also quite useful for sending events in orchestration
states where the ``fire_event`` requisite isn't sufficient because it does
not support sending custom data with t... | [
"Send",
"an",
"event",
"with",
"the",
"given",
"tag",
"and",
"data",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/event.py#L17-L80 | train |
saltstack/salt | salt/runners/cache.py | grains | def grains(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. vers... | python | def grains(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. vers... | [
"def",
"grains",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"tgt",
"is",
"None",
":",
"# Change ``tgt=None`` to ``tgt`` (mandatory kwarg) in Salt Sodium.",
"# This behavior was changed in PR #45588 to fix Issue #45489... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. versionchanged:: 2017.7.5,2018.3.0
The ``tgt`` argume... | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L33-L74 | train |
saltstack/salt | salt/runners/cache.py | pillar | def pillar(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached pillars of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... | python | def pillar(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached pillars of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... | [
"def",
"pillar",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
",",
"*",
"*",
"kwargs",
")",
":",
"pillar_util",
"=",
"salt",
".",
"utils",
".",
"master",
".",
"MasterPillarUtil",
"(",
"tgt",
",",
"tgt_type",
",",
"use_cached_grains",
"=",
"... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached pillars of the targeted minions
CLI Example:
.. code-block:: bash
salt-run cache.pillar | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L77-L98 | train |
saltstack/salt | salt/runners/cache.py | mine | def mine(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached mine data of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... | python | def mine(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached mine data of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... | [
"def",
"mine",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
",",
"*",
"*",
"kwargs",
")",
":",
"pillar_util",
"=",
"salt",
".",
"utils",
".",
"master",
".",
"MasterPillarUtil",
"(",
"tgt",
",",
"tgt_type",
",",
"use_cached_grains",
"=",
"Fa... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached mine data of the targeted minions
CLI Example:
.. code-block:: bash
salt-run cache.mine | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L101-L122 | train |
saltstack/salt | salt/runners/cache.py | _clear_cache | def _clear_cache(tgt=None,
tgt_type='glob',
clear_pillar_flag=False,
clear_grains_flag=False,
clear_mine_flag=False,
clear_mine_func_flag=None):
'''
Clear the cached data/files for the targeted minions.
'''
if tgt is No... | python | def _clear_cache(tgt=None,
tgt_type='glob',
clear_pillar_flag=False,
clear_grains_flag=False,
clear_mine_flag=False,
clear_mine_func_flag=None):
'''
Clear the cached data/files for the targeted minions.
'''
if tgt is No... | [
"def",
"_clear_cache",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
",",
"clear_pillar_flag",
"=",
"False",
",",
"clear_grains_flag",
"=",
"False",
",",
"clear_mine_flag",
"=",
"False",
",",
"clear_mine_func_flag",
"=",
"None",
")",
":",
"if",
"t... | Clear the cached data/files for the targeted minions. | [
"Clear",
"the",
"cached",
"data",
"/",
"files",
"for",
"the",
"targeted",
"minions",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L125-L145 | train |
saltstack/salt | salt/runners/cache.py | clear_all | def clear_all(tgt=None, tgt_type='glob'):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Clear the cached pillar, grains, and mine data of the targeted minions
CLI Example:
.. code-block:: bash... | python | def clear_all(tgt=None, tgt_type='glob'):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Clear the cached pillar, grains, and mine data of the targeted minions
CLI Example:
.. code-block:: bash... | [
"def",
"clear_all",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
")",
":",
"return",
"_clear_cache",
"(",
"tgt",
",",
"tgt_type",
",",
"clear_pillar_flag",
"=",
"True",
",",
"clear_grains_flag",
"=",
"True",
",",
"clear_mine_flag",
"=",
"True",
... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Clear the cached pillar, grains, and mine data of the targeted minions
CLI Example:
.. code-block:: bash
salt-run cache.clear_all | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L218-L236 | train |
saltstack/salt | salt/runners/cache.py | clear_git_lock | def clear_git_lock(role, remote=None, **kwargs):
'''
.. versionadded:: 2015.8.2
Remove the update locks for Salt components (gitfs, git_pillar, winrepo)
which use gitfs backend code from salt.utils.gitfs.
.. note::
Running :py:func:`cache.clear_all <salt.runners.cache.clear_all>` will
... | python | def clear_git_lock(role, remote=None, **kwargs):
'''
.. versionadded:: 2015.8.2
Remove the update locks for Salt components (gitfs, git_pillar, winrepo)
which use gitfs backend code from salt.utils.gitfs.
.. note::
Running :py:func:`cache.clear_all <salt.runners.cache.clear_all>` will
... | [
"def",
"clear_git_lock",
"(",
"role",
",",
"remote",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"type_",
"=",
"salt",
".",
"utils",
".",
"args... | .. versionadded:: 2015.8.2
Remove the update locks for Salt components (gitfs, git_pillar, winrepo)
which use gitfs backend code from salt.utils.gitfs.
.. note::
Running :py:func:`cache.clear_all <salt.runners.cache.clear_all>` will
not include this function as it does for pillar, grains, ... | [
"..",
"versionadded",
"::",
"2015",
".",
"8",
".",
"2"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L239-L343 | train |
saltstack/salt | salt/runners/cache.py | cloud | def cloud(tgt, provider=None):
'''
Return cloud cache data for target.
.. note:: Only works with glob matching
tgt
Glob Target to match minion ids
provider
Cloud Provider
CLI Example:
.. code-block:: bash
salt-run cache.cloud 'salt*'
salt-run cache.cloud gla... | python | def cloud(tgt, provider=None):
'''
Return cloud cache data for target.
.. note:: Only works with glob matching
tgt
Glob Target to match minion ids
provider
Cloud Provider
CLI Example:
.. code-block:: bash
salt-run cache.cloud 'salt*'
salt-run cache.cloud gla... | [
"def",
"cloud",
"(",
"tgt",
",",
"provider",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"tgt",
",",
"six",
".",
"string_types",
")",
":",
"return",
"{",
"}",
"opts",
"=",
"salt",
".",
"config",
".",
"cloud_config",
"(",
"os",
".",
"path... | Return cloud cache data for target.
.. note:: Only works with glob matching
tgt
Glob Target to match minion ids
provider
Cloud Provider
CLI Example:
.. code-block:: bash
salt-run cache.cloud 'salt*'
salt-run cache.cloud glance.example.org provider=openstack | [
"Return",
"cloud",
"cache",
"data",
"for",
"target",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L346-L385 | train |
saltstack/salt | salt/runners/cache.py | store | def store(bank, key, data, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.store mycache mykey 'The time has come the walrus said'
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache ... | python | def store(bank, key, data, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.store mycache mykey 'The time has come the walrus said'
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache ... | [
"def",
"store",
"(",
"bank",
",",
"key",
",",
"data",
",",
"cachedir",
"=",
"None",
")",
":",
"if",
"cachedir",
"is",
"None",
":",
"cachedir",
"=",
"__opts__",
"[",
"'cachedir'",
"]",
"try",
":",
"cache",
"=",
"salt",
".",
"cache",
".",
"Cache",
"(... | Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.store mycache mykey 'The time has come the walrus said' | [
"Lists",
"entries",
"stored",
"in",
"the",
"specified",
"bank",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L388-L405 | train |
saltstack/salt | salt/runners/cache.py | list_ | def list_(bank, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.list cloud/active/ec2/myec2 cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.cache.... | python | def list_(bank, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.list cloud/active/ec2/myec2 cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.cache.... | [
"def",
"list_",
"(",
"bank",
",",
"cachedir",
"=",
"None",
")",
":",
"if",
"cachedir",
"is",
"None",
":",
"cachedir",
"=",
"__opts__",
"[",
"'cachedir'",
"]",
"try",
":",
"cache",
"=",
"salt",
".",
"cache",
".",
"Cache",
"(",
"__opts__",
",",
"cached... | Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.list cloud/active/ec2/myec2 cachedir=/var/cache/salt/ | [
"Lists",
"entries",
"stored",
"in",
"the",
"specified",
"bank",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L408-L425 | train |
saltstack/salt | salt/runners/cache.py | fetch | def fetch(bank, key, cachedir=None):
'''
Fetch data from a salt.cache bank.
CLI Example:
.. code-block:: bash
salt-run cache.fetch cloud/active/ec2/myec2 myminion cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.... | python | def fetch(bank, key, cachedir=None):
'''
Fetch data from a salt.cache bank.
CLI Example:
.. code-block:: bash
salt-run cache.fetch cloud/active/ec2/myec2 myminion cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.... | [
"def",
"fetch",
"(",
"bank",
",",
"key",
",",
"cachedir",
"=",
"None",
")",
":",
"if",
"cachedir",
"is",
"None",
":",
"cachedir",
"=",
"__opts__",
"[",
"'cachedir'",
"]",
"try",
":",
"cache",
"=",
"salt",
".",
"cache",
".",
"Cache",
"(",
"__opts__",
... | Fetch data from a salt.cache bank.
CLI Example:
.. code-block:: bash
salt-run cache.fetch cloud/active/ec2/myec2 myminion cachedir=/var/cache/salt/ | [
"Fetch",
"data",
"from",
"a",
"salt",
".",
"cache",
"bank",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L428-L445 | train |
saltstack/salt | salt/queues/pgjsonb_queue.py | _conn | def _conn(commit=False):
'''
Return an postgres cursor
'''
defaults = {'host': 'localhost',
'user': 'salt',
'password': 'salt',
'dbname': 'salt',
'port': 5432}
conn_kwargs = {}
for key, value in defaults.items():
conn_kwarg... | python | def _conn(commit=False):
'''
Return an postgres cursor
'''
defaults = {'host': 'localhost',
'user': 'salt',
'password': 'salt',
'dbname': 'salt',
'port': 5432}
conn_kwargs = {}
for key, value in defaults.items():
conn_kwarg... | [
"def",
"_conn",
"(",
"commit",
"=",
"False",
")",
":",
"defaults",
"=",
"{",
"'host'",
":",
"'localhost'",
",",
"'user'",
":",
"'salt'",
",",
"'password'",
":",
"'salt'",
",",
"'dbname'",
":",
"'salt'",
",",
"'port'",
":",
"5432",
"}",
"conn_kwargs",
"... | Return an postgres cursor | [
"Return",
"an",
"postgres",
"cursor"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/queues/pgjsonb_queue.py#L72-L105 | train |
saltstack/salt | salt/queues/pgjsonb_queue.py | insert | def insert(queue, items):
'''
Add an item or items to a queue
'''
handle_queue_creation(queue)
with _conn(commit=True) as cur:
if isinstance(items, dict):
items = salt.utils.json.dumps(items)
cmd = str('''INSERT INTO {0}(data) VALUES('{1}')''').format(queue, items) ... | python | def insert(queue, items):
'''
Add an item or items to a queue
'''
handle_queue_creation(queue)
with _conn(commit=True) as cur:
if isinstance(items, dict):
items = salt.utils.json.dumps(items)
cmd = str('''INSERT INTO {0}(data) VALUES('{1}')''').format(queue, items) ... | [
"def",
"insert",
"(",
"queue",
",",
"items",
")",
":",
"handle_queue_creation",
"(",
"queue",
")",
"with",
"_conn",
"(",
"commit",
"=",
"True",
")",
"as",
"cur",
":",
"if",
"isinstance",
"(",
"items",
",",
"dict",
")",
":",
"items",
"=",
"salt",
".",... | Add an item or items to a queue | [
"Add",
"an",
"item",
"or",
"items",
"to",
"a",
"queue"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/queues/pgjsonb_queue.py#L183-L208 | train |
saltstack/salt | salt/queues/pgjsonb_queue.py | delete | def delete(queue, items):
'''
Delete an item or items from a queue
'''
with _conn(commit=True) as cur:
if isinstance(items, dict):
cmd = str("""DELETE FROM {0} WHERE data = '{1}'""").format( # future lint: disable=blacklisted-function
queue,
salt.util... | python | def delete(queue, items):
'''
Delete an item or items from a queue
'''
with _conn(commit=True) as cur:
if isinstance(items, dict):
cmd = str("""DELETE FROM {0} WHERE data = '{1}'""").format( # future lint: disable=blacklisted-function
queue,
salt.util... | [
"def",
"delete",
"(",
"queue",
",",
"items",
")",
":",
"with",
"_conn",
"(",
"commit",
"=",
"True",
")",
"as",
"cur",
":",
"if",
"isinstance",
"(",
"items",
",",
"dict",
")",
":",
"cmd",
"=",
"str",
"(",
"\"\"\"DELETE FROM {0} WHERE data = '{1}'\"\"\"",
... | Delete an item or items from a queue | [
"Delete",
"an",
"item",
"or",
"items",
"from",
"a",
"queue"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/queues/pgjsonb_queue.py#L211-L228 | train |
saltstack/salt | salt/queues/pgjsonb_queue.py | pop | def pop(queue, quantity=1, is_runner=False):
'''
Pop one or more or all items from the queue return them.
'''
cmd = 'SELECT id, data FROM {0}'.format(queue)
if quantity != 'all':
try:
quantity = int(quantity)
except ValueError as exc:
error_txt = ('Quantity mu... | python | def pop(queue, quantity=1, is_runner=False):
'''
Pop one or more or all items from the queue return them.
'''
cmd = 'SELECT id, data FROM {0}'.format(queue)
if quantity != 'all':
try:
quantity = int(quantity)
except ValueError as exc:
error_txt = ('Quantity mu... | [
"def",
"pop",
"(",
"queue",
",",
"quantity",
"=",
"1",
",",
"is_runner",
"=",
"False",
")",
":",
"cmd",
"=",
"'SELECT id, data FROM {0}'",
".",
"format",
"(",
"queue",
")",
"if",
"quantity",
"!=",
"'all'",
":",
"try",
":",
"quantity",
"=",
"int",
"(",
... | Pop one or more or all items from the queue return them. | [
"Pop",
"one",
"or",
"more",
"or",
"all",
"items",
"from",
"the",
"queue",
"return",
"them",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/queues/pgjsonb_queue.py#L231-L259 | train |
saltstack/salt | salt/utils/process.py | daemonize | def daemonize(redirect_out=True):
'''
Daemonize a process
'''
# Avoid circular import
import salt.utils.crypt
try:
pid = os.fork()
if pid > 0:
# exit first parent
salt.utils.crypt.reinit_crypto()
os._exit(salt.defaults.exitcodes.EX_OK)
exce... | python | def daemonize(redirect_out=True):
'''
Daemonize a process
'''
# Avoid circular import
import salt.utils.crypt
try:
pid = os.fork()
if pid > 0:
# exit first parent
salt.utils.crypt.reinit_crypto()
os._exit(salt.defaults.exitcodes.EX_OK)
exce... | [
"def",
"daemonize",
"(",
"redirect_out",
"=",
"True",
")",
":",
"# Avoid circular import",
"import",
"salt",
".",
"utils",
".",
"crypt",
"try",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
">",
"0",
":",
"# exit first parent",
"salt",
".",
... | Daemonize a process | [
"Daemonize",
"a",
"process"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L63-L110 | train |
saltstack/salt | salt/utils/process.py | daemonize_if | def daemonize_if(opts):
'''
Daemonize a module function process if multiprocessing is True and the
process is not being called by salt-call
'''
if 'salt-call' in sys.argv[0]:
return
if not opts.get('multiprocessing', True):
return
if sys.platform.startswith('win'):
re... | python | def daemonize_if(opts):
'''
Daemonize a module function process if multiprocessing is True and the
process is not being called by salt-call
'''
if 'salt-call' in sys.argv[0]:
return
if not opts.get('multiprocessing', True):
return
if sys.platform.startswith('win'):
re... | [
"def",
"daemonize_if",
"(",
"opts",
")",
":",
"if",
"'salt-call'",
"in",
"sys",
".",
"argv",
"[",
"0",
"]",
":",
"return",
"if",
"not",
"opts",
".",
"get",
"(",
"'multiprocessing'",
",",
"True",
")",
":",
"return",
"if",
"sys",
".",
"platform",
".",
... | Daemonize a module function process if multiprocessing is True and the
process is not being called by salt-call | [
"Daemonize",
"a",
"module",
"function",
"process",
"if",
"multiprocessing",
"is",
"True",
"and",
"the",
"process",
"is",
"not",
"being",
"called",
"by",
"salt",
"-",
"call"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L113-L124 | train |
saltstack/salt | salt/utils/process.py | notify_systemd | def notify_systemd():
'''
Notify systemd that this process has started
'''
try:
import systemd.daemon
except ImportError:
if salt.utils.path.which('systemd-notify') \
and systemd_notify_call('--booted'):
# Notify systemd synchronously
notify_so... | python | def notify_systemd():
'''
Notify systemd that this process has started
'''
try:
import systemd.daemon
except ImportError:
if salt.utils.path.which('systemd-notify') \
and systemd_notify_call('--booted'):
# Notify systemd synchronously
notify_so... | [
"def",
"notify_systemd",
"(",
")",
":",
"try",
":",
"import",
"systemd",
".",
"daemon",
"except",
"ImportError",
":",
"if",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'systemd-notify'",
")",
"and",
"systemd_notify_call",
"(",
"'--booted'",
")",
... | Notify systemd that this process has started | [
"Notify",
"systemd",
"that",
"this",
"process",
"has",
"started"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L134-L164 | train |
saltstack/salt | salt/utils/process.py | set_pidfile | def set_pidfile(pidfile, user):
'''
Save the pidfile
'''
pdir = os.path.dirname(pidfile)
if not os.path.isdir(pdir) and pdir:
os.makedirs(pdir)
try:
with salt.utils.files.fopen(pidfile, 'w+') as ofile:
ofile.write(str(os.getpid())) # future lint: disable=blacklisted-... | python | def set_pidfile(pidfile, user):
'''
Save the pidfile
'''
pdir = os.path.dirname(pidfile)
if not os.path.isdir(pdir) and pdir:
os.makedirs(pdir)
try:
with salt.utils.files.fopen(pidfile, 'w+') as ofile:
ofile.write(str(os.getpid())) # future lint: disable=blacklisted-... | [
"def",
"set_pidfile",
"(",
"pidfile",
",",
"user",
")",
":",
"pdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"pidfile",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"pdir",
")",
"and",
"pdir",
":",
"os",
".",
"makedirs",
"(",
"pdi... | Save the pidfile | [
"Save",
"the",
"pidfile"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L167-L215 | train |
saltstack/salt | salt/utils/process.py | get_pidfile | def get_pidfile(pidfile):
'''
Return the pid from a pidfile as an integer
'''
try:
with salt.utils.files.fopen(pidfile) as pdf:
pid = pdf.read().strip()
return int(pid)
except (OSError, IOError, TypeError, ValueError):
return -1 | python | def get_pidfile(pidfile):
'''
Return the pid from a pidfile as an integer
'''
try:
with salt.utils.files.fopen(pidfile) as pdf:
pid = pdf.read().strip()
return int(pid)
except (OSError, IOError, TypeError, ValueError):
return -1 | [
"def",
"get_pidfile",
"(",
"pidfile",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"pidfile",
")",
"as",
"pdf",
":",
"pid",
"=",
"pdf",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
"return",
"int",
"(",
... | Return the pid from a pidfile as an integer | [
"Return",
"the",
"pid",
"from",
"a",
"pidfile",
"as",
"an",
"integer"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L225-L234 | train |
saltstack/salt | salt/utils/process.py | clean_proc | def clean_proc(proc, wait_for_kill=10):
'''
Generic method for cleaning up multiprocessing procs
'''
# NoneType and other fun stuff need not apply
if not proc:
return
try:
waited = 0
while proc.is_alive():
proc.terminate()
waited += 1
t... | python | def clean_proc(proc, wait_for_kill=10):
'''
Generic method for cleaning up multiprocessing procs
'''
# NoneType and other fun stuff need not apply
if not proc:
return
try:
waited = 0
while proc.is_alive():
proc.terminate()
waited += 1
t... | [
"def",
"clean_proc",
"(",
"proc",
",",
"wait_for_kill",
"=",
"10",
")",
":",
"# NoneType and other fun stuff need not apply",
"if",
"not",
"proc",
":",
"return",
"try",
":",
"waited",
"=",
"0",
"while",
"proc",
".",
"is_alive",
"(",
")",
":",
"proc",
".",
... | Generic method for cleaning up multiprocessing procs | [
"Generic",
"method",
"for",
"cleaning",
"up",
"multiprocessing",
"procs"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L237-L257 | train |
saltstack/salt | salt/utils/process.py | os_is_running | def os_is_running(pid):
'''
Use OS facilities to determine if a process is running
'''
if isinstance(pid, six.string_types):
pid = int(pid)
if HAS_PSUTIL:
return psutil.pid_exists(pid)
else:
try:
os.kill(pid, 0) # SIG 0 is the "are you alive?" signal
... | python | def os_is_running(pid):
'''
Use OS facilities to determine if a process is running
'''
if isinstance(pid, six.string_types):
pid = int(pid)
if HAS_PSUTIL:
return psutil.pid_exists(pid)
else:
try:
os.kill(pid, 0) # SIG 0 is the "are you alive?" signal
... | [
"def",
"os_is_running",
"(",
"pid",
")",
":",
"if",
"isinstance",
"(",
"pid",
",",
"six",
".",
"string_types",
")",
":",
"pid",
"=",
"int",
"(",
"pid",
")",
"if",
"HAS_PSUTIL",
":",
"return",
"psutil",
".",
"pid_exists",
"(",
"pid",
")",
"else",
":",... | Use OS facilities to determine if a process is running | [
"Use",
"OS",
"facilities",
"to",
"determine",
"if",
"a",
"process",
"is",
"running"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L260-L273 | train |
saltstack/salt | salt/utils/process.py | ProcessManager.add_process | def add_process(self, tgt, args=None, kwargs=None, name=None):
'''
Create a processes and args + kwargs
This will deterimine if it is a Process class, otherwise it assumes
it is a function
'''
if args is None:
args = []
if kwargs is None:
... | python | def add_process(self, tgt, args=None, kwargs=None, name=None):
'''
Create a processes and args + kwargs
This will deterimine if it is a Process class, otherwise it assumes
it is a function
'''
if args is None:
args = []
if kwargs is None:
... | [
"def",
"add_process",
"(",
"self",
",",
"tgt",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"... | Create a processes and args + kwargs
This will deterimine if it is a Process class, otherwise it assumes
it is a function | [
"Create",
"a",
"processes",
"and",
"args",
"+",
"kwargs",
"This",
"will",
"deterimine",
"if",
"it",
"is",
"a",
"Process",
"class",
"otherwise",
"it",
"assumes",
"it",
"is",
"a",
"function"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L366-L433 | train |
saltstack/salt | salt/utils/process.py | ProcessManager.restart_process | def restart_process(self, pid):
'''
Create new process (assuming this one is dead), then remove the old one
'''
if self._restart_processes is False:
return
log.info(
'Process %s (%s) died with exit status %s, restarting...',
self._process_map[p... | python | def restart_process(self, pid):
'''
Create new process (assuming this one is dead), then remove the old one
'''
if self._restart_processes is False:
return
log.info(
'Process %s (%s) died with exit status %s, restarting...',
self._process_map[p... | [
"def",
"restart_process",
"(",
"self",
",",
"pid",
")",
":",
"if",
"self",
".",
"_restart_processes",
"is",
"False",
":",
"return",
"log",
".",
"info",
"(",
"'Process %s (%s) died with exit status %s, restarting...'",
",",
"self",
".",
"_process_map",
"[",
"pid",
... | Create new process (assuming this one is dead), then remove the old one | [
"Create",
"new",
"process",
"(",
"assuming",
"this",
"one",
"is",
"dead",
")",
"then",
"remove",
"the",
"old",
"one"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L435-L454 | train |
saltstack/salt | salt/utils/process.py | ProcessManager.run | def run(self, asynchronous=False):
'''
Load and start all available api modules
'''
log.debug('Process Manager starting!')
appendproctitle(self.name)
# make sure to kill the subprocesses if the parent is killed
if signal.getsignal(signal.SIGTERM) is signal.SIG_DF... | python | def run(self, asynchronous=False):
'''
Load and start all available api modules
'''
log.debug('Process Manager starting!')
appendproctitle(self.name)
# make sure to kill the subprocesses if the parent is killed
if signal.getsignal(signal.SIGTERM) is signal.SIG_DF... | [
"def",
"run",
"(",
"self",
",",
"asynchronous",
"=",
"False",
")",
":",
"log",
".",
"debug",
"(",
"'Process Manager starting!'",
")",
"appendproctitle",
"(",
"self",
".",
"name",
")",
"# make sure to kill the subprocesses if the parent is killed",
"if",
"signal",
".... | Load and start all available api modules | [
"Load",
"and",
"start",
"all",
"available",
"api",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L485-L522 | train |
saltstack/salt | salt/utils/process.py | ProcessManager.check_children | def check_children(self):
'''
Check the children once
'''
if self._restart_processes is True:
for pid, mapping in six.iteritems(self._process_map):
if not mapping['Process'].is_alive():
log.trace('Process restart of %s', pid)
... | python | def check_children(self):
'''
Check the children once
'''
if self._restart_processes is True:
for pid, mapping in six.iteritems(self._process_map):
if not mapping['Process'].is_alive():
log.trace('Process restart of %s', pid)
... | [
"def",
"check_children",
"(",
"self",
")",
":",
"if",
"self",
".",
"_restart_processes",
"is",
"True",
":",
"for",
"pid",
",",
"mapping",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_process_map",
")",
":",
"if",
"not",
"mapping",
"[",
"'Process'",... | Check the children once | [
"Check",
"the",
"children",
"once"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L524-L532 | train |
saltstack/salt | salt/utils/process.py | ProcessManager.kill_children | def kill_children(self, *args, **kwargs):
'''
Kill all of the children
'''
# first lets reset signal handlers to default one to prevent running this twice
signal.signal(signal.SIGTERM, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
# check that this... | python | def kill_children(self, *args, **kwargs):
'''
Kill all of the children
'''
# first lets reset signal handlers to default one to prevent running this twice
signal.signal(signal.SIGTERM, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
# check that this... | [
"def",
"kill_children",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# first lets reset signal handlers to default one to prevent running this twice",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"signal",
".",
"SIG_IGN",
")",
... | Kill all of the children | [
"Kill",
"all",
"of",
"the",
"children"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L534-L657 | train |
saltstack/salt | salt/modules/victorops.py | _query | def _query(action=None,
routing_key=None,
args=None,
method='GET',
header_dict=None,
data=None):
'''
Make a web call to VictorOps
'''
api_key = __salt__['config.get']('victorops.api_key') or \
__salt__['config.get']('victorops:api_key')
... | python | def _query(action=None,
routing_key=None,
args=None,
method='GET',
header_dict=None,
data=None):
'''
Make a web call to VictorOps
'''
api_key = __salt__['config.get']('victorops.api_key') or \
__salt__['config.get']('victorops:api_key')
... | [
"def",
"_query",
"(",
"action",
"=",
"None",
",",
"routing_key",
"=",
"None",
",",
"args",
"=",
"None",
",",
"method",
"=",
"'GET'",
",",
"header_dict",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"api_key",
"=",
"__salt__",
"[",
"'config.get'",
... | Make a web call to VictorOps | [
"Make",
"a",
"web",
"call",
"to",
"VictorOps"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/victorops.py#L41-L97 | train |
saltstack/salt | salt/modules/victorops.py | create_event | def create_event(message_type=None, routing_key='everybody', **kwargs):
'''
Create an event in VictorOps. Designed for use in states.
The following parameters are required:
:param message_type: One of the following values: INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, RECOVERY.
The followi... | python | def create_event(message_type=None, routing_key='everybody', **kwargs):
'''
Create an event in VictorOps. Designed for use in states.
The following parameters are required:
:param message_type: One of the following values: INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, RECOVERY.
The followi... | [
"def",
"create_event",
"(",
"message_type",
"=",
"None",
",",
"routing_key",
"=",
"'everybody'",
",",
"*",
"*",
"kwargs",
")",
":",
"keyword_args",
"=",
"{",
"'entity_id'",
":",
"str",
",",
"'state_message'",
":",
"str",
",",
"'entity_is_host'",
":",
"bool",... | Create an event in VictorOps. Designed for use in states.
The following parameters are required:
:param message_type: One of the following values: INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, RECOVERY.
The following parameters are optional:
:param routing_key: The key for where m... | [
"Create",
"an",
"event",
"in",
"VictorOps",
".",
"Designed",
"for",
"use",
"in",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/victorops.py#L100-L211 | train |
saltstack/salt | salt/states/telemetry_alert.py | present | def present(name, deployment_id, metric_name, alert_config, api_key=None, profile='telemetry'):
'''
Ensure the telemetry alert exists.
name
An optional description of the alarm (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... | python | def present(name, deployment_id, metric_name, alert_config, api_key=None, profile='telemetry'):
'''
Ensure the telemetry alert exists.
name
An optional description of the alarm (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... | [
"def",
"present",
"(",
"name",
",",
"deployment_id",
",",
"metric_name",
",",
"alert_config",
",",
"api_key",
"=",
"None",
",",
"profile",
"=",
"'telemetry'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"metric_name",
",",
"'result'",
":",
"True",
",",
"'c... | Ensure the telemetry alert exists.
name
An optional description of the alarm (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
(replica set cluster or sharded cluster) to which this alert definition is attached
metric_name
... | [
"Ensure",
"the",
"telemetry",
"alert",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/telemetry_alert.py#L40-L155 | train |
saltstack/salt | salt/states/telemetry_alert.py | absent | def absent(name, deployment_id, metric_name, api_key=None, profile="telemetry"):
'''
Ensure the telemetry alert config is deleted
name
An optional description of the alarms (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... | python | def absent(name, deployment_id, metric_name, api_key=None, profile="telemetry"):
'''
Ensure the telemetry alert config is deleted
name
An optional description of the alarms (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... | [
"def",
"absent",
"(",
"name",
",",
"deployment_id",
",",
"metric_name",
",",
"api_key",
"=",
"None",
",",
"profile",
"=",
"\"telemetry\"",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"metric_name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",... | Ensure the telemetry alert config is deleted
name
An optional description of the alarms (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
(replica set cluster or sharded cluster) to which this alert definition is attached
met... | [
"Ensure",
"the",
"telemetry",
"alert",
"config",
"is",
"deleted"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/telemetry_alert.py#L158-L201 | train |
saltstack/salt | salt/modules/mac_pkgutil.py | list_ | def list_():
'''
List the installed packages.
:return: A list of installed packages
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' pkgutil.list
'''
cmd = 'pkgutil --pkgs'
ret = salt.utils.mac_utils.execute_return_result(cmd)
return ret.splitlines() | python | def list_():
'''
List the installed packages.
:return: A list of installed packages
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' pkgutil.list
'''
cmd = 'pkgutil --pkgs'
ret = salt.utils.mac_utils.execute_return_result(cmd)
return ret.splitlines() | [
"def",
"list_",
"(",
")",
":",
"cmd",
"=",
"'pkgutil --pkgs'",
"ret",
"=",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"execute_return_result",
"(",
"cmd",
")",
"return",
"ret",
".",
"splitlines",
"(",
")"
] | List the installed packages.
:return: A list of installed packages
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' pkgutil.list | [
"List",
"the",
"installed",
"packages",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_pkgutil.py#L39-L54 | train |
saltstack/salt | salt/modules/mac_pkgutil.py | _install_from_path | def _install_from_path(path):
'''
Internal function to install a package from the given path
'''
if not os.path.exists(path):
msg = 'File not found: {0}'.format(path)
raise SaltInvocationError(msg)
cmd = 'installer -pkg "{0}" -target /'.format(path)
return salt.utils.mac_utils.e... | python | def _install_from_path(path):
'''
Internal function to install a package from the given path
'''
if not os.path.exists(path):
msg = 'File not found: {0}'.format(path)
raise SaltInvocationError(msg)
cmd = 'installer -pkg "{0}" -target /'.format(path)
return salt.utils.mac_utils.e... | [
"def",
"_install_from_path",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"msg",
"=",
"'File not found: {0}'",
".",
"format",
"(",
"path",
")",
"raise",
"SaltInvocationError",
"(",
"msg",
")",
"cmd",
"=",
... | Internal function to install a package from the given path | [
"Internal",
"function",
"to",
"install",
"a",
"package",
"from",
"the",
"given",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_pkgutil.py#L73-L82 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.