partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | get_filter_pillar | Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
pillar_key
The root key of the whole policy config.
pillarenv
Query the master to generate fresh pillar data on the fly,
specificall... | salt/modules/capirca_acl.py | def get_filter_pillar(filter_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
... | def get_filter_pillar(filter_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
... | [
"Helper",
"that",
"can",
"be",
"used",
"inside",
"a",
"state",
"SLS",
"in",
"order",
"to",
"get",
"the",
"filter",
"configuration",
"given",
"its",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/capirca_acl.py#L1205-L1230 | [
"def",
"get_filter_pillar",
"(",
"filter_name",
",",
"pillar_key",
"=",
"'acl'",
",",
"pillarenv",
"=",
"None",
",",
"saltenv",
"=",
"None",
")",
":",
"pillar_cfg",
"=",
"_get_pillar_cfg",
"(",
"pillar_key",
",",
"pillarenv",
"=",
"pillarenv",
",",
"saltenv",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_term_pillar | Helper that can be used inside a state SLS,
in order to get the term configuration given its name,
under a certain filter uniquely identified by its name.
filter_name
The name of the filter.
term_name
The name of the term.
pillar_key: ``acl``
The root key of the whole poli... | salt/modules/capirca_acl.py | def get_term_pillar(filter_name,
term_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the term configuration given its name,
under a certain filter uniqu... | def get_term_pillar(filter_name,
term_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the term configuration given its name,
under a certain filter uniqu... | [
"Helper",
"that",
"can",
"be",
"used",
"inside",
"a",
"state",
"SLS",
"in",
"order",
"to",
"get",
"the",
"term",
"configuration",
"given",
"its",
"name",
"under",
"a",
"certain",
"filter",
"uniquely",
"identified",
"by",
"its",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/capirca_acl.py#L1233-L1266 | [
"def",
"get_term_pillar",
"(",
"filter_name",
",",
"term_name",
",",
"pillar_key",
"=",
"'acl'",
",",
"pillarenv",
"=",
"None",
",",
"saltenv",
"=",
"None",
")",
":",
"filter_pillar_cfg",
"=",
"get_filter_pillar",
"(",
"filter_name",
",",
"pillar_key",
"=",
"p... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | SaltCall.run | Execute the salt call! | salt/cli/call.py | def run(self):
'''
Execute the salt call!
'''
self.parse_args()
if self.options.file_root:
# check if the argument is pointing to a file on disk
file_root = os.path.abspath(self.options.file_root)
self.config['file_roots'] = {'base': _expand_g... | def run(self):
'''
Execute the salt call!
'''
self.parse_args()
if self.options.file_root:
# check if the argument is pointing to a file on disk
file_root = os.path.abspath(self.options.file_root)
self.config['file_roots'] = {'base': _expand_g... | [
"Execute",
"the",
"salt",
"call!"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/call.py#L17-L57 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"parse_args",
"(",
")",
"if",
"self",
".",
"options",
".",
"file_root",
":",
"# check if the argument is pointing to a file on disk",
"file_root",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"op... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | note | Add content to a document generated using `highstate_doc.render`.
This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers
to include extra documents.
.. code-block:: yaml
{{sls}} example note:
highstate_doc.note:
- name:... | salt/states/highstate_doc.py | def note(name, source=None, contents=None, **kwargs):
'''
Add content to a document generated using `highstate_doc.render`.
This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers
to include extra documents.
.. code-block:: yaml
{{sls}} exa... | def note(name, source=None, contents=None, **kwargs):
'''
Add content to a document generated using `highstate_doc.render`.
This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers
to include extra documents.
.. code-block:: yaml
{{sls}} exa... | [
"Add",
"content",
"to",
"a",
"document",
"generated",
"using",
"highstate_doc",
".",
"render",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/highstate_doc.py#L12-L45 | [
"def",
"note",
"(",
"name",
",",
"source",
"=",
"None",
",",
"contents",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"comment",
"=",
"''",
"if",
"source",
":",
"comment",
"+=",
"'include file: {0}\\n'",
".",
"format",
"(",
"source",
")",
"if",
"c... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | available | .. versionadded:: 2017.7.0
List updates that match the passed criteria. This allows for more filter
options than :func:`list`. Good for finding a specific GUID or KB.
Args:
software (bool):
Include software updates in the results (default is True)
drivers (bool):
... | salt/modules/win_wua.py | def available(software=True,
drivers=True,
summary=False,
skip_installed=True,
skip_hidden=True,
skip_mandatory=False,
skip_reboot=False,
categories=None,
severities=None,):
'''
.. versionadded:: 2017... | def available(software=True,
drivers=True,
summary=False,
skip_installed=True,
skip_hidden=True,
skip_mandatory=False,
skip_reboot=False,
categories=None,
severities=None,):
'''
.. versionadded:: 2017... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L99-L236 | [
"def",
"available",
"(",
"software",
"=",
"True",
",",
"drivers",
"=",
"True",
",",
"summary",
"=",
"False",
",",
"skip_installed",
"=",
"True",
",",
"skip_hidden",
"=",
"True",
",",
"skip_mandatory",
"=",
"False",
",",
"skip_reboot",
"=",
"False",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get | .. versionadded:: 2017.7.0
Returns details for the named update
Args:
name (str):
The name of the update you're searching for. This can be the GUID, a
KB number, or any part of the name of the update. GUIDs and KBs are
preferred. Run ``list`` to get the GUID for th... | salt/modules/win_wua.py | def get(name, download=False, install=False):
'''
.. versionadded:: 2017.7.0
Returns details for the named update
Args:
name (str):
The name of the update you're searching for. This can be the GUID, a
KB number, or any part of the name of the update. GUIDs and KBs are
... | def get(name, download=False, install=False):
'''
.. versionadded:: 2017.7.0
Returns details for the named update
Args:
name (str):
The name of the update you're searching for. This can be the GUID, a
KB number, or any part of the name of the update. GUIDs and KBs are
... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L239-L328 | [
"def",
"get",
"(",
"name",
",",
"download",
"=",
"False",
",",
"install",
"=",
"False",
")",
":",
"# Create a Windows Update Agent instance",
"wua",
"=",
"salt",
".",
"utils",
".",
"win_update",
".",
"WindowsUpdateAgent",
"(",
")",
"# Search for Update",
"update... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list | .. versionadded:: 2017.7.0
Returns a detailed list of available updates or a summary. If download or
install is True the same list will be downloaded and/or installed.
Args:
software (bool):
Include software updates in the results (default is True)
drivers (bool):
... | salt/modules/win_wua.py | def list(software=True,
drivers=False,
summary=False,
skip_installed=True,
categories=None,
severities=None,
download=False,
install=False):
'''
.. versionadded:: 2017.7.0
Returns a detailed list of available updates or a summary. If download o... | def list(software=True,
drivers=False,
summary=False,
skip_installed=True,
categories=None,
severities=None,
download=False,
install=False):
'''
.. versionadded:: 2017.7.0
Returns a detailed list of available updates or a summary. If download o... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L331-L479 | [
"def",
"list",
"(",
"software",
"=",
"True",
",",
"drivers",
"=",
"False",
",",
"summary",
"=",
"False",
",",
"skip_installed",
"=",
"True",
",",
"categories",
"=",
"None",
",",
"severities",
"=",
"None",
",",
"download",
"=",
"False",
",",
"install",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | download | .. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination o... | salt/modules/win_wua.py | def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can... | def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L482-L531 | [
"def",
"download",
"(",
"names",
")",
":",
"# Create a Windows Update Agent instance",
"wua",
"=",
"salt",
".",
"utils",
".",
"win_update",
".",
"WindowsUpdateAgent",
"(",
")",
"# Search for Update",
"updates",
"=",
"wua",
".",
"search",
"(",
"names",
")",
"if",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | uninstall | .. versionadded:: 2017.7.0
Uninstall updates.
Args:
names (str, list):
A single update or a list of updates to uninstall. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
Returns:
dict: A dictionary containing th... | salt/modules/win_wua.py | def uninstall(names):
'''
.. versionadded:: 2017.7.0
Uninstall updates.
Args:
names (str, list):
A single update or a list of updates to uninstall. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
Returns:
... | def uninstall(names):
'''
.. versionadded:: 2017.7.0
Uninstall updates.
Args:
names (str, list):
A single update or a list of updates to uninstall. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
Returns:
... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L586-L622 | [
"def",
"uninstall",
"(",
"names",
")",
":",
"# Create a Windows Update Agent instance",
"wua",
"=",
"salt",
".",
"utils",
".",
"win_update",
".",
"WindowsUpdateAgent",
"(",
")",
"# Search for Updates",
"updates",
"=",
"wua",
".",
"search",
"(",
"names",
")",
"if... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_wu_settings | Change Windows Update settings. If no parameters are passed, the current
value will be returned.
Supported:
- Windows Vista / Server 2008
- Windows 7 / Server 2008R2
- Windows 8 / Server 2012
- Windows 8.1 / Server 2012R2
.. note:
Microsoft began using the Unified U... | salt/modules/win_wua.py | def set_wu_settings(level=None,
recommended=None,
featured=None,
elevated=None,
msupdate=None,
day=None,
time=None):
'''
Change Windows Update settings. If no parameters are passed, the curren... | def set_wu_settings(level=None,
recommended=None,
featured=None,
elevated=None,
msupdate=None,
day=None,
time=None):
'''
Change Windows Update settings. If no parameters are passed, the curren... | [
"Change",
"Windows",
"Update",
"settings",
".",
"If",
"no",
"parameters",
"are",
"passed",
"the",
"current",
"value",
"will",
"be",
"returned",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L625-L863 | [
"def",
"set_wu_settings",
"(",
"level",
"=",
"None",
",",
"recommended",
"=",
"None",
",",
"featured",
"=",
"None",
",",
"elevated",
"=",
"None",
",",
"msupdate",
"=",
"None",
",",
"day",
"=",
"None",
",",
"time",
"=",
"None",
")",
":",
"# The Automati... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_wu_settings | Get current Windows Update settings.
Returns:
dict: A dictionary of Windows Update settings:
Featured Updates:
Boolean value that indicates whether to display notifications for
featured updates.
Group Policy Required (Read-only):
Boolean value that indi... | salt/modules/win_wua.py | def get_wu_settings():
'''
Get current Windows Update settings.
Returns:
dict: A dictionary of Windows Update settings:
Featured Updates:
Boolean value that indicates whether to display notifications for
featured updates.
Group Policy Required (Read-only):
... | def get_wu_settings():
'''
Get current Windows Update settings.
Returns:
dict: A dictionary of Windows Update settings:
Featured Updates:
Boolean value that indicates whether to display notifications for
featured updates.
Group Policy Required (Read-only):
... | [
"Get",
"current",
"Windows",
"Update",
"settings",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L866-L953 | [
"def",
"get_wu_settings",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"day",
"=",
"[",
"'Every Day'",
",",
"'Sunday'",
",",
"'Monday'",
",",
"'Tuesday'",
",",
"'Wednesday'",
",",
"'Thursday'",
",",
"'Friday'",
",",
"'Saturday'",
"]",
"# Initialize the PyCom system",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_msupdate_status | Check to see if Microsoft Update is Enabled
Return Boolean | salt/modules/win_wua.py | def _get_msupdate_status():
'''
Check to see if Microsoft Update is Enabled
Return Boolean
'''
# To get the status of Microsoft Update we actually have to check the
# Microsoft Update Service Manager
# Initialize the PyCom system
with salt.utils.winapi.Com():
# Create a ServiceMa... | def _get_msupdate_status():
'''
Check to see if Microsoft Update is Enabled
Return Boolean
'''
# To get the status of Microsoft Update we actually have to check the
# Microsoft Update Service Manager
# Initialize the PyCom system
with salt.utils.winapi.Com():
# Create a ServiceMa... | [
"Check",
"to",
"see",
"if",
"Microsoft",
"Update",
"is",
"Enabled",
"Return",
"Boolean"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L956-L977 | [
"def",
"_get_msupdate_status",
"(",
")",
":",
"# To get the status of Microsoft Update we actually have to check the",
"# Microsoft Update Service Manager",
"# Initialize the PyCom system",
"with",
"salt",
".",
"utils",
".",
"winapi",
".",
"Com",
"(",
")",
":",
"# Create a Serv... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_object_metadata | Get metadata about an S3 object.
Returns None if the object does not exist.
You can pass AWS SSE-C related args and/or RequestPayer in extra_args.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.get_object_metadata \\
my_bucket/path/to/object \\
... | salt/modules/boto_s3.py | def get_object_metadata(
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Get metadata about an S3 object.
Returns None if the object does not exist.
You can pass AWS SSE-C related args and/or RequestPayer in extra_args.
CLI Example:
.. co... | def get_object_metadata(
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Get metadata about an S3 object.
Returns None if the object does not exist.
You can pass AWS SSE-C related args and/or RequestPayer in extra_args.
CLI Example:
.. co... | [
"Get",
"metadata",
"about",
"an",
"S3",
"object",
".",
"Returns",
"None",
"if",
"the",
"object",
"does",
"not",
"exist",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3.py#L90-L132 | [
"def",
"get_object_metadata",
"(",
"name",
",",
"extra_args",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
")",
":",
"bucket",
",",
"_",
",",
"s3_key",
"=",
"name",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | upload_file | Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
my_bucket/path/to/object \\
region=us-east-1 \\
key=key \\
... | salt/modules/boto_s3.py | def upload_file(
source,
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
... | def upload_file(
source,
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
... | [
"Upload",
"a",
"local",
"file",
"as",
"an",
"S3",
"object",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3.py#L135-L169 | [
"def",
"upload_file",
"(",
"source",
",",
"name",
",",
"extra_args",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
",",
")",
":",
"bucket",
",",
"_",
",",
"s3_key",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | profile_func | Decorator for adding profiling to a nested function in Salt | salt/utils/profile.py | def profile_func(filename=None):
'''
Decorator for adding profiling to a nested function in Salt
'''
def proffunc(fun):
def profiled_func(*args, **kwargs):
logging.info('Profiling function %s', fun.__name__)
try:
profiler = cProfile.Profile()
... | def profile_func(filename=None):
'''
Decorator for adding profiling to a nested function in Salt
'''
def proffunc(fun):
def profiled_func(*args, **kwargs):
logging.info('Profiling function %s', fun.__name__)
try:
profiler = cProfile.Profile()
... | [
"Decorator",
"for",
"adding",
"profiling",
"to",
"a",
"nested",
"function",
"in",
"Salt"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/profile.py#L30-L47 | [
"def",
"profile_func",
"(",
"filename",
"=",
"None",
")",
":",
"def",
"proffunc",
"(",
"fun",
")",
":",
"def",
"profiled_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"'Profiling function %s'",
",",
"fun",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_django_admin | Return the django admin | salt/modules/djangomod.py | def _get_django_admin(bin_env):
'''
Return the django admin
'''
if not bin_env:
if salt.utils.path.which('django-admin.py'):
return 'django-admin.py'
elif salt.utils.path.which('django-admin'):
return 'django-admin'
else:
raise salt.exceptions.... | def _get_django_admin(bin_env):
'''
Return the django admin
'''
if not bin_env:
if salt.utils.path.which('django-admin.py'):
return 'django-admin.py'
elif salt.utils.path.which('django-admin'):
return 'django-admin'
else:
raise salt.exceptions.... | [
"Return",
"the",
"django",
"admin"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L26-L42 | [
"def",
"_get_django_admin",
"(",
"bin_env",
")",
":",
"if",
"not",
"bin_env",
":",
"if",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'django-admin.py'",
")",
":",
"return",
"'django-admin.py'",
"elif",
"salt",
".",
"utils",
".",
"path",
".",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | command | Run arbitrary django management command
CLI Example:
.. code-block:: bash
salt '*' django.command <settings_module> <command> | salt/modules/djangomod.py | def command(settings_module,
command,
bin_env=None,
pythonpath=None,
env=None,
runas=None,
*args, **kwargs):
'''
Run arbitrary django management command
CLI Example:
.. code-block:: bash
salt '*' django.command <settings_... | def command(settings_module,
command,
bin_env=None,
pythonpath=None,
env=None,
runas=None,
*args, **kwargs):
'''
Run arbitrary django management command
CLI Example:
.. code-block:: bash
salt '*' django.command <settings_... | [
"Run",
"arbitrary",
"django",
"management",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L45-L73 | [
"def",
"command",
"(",
"settings_module",
",",
"command",
",",
"bin_env",
"=",
"None",
",",
"pythonpath",
"=",
"None",
",",
"env",
"=",
"None",
",",
"runas",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dja",
"=",
"_get_django_a... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | syncdb | Run syncdb
Execute the Django-Admin syncdb command, if South is available on the
minion the ``migrate`` option can be passed as ``True`` calling the
migrations to run after the syncdb completes
NOTE: The syncdb command was deprecated in Django 1.7 and removed in Django 1.9.
For Django versions 1.9... | salt/modules/djangomod.py | def syncdb(settings_module,
bin_env=None,
migrate=False,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run syncdb
Execute the Django-Admin syncdb command, if South is available on the
minion the ``mi... | def syncdb(settings_module,
bin_env=None,
migrate=False,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run syncdb
Execute the Django-Admin syncdb command, if South is available on the
minion the ``mi... | [
"Run",
"syncdb"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L76-L115 | [
"def",
"syncdb",
"(",
"settings_module",
",",
"bin_env",
"=",
"None",
",",
"migrate",
"=",
"False",
",",
"database",
"=",
"None",
",",
"pythonpath",
"=",
"None",
",",
"env",
"=",
"None",
",",
"noinput",
"=",
"True",
",",
"runas",
"=",
"None",
")",
":... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | migrate | Run migrate
Execute the Django-Admin migrate command (requires Django 1.7 or higher).
.. versionadded:: Neon
settings_module
Specifies the settings module to use.
The settings module should be in Python package syntax, e.g. mysite.settings.
If this isn’t provided, django-admin wil... | salt/modules/djangomod.py | def migrate(settings_module,
app_label=None,
migration_name=None,
bin_env=None,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run migrate
Execute the Django-Admin migrate command (requires Dja... | def migrate(settings_module,
app_label=None,
migration_name=None,
bin_env=None,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run migrate
Execute the Django-Admin migrate command (requires Dja... | [
"Run",
"migrate"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L118-L211 | [
"def",
"migrate",
"(",
"settings_module",
",",
"app_label",
"=",
"None",
",",
"migration_name",
"=",
"None",
",",
"bin_env",
"=",
"None",
",",
"database",
"=",
"None",
",",
"pythonpath",
"=",
"None",
",",
"env",
"=",
"None",
",",
"noinput",
"=",
"True",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | createsuperuser | Create a super user for the database.
This function defaults to use the ``--noinput`` flag which prevents the
creation of a password for the superuser.
CLI Example:
.. code-block:: bash
salt '*' django.createsuperuser <settings_module> user user@example.com | salt/modules/djangomod.py | def createsuperuser(settings_module,
username,
email,
bin_env=None,
database=None,
pythonpath=None,
env=None,
runas=None):
'''
Create a super user for the database.
Thi... | def createsuperuser(settings_module,
username,
email,
bin_env=None,
database=None,
pythonpath=None,
env=None,
runas=None):
'''
Create a super user for the database.
Thi... | [
"Create",
"a",
"super",
"user",
"for",
"the",
"database",
".",
"This",
"function",
"defaults",
"to",
"use",
"the",
"--",
"noinput",
"flag",
"which",
"prevents",
"the",
"creation",
"of",
"a",
"password",
"for",
"the",
"superuser",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L214-L246 | [
"def",
"createsuperuser",
"(",
"settings_module",
",",
"username",
",",
"email",
",",
"bin_env",
"=",
"None",
",",
"database",
"=",
"None",
",",
"pythonpath",
"=",
"None",
",",
"env",
"=",
"None",
",",
"runas",
"=",
"None",
")",
":",
"args",
"=",
"[",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | loaddata | Load fixture data
Fixtures:
comma separated list of fixtures to load
CLI Example:
.. code-block:: bash
salt '*' django.loaddata <settings_module> <comma delimited list of fixtures> | salt/modules/djangomod.py | def loaddata(settings_module,
fixtures,
bin_env=None,
database=None,
pythonpath=None,
env=None):
'''
Load fixture data
Fixtures:
comma separated list of fixtures to load
CLI Example:
.. code-block:: bash
salt '*' dj... | def loaddata(settings_module,
fixtures,
bin_env=None,
database=None,
pythonpath=None,
env=None):
'''
Load fixture data
Fixtures:
comma separated list of fixtures to load
CLI Example:
.. code-block:: bash
salt '*' dj... | [
"Load",
"fixture",
"data"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L249-L280 | [
"def",
"loaddata",
"(",
"settings_module",
",",
"fixtures",
",",
"bin_env",
"=",
"None",
",",
"database",
"=",
"None",
",",
"pythonpath",
"=",
"None",
",",
"env",
"=",
"None",
")",
":",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"if",
"database"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | collectstatic | Collect static files from each of your applications into a single location
that can easily be served in production.
CLI Example:
.. code-block:: bash
salt '*' django.collectstatic <settings_module> | salt/modules/djangomod.py | def collectstatic(settings_module,
bin_env=None,
no_post_process=False,
ignore=None,
dry_run=False,
clear=False,
link=False,
no_default_ignore=False,
pythonpath=None,
... | def collectstatic(settings_module,
bin_env=None,
no_post_process=False,
ignore=None,
dry_run=False,
clear=False,
link=False,
no_default_ignore=False,
pythonpath=None,
... | [
"Collect",
"static",
"files",
"from",
"each",
"of",
"your",
"applications",
"into",
"a",
"single",
"location",
"that",
"can",
"easily",
"be",
"served",
"in",
"production",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/djangomod.py#L283-L325 | [
"def",
"collectstatic",
"(",
"settings_module",
",",
"bin_env",
"=",
"None",
",",
"no_post_process",
"=",
"False",
",",
"ignore",
"=",
"None",
",",
"dry_run",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"link",
"=",
"False",
",",
"no_default_ignore",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Grant the requested privilege(s) on the specified object to a role
name
Name of the role to which privileges should be granted
object_name
Name of the object on which the grant is to be performed.
'ALL' may be used for objects of type 'table' or 'sequence'.
object_type
The ob... | salt/states/postgres_default_privileges.py | def present(name,
object_name,
object_type,
defprivileges=None,
grant_option=None,
prepend='public',
maintenance_db=None,
user=None,
db_password=None,
db_host=None,
db_port=None,
db_user=N... | def present(name,
object_name,
object_type,
defprivileges=None,
grant_option=None,
prepend='public',
maintenance_db=None,
user=None,
db_password=None,
db_host=None,
db_port=None,
db_user=N... | [
"Grant",
"the",
"requested",
"privilege",
"(",
"s",
")",
"on",
"the",
"specified",
"object",
"to",
"a",
"role"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_default_privileges.py#L77-L196 | [
"def",
"present",
"(",
"name",
",",
"object_name",
",",
"object_type",
",",
"defprivileges",
"=",
"None",
",",
"grant_option",
"=",
"None",
",",
"prepend",
"=",
"'public'",
",",
"maintenance_db",
"=",
"None",
",",
"user",
"=",
"None",
",",
"db_password",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_exports | List configured exports
CLI Example:
.. code-block:: bash
salt '*' nfs.list_exports | salt/modules/nfs3.py | def list_exports(exports='/etc/exports'):
'''
List configured exports
CLI Example:
.. code-block:: bash
salt '*' nfs.list_exports
'''
ret = {}
with salt.utils.files.fopen(exports, 'r') as efl:
for line in salt.utils.stringutils.to_unicode(efl.read()).splitlines():
... | def list_exports(exports='/etc/exports'):
'''
List configured exports
CLI Example:
.. code-block:: bash
salt '*' nfs.list_exports
'''
ret = {}
with salt.utils.files.fopen(exports, 'r') as efl:
for line in salt.utils.stringutils.to_unicode(efl.read()).splitlines():
... | [
"List",
"configured",
"exports"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L28-L66 | [
"def",
"list_exports",
"(",
"exports",
"=",
"'/etc/exports'",
")",
":",
"ret",
"=",
"{",
"}",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"exports",
",",
"'r'",
")",
"as",
"efl",
":",
"for",
"line",
"in",
"salt",
".",
"utils",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | del_export | Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage | salt/modules/nfs3.py | def del_export(exports='/etc/exports', path=None):
'''
Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage
'''
edict = list_exports(exports)
del edict[path]
_write_exports(exports, edict)
return edict | def del_export(exports='/etc/exports', path=None):
'''
Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage
'''
edict = list_exports(exports)
del edict[path]
_write_exports(exports, edict)
return edict | [
"Remove",
"an",
"export"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L69-L82 | [
"def",
"del_export",
"(",
"exports",
"=",
"'/etc/exports'",
",",
"path",
"=",
"None",
")",
":",
"edict",
"=",
"list_exports",
"(",
"exports",
")",
"del",
"edict",
"[",
"path",
"]",
"_write_exports",
"(",
"exports",
",",
"edict",
")",
"return",
"edict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_export | Add an export
CLI Example:
.. code-block:: bash
salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw'] | salt/modules/nfs3.py | def add_export(exports='/etc/exports', path=None, hosts=None, options=None):
'''
Add an export
CLI Example:
.. code-block:: bash
salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw']
'''
if options is None:
options = []
if not isinstance(hosts, six.str... | def add_export(exports='/etc/exports', path=None, hosts=None, options=None):
'''
Add an export
CLI Example:
.. code-block:: bash
salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw']
'''
if options is None:
options = []
if not isinstance(hosts, six.str... | [
"Add",
"an",
"export"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L85-L107 | [
"def",
"add_export",
"(",
"exports",
"=",
"'/etc/exports'",
",",
"path",
"=",
"None",
",",
"hosts",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"hos... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _write_exports | Write an exports file to disk
If multiple shares were initially configured per line, like:
/media/storage /media/data *(ro,sync,no_subtree_check)
...then they will be saved to disk with only one share per line:
/media/storage *(ro,sync,no_subtree_check)
/media/data *(ro,sync,no_subtr... | salt/modules/nfs3.py | def _write_exports(exports, edict):
'''
Write an exports file to disk
If multiple shares were initially configured per line, like:
/media/storage /media/data *(ro,sync,no_subtree_check)
...then they will be saved to disk with only one share per line:
/media/storage *(ro,sync,no_subtr... | def _write_exports(exports, edict):
'''
Write an exports file to disk
If multiple shares were initially configured per line, like:
/media/storage /media/data *(ro,sync,no_subtree_check)
...then they will be saved to disk with only one share per line:
/media/storage *(ro,sync,no_subtr... | [
"Write",
"an",
"exports",
"file",
"to",
"disk"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L110-L130 | [
"def",
"_write_exports",
"(",
"exports",
",",
"edict",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"exports",
",",
"'w'",
")",
"as",
"efh",
":",
"for",
"export",
"in",
"edict",
":",
"line",
"=",
"salt",
".",
"utils",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | reload_exports | Trigger a reload of the exports file to apply changes
CLI Example:
.. code-block:: bash
salt '*' nfs3.reload_exports | salt/modules/nfs3.py | def reload_exports():
'''
Trigger a reload of the exports file to apply changes
CLI Example:
.. code-block:: bash
salt '*' nfs3.reload_exports
'''
ret = {}
command = 'exportfs -r'
output = __salt__['cmd.run_all'](command)
ret['stdout'] = output['stdout']
ret['stderr'... | def reload_exports():
'''
Trigger a reload of the exports file to apply changes
CLI Example:
.. code-block:: bash
salt '*' nfs3.reload_exports
'''
ret = {}
command = 'exportfs -r'
output = __salt__['cmd.run_all'](command)
ret['stdout'] = output['stdout']
ret['stderr'... | [
"Trigger",
"a",
"reload",
"of",
"the",
"exports",
"file",
"to",
"apply",
"changes"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L133-L154 | [
"def",
"reload_exports",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"command",
"=",
"'exportfs -r'",
"output",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"command",
")",
"ret",
"[",
"'stdout'",
"]",
"=",
"output",
"[",
"'stdout'",
"]",
"ret",
"[",
"'st... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | .. versionchanged:: 2018.3.0
The ``tag`` argument has been added. It is now required unless pulling
from a registry.
Ensure that an image is present. The image can either be pulled from a
Docker registry, built from a Dockerfile, loaded from a saved image, or
built by running SLS files agai... | salt/states/docker_image.py | def present(name,
tag=None,
build=None,
load=None,
force=False,
insecure_registry=False,
client_timeout=salt.utils.docker.CLIENT_TIMEOUT,
dockerfile=None,
sls=None,
base='opensuse/python',
saltenv='ba... | def present(name,
tag=None,
build=None,
load=None,
force=False,
insecure_registry=False,
client_timeout=salt.utils.docker.CLIENT_TIMEOUT,
dockerfile=None,
sls=None,
base='opensuse/python',
saltenv='ba... | [
"..",
"versionchanged",
"::",
"2018",
".",
"3",
".",
"0",
"The",
"tag",
"argument",
"has",
"been",
"added",
".",
"It",
"is",
"now",
"required",
"unless",
"pulling",
"from",
"a",
"registry",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_image.py#L65-L375 | [
"def",
"present",
"(",
"name",
",",
"tag",
"=",
"None",
",",
"build",
"=",
"None",
",",
"load",
"=",
"None",
",",
"force",
"=",
"False",
",",
"insecure_registry",
"=",
"False",
",",
"client_timeout",
"=",
"salt",
".",
"utils",
".",
"docker",
".",
"CL... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure that an image is absent from the Minion. Image names can be
specified either using ``repo:tag`` notation, or just the repo name (in
which case a tag of ``latest`` is assumed).
images
Run this state on more than one image at a time. The following two
examples accomplish the same thing... | salt/states/docker_image.py | def absent(name=None, images=None, force=False):
'''
Ensure that an image is absent from the Minion. Image names can be
specified either using ``repo:tag`` notation, or just the repo name (in
which case a tag of ``latest`` is assumed).
images
Run this state on more than one image at a time.... | def absent(name=None, images=None, force=False):
'''
Ensure that an image is absent from the Minion. Image names can be
specified either using ``repo:tag`` notation, or just the repo name (in
which case a tag of ``latest`` is assumed).
images
Run this state on more than one image at a time.... | [
"Ensure",
"that",
"an",
"image",
"is",
"absent",
"from",
"the",
"Minion",
".",
"Image",
"names",
"can",
"be",
"specified",
"either",
"using",
"repo",
":",
"tag",
"notation",
"or",
"just",
"the",
"repo",
"name",
"(",
"in",
"which",
"case",
"a",
"tag",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_image.py#L378-L502 | [
"def",
"absent",
"(",
"name",
"=",
"None",
",",
"images",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mod_watch | The docker_image watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function should be set by the state being triggered. | salt/states/docker_image.py | def mod_watch(name, sfun=None, **kwargs):
'''
The docker_image watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function should... | def mod_watch(name, sfun=None, **kwargs):
'''
The docker_image watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function should... | [
"The",
"docker_image",
"watcher",
"called",
"to",
"invoke",
"the",
"watch",
"command",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/docker_image.py#L505-L524 | [
"def",
"mod_watch",
"(",
"name",
",",
"sfun",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sfun",
"==",
"'present'",
":",
"# Force image to be updated",
"kwargs",
"[",
"'force'",
"]",
"=",
"True",
"return",
"present",
"(",
"name",
",",
"*",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | render | Render a Genshi template. A method should be passed in as part of the
kwargs. If no method is passed in, xml is assumed. Valid methods are:
.. code-block:
- xml
- xhtml
- html
- text
- newtext
- oldtext
Note that the ``text`` method will call ``NewTextTempl... | salt/renderers/genshi.py | def render(genshi_data, saltenv='base', sls='', method='xml', **kws):
'''
Render a Genshi template. A method should be passed in as part of the
kwargs. If no method is passed in, xml is assumed. Valid methods are:
.. code-block:
- xml
- xhtml
- html
- text
- new... | def render(genshi_data, saltenv='base', sls='', method='xml', **kws):
'''
Render a Genshi template. A method should be passed in as part of the
kwargs. If no method is passed in, xml is assumed. Valid methods are:
.. code-block:
- xml
- xhtml
- html
- text
- new... | [
"Render",
"a",
"Genshi",
"template",
".",
"A",
"method",
"should",
"be",
"passed",
"in",
"as",
"part",
"of",
"the",
"kwargs",
".",
"If",
"no",
"method",
"is",
"passed",
"in",
"xml",
"is",
"assumed",
".",
"Valid",
"methods",
"are",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/genshi.py#L21-L58 | [
"def",
"render",
"(",
"genshi_data",
",",
"saltenv",
"=",
"'base'",
",",
"sls",
"=",
"''",
",",
"method",
"=",
"'xml'",
",",
"*",
"*",
"kws",
")",
":",
"if",
"not",
"HAS_LIBS",
":",
"return",
"{",
"}",
"if",
"not",
"isinstance",
"(",
"genshi_data",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | output | Display ret data | salt/output/nested.py | def output(ret, **kwargs):
'''
Display ret data
'''
# Prefer kwargs before opts
retcode = kwargs.get('_retcode', 0)
base_indent = kwargs.get('nested_indent', 0) \
or __opts__.get('nested_indent', 0)
nest = NestDisplay(retcode=retcode)
lines = nest.display(ret, base_indent, '', []... | def output(ret, **kwargs):
'''
Display ret data
'''
# Prefer kwargs before opts
retcode = kwargs.get('_retcode', 0)
base_indent = kwargs.get('nested_indent', 0) \
or __opts__.get('nested_indent', 0)
nest = NestDisplay(retcode=retcode)
lines = nest.display(ret, base_indent, '', []... | [
"Display",
"ret",
"data"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/nested.py#L208-L224 | [
"def",
"output",
"(",
"ret",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prefer kwargs before opts",
"retcode",
"=",
"kwargs",
".",
"get",
"(",
"'_retcode'",
",",
"0",
")",
"base_indent",
"=",
"kwargs",
".",
"get",
"(",
"'nested_indent'",
",",
"0",
")",
"or",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | NestDisplay.display | Recursively iterate down through data structures to determine output | salt/output/nested.py | def display(self, ret, indent, prefix, out):
'''
Recursively iterate down through data structures to determine output
'''
if isinstance(ret, bytes):
try:
ret = salt.utils.stringutils.to_unicode(ret)
except UnicodeDecodeError:
# ret ... | def display(self, ret, indent, prefix, out):
'''
Recursively iterate down through data structures to determine output
'''
if isinstance(ret, bytes):
try:
ret = salt.utils.stringutils.to_unicode(ret)
except UnicodeDecodeError:
# ret ... | [
"Recursively",
"iterate",
"down",
"through",
"data",
"structures",
"to",
"determine",
"output"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/nested.py#L97-L205 | [
"def",
"display",
"(",
"self",
",",
"ret",
",",
"indent",
",",
"prefix",
",",
"out",
")",
":",
"if",
"isinstance",
"(",
"ret",
",",
"bytes",
")",
":",
"try",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
"ret",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _read_file | Reads and returns the contents of a text file | salt/utils/mount.py | def _read_file(path):
'''
Reads and returns the contents of a text file
'''
try:
with salt.utils.files.fopen(path, 'rb') as contents:
return salt.utils.yaml.safe_load(contents)
except (OSError, IOError):
return {} | def _read_file(path):
'''
Reads and returns the contents of a text file
'''
try:
with salt.utils.files.fopen(path, 'rb') as contents:
return salt.utils.yaml.safe_load(contents)
except (OSError, IOError):
return {} | [
"Reads",
"and",
"returns",
"the",
"contents",
"of",
"a",
"text",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mount.py#L20-L28 | [
"def",
"_read_file",
"(",
"path",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"path",
",",
"'rb'",
")",
"as",
"contents",
":",
"return",
"salt",
".",
"utils",
".",
"yaml",
".",
"safe_load",
"(",
"contents",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | write_cache | Write the mount cache file. | salt/utils/mount.py | def write_cache(cache, opts):
'''
Write the mount cache file.
'''
cache_file = get_cache(opts)
try:
_cache = salt.utils.stringutils.to_bytes(
salt.utils.yaml.safe_dump(cache)
)
with salt.utils.files.fopen(cache_file, 'wb+') as fp_:
fp_.write(_cache)
... | def write_cache(cache, opts):
'''
Write the mount cache file.
'''
cache_file = get_cache(opts)
try:
_cache = salt.utils.stringutils.to_bytes(
salt.utils.yaml.safe_dump(cache)
)
with salt.utils.files.fopen(cache_file, 'wb+') as fp_:
fp_.write(_cache)
... | [
"Write",
"the",
"mount",
"cache",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/mount.py#L46-L62 | [
"def",
"write_cache",
"(",
"cache",
",",
"opts",
")",
":",
"cache_file",
"=",
"get_cache",
"(",
"opts",
")",
"try",
":",
"_cache",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_bytes",
"(",
"salt",
".",
"utils",
".",
"yaml",
".",
"safe_dump",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_diff_text | Returns the diff of two text blobs. | salt/modules/iosconfig.py | def _get_diff_text(old, new):
'''
Returns the diff of two text blobs.
'''
diff = difflib.unified_diff(old.splitlines(1),
new.splitlines(1))
return ''.join([x.replace('\r', '') for x in diff]) | def _get_diff_text(old, new):
'''
Returns the diff of two text blobs.
'''
diff = difflib.unified_diff(old.splitlines(1),
new.splitlines(1))
return ''.join([x.replace('\r', '') for x in diff]) | [
"Returns",
"the",
"diff",
"of",
"two",
"text",
"blobs",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L116-L122 | [
"def",
"_get_diff_text",
"(",
"old",
",",
"new",
")",
":",
"diff",
"=",
"difflib",
".",
"unified_diff",
"(",
"old",
".",
"splitlines",
"(",
"1",
")",
",",
"new",
".",
"splitlines",
"(",
"1",
")",
")",
"return",
"''",
".",
"join",
"(",
"[",
"x",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _print_config_text | Return the config as text from a config tree. | salt/modules/iosconfig.py | def _print_config_text(tree, indentation=0):
'''
Return the config as text from a config tree.
'''
config = ''
for key, value in six.iteritems(tree):
config += '{indent}{line}\n'.format(indent=' '*indentation, line=key)
if value:
config += _print_config_text(value, indent... | def _print_config_text(tree, indentation=0):
'''
Return the config as text from a config tree.
'''
config = ''
for key, value in six.iteritems(tree):
config += '{indent}{line}\n'.format(indent=' '*indentation, line=key)
if value:
config += _print_config_text(value, indent... | [
"Return",
"the",
"config",
"as",
"text",
"from",
"a",
"config",
"tree",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L125-L134 | [
"def",
"_print_config_text",
"(",
"tree",
",",
"indentation",
"=",
"0",
")",
":",
"config",
"=",
"''",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"tree",
")",
":",
"config",
"+=",
"'{indent}{line}\\n'",
".",
"format",
"(",
"indent",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | tree | Transform Cisco IOS style configuration to structured Python dictionary.
Depending on the value of the ``with_tags`` argument, this function may
provide different views, valuable in different situations.
config
The configuration sent as text. This argument is ignored when ``path``
is config... | salt/modules/iosconfig.py | def tree(config=None,
path=None,
with_tags=False,
saltenv='base'):
'''
Transform Cisco IOS style configuration to structured Python dictionary.
Depending on the value of the ``with_tags`` argument, this function may
provide different views, valuable in different situations.
... | def tree(config=None,
path=None,
with_tags=False,
saltenv='base'):
'''
Transform Cisco IOS style configuration to structured Python dictionary.
Depending on the value of the ``with_tags`` argument, this function may
provide different views, valuable in different situations.
... | [
"Transform",
"Cisco",
"IOS",
"style",
"configuration",
"to",
"structured",
"Python",
"dictionary",
".",
"Depending",
"on",
"the",
"value",
"of",
"the",
"with_tags",
"argument",
"this",
"function",
"may",
"provide",
"different",
"views",
"valuable",
"in",
"differen... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L141-L179 | [
"def",
"tree",
"(",
"config",
"=",
"None",
",",
"path",
"=",
"None",
",",
"with_tags",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
")",
":",
"if",
"path",
":",
"config",
"=",
"__salt__",
"[",
"'cp.get_file_str'",
"]",
"(",
"path",
",",
"saltenv",
"=... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | clean | Return a clean version of the config, without any special signs (such as
``!`` as an individual line) or empty lines, but just lines with significant
value in the configuration of the network device.
config
The configuration sent as text. This argument is ignored when ``path``
is configured... | salt/modules/iosconfig.py | def clean(config=None, path=None, saltenv='base'):
'''
Return a clean version of the config, without any special signs (such as
``!`` as an individual line) or empty lines, but just lines with significant
value in the configuration of the network device.
config
The configuration sent as tex... | def clean(config=None, path=None, saltenv='base'):
'''
Return a clean version of the config, without any special signs (such as
``!`` as an individual line) or empty lines, but just lines with significant
value in the configuration of the network device.
config
The configuration sent as tex... | [
"Return",
"a",
"clean",
"version",
"of",
"the",
"config",
"without",
"any",
"special",
"signs",
"(",
"such",
"as",
"!",
"as",
"an",
"individual",
"line",
")",
"or",
"empty",
"lines",
"but",
"just",
"lines",
"with",
"significant",
"value",
"in",
"the",
"c... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L182-L210 | [
"def",
"clean",
"(",
"config",
"=",
"None",
",",
"path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"config_tree",
"=",
"tree",
"(",
"config",
"=",
"config",
",",
"path",
"=",
"path",
",",
"saltenv",
"=",
"saltenv",
")",
"return",
"_print_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | merge_tree | Return the merge tree of the ``initial_config`` with the ``merge_config``,
as a Python dictionary.
initial_config
The initial configuration sent as text. This argument is ignored when
``initial_path`` is set.
initial_path
Absolute or remote path from where to load the initial confi... | salt/modules/iosconfig.py | def merge_tree(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge tree of the ``initial_config`` with the ``merge_config``,
as a Python dictionary.
initial_config
The initi... | def merge_tree(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge tree of the ``initial_config`` with the ``merge_config``,
as a Python dictionary.
initial_config
The initi... | [
"Return",
"the",
"merge",
"tree",
"of",
"the",
"initial_config",
"with",
"the",
"merge_config",
"as",
"a",
"Python",
"dictionary",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L213-L258 | [
"def",
"merge_tree",
"(",
"initial_config",
"=",
"None",
",",
"initial_path",
"=",
"None",
",",
"merge_config",
"=",
"None",
",",
"merge_path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"merge_tree",
"=",
"tree",
"(",
"config",
"=",
"merge_conf... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | merge_text | Return the merge result of the ``initial_config`` with the ``merge_config``,
as plain text.
initial_config
The initial configuration sent as text. This argument is ignored when
``initial_path`` is set.
initial_path
Absolute or remote path from where to load the initial configuratio... | salt/modules/iosconfig.py | def merge_text(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge result of the ``initial_config`` with the ``merge_config``,
as plain text.
initial_config
The initial conf... | def merge_text(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge result of the ``initial_config`` with the ``merge_config``,
as plain text.
initial_config
The initial conf... | [
"Return",
"the",
"merge",
"result",
"of",
"the",
"initial_config",
"with",
"the",
"merge_config",
"as",
"plain",
"text",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L261-L305 | [
"def",
"merge_text",
"(",
"initial_config",
"=",
"None",
",",
"initial_path",
"=",
"None",
",",
"merge_config",
"=",
"None",
",",
"merge_path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"candidate_tree",
"=",
"merge_tree",
"(",
"initial_config",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | merge_diff | Return the merge diff, as text, after merging the merge config into the
initial config.
initial_config
The initial configuration sent as text. This argument is ignored when
``initial_path`` is set.
initial_path
Absolute or remote path from where to load the initial configuration
... | salt/modules/iosconfig.py | def merge_diff(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge diff, as text, after merging the merge config into the
initial config.
initial_config
The initial configur... | def merge_diff(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge diff, as text, after merging the merge config into the
initial config.
initial_config
The initial configur... | [
"Return",
"the",
"merge",
"diff",
"as",
"text",
"after",
"merging",
"the",
"merge",
"config",
"into",
"the",
"initial",
"config",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L308-L355 | [
"def",
"merge_diff",
"(",
"initial_config",
"=",
"None",
",",
"initial_path",
"=",
"None",
",",
"merge_config",
"=",
"None",
",",
"merge_path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"if",
"initial_path",
":",
"initial_config",
"=",
"__salt__"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | diff_tree | Return the diff, as Python dictionary, between the candidate and the running
configuration.
candidate_config
The candidate configuration sent as text. This argument is ignored when
``candidate_path`` is set.
candidate_path
Absolute or remote path from where to load the candidate co... | salt/modules/iosconfig.py | def diff_tree(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as Python dictionary, between the candidate and the running
configuration.
candidate_config
The candida... | def diff_tree(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as Python dictionary, between the candidate and the running
configuration.
candidate_config
The candida... | [
"Return",
"the",
"diff",
"as",
"Python",
"dictionary",
"between",
"the",
"candidate",
"and",
"the",
"running",
"configuration",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L358-L404 | [
"def",
"diff_tree",
"(",
"candidate_config",
"=",
"None",
",",
"candidate_path",
"=",
"None",
",",
"running_config",
"=",
"None",
",",
"running_path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"candidate_tree",
"=",
"tree",
"(",
"config",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | diff_text | Return the diff, as text, between the candidate and the running config.
candidate_config
The candidate configuration sent as text. This argument is ignored when
``candidate_path`` is set.
candidate_path
Absolute or remote path from where to load the candidate configuration
text... | salt/modules/iosconfig.py | def diff_text(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as text, between the candidate and the running config.
candidate_config
The candidate configuration sent as... | def diff_text(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as text, between the candidate and the running config.
candidate_config
The candidate configuration sent as... | [
"Return",
"the",
"diff",
"as",
"text",
"between",
"the",
"candidate",
"and",
"the",
"running",
"config",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iosconfig.py#L407-L452 | [
"def",
"diff_text",
"(",
"candidate_config",
"=",
"None",
",",
"candidate_path",
"=",
"None",
",",
"running_config",
"=",
"None",
",",
"running_path",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"candidate_text",
"=",
"clean",
"(",
"config",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | item_show | Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs ... | salt/modules/pcs.py | def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show... | def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show... | [
"Show",
"an",
"item",
"via",
"pcs",
"command",
"(",
"mainly",
"for",
"use",
"with",
"the",
"pcs",
"state",
"module",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L29-L77 | [
"def",
"item_show",
"(",
"item",
",",
"item_id",
"=",
"None",
",",
"item_type",
"=",
"None",
",",
"show",
"=",
"'show'",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
"]",
"if",
"isinstance",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | item_create | Create an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
create
create command (create or set f.e., default: create)
extra_args
additional options... | salt/modules/pcs.py | def item_create(item, item_id, item_type, create='create', extra_args=None, cibfile=None):
'''
Create an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
create... | def item_create(item, item_id, item_type, create='create', extra_args=None, cibfile=None):
'''
Create an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
create... | [
"Create",
"an",
"item",
"via",
"pcs",
"command",
"(",
"mainly",
"for",
"use",
"with",
"the",
"pcs",
"state",
"module",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L80-L130 | [
"def",
"item_create",
"(",
"item",
",",
"item_id",
",",
"item_type",
",",
"create",
"=",
"'create'",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
"]",
"if",
"isinstance",
"(",
"cibfile",
",",
"six",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | auth | Authorize nodes to the cluster
nodes
a list of nodes which should be authorized to the cluster
pcsuser
user for communitcation with PCS (default: hacluster)
pcspasswd
password for pcsuser (default: hacluster)
extra_args
list of extra option for the \'pcs cluster auth\' c... | salt/modules/pcs.py | def auth(nodes, pcsuser='hacluster', pcspasswd='hacluster', extra_args=None):
'''
Authorize nodes to the cluster
nodes
a list of nodes which should be authorized to the cluster
pcsuser
user for communitcation with PCS (default: hacluster)
pcspasswd
password for pcsuser (defa... | def auth(nodes, pcsuser='hacluster', pcspasswd='hacluster', extra_args=None):
'''
Authorize nodes to the cluster
nodes
a list of nodes which should be authorized to the cluster
pcsuser
user for communitcation with PCS (default: hacluster)
pcspasswd
password for pcsuser (defa... | [
"Authorize",
"nodes",
"to",
"the",
"cluster"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L133-L164 | [
"def",
"auth",
"(",
"nodes",
",",
"pcsuser",
"=",
"'hacluster'",
",",
"pcspasswd",
"=",
"'hacluster'",
",",
"extra_args",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
",",
"'cluster'",
",",
"'auth'",
"]",
"if",
"pcsuser",
":",
"cmd",
"+=",
"[",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | is_auth | Check if nodes are already authorized
nodes
a list of nodes to be checked for authorization to the cluster
CLI Example:
.. code-block:: bash
salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]' | salt/modules/pcs.py | def is_auth(nodes):
'''
Check if nodes are already authorized
nodes
a list of nodes to be checked for authorization to the cluster
CLI Example:
.. code-block:: bash
salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]'
'''
cmd = ['pcs', 'cluster', 'auth']
... | def is_auth(nodes):
'''
Check if nodes are already authorized
nodes
a list of nodes to be checked for authorization to the cluster
CLI Example:
.. code-block:: bash
salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]'
'''
cmd = ['pcs', 'cluster', 'auth']
... | [
"Check",
"if",
"nodes",
"are",
"already",
"authorized"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L167-L183 | [
"def",
"is_auth",
"(",
"nodes",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
",",
"'cluster'",
",",
"'auth'",
"]",
"cmd",
"+=",
"nodes",
"return",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"stdin",
"=",
"'\\n\\n'",
",",
"output_loglevel",
"=",
"'t... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cluster_setup | Setup pacemaker cluster via pcs command
nodes
a list of nodes which should be set up
pcsclustername
Name of the Pacemaker cluster (default: pcscluster)
extra_args
list of extra option for the \'pcs cluster setup\' command
CLI Example:
.. code-block:: bash
salt '*'... | salt/modules/pcs.py | def cluster_setup(nodes, pcsclustername='pcscluster', extra_args=None):
'''
Setup pacemaker cluster via pcs command
nodes
a list of nodes which should be set up
pcsclustername
Name of the Pacemaker cluster (default: pcscluster)
extra_args
list of extra option for the \'pcs c... | def cluster_setup(nodes, pcsclustername='pcscluster', extra_args=None):
'''
Setup pacemaker cluster via pcs command
nodes
a list of nodes which should be set up
pcsclustername
Name of the Pacemaker cluster (default: pcscluster)
extra_args
list of extra option for the \'pcs c... | [
"Setup",
"pacemaker",
"cluster",
"via",
"pcs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L186-L211 | [
"def",
"cluster_setup",
"(",
"nodes",
",",
"pcsclustername",
"=",
"'pcscluster'",
",",
"extra_args",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
",",
"'cluster'",
",",
"'setup'",
"]",
"cmd",
"+=",
"[",
"'--name'",
",",
"pcsclustername",
"]",
"cmd",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cluster_node_add | Add a node to the pacemaker cluster via pcs command
node
node that should be added
extra_args
list of extra option for the \'pcs cluster node add\' command
CLI Example:
.. code-block:: bash
salt '*' pcs.cluster_node_add node=node2.example.org | salt/modules/pcs.py | def cluster_node_add(node, extra_args=None):
'''
Add a node to the pacemaker cluster via pcs command
node
node that should be added
extra_args
list of extra option for the \'pcs cluster node add\' command
CLI Example:
.. code-block:: bash
salt '*' pcs.cluster_node_add... | def cluster_node_add(node, extra_args=None):
'''
Add a node to the pacemaker cluster via pcs command
node
node that should be added
extra_args
list of extra option for the \'pcs cluster node add\' command
CLI Example:
.. code-block:: bash
salt '*' pcs.cluster_node_add... | [
"Add",
"a",
"node",
"to",
"the",
"pacemaker",
"cluster",
"via",
"pcs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L214-L235 | [
"def",
"cluster_node_add",
"(",
"node",
",",
"extra_args",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
",",
"'cluster'",
",",
"'node'",
",",
"'add'",
"]",
"cmd",
"+=",
"[",
"node",
"]",
"if",
"isinstance",
"(",
"extra_args",
",",
"(",
"list",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cib_create | Create a CIB-file from the current CIB of the cluster
cibfile
name/path of the file containing the CIB
scope
specific section of the CIB (default: configuration)
extra_args
additional options for creating the CIB-file
CLI Example:
.. code-block:: bash
salt '*' pcs... | salt/modules/pcs.py | def cib_create(cibfile, scope='configuration', extra_args=None):
'''
Create a CIB-file from the current CIB of the cluster
cibfile
name/path of the file containing the CIB
scope
specific section of the CIB (default: configuration)
extra_args
additional options for creating t... | def cib_create(cibfile, scope='configuration', extra_args=None):
'''
Create a CIB-file from the current CIB of the cluster
cibfile
name/path of the file containing the CIB
scope
specific section of the CIB (default: configuration)
extra_args
additional options for creating t... | [
"Create",
"a",
"CIB",
"-",
"file",
"from",
"the",
"current",
"CIB",
"of",
"the",
"cluster"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L238-L261 | [
"def",
"cib_create",
"(",
"cibfile",
",",
"scope",
"=",
"'configuration'",
",",
"extra_args",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
",",
"'cluster'",
",",
"'cib'",
",",
"cibfile",
"]",
"if",
"isinstance",
"(",
"scope",
",",
"six",
".",
"stri... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | prop_show | Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
salt '*' pcs.prop_show cibfile='/tmp/2_node_cluster.cib' prop='n... | salt/modules/pcs.py | def prop_show(prop, extra_args=None, cibfile=None):
'''
Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... | def prop_show(prop, extra_args=None, cibfile=None):
'''
Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... | [
"Show",
"the",
"value",
"of",
"a",
"cluster",
"property"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L306-L323 | [
"def",
"prop_show",
"(",
"prop",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_show",
"(",
"item",
"=",
"'property'",
",",
"item_id",
"=",
"prop",
",",
"extra_args",
"=",
"extra_args",
",",
"cibfile",
"=",
"cibfil... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | prop_set | Set the value of a cluster property
prop
name of the property
value
value of the property prop
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
salt '*' pcs.prop_se... | salt/modules/pcs.py | def prop_set(prop, value, extra_args=None, cibfile=None):
'''
Set the value of a cluster property
prop
name of the property
value
value of the property prop
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
... | def prop_set(prop, value, extra_args=None, cibfile=None):
'''
Set the value of a cluster property
prop
name of the property
value
value of the property prop
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
... | [
"Set",
"the",
"value",
"of",
"a",
"cluster",
"property"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L326-L350 | [
"def",
"prop_set",
"(",
"prop",
",",
"value",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_create",
"(",
"item",
"=",
"'property'",
",",
"item_id",
"=",
"'{0}={1}'",
".",
"format",
"(",
"prop",
",",
"value",
")... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | stonith_show | Show the value of a cluster stonith
stonith_id
name for the stonith resource
extra_args
additional options for the pcs stonith command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
salt '*' pcs.stonith_show stonith_id='eps_fence' ci... | salt/modules/pcs.py | def stonith_show(stonith_id, extra_args=None, cibfile=None):
'''
Show the value of a cluster stonith
stonith_id
name for the stonith resource
extra_args
additional options for the pcs stonith command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-... | def stonith_show(stonith_id, extra_args=None, cibfile=None):
'''
Show the value of a cluster stonith
stonith_id
name for the stonith resource
extra_args
additional options for the pcs stonith command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-... | [
"Show",
"the",
"value",
"of",
"a",
"cluster",
"stonith"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L353-L370 | [
"def",
"stonith_show",
"(",
"stonith_id",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_show",
"(",
"item",
"=",
"'stonith'",
",",
"item_id",
"=",
"stonith_id",
",",
"extra_args",
"=",
"extra_args",
",",
"cibfile",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | stonith_create | Create a stonith resource via pcs command
stonith_id
name for the stonith resource
stonith_device_type
name of the stonith agent fence_eps, fence_xvm f.e.
stonith_device_options
additional options for creating the stonith resource
cibfile
use cibfile instead of the live ... | salt/modules/pcs.py | def stonith_create(stonith_id, stonith_device_type, stonith_device_options=None, cibfile=None):
'''
Create a stonith resource via pcs command
stonith_id
name for the stonith resource
stonith_device_type
name of the stonith agent fence_eps, fence_xvm f.e.
stonith_device_options
... | def stonith_create(stonith_id, stonith_device_type, stonith_device_options=None, cibfile=None):
'''
Create a stonith resource via pcs command
stonith_id
name for the stonith resource
stonith_device_type
name of the stonith agent fence_eps, fence_xvm f.e.
stonith_device_options
... | [
"Create",
"a",
"stonith",
"resource",
"via",
"pcs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L373-L397 | [
"def",
"stonith_create",
"(",
"stonith_id",
",",
"stonith_device_type",
",",
"stonith_device_options",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_create",
"(",
"item",
"=",
"'stonith'",
",",
"item_id",
"=",
"stonith_id",
",",
"item_type"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | resource_show | Show a resource via pcs command
resource_id
name of the resource
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
salt '*' pcs.resource_show resource_id='galera' cibfile='/tmp/cib_for_g... | salt/modules/pcs.py | def resource_show(resource_id, extra_args=None, cibfile=None):
'''
Show a resource via pcs command
resource_id
name of the resource
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... | def resource_show(resource_id, extra_args=None, cibfile=None):
'''
Show a resource via pcs command
resource_id
name of the resource
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... | [
"Show",
"a",
"resource",
"via",
"pcs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L400-L417 | [
"def",
"resource_show",
"(",
"resource_id",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_show",
"(",
"item",
"=",
"'resource'",
",",
"item_id",
"=",
"resource_id",
",",
"extra_args",
"=",
"extra_args",
",",
"cibfile"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | resource_create | Create a resource via pcs command
resource_id
name for the resource
resource_type
resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP)
resource_options
additional options for creating the resource
cibfile
use cibfile instead of the live CIB for manipulation
CLI E... | salt/modules/pcs.py | def resource_create(resource_id, resource_type, resource_options=None, cibfile=None):
'''
Create a resource via pcs command
resource_id
name for the resource
resource_type
resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP)
resource_options
additional options for creatin... | def resource_create(resource_id, resource_type, resource_options=None, cibfile=None):
'''
Create a resource via pcs command
resource_id
name for the resource
resource_type
resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP)
resource_options
additional options for creatin... | [
"Create",
"a",
"resource",
"via",
"pcs",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L420-L443 | [
"def",
"resource_create",
"(",
"resource_id",
",",
"resource_type",
",",
"resource_options",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_create",
"(",
"item",
"=",
"'resource'",
",",
"item_id",
"=",
"resource_id",
",",
"item_type",
"=",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | wrap | Wrap text to the required dimensions and clean it up, prepare for display.
:param txt:
:param width:
:return: | salt/cli/support/console.py | def wrap(txt, width=80, ident=0):
'''
Wrap text to the required dimensions and clean it up, prepare for display.
:param txt:
:param width:
:return:
'''
ident = ' ' * ident
txt = (txt or '').replace(os.linesep, ' ').strip()
wrapper = textwrap.TextWrapper()
wrapper.fix_sentence_e... | def wrap(txt, width=80, ident=0):
'''
Wrap text to the required dimensions and clean it up, prepare for display.
:param txt:
:param width:
:return:
'''
ident = ' ' * ident
txt = (txt or '').replace(os.linesep, ' ').strip()
wrapper = textwrap.TextWrapper()
wrapper.fix_sentence_e... | [
"Wrap",
"text",
"to",
"the",
"required",
"dimensions",
"and",
"clean",
"it",
"up",
"prepare",
"for",
"display",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/console.py#L150-L165 | [
"def",
"wrap",
"(",
"txt",
",",
"width",
"=",
"80",
",",
"ident",
"=",
"0",
")",
":",
"ident",
"=",
"' '",
"*",
"ident",
"txt",
"=",
"(",
"txt",
"or",
"''",
")",
".",
"replace",
"(",
"os",
".",
"linesep",
",",
"' '",
")",
".",
"strip",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | IndentOutput.put | Print message with an indent.
:param message:
:param indent:
:return: | salt/cli/support/console.py | def put(self, message, indent=0):
'''
Print message with an indent.
:param message:
:param indent:
:return:
'''
color = self._colors_conf.get(indent + indent % 2, self._colors_conf.get(0, self._default_color))
for chunk in [' ' * indent, self._colors[col... | def put(self, message, indent=0):
'''
Print message with an indent.
:param message:
:param indent:
:return:
'''
color = self._colors_conf.get(indent + indent % 2, self._colors_conf.get(0, self._default_color))
for chunk in [' ' * indent, self._colors[col... | [
"Print",
"message",
"with",
"an",
"indent",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/console.py#L30-L43 | [
"def",
"put",
"(",
"self",
",",
"message",
",",
"indent",
"=",
"0",
")",
":",
"color",
"=",
"self",
".",
"_colors_conf",
".",
"get",
"(",
"indent",
"+",
"indent",
"%",
"2",
",",
"self",
".",
"_colors_conf",
".",
"get",
"(",
"0",
",",
"self",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | MessagesOutput.msg | Hint message.
:param message:
:param title:
:param title_color:
:param color:
:param ident:
:return: | salt/cli/support/console.py | def msg(self, message, title=None, title_color=None, color='BLUE', ident=0):
'''
Hint message.
:param message:
:param title:
:param title_color:
:param color:
:param ident:
:return:
'''
if title and not title_color:
title_color... | def msg(self, message, title=None, title_color=None, color='BLUE', ident=0):
'''
Hint message.
:param message:
:param title:
:param title_color:
:param color:
:param ident:
:return:
'''
if title and not title_color:
title_color... | [
"Hint",
"message",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/console.py#L50-L66 | [
"def",
"msg",
"(",
"self",
",",
"message",
",",
"title",
"=",
"None",
",",
"title_color",
"=",
"None",
",",
"color",
"=",
"'BLUE'",
",",
"ident",
"=",
"0",
")",
":",
"if",
"title",
"and",
"not",
"title_color",
":",
"title_color",
"=",
"color",
"if",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | MessagesOutput.highlight | Highlighter works the way that message parameter is a template,
the "values" is a list of arguments going one after another as values there.
And so the "colors" should designate either highlight color or alternate for each.
Example:
highlight('Hello {}, there! It is {}.', 'user', 'd... | salt/cli/support/console.py | def highlight(self, message, *values, **colors):
'''
Highlighter works the way that message parameter is a template,
the "values" is a list of arguments going one after another as values there.
And so the "colors" should designate either highlight color or alternate for each.
Ex... | def highlight(self, message, *values, **colors):
'''
Highlighter works the way that message parameter is a template,
the "values" is a list of arguments going one after another as values there.
And so the "colors" should designate either highlight color or alternate for each.
Ex... | [
"Highlighter",
"works",
"the",
"way",
"that",
"message",
"parameter",
"is",
"a",
"template",
"the",
"values",
"is",
"a",
"list",
"of",
"arguments",
"going",
"one",
"after",
"another",
"as",
"values",
"there",
".",
"And",
"so",
"the",
"colors",
"should",
"d... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/console.py#L110-L147 | [
"def",
"highlight",
"(",
"self",
",",
"message",
",",
"*",
"values",
",",
"*",
"*",
"colors",
")",
":",
"m_color",
"=",
"colors",
".",
"get",
"(",
"'_main'",
",",
"self",
".",
"_default_color",
")",
"h_color",
"=",
"colors",
".",
"get",
"(",
"'_highl... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _ensure_exists | Decorator to ensure that the named container exists. | salt/modules/nspawn.py | def _ensure_exists(wrapped):
'''
Decorator to ensure that the named container exists.
'''
@functools.wraps(wrapped)
def check_exists(name, *args, **kwargs):
if not exists(name):
raise CommandExecutionError(
'Container \'{0}\' does not exist'.format(name)
... | def _ensure_exists(wrapped):
'''
Decorator to ensure that the named container exists.
'''
@functools.wraps(wrapped)
def check_exists(name, *args, **kwargs):
if not exists(name):
raise CommandExecutionError(
'Container \'{0}\' does not exist'.format(name)
... | [
"Decorator",
"to",
"ensure",
"that",
"the",
"named",
"container",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L79-L90 | [
"def",
"_ensure_exists",
"(",
"wrapped",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"wrapped",
")",
"def",
"check_exists",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"exists",
"(",
"name",
")",
":",
"raise",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _root | Return the container root directory. Starting with systemd 219, new
images go into /var/lib/machines. | salt/modules/nspawn.py | def _root(name='', all_roots=False):
'''
Return the container root directory. Starting with systemd 219, new
images go into /var/lib/machines.
'''
if _sd_version() >= 219:
if all_roots:
return [os.path.join(x, name)
for x in ('/var/lib/machines', '/var/lib/con... | def _root(name='', all_roots=False):
'''
Return the container root directory. Starting with systemd 219, new
images go into /var/lib/machines.
'''
if _sd_version() >= 219:
if all_roots:
return [os.path.join(x, name)
for x in ('/var/lib/machines', '/var/lib/con... | [
"Return",
"the",
"container",
"root",
"directory",
".",
"Starting",
"with",
"systemd",
"219",
"new",
"images",
"go",
"into",
"/",
"var",
"/",
"lib",
"/",
"machines",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L93-L109 | [
"def",
"_root",
"(",
"name",
"=",
"''",
",",
"all_roots",
"=",
"False",
")",
":",
"if",
"_sd_version",
"(",
")",
">=",
"219",
":",
"if",
"all_roots",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"x",
",",
"name",
")",
"for",
"x",
"i... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _make_container_root | Make the container root directory | salt/modules/nspawn.py | def _make_container_root(name):
'''
Make the container root directory
'''
path = _root(name)
if os.path.exists(path):
__context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL
raise CommandExecutionError(
'Container {0} already exists'.format(name)
)
el... | def _make_container_root(name):
'''
Make the container root directory
'''
path = _root(name)
if os.path.exists(path):
__context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL
raise CommandExecutionError(
'Container {0} already exists'.format(name)
)
el... | [
"Make",
"the",
"container",
"root",
"directory"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L112-L130 | [
"def",
"_make_container_root",
"(",
"name",
")",
":",
"path",
"=",
"_root",
"(",
"name",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"__context__",
"[",
"'retcode'",
"]",
"=",
"salt",
".",
"defaults",
".",
"exitcodes",
".",
"S... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _bootstrap_arch | Bootstrap an Arch Linux container | salt/modules/nspawn.py | def _bootstrap_arch(name, **kwargs):
'''
Bootstrap an Arch Linux container
'''
if not salt.utils.path.which('pacstrap'):
raise CommandExecutionError(
'pacstrap not found, is the arch-install-scripts package '
'installed?'
)
dst = _make_container_root(name)
... | def _bootstrap_arch(name, **kwargs):
'''
Bootstrap an Arch Linux container
'''
if not salt.utils.path.which('pacstrap'):
raise CommandExecutionError(
'pacstrap not found, is the arch-install-scripts package '
'installed?'
)
dst = _make_container_root(name)
... | [
"Bootstrap",
"an",
"Arch",
"Linux",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L147-L161 | [
"def",
"_bootstrap_arch",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'pacstrap'",
")",
":",
"raise",
"CommandExecutionError",
"(",
"'pacstrap not found, is the arch-install-scripts package '"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _bootstrap_debian | Bootstrap a Debian Linux container | salt/modules/nspawn.py | def _bootstrap_debian(name, **kwargs):
'''
Bootstrap a Debian Linux container
'''
version = kwargs.get('version', False)
if not version:
if __grains__['os'].lower() == 'debian':
version = __grains__['osrelease']
else:
version = 'stable'
release_blacklist ... | def _bootstrap_debian(name, **kwargs):
'''
Bootstrap a Debian Linux container
'''
version = kwargs.get('version', False)
if not version:
if __grains__['os'].lower() == 'debian':
version = __grains__['osrelease']
else:
version = 'stable'
release_blacklist ... | [
"Bootstrap",
"a",
"Debian",
"Linux",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L164-L187 | [
"def",
"_bootstrap_debian",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"version",
"=",
"kwargs",
".",
"get",
"(",
"'version'",
",",
"False",
")",
"if",
"not",
"version",
":",
"if",
"__grains__",
"[",
"'os'",
"]",
".",
"lower",
"(",
")",
"==",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _bootstrap_fedora | Bootstrap a Fedora container | salt/modules/nspawn.py | def _bootstrap_fedora(name, **kwargs):
'''
Bootstrap a Fedora container
'''
dst = _make_container_root(name)
if not kwargs.get('version', False):
if __grains__['os'].lower() == 'fedora':
version = __grains__['osrelease']
else:
version = '21'
else:
... | def _bootstrap_fedora(name, **kwargs):
'''
Bootstrap a Fedora container
'''
dst = _make_container_root(name)
if not kwargs.get('version', False):
if __grains__['os'].lower() == 'fedora':
version = __grains__['osrelease']
else:
version = '21'
else:
... | [
"Bootstrap",
"a",
"Fedora",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L190-L208 | [
"def",
"_bootstrap_fedora",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"dst",
"=",
"_make_container_root",
"(",
"name",
")",
"if",
"not",
"kwargs",
".",
"get",
"(",
"'version'",
",",
"False",
")",
":",
"if",
"__grains__",
"[",
"'os'",
"]",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _ensure_systemd | Raises an exception if the systemd version is not greater than the
passed version. | salt/modules/nspawn.py | def _ensure_systemd(version):
'''
Raises an exception if the systemd version is not greater than the
passed version.
'''
try:
version = int(version)
except ValueError:
raise CommandExecutionError('Invalid version \'{0}\''.format(version))
try:
installed = _sd_version... | def _ensure_systemd(version):
'''
Raises an exception if the systemd version is not greater than the
passed version.
'''
try:
version = int(version)
except ValueError:
raise CommandExecutionError('Invalid version \'{0}\''.format(version))
try:
installed = _sd_version... | [
"Raises",
"an",
"exception",
"if",
"the",
"systemd",
"version",
"is",
"not",
"greater",
"than",
"the",
"passed",
"version",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L248-L268 | [
"def",
"_ensure_systemd",
"(",
"version",
")",
":",
"try",
":",
"version",
"=",
"int",
"(",
"version",
")",
"except",
"ValueError",
":",
"raise",
"CommandExecutionError",
"(",
"'Invalid version \\'{0}\\''",
".",
"format",
"(",
"version",
")",
")",
"try",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _machinectl | Helper function to run machinectl | salt/modules/nspawn.py | def _machinectl(cmd,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False):
'''
Helper function to run machinectl
'''
prefix = 'machinectl --no-legend --no-pager'
return __salt__['cmd.run_all']('{0} {1}'.format(prefix, cmd),
... | def _machinectl(cmd,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False):
'''
Helper function to run machinectl
'''
prefix = 'machinectl --no-legend --no-pager'
return __salt__['cmd.run_all']('{0} {1}'.format(prefix, cmd),
... | [
"Helper",
"function",
"to",
"run",
"machinectl"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L271-L282 | [
"def",
"_machinectl",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'debug'",
",",
"ignore_retcode",
"=",
"False",
",",
"use_vt",
"=",
"False",
")",
":",
"prefix",
"=",
"'machinectl --no-legend --no-pager'",
"return",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'{0... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _run | Common logic for nspawn.run functions | salt/modules/nspawn.py | def _run(name,
cmd,
output=None,
no_start=False,
stdin=None,
python_shell=True,
preserve_state=False,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False,
keep_env=None):
'''
Common logic for nspawn.run functions
... | def _run(name,
cmd,
output=None,
no_start=False,
stdin=None,
python_shell=True,
preserve_state=False,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False,
keep_env=None):
'''
Common logic for nspawn.run functions
... | [
"Common",
"logic",
"for",
"nspawn",
".",
"run",
"functions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L286-L329 | [
"def",
"_run",
"(",
"name",
",",
"cmd",
",",
"output",
"=",
"None",
",",
"no_start",
"=",
"False",
",",
"stdin",
"=",
"None",
",",
"python_shell",
"=",
"True",
",",
"preserve_state",
"=",
"False",
",",
"output_loglevel",
"=",
"'debug'",
",",
"ignore_retc... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pid | Returns the PID of a container
name
Container name
CLI Example:
.. code-block:: bash
salt myminion nspawn.pid arch1 | salt/modules/nspawn.py | def pid(name):
'''
Returns the PID of a container
name
Container name
CLI Example:
.. code-block:: bash
salt myminion nspawn.pid arch1
'''
try:
return int(info(name).get('PID'))
except (TypeError, ValueError) as exc:
raise CommandExecutionError(
... | def pid(name):
'''
Returns the PID of a container
name
Container name
CLI Example:
.. code-block:: bash
salt myminion nspawn.pid arch1
'''
try:
return int(info(name).get('PID'))
except (TypeError, ValueError) as exc:
raise CommandExecutionError(
... | [
"Returns",
"the",
"PID",
"of",
"a",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L333-L351 | [
"def",
"pid",
"(",
"name",
")",
":",
"try",
":",
"return",
"int",
"(",
"info",
"(",
"name",
")",
".",
"get",
"(",
"'PID'",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
"as",
"exc",
":",
"raise",
"CommandExecutionError",
"(",
"'Unable... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | bootstrap_container | Bootstrap a container from package servers, if dist is None the os the
minion is running as will be created, otherwise the needed bootstrapping
tools will need to be available on the host.
CLI Example:
.. code-block:: bash
salt myminion nspawn.bootstrap_container <name> | salt/modules/nspawn.py | def bootstrap_container(name, dist=None, version=None):
'''
Bootstrap a container from package servers, if dist is None the os the
minion is running as will be created, otherwise the needed bootstrapping
tools will need to be available on the host.
CLI Example:
.. code-block:: bash
sa... | def bootstrap_container(name, dist=None, version=None):
'''
Bootstrap a container from package servers, if dist is None the os the
minion is running as will be created, otherwise the needed bootstrapping
tools will need to be available on the host.
CLI Example:
.. code-block:: bash
sa... | [
"Bootstrap",
"a",
"container",
"from",
"package",
"servers",
"if",
"dist",
"is",
"None",
"the",
"os",
"the",
"minion",
"is",
"running",
"as",
"will",
"be",
"created",
"otherwise",
"the",
"needed",
"bootstrapping",
"tools",
"will",
"need",
"to",
"be",
"availa... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L673-L691 | [
"def",
"bootstrap_container",
"(",
"name",
",",
"dist",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"if",
"not",
"dist",
":",
"dist",
"=",
"__grains__",
"[",
"'os'",
"]",
".",
"lower",
"(",
")",
"log",
".",
"debug",
"(",
"'nspawn.bootstrap: no ... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | bootstrap_salt | Bootstrap a container from package servers, if dist is None the os the
minion is running as will be created, otherwise the needed bootstrapping
tools will need to be available on the host.
CLI Example::
salt '*' nspawn.bootstrap_salt arch1 | salt/modules/nspawn.py | def bootstrap_salt(name,
config=None,
approve_key=True,
install=True,
pub_key=None,
priv_key=None,
bootstrap_url=None,
force_install=False,
unconditional_install=False,... | def bootstrap_salt(name,
config=None,
approve_key=True,
install=True,
pub_key=None,
priv_key=None,
bootstrap_url=None,
force_install=False,
unconditional_install=False,... | [
"Bootstrap",
"a",
"container",
"from",
"package",
"servers",
"if",
"dist",
"is",
"None",
"the",
"os",
"the",
"minion",
"is",
"running",
"as",
"will",
"be",
"created",
"otherwise",
"the",
"needed",
"bootstrapping",
"tools",
"will",
"need",
"to",
"be",
"availa... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L712-L831 | [
"def",
"bootstrap_salt",
"(",
"name",
",",
"config",
"=",
"None",
",",
"approve_key",
"=",
"True",
",",
"install",
"=",
"True",
",",
"pub_key",
"=",
"None",
",",
"priv_key",
"=",
"None",
",",
"bootstrap_url",
"=",
"None",
",",
"force_install",
"=",
"Fals... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_all | Lists all nspawn containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_all | salt/modules/nspawn.py | def list_all():
'''
Lists all nspawn containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_all
'''
ret = []
if _sd_version() >= 219:
for line in _machinectl('list-images')['stdout'].splitlines():
try:
ret.append(line.split()[0])... | def list_all():
'''
Lists all nspawn containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_all
'''
ret = []
if _sd_version() >= 219:
for line in _machinectl('list-images')['stdout'].splitlines():
try:
ret.append(line.split()[0])... | [
"Lists",
"all",
"nspawn",
"containers"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L834-L859 | [
"def",
"list_all",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"_sd_version",
"(",
")",
">=",
"219",
":",
"for",
"line",
"in",
"_machinectl",
"(",
"'list-images'",
")",
"[",
"'stdout'",
"]",
".",
"splitlines",
"(",
")",
":",
"try",
":",
"ret",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_running | Lists running nspawn containers
.. note::
``nspawn.list`` also works to list running containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_running
salt myminion nspawn.list | salt/modules/nspawn.py | def list_running():
'''
Lists running nspawn containers
.. note::
``nspawn.list`` also works to list running containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_running
salt myminion nspawn.list
'''
ret = []
for line in _machinectl('list')[... | def list_running():
'''
Lists running nspawn containers
.. note::
``nspawn.list`` also works to list running containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_running
salt myminion nspawn.list
'''
ret = []
for line in _machinectl('list')[... | [
"Lists",
"running",
"nspawn",
"containers"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L862-L883 | [
"def",
"list_running",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"line",
"in",
"_machinectl",
"(",
"'list'",
")",
"[",
"'stdout'",
"]",
".",
"splitlines",
"(",
")",
":",
"try",
":",
"ret",
".",
"append",
"(",
"line",
".",
"split",
"(",
")",
"["... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | exists | Returns true if the named container exists
CLI Example:
.. code-block:: bash
salt myminion nspawn.exists <name> | salt/modules/nspawn.py | def exists(name):
'''
Returns true if the named container exists
CLI Example:
.. code-block:: bash
salt myminion nspawn.exists <name>
'''
contextkey = 'nspawn.exists.{0}'.format(name)
if contextkey in __context__:
return __context__[contextkey]
__context__[contextkey] ... | def exists(name):
'''
Returns true if the named container exists
CLI Example:
.. code-block:: bash
salt myminion nspawn.exists <name>
'''
contextkey = 'nspawn.exists.{0}'.format(name)
if contextkey in __context__:
return __context__[contextkey]
__context__[contextkey] ... | [
"Returns",
"true",
"if",
"the",
"named",
"container",
"exists"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L904-L918 | [
"def",
"exists",
"(",
"name",
")",
":",
"contextkey",
"=",
"'nspawn.exists.{0}'",
".",
"format",
"(",
"name",
")",
"if",
"contextkey",
"in",
"__context__",
":",
"return",
"__context__",
"[",
"contextkey",
"]",
"__context__",
"[",
"contextkey",
"]",
"=",
"nam... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | state | Return state of container (running or stopped)
CLI Example:
.. code-block:: bash
salt myminion nspawn.state <name> | salt/modules/nspawn.py | def state(name):
'''
Return state of container (running or stopped)
CLI Example:
.. code-block:: bash
salt myminion nspawn.state <name>
'''
try:
cmd = 'show {0} --property=State'.format(name)
return _machinectl(cmd, ignore_retcode=True)['stdout'].split('=')[-1]
exc... | def state(name):
'''
Return state of container (running or stopped)
CLI Example:
.. code-block:: bash
salt myminion nspawn.state <name>
'''
try:
cmd = 'show {0} --property=State'.format(name)
return _machinectl(cmd, ignore_retcode=True)['stdout'].split('=')[-1]
exc... | [
"Return",
"state",
"of",
"container",
"(",
"running",
"or",
"stopped",
")"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L922-L936 | [
"def",
"state",
"(",
"name",
")",
":",
"try",
":",
"cmd",
"=",
"'show {0} --property=State'",
".",
"format",
"(",
"name",
")",
"return",
"_machinectl",
"(",
"cmd",
",",
"ignore_retcode",
"=",
"True",
")",
"[",
"'stdout'",
"]",
".",
"split",
"(",
"'='",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | info | Return info about a container
.. note::
The container must be running for ``machinectl`` to gather information
about it. If the container is stopped, then this function will start
it.
start : False
If ``True``, then the container will be started to retrieve the info. A
... | salt/modules/nspawn.py | def info(name, **kwargs):
'''
Return info about a container
.. note::
The container must be running for ``machinectl`` to gather information
about it. If the container is stopped, then this function will start
it.
start : False
If ``True``, then the container will be s... | def info(name, **kwargs):
'''
Return info about a container
.. note::
The container must be running for ``machinectl`` to gather information
about it. If the container is stopped, then this function will start
it.
start : False
If ``True``, then the container will be s... | [
"Return",
"info",
"about",
"a",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L939-L1019 | [
"def",
"info",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"start_",
"=",
"kwargs",
".",
"pop",
"(",
"'start'",
",",
"False",
")",
"if",
"kwa... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | enable | Set the named container to be launched at boot
CLI Example:
.. code-block:: bash
salt myminion nspawn.enable <name> | salt/modules/nspawn.py | def enable(name):
'''
Set the named container to be launched at boot
CLI Example:
.. code-block:: bash
salt myminion nspawn.enable <name>
'''
cmd = 'systemctl enable systemd-nspawn@{0}'.format(name)
if __salt__['cmd.retcode'](cmd, python_shell=False) != 0:
__context__['ret... | def enable(name):
'''
Set the named container to be launched at boot
CLI Example:
.. code-block:: bash
salt myminion nspawn.enable <name>
'''
cmd = 'systemctl enable systemd-nspawn@{0}'.format(name)
if __salt__['cmd.retcode'](cmd, python_shell=False) != 0:
__context__['ret... | [
"Set",
"the",
"named",
"container",
"to",
"be",
"launched",
"at",
"boot"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1023-L1037 | [
"def",
"enable",
"(",
"name",
")",
":",
"cmd",
"=",
"'systemctl enable systemd-nspawn@{0}'",
".",
"format",
"(",
"name",
")",
"if",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
"!=",
"0",
":",
"__context__",
"[... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | start | Start the named container
CLI Example:
.. code-block:: bash
salt myminion nspawn.start <name> | salt/modules/nspawn.py | def start(name):
'''
Start the named container
CLI Example:
.. code-block:: bash
salt myminion nspawn.start <name>
'''
if _sd_version() >= 219:
ret = _machinectl('start {0}'.format(name))
else:
cmd = 'systemctl start systemd-nspawn@{0}'.format(name)
ret = _... | def start(name):
'''
Start the named container
CLI Example:
.. code-block:: bash
salt myminion nspawn.start <name>
'''
if _sd_version() >= 219:
ret = _machinectl('start {0}'.format(name))
else:
cmd = 'systemctl start systemd-nspawn@{0}'.format(name)
ret = _... | [
"Start",
"the",
"named",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1059-L1078 | [
"def",
"start",
"(",
"name",
")",
":",
"if",
"_sd_version",
"(",
")",
">=",
"219",
":",
"ret",
"=",
"_machinectl",
"(",
"'start {0}'",
".",
"format",
"(",
"name",
")",
")",
"else",
":",
"cmd",
"=",
"'systemctl start systemd-nspawn@{0}'",
".",
"format",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | stop | This is a compatibility function which provides the logic for
nspawn.poweroff and nspawn.terminate. | salt/modules/nspawn.py | def stop(name, kill=False):
'''
This is a compatibility function which provides the logic for
nspawn.poweroff and nspawn.terminate.
'''
if _sd_version() >= 219:
if kill:
action = 'terminate'
else:
action = 'poweroff'
ret = _machinectl('{0} {1}'.format(... | def stop(name, kill=False):
'''
This is a compatibility function which provides the logic for
nspawn.poweroff and nspawn.terminate.
'''
if _sd_version() >= 219:
if kill:
action = 'terminate'
else:
action = 'poweroff'
ret = _machinectl('{0} {1}'.format(... | [
"This",
"is",
"a",
"compatibility",
"function",
"which",
"provides",
"the",
"logic",
"for",
"nspawn",
".",
"poweroff",
"and",
"nspawn",
".",
"terminate",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1083-L1101 | [
"def",
"stop",
"(",
"name",
",",
"kill",
"=",
"False",
")",
":",
"if",
"_sd_version",
"(",
")",
">=",
"219",
":",
"if",
"kill",
":",
"action",
"=",
"'terminate'",
"else",
":",
"action",
"=",
"'poweroff'",
"ret",
"=",
"_machinectl",
"(",
"'{0} {1}'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | reboot | Reboot the container by sending a SIGINT to its init process. Equivalent
to running ``machinectl reboot`` on the named container.
For convenience, running ``nspawn.restart`` (as shown in the CLI examples
below) is equivalent to running ``nspawn.reboot``.
.. note::
``machinectl reboot`` is onl... | salt/modules/nspawn.py | def reboot(name, kill=False):
'''
Reboot the container by sending a SIGINT to its init process. Equivalent
to running ``machinectl reboot`` on the named container.
For convenience, running ``nspawn.restart`` (as shown in the CLI examples
below) is equivalent to running ``nspawn.reboot``.
.. no... | def reboot(name, kill=False):
'''
Reboot the container by sending a SIGINT to its init process. Equivalent
to running ``machinectl reboot`` on the named container.
For convenience, running ``nspawn.restart`` (as shown in the CLI examples
below) is equivalent to running ``nspawn.reboot``.
.. no... | [
"Reboot",
"the",
"container",
"by",
"sending",
"a",
"SIGINT",
"to",
"its",
"init",
"process",
".",
"Equivalent",
"to",
"running",
"machinectl",
"reboot",
"on",
"the",
"named",
"container",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1162-L1209 | [
"def",
"reboot",
"(",
"name",
",",
"kill",
"=",
"False",
")",
":",
"if",
"_sd_version",
"(",
")",
">=",
"219",
":",
"if",
"state",
"(",
"name",
")",
"==",
"'running'",
":",
"ret",
"=",
"_machinectl",
"(",
"'reboot {0}'",
".",
"format",
"(",
"name",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove | Remove the named container
.. warning::
This function will remove all data associated with the container. It
will not, however, remove the btrfs subvolumes created by pulling
container images (:mod:`nspawn.pull_raw
<salt.modules.nspawn.pull_raw>`, :mod:`nspawn.pull_tar
<sal... | salt/modules/nspawn.py | def remove(name, stop=False):
'''
Remove the named container
.. warning::
This function will remove all data associated with the container. It
will not, however, remove the btrfs subvolumes created by pulling
container images (:mod:`nspawn.pull_raw
<salt.modules.nspawn.pull... | def remove(name, stop=False):
'''
Remove the named container
.. warning::
This function will remove all data associated with the container. It
will not, however, remove the btrfs subvolumes created by pulling
container images (:mod:`nspawn.pull_raw
<salt.modules.nspawn.pull... | [
"Remove",
"the",
"named",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1213-L1257 | [
"def",
"remove",
"(",
"name",
",",
"stop",
"=",
"False",
")",
":",
"if",
"not",
"stop",
"and",
"state",
"(",
"name",
")",
"!=",
"'stopped'",
":",
"raise",
"CommandExecutionError",
"(",
"'Container \\'{0}\\' is not stopped'",
".",
"format",
"(",
"name",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | copy_to | Copy a file from the host into a container
name
Container name
source
File to be copied to the container
dest
Destination on the container. Must be an absolute path.
overwrite : False
Unless this option is set to ``True``, then if a file exists at the
location... | salt/modules/nspawn.py | def copy_to(name, source, dest, overwrite=False, makedirs=False):
'''
Copy a file from the host into a container
name
Container name
source
File to be copied to the container
dest
Destination on the container. Must be an absolute path.
overwrite : False
Unless... | def copy_to(name, source, dest, overwrite=False, makedirs=False):
'''
Copy a file from the host into a container
name
Container name
source
File to be copied to the container
dest
Destination on the container. Must be an absolute path.
overwrite : False
Unless... | [
"Copy",
"a",
"file",
"from",
"the",
"host",
"into",
"a",
"container"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1265-L1315 | [
"def",
"copy_to",
"(",
"name",
",",
"source",
",",
"dest",
",",
"overwrite",
"=",
"False",
",",
"makedirs",
"=",
"False",
")",
":",
"path",
"=",
"source",
"try",
":",
"if",
"source",
".",
"startswith",
"(",
"'salt://'",
")",
":",
"cached_source",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _pull_image | Common logic for machinectl pull-* commands | salt/modules/nspawn.py | def _pull_image(pull_type, image, name, **kwargs):
'''
Common logic for machinectl pull-* commands
'''
_ensure_systemd(219)
if exists(name):
raise SaltInvocationError(
'Container \'{0}\' already exists'.format(name)
)
if pull_type in ('raw', 'tar'):
valid_kwar... | def _pull_image(pull_type, image, name, **kwargs):
'''
Common logic for machinectl pull-* commands
'''
_ensure_systemd(219)
if exists(name):
raise SaltInvocationError(
'Container \'{0}\' already exists'.format(name)
)
if pull_type in ('raw', 'tar'):
valid_kwar... | [
"Common",
"logic",
"for",
"machinectl",
"pull",
"-",
"*",
"commands"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1324-L1388 | [
"def",
"_pull_image",
"(",
"pull_type",
",",
"image",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"_ensure_systemd",
"(",
"219",
")",
"if",
"exists",
"(",
"name",
")",
":",
"raise",
"SaltInvocationError",
"(",
"'Container \\'{0}\\' already exists'",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pull_raw | Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for the new container
verify : False
Perform... | salt/modules/nspawn.py | def pull_raw(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for th... | def pull_raw(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for th... | [
"Execute",
"a",
"machinectl",
"pull",
"-",
"raw",
"to",
"download",
"a",
".",
"qcow2",
"or",
"raw",
"disk",
"image",
"and",
"add",
"it",
"to",
"/",
"var",
"/",
"lib",
"/",
"machines",
"as",
"a",
"new",
"container",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1391-L1420 | [
"def",
"pull_raw",
"(",
"url",
",",
"name",
",",
"verify",
"=",
"False",
")",
":",
"return",
"_pull_image",
"(",
"'raw'",
",",
"url",
",",
"name",
",",
"verify",
"=",
"verify",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pull_tar | Execute a ``machinectl pull-raw`` to download a .tar container image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for the new container
verify : False
Perform sig... | salt/modules/nspawn.py | def pull_tar(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .tar container image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for the ne... | def pull_tar(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .tar container image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for the ne... | [
"Execute",
"a",
"machinectl",
"pull",
"-",
"raw",
"to",
"download",
"a",
".",
"tar",
"container",
"image",
"and",
"add",
"it",
"to",
"/",
"var",
"/",
"lib",
"/",
"machines",
"as",
"a",
"new",
"container",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1423-L1452 | [
"def",
"pull_tar",
"(",
"url",
",",
"name",
",",
"verify",
"=",
"False",
")",
":",
"return",
"_pull_image",
"(",
"'tar'",
",",
"url",
",",
"name",
",",
"verify",
"=",
"verify",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _prep_acl_for_compare | Prepares the ACL returned from the AWS API for comparison with a given one. | salt/states/boto_s3_bucket.py | def _prep_acl_for_compare(ACL):
'''
Prepares the ACL returned from the AWS API for comparison with a given one.
'''
ret = copy.deepcopy(ACL)
ret['Owner'] = _normalize_user(ret['Owner'])
for item in ret.get('Grants', ()):
item['Grantee'] = _normalize_user(item.get('Grantee'))
return r... | def _prep_acl_for_compare(ACL):
'''
Prepares the ACL returned from the AWS API for comparison with a given one.
'''
ret = copy.deepcopy(ACL)
ret['Owner'] = _normalize_user(ret['Owner'])
for item in ret.get('Grants', ()):
item['Grantee'] = _normalize_user(item.get('Grantee'))
return r... | [
"Prepares",
"the",
"ACL",
"returned",
"from",
"the",
"AWS",
"API",
"for",
"comparison",
"with",
"a",
"given",
"one",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_s3_bucket.py#L178-L186 | [
"def",
"_prep_acl_for_compare",
"(",
"ACL",
")",
":",
"ret",
"=",
"copy",
".",
"deepcopy",
"(",
"ACL",
")",
"ret",
"[",
"'Owner'",
"]",
"=",
"_normalize_user",
"(",
"ret",
"[",
"'Owner'",
"]",
")",
"for",
"item",
"in",
"ret",
".",
"get",
"(",
"'Grant... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _compare_acl | ACLs can be specified using macro-style names that get expanded to
something more complex. There's no predictable way to reverse it.
So expand all syntactic sugar in our input, and compare against that
rather than the input itself. | salt/states/boto_s3_bucket.py | def _compare_acl(current, desired, region, key, keyid, profile):
'''
ACLs can be specified using macro-style names that get expanded to
something more complex. There's no predictable way to reverse it.
So expand all syntactic sugar in our input, and compare against that
rather than the input itself.... | def _compare_acl(current, desired, region, key, keyid, profile):
'''
ACLs can be specified using macro-style names that get expanded to
something more complex. There's no predictable way to reverse it.
So expand all syntactic sugar in our input, and compare against that
rather than the input itself.... | [
"ACLs",
"can",
"be",
"specified",
"using",
"macro",
"-",
"style",
"names",
"that",
"get",
"expanded",
"to",
"something",
"more",
"complex",
".",
"There",
"s",
"no",
"predictable",
"way",
"to",
"reverse",
"it",
".",
"So",
"expand",
"all",
"syntactic",
"suga... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_s3_bucket.py#L311-L319 | [
"def",
"_compare_acl",
"(",
"current",
",",
"desired",
",",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"ocid",
"=",
"_get_canonical_id",
"(",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
"return",
"__utils__",
"[",
"'boto3.... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _compare_replication | Replication accepts a non-ARN role name, but always returns an ARN | salt/states/boto_s3_bucket.py | def _compare_replication(current, desired, region, key, keyid, profile):
'''
Replication accepts a non-ARN role name, but always returns an ARN
'''
if desired is not None and desired.get('Role'):
desired = copy.deepcopy(desired)
desired['Role'] = _get_role_arn(desired['Role'],
... | def _compare_replication(current, desired, region, key, keyid, profile):
'''
Replication accepts a non-ARN role name, but always returns an ARN
'''
if desired is not None and desired.get('Role'):
desired = copy.deepcopy(desired)
desired['Role'] = _get_role_arn(desired['Role'],
... | [
"Replication",
"accepts",
"a",
"non",
"-",
"ARN",
"role",
"name",
"but",
"always",
"returns",
"an",
"ARN"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_s3_bucket.py#L326-L334 | [
"def",
"_compare_replication",
"(",
"current",
",",
"desired",
",",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"if",
"desired",
"is",
"not",
"None",
"and",
"desired",
".",
"get",
"(",
"'Role'",
")",
":",
"desired",
"=",
"copy",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensure bucket exists.
name
The name of the state definition
Bucket
Name of the bucket.
LocationConstraint
'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'
ACL
The permissions on a bucke... | salt/states/boto_s3_bucket.py | def present(name, Bucket,
LocationConstraint=None,
ACL=None,
CORSRules=None,
LifecycleConfiguration=None,
Logging=None,
NotificationConfiguration=None,
Policy=None,
Replication=None,
RequestPayment=None,
... | def present(name, Bucket,
LocationConstraint=None,
ACL=None,
CORSRules=None,
LifecycleConfiguration=None,
Logging=None,
NotificationConfiguration=None,
Policy=None,
Replication=None,
RequestPayment=None,
... | [
"Ensure",
"bucket",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_s3_bucket.py#L337-L611 | [
"def",
"present",
"(",
"name",
",",
"Bucket",
",",
"LocationConstraint",
"=",
"None",
",",
"ACL",
"=",
"None",
",",
"CORSRules",
"=",
"None",
",",
"LifecycleConfiguration",
"=",
"None",
",",
"Logging",
"=",
"None",
",",
"NotificationConfiguration",
"=",
"Non... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _check_pkgin | Looks to see if pkgin is present on the system, return full path | salt/modules/pkgin.py | def _check_pkgin():
'''
Looks to see if pkgin is present on the system, return full path
'''
ppath = salt.utils.path.which('pkgin')
if ppath is None:
# pkgin was not found in $PATH, try to find it via LOCALBASE
try:
localbase = __salt__['cmd.run'](
'pkg_inf... | def _check_pkgin():
'''
Looks to see if pkgin is present on the system, return full path
'''
ppath = salt.utils.path.which('pkgin')
if ppath is None:
# pkgin was not found in $PATH, try to find it via LOCALBASE
try:
localbase = __salt__['cmd.run'](
'pkg_inf... | [
"Looks",
"to",
"see",
"if",
"pkgin",
"is",
"present",
"on",
"the",
"system",
"return",
"full",
"path"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L38-L56 | [
"def",
"_check_pkgin",
"(",
")",
":",
"ppath",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'pkgin'",
")",
"if",
"ppath",
"is",
"None",
":",
"# pkgin was not found in $PATH, try to find it via LOCALBASE",
"try",
":",
"localbase",
"=",
"__salt__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_version | Get the pkgin version | salt/modules/pkgin.py | def _get_version():
'''
Get the pkgin version
'''
version_string = __salt__['cmd.run'](
[_check_pkgin(), '-v'],
output_loglevel='trace')
if version_string is None:
# Dunno why it would, but...
return False
version_match = VERSION_MATCH.search(version_string)
... | def _get_version():
'''
Get the pkgin version
'''
version_string = __salt__['cmd.run'](
[_check_pkgin(), '-v'],
output_loglevel='trace')
if version_string is None:
# Dunno why it would, but...
return False
version_match = VERSION_MATCH.search(version_string)
... | [
"Get",
"the",
"pkgin",
"version"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L60-L75 | [
"def",
"_get_version",
"(",
")",
":",
"version_string",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"[",
"_check_pkgin",
"(",
")",
",",
"'-v'",
"]",
",",
"output_loglevel",
"=",
"'trace'",
")",
"if",
"version_string",
"is",
"None",
":",
"# Dunno why it woul... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | search | Searches for an exact match using pkgin ^package$
CLI Example:
.. code-block:: bash
salt '*' pkg.search 'mysql-server' | salt/modules/pkgin.py | def search(pkg_name, **kwargs):
'''
Searches for an exact match using pkgin ^package$
CLI Example:
.. code-block:: bash
salt '*' pkg.search 'mysql-server'
'''
pkglist = {}
pkgin = _check_pkgin()
if not pkgin:
return pkglist
if _supports_regex():
pkg_name ... | def search(pkg_name, **kwargs):
'''
Searches for an exact match using pkgin ^package$
CLI Example:
.. code-block:: bash
salt '*' pkg.search 'mysql-server'
'''
pkglist = {}
pkgin = _check_pkgin()
if not pkgin:
return pkglist
if _supports_regex():
pkg_name ... | [
"Searches",
"for",
"an",
"exact",
"match",
"using",
"pkgin",
"^package$"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L120-L149 | [
"def",
"search",
"(",
"pkg_name",
",",
"*",
"*",
"kwargs",
")",
":",
"pkglist",
"=",
"{",
"}",
"pkgin",
"=",
"_check_pkgin",
"(",
")",
"if",
"not",
"pkgin",
":",
"return",
"pkglist",
"if",
"_supports_regex",
"(",
")",
":",
"pkg_name",
"=",
"'^{0}$'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | refresh_db | Use pkg update to get latest pkg_summary
force
Pass -f so that the cache is always refreshed.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db | salt/modules/pkgin.py | def refresh_db(force=False, **kwargs):
'''
Use pkg update to get latest pkg_summary
force
Pass -f so that the cache is always refreshed.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
'''
# Remove rtag file to keep multiple ... | def refresh_db(force=False, **kwargs):
'''
Use pkg update to get latest pkg_summary
force
Pass -f so that the cache is always refreshed.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
'''
# Remove rtag file to keep multiple ... | [
"Use",
"pkg",
"update",
"to",
"get",
"latest",
"pkg_summary"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L233-L266 | [
"def",
"refresh_db",
"(",
"force",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Remove rtag file to keep multiple refreshes from happening in pkg states",
"salt",
".",
"utils",
".",
"pkg",
".",
"clear_rtag",
"(",
"__opts__",
")",
"pkgin",
"=",
"_check_pkgin",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_pkgs | .. versionchanged: 2016.3.0
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs | salt/modules/pkgin.py | def list_pkgs(versions_as_list=False, **kwargs):
'''
.. versionchanged: 2016.3.0
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(vers... | def list_pkgs(versions_as_list=False, **kwargs):
'''
.. versionchanged: 2016.3.0
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(vers... | [
"..",
"versionchanged",
":",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L269-L317 | [
"def",
"list_pkgs",
"(",
"versions_as_list",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"versions_as_list",
"=",
"salt",
".",
"utils",
".",
"data",
".",
"is_true",
"(",
"versions_as_list",
")",
"# not yet implemented or not applicable",
"if",
"any",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_upgrades | List all available package upgrades.
.. versionadded:: 2018.3.0
refresh
Whether or not to refresh the package database before installing.
CLI Example:
.. code-block:: bash
salt '*' pkg.list_upgrades | salt/modules/pkgin.py | def list_upgrades(refresh=True, **kwargs):
'''
List all available package upgrades.
.. versionadded:: 2018.3.0
refresh
Whether or not to refresh the package database before installing.
CLI Example:
.. code-block:: bash
salt '*' pkg.list_upgrades
'''
pkgs = {}
for... | def list_upgrades(refresh=True, **kwargs):
'''
List all available package upgrades.
.. versionadded:: 2018.3.0
refresh
Whether or not to refresh the package database before installing.
CLI Example:
.. code-block:: bash
salt '*' pkg.list_upgrades
'''
pkgs = {}
for... | [
"List",
"all",
"available",
"package",
"upgrades",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L320-L341 | [
"def",
"list_upgrades",
"(",
"refresh",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"pkgs",
"=",
"{",
"}",
"for",
"pkg",
"in",
"sorted",
"(",
"list_pkgs",
"(",
"refresh",
"=",
"refresh",
")",
".",
"keys",
"(",
")",
")",
":",
"# NOTE: we already o... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | install | Install the passed package
name
The name of the package to be installed.
refresh
Whether or not to refresh the package database before installing.
fromrepo
Specify a package repository to install from.
Multiple Package Installation Options:
pkgs
A list of packag... | salt/modules/pkgin.py | def install(name=None, refresh=False, fromrepo=None,
pkgs=None, sources=None, **kwargs):
'''
Install the passed package
name
The name of the package to be installed.
refresh
Whether or not to refresh the package database before installing.
fromrepo
Specify a pa... | def install(name=None, refresh=False, fromrepo=None,
pkgs=None, sources=None, **kwargs):
'''
Install the passed package
name
The name of the package to be installed.
refresh
Whether or not to refresh the package database before installing.
fromrepo
Specify a pa... | [
"Install",
"the",
"passed",
"package"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L344-L453 | [
"def",
"install",
"(",
"name",
"=",
"None",
",",
"refresh",
"=",
"False",
",",
"fromrepo",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"pkg_params",
",",
"pkg_type",
"=",
"__sal... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | upgrade | Run pkg upgrade, if pkgin used. Otherwise do nothing
refresh
Whether or not to refresh the package database before installing.
Multiple Package Upgrade Options:
pkgs
A list of packages to upgrade from a software repository. Must be
passed as a python list.
CLI Example:
... | salt/modules/pkgin.py | def upgrade(refresh=True, pkgs=None, **kwargs):
'''
Run pkg upgrade, if pkgin used. Otherwise do nothing
refresh
Whether or not to refresh the package database before installing.
Multiple Package Upgrade Options:
pkgs
A list of packages to upgrade from a software repository. Must ... | def upgrade(refresh=True, pkgs=None, **kwargs):
'''
Run pkg upgrade, if pkgin used. Otherwise do nothing
refresh
Whether or not to refresh the package database before installing.
Multiple Package Upgrade Options:
pkgs
A list of packages to upgrade from a software repository. Must ... | [
"Run",
"pkg",
"upgrade",
"if",
"pkgin",
"used",
".",
"Otherwise",
"do",
"nothing"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgin.py#L456-L526 | [
"def",
"upgrade",
"(",
"refresh",
"=",
"True",
",",
"pkgs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"pkgin",
"=",
"_check_pkgin",
"(",
")",
"if",
"not",
"pkgin",
":",
"# There is not easy way to upgrade packages with old package system",
"return",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.