repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/quota.py | _parse_quota | def _parse_quota(mount, opts):
'''
Parse the output from repquota. Requires that -u -g are passed in
'''
cmd = 'repquota -vp {0} {1}'.format(opts, mount)
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
mode = 'header'
if '-u' in opts:
quotatype = 'Users'
elif '-g... | python | def _parse_quota(mount, opts):
'''
Parse the output from repquota. Requires that -u -g are passed in
'''
cmd = 'repquota -vp {0} {1}'.format(opts, mount)
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
mode = 'header'
if '-u' in opts:
quotatype = 'Users'
elif '-g... | [
"def",
"_parse_quota",
"(",
"mount",
",",
"opts",
")",
":",
"cmd",
"=",
"'repquota -vp {0} {1}'",
".",
"format",
"(",
"opts",
",",
"mount",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
".",
"sp... | Parse the output from repquota. Requires that -u -g are passed in | [
"Parse",
"the",
"output",
"from",
"repquota",
".",
"Requires",
"that",
"-",
"u",
"-",
"g",
"are",
"passed",
"in"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L54-L94 | train |
saltstack/salt | salt/modules/quota.py | set_ | def set_(device, **kwargs):
'''
Calls out to setquota, for a specific user or group
CLI Example:
.. code-block:: bash
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
salt '*' quota.set /media/data group=painters file-hard-limit=1000
'''
empty = {'block-soft-... | python | def set_(device, **kwargs):
'''
Calls out to setquota, for a specific user or group
CLI Example:
.. code-block:: bash
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
salt '*' quota.set /media/data group=painters file-hard-limit=1000
'''
empty = {'block-soft-... | [
"def",
"set_",
"(",
"device",
",",
"*",
"*",
"kwargs",
")",
":",
"empty",
"=",
"{",
"'block-soft-limit'",
":",
"0",
",",
"'block-hard-limit'",
":",
"0",
",",
"'file-soft-limit'",
":",
"0",
",",
"'file-hard-limit'",
":",
"0",
"}",
"current",
"=",
"None",
... | Calls out to setquota, for a specific user or group
CLI Example:
.. code-block:: bash
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
salt '*' quota.set /media/data group=painters file-hard-limit=1000 | [
"Calls",
"out",
"to",
"setquota",
"for",
"a",
"specific",
"user",
"or",
"group"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L97-L155 | train |
saltstack/salt | salt/modules/quota.py | stats | def stats():
'''
Runs the quotastats command, and returns the parsed output
CLI Example:
.. code-block:: bash
salt '*' quota.stats
'''
ret = {}
out = __salt__['cmd.run']('quotastats').splitlines()
for line in out:
if not line:
continue
comps = line.... | python | def stats():
'''
Runs the quotastats command, and returns the parsed output
CLI Example:
.. code-block:: bash
salt '*' quota.stats
'''
ret = {}
out = __salt__['cmd.run']('quotastats').splitlines()
for line in out:
if not line:
continue
comps = line.... | [
"def",
"stats",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'quotastats'",
")",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"out",
":",
"if",
"not",
"line",
":",
"continue",
"comps",
"=",
"line",
... | Runs the quotastats command, and returns the parsed output
CLI Example:
.. code-block:: bash
salt '*' quota.stats | [
"Runs",
"the",
"quotastats",
"command",
"and",
"returns",
"the",
"parsed",
"output"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L172-L190 | train |
saltstack/salt | salt/modules/quota.py | on | def on(device):
'''
Turns on the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.on
'''
cmd = 'quotaon {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | python | def on(device):
'''
Turns on the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.on
'''
cmd = 'quotaon {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | [
"def",
"on",
"(",
"device",
")",
":",
"cmd",
"=",
"'quotaon {0}'",
".",
"format",
"(",
"device",
")",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
"return",
"True"
] | Turns on the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.on | [
"Turns",
"on",
"the",
"quota",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L193-L205 | train |
saltstack/salt | salt/modules/quota.py | off | def off(device):
'''
Turns off the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.off
'''
cmd = 'quotaoff {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | python | def off(device):
'''
Turns off the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.off
'''
cmd = 'quotaoff {0}'.format(device)
__salt__['cmd.run'](cmd, python_shell=False)
return True | [
"def",
"off",
"(",
"device",
")",
":",
"cmd",
"=",
"'quotaoff {0}'",
".",
"format",
"(",
"device",
")",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
"return",
"True"
] | Turns off the quota system
CLI Example:
.. code-block:: bash
salt '*' quota.off | [
"Turns",
"off",
"the",
"quota",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L208-L220 | train |
saltstack/salt | salt/modules/quota.py | get_mode | def get_mode(device):
'''
Report whether the quota system for this device is on or off
CLI Example:
.. code-block:: bash
salt '*' quota.get_mode
'''
ret = {}
cmd = 'quotaon -p {0}'.format(device)
out = __salt__['cmd.run'](cmd, python_shell=False)
for line in out.splitlines... | python | def get_mode(device):
'''
Report whether the quota system for this device is on or off
CLI Example:
.. code-block:: bash
salt '*' quota.get_mode
'''
ret = {}
cmd = 'quotaon -p {0}'.format(device)
out = __salt__['cmd.run'](cmd, python_shell=False)
for line in out.splitlines... | [
"def",
"get_mode",
"(",
"device",
")",
":",
"ret",
"=",
"{",
"}",
"cmd",
"=",
"'quotaon -p {0}'",
".",
"format",
"(",
"device",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False",
")",
"for",
"line",
"in... | Report whether the quota system for this device is on or off
CLI Example:
.. code-block:: bash
salt '*' quota.get_mode | [
"Report",
"whether",
"the",
"quota",
"system",
"for",
"this",
"device",
"is",
"on",
"or",
"off"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/quota.py#L223-L251 | train |
saltstack/salt | salt/states/pagerduty_user.py | present | def present(profile='pagerduty', subdomain=None, api_key=None, **kwargs):
'''
Ensure pagerduty user exists.
Arguments match those supported by
https://developer.pagerduty.com/documentation/rest/users/create.
'''
return __salt__['pagerduty_util.resource_present']('users',
... | python | def present(profile='pagerduty', subdomain=None, api_key=None, **kwargs):
'''
Ensure pagerduty user exists.
Arguments match those supported by
https://developer.pagerduty.com/documentation/rest/users/create.
'''
return __salt__['pagerduty_util.resource_present']('users',
... | [
"def",
"present",
"(",
"profile",
"=",
"'pagerduty'",
",",
"subdomain",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"__salt__",
"[",
"'pagerduty_util.resource_present'",
"]",
"(",
"'users'",
",",
"[",
"'email'",
"... | Ensure pagerduty user exists.
Arguments match those supported by
https://developer.pagerduty.com/documentation/rest/users/create. | [
"Ensure",
"pagerduty",
"user",
"exists",
".",
"Arguments",
"match",
"those",
"supported",
"by",
"https",
":",
"//",
"developer",
".",
"pagerduty",
".",
"com",
"/",
"documentation",
"/",
"rest",
"/",
"users",
"/",
"create",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pagerduty_user.py#L28-L40 | train |
saltstack/salt | salt/modules/rsync.py | _check | def _check(delete, force, update, passwordfile, exclude, excludefrom, dryrun, rsh):
'''
Generate rsync options
'''
options = ['-avz']
if delete:
options.append('--delete')
if force:
options.append('--force')
if update:
options.append('--update')
if rsh:
o... | python | def _check(delete, force, update, passwordfile, exclude, excludefrom, dryrun, rsh):
'''
Generate rsync options
'''
options = ['-avz']
if delete:
options.append('--delete')
if force:
options.append('--force')
if update:
options.append('--update')
if rsh:
o... | [
"def",
"_check",
"(",
"delete",
",",
"force",
",",
"update",
",",
"passwordfile",
",",
"exclude",
",",
"excludefrom",
",",
"dryrun",
",",
"rsh",
")",
":",
"options",
"=",
"[",
"'-avz'",
"]",
"if",
"delete",
":",
"options",
".",
"append",
"(",
"'--delet... | Generate rsync options | [
"Generate",
"rsync",
"options"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L38-L66 | train |
saltstack/salt | salt/modules/rsync.py | rsync | def rsync(src,
dst,
delete=False,
force=False,
update=False,
passwordfile=None,
exclude=None,
excludefrom=None,
dryrun=False,
rsh=None,
additional_opts=None,
saltenv='base'):
'''
.. versionchanged:: 201... | python | def rsync(src,
dst,
delete=False,
force=False,
update=False,
passwordfile=None,
exclude=None,
excludefrom=None,
dryrun=False,
rsh=None,
additional_opts=None,
saltenv='base'):
'''
.. versionchanged:: 201... | [
"def",
"rsync",
"(",
"src",
",",
"dst",
",",
"delete",
"=",
"False",
",",
"force",
"=",
"False",
",",
"update",
"=",
"False",
",",
"passwordfile",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"excludefrom",
"=",
"None",
",",
"dryrun",
"=",
"False",... | .. versionchanged:: 2016.3.0
Return data now contains just the output of the rsync command, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Rsync files from src to dst
src
The source location where files will be rsynced from.
... | [
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"Return",
"data",
"now",
"contains",
"just",
"the",
"output",
"of",
"the",
"rsync",
"command",
"instead",
"of",
"a",
"dictionary",
"as",
"returned",
"from",
":",
"py",
":",
"func",
":",
"cmd",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L69-L219 | train |
saltstack/salt | salt/modules/rsync.py | version | def version():
'''
.. versionchanged:: 2016.3.0
Return data now contains just the version number as a string, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns rsync version
CLI Example:
.. code-block:: bash
sal... | python | def version():
'''
.. versionchanged:: 2016.3.0
Return data now contains just the version number as a string, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns rsync version
CLI Example:
.. code-block:: bash
sal... | [
"def",
"version",
"(",
")",
":",
"try",
":",
"out",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"[",
"'rsync'",
",",
"'--version'",
"]",
",",
"python_shell",
"=",
"False",
")",
"except",
"(",
"IOError",
",",
"OSError",
")",
"as",
"exc",
":",
... | .. versionchanged:: 2016.3.0
Return data now contains just the version number as a string, instead
of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns rsync version
CLI Example:
.. code-block:: bash
salt '*' rsync.version | [
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"Return",
"data",
"now",
"contains",
"just",
"the",
"version",
"number",
"as",
"a",
"string",
"instead",
"of",
"a",
"dictionary",
"as",
"returned",
"from",
":",
"py",
":",
"func",
":",
"cmd",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L222-L246 | train |
saltstack/salt | salt/modules/rsync.py | config | def config(conf_path='/etc/rsyncd.conf'):
'''
.. versionchanged:: 2016.3.0
Return data now contains just the contents of the rsyncd.conf as a
string, instead of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns the contents of the rsync conf... | python | def config(conf_path='/etc/rsyncd.conf'):
'''
.. versionchanged:: 2016.3.0
Return data now contains just the contents of the rsyncd.conf as a
string, instead of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns the contents of the rsync conf... | [
"def",
"config",
"(",
"conf_path",
"=",
"'/etc/rsyncd.conf'",
")",
":",
"ret",
"=",
"''",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"conf_path",
",",
"'r'",
")",
"as",
"fp_",
":",
"for",
"line",
"in",
"fp_",
":",
"r... | .. versionchanged:: 2016.3.0
Return data now contains just the contents of the rsyncd.conf as a
string, instead of a dictionary as returned from :py:func:`cmd.run_all
<salt.modules.cmdmod.run_all>`.
Returns the contents of the rsync config file
conf_path : /etc/rsyncd.conf
Path... | [
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"0",
"Return",
"data",
"now",
"contains",
"just",
"the",
"contents",
"of",
"the",
"rsyncd",
".",
"conf",
"as",
"a",
"string",
"instead",
"of",
"a",
"dictionary",
"as",
"returned",
"from",
":",
"py",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rsync.py#L249-L288 | train |
saltstack/salt | salt/states/keystone_role.py | present | def present(name, auth=None, **kwargs):
'''
Ensure an role exists
name
Name of the role
description
An arbitrary description of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
kwargs = __utils__['args.clean_k... | python | def present(name, auth=None, **kwargs):
'''
Ensure an role exists
name
Name of the role
description
An arbitrary description of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
kwargs = __utils__['args.clean_k... | [
"def",
"present",
"(",
"name",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"kwargs",
"=",
... | Ensure an role exists
name
Name of the role
description
An arbitrary description of the role | [
"Ensure",
"an",
"role",
"exists"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_role.py#L40-L75 | train |
saltstack/salt | salt/states/keystone_role.py | absent | def absent(name, auth=None, **kwargs):
'''
Ensure role does not exist
name
Name of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
__salt__['keystoneng.setup_clouds'](auth)
kwargs['name'] = name
role = __salt__['... | python | def absent(name, auth=None, **kwargs):
'''
Ensure role does not exist
name
Name of the role
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
__salt__['keystoneng.setup_clouds'](auth)
kwargs['name'] = name
role = __salt__['... | [
"def",
"absent",
"(",
"name",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"__salt__",
"[",
... | Ensure role does not exist
name
Name of the role | [
"Ensure",
"role",
"does",
"not",
"exist"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_role.py#L78-L106 | train |
saltstack/salt | salt/modules/mac_assistive.py | install | def install(app_id, enable=True):
'''
Install a bundle ID or command as being allowed to use
assistive access.
app_id
The bundle ID or command to install for assistive access.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
... | python | def install(app_id, enable=True):
'''
Install a bundle ID or command as being allowed to use
assistive access.
app_id
The bundle ID or command to install for assistive access.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
... | [
"def",
"install",
"(",
"app_id",
",",
"enable",
"=",
"True",
")",
":",
"ge_el_capitan",
"=",
"True",
"if",
"_LooseVersion",
"(",
"__grains__",
"[",
"'osrelease'",
"]",
")",
">=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_str",
"(",
"'10.11'",
")... | Install a bundle ID or command as being allowed to use
assistive access.
app_id
The bundle ID or command to install for assistive access.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' assistive.install /usr/bin/o... | [
"Install",
"a",
"bundle",
"ID",
"or",
"command",
"as",
"being",
"allowed",
"to",
"use",
"assistive",
"access",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L39-L78 | train |
saltstack/salt | salt/modules/mac_assistive.py | enable | def enable(app_id, enabled=True):
'''
Enable or disable an existing assistive access application.
app_id
The bundle ID or command to set assistive access status.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' ... | python | def enable(app_id, enabled=True):
'''
Enable or disable an existing assistive access application.
app_id
The bundle ID or command to set assistive access status.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' ... | [
"def",
"enable",
"(",
"app_id",
",",
"enabled",
"=",
"True",
")",
":",
"enable_str",
"=",
"'1'",
"if",
"enabled",
"else",
"'0'",
"for",
"a",
"in",
"_get_assistive_access",
"(",
")",
":",
"if",
"app_id",
"==",
"a",
"[",
"0",
"]",
":",
"cmd",
"=",
"'... | Enable or disable an existing assistive access application.
app_id
The bundle ID or command to set assistive access status.
enabled
Sets enabled or disabled status. Default is ``True``.
CLI Example:
.. code-block:: bash
salt '*' assistive.enable /usr/bin/osascript
sa... | [
"Enable",
"or",
"disable",
"an",
"existing",
"assistive",
"access",
"application",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L103-L143 | train |
saltstack/salt | salt/modules/mac_assistive.py | remove | def remove(app_id):
'''
Remove a bundle ID or command as being allowed to use assistive access.
app_id
The bundle ID or command to remove from assistive access list.
CLI Example:
.. code-block:: bash
salt '*' assistive.remove /usr/bin/osascript
salt '*' assistive.remove c... | python | def remove(app_id):
'''
Remove a bundle ID or command as being allowed to use assistive access.
app_id
The bundle ID or command to remove from assistive access list.
CLI Example:
.. code-block:: bash
salt '*' assistive.remove /usr/bin/osascript
salt '*' assistive.remove c... | [
"def",
"remove",
"(",
"app_id",
")",
":",
"cmd",
"=",
"'sqlite3 \"/Library/Application Support/com.apple.TCC/TCC.db\" '",
"'\"DELETE from access where client=\\'{0}\\'\"'",
".",
"format",
"(",
"app_id",
")",
"call",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
... | Remove a bundle ID or command as being allowed to use assistive access.
app_id
The bundle ID or command to remove from assistive access list.
CLI Example:
.. code-block:: bash
salt '*' assistive.remove /usr/bin/osascript
salt '*' assistive.remove com.smileonmymac.textexpander | [
"Remove",
"a",
"bundle",
"ID",
"or",
"command",
"as",
"being",
"allowed",
"to",
"use",
"assistive",
"access",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L168-L199 | train |
saltstack/salt | salt/modules/mac_assistive.py | _get_assistive_access | def _get_assistive_access():
'''
Get a list of all of the assistive access applications installed,
returns as a ternary showing whether each app is enabled or not.
'''
cmd = 'sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT * FROM access"'
call = __salt__['cmd.run_all'](
... | python | def _get_assistive_access():
'''
Get a list of all of the assistive access applications installed,
returns as a ternary showing whether each app is enabled or not.
'''
cmd = 'sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT * FROM access"'
call = __salt__['cmd.run_all'](
... | [
"def",
"_get_assistive_access",
"(",
")",
":",
"cmd",
"=",
"'sqlite3 \"/Library/Application Support/com.apple.TCC/TCC.db\" \"SELECT * FROM access\"'",
"call",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'debug'",
",",
"python_shell"... | Get a list of all of the assistive access applications installed,
returns as a ternary showing whether each app is enabled or not. | [
"Get",
"a",
"list",
"of",
"all",
"of",
"the",
"assistive",
"access",
"applications",
"installed",
"returns",
"as",
"a",
"ternary",
"showing",
"whether",
"each",
"app",
"is",
"enabled",
"or",
"not",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_assistive.py#L210-L232 | train |
saltstack/salt | salt/serializers/yaml.py | deserialize | def deserialize(stream_or_string, **options):
'''
Deserialize any string of stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower yaml module.
'''
options.setdefault('Loader', Loader)
try:
r... | python | def deserialize(stream_or_string, **options):
'''
Deserialize any string of stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower yaml module.
'''
options.setdefault('Loader', Loader)
try:
r... | [
"def",
"deserialize",
"(",
"stream_or_string",
",",
"*",
"*",
"options",
")",
":",
"options",
".",
"setdefault",
"(",
"'Loader'",
",",
"Loader",
")",
"try",
":",
"return",
"yaml",
".",
"load",
"(",
"stream_or_string",
",",
"*",
"*",
"options",
")",
"exce... | Deserialize any string of stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower yaml module. | [
"Deserialize",
"any",
"string",
"of",
"stream",
"like",
"object",
"into",
"a",
"Python",
"data",
"structure",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/yaml.py#L41-L64 | train |
saltstack/salt | salt/serializers/yaml.py | serialize | def serialize(obj, **options):
'''
Serialize Python data to YAML.
:param obj: the data structure to serialize
:param options: options given to lower yaml module.
'''
options.setdefault('Dumper', Dumper)
try:
response = yaml.dump(obj, **options)
if response.endswith('\n...\n... | python | def serialize(obj, **options):
'''
Serialize Python data to YAML.
:param obj: the data structure to serialize
:param options: options given to lower yaml module.
'''
options.setdefault('Dumper', Dumper)
try:
response = yaml.dump(obj, **options)
if response.endswith('\n...\n... | [
"def",
"serialize",
"(",
"obj",
",",
"*",
"*",
"options",
")",
":",
"options",
".",
"setdefault",
"(",
"'Dumper'",
",",
"Dumper",
")",
"try",
":",
"response",
"=",
"yaml",
".",
"dump",
"(",
"obj",
",",
"*",
"*",
"options",
")",
"if",
"response",
".... | Serialize Python data to YAML.
:param obj: the data structure to serialize
:param options: options given to lower yaml module. | [
"Serialize",
"Python",
"data",
"to",
"YAML",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/yaml.py#L67-L85 | train |
saltstack/salt | salt/modules/win_certutil.py | get_cert_serial | def get_cert_serial(cert_file):
'''
Get the serial number of a certificate file
cert_file
The certificate file to find the serial for
CLI Example:
.. code-block:: bash
salt '*' certutil.get_cert_serial <certificate name>
'''
cmd = "certutil.exe -silent -verify {0}".format... | python | def get_cert_serial(cert_file):
'''
Get the serial number of a certificate file
cert_file
The certificate file to find the serial for
CLI Example:
.. code-block:: bash
salt '*' certutil.get_cert_serial <certificate name>
'''
cmd = "certutil.exe -silent -verify {0}".format... | [
"def",
"get_cert_serial",
"(",
"cert_file",
")",
":",
"cmd",
"=",
"\"certutil.exe -silent -verify {0}\"",
".",
"format",
"(",
"cert_file",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
"# match serial number by paragraph to work with multiple lang... | Get the serial number of a certificate file
cert_file
The certificate file to find the serial for
CLI Example:
.. code-block:: bash
salt '*' certutil.get_cert_serial <certificate name> | [
"Get",
"the",
"serial",
"number",
"of",
"a",
"certificate",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L32-L52 | train |
saltstack/salt | salt/modules/win_certutil.py | get_stored_cert_serials | def get_stored_cert_serials(store):
'''
Get all of the certificate serials in the specified store
store
The store to get all the certificate serials from
CLI Example:
.. code-block:: bash
salt '*' certutil.get_stored_cert_serials <store>
'''
cmd = "certutil.exe -store {0}... | python | def get_stored_cert_serials(store):
'''
Get all of the certificate serials in the specified store
store
The store to get all the certificate serials from
CLI Example:
.. code-block:: bash
salt '*' certutil.get_stored_cert_serials <store>
'''
cmd = "certutil.exe -store {0}... | [
"def",
"get_stored_cert_serials",
"(",
"store",
")",
":",
"cmd",
"=",
"\"certutil.exe -store {0}\"",
".",
"format",
"(",
"store",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
")",
"# match serial numbers by header position to work with multiple langua... | Get all of the certificate serials in the specified store
store
The store to get all the certificate serials from
CLI Example:
.. code-block:: bash
salt '*' certutil.get_stored_cert_serials <store> | [
"Get",
"all",
"of",
"the",
"certificate",
"serials",
"in",
"the",
"specified",
"store"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L55-L72 | train |
saltstack/salt | salt/modules/win_certutil.py | add_store | def add_store(source, store, saltenv='base'):
'''
Add the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to add the certificate to
saltenv
The salt environment t... | python | def add_store(source, store, saltenv='base'):
'''
Add the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to add the certificate to
saltenv
The salt environment t... | [
"def",
"add_store",
"(",
"source",
",",
"store",
",",
"saltenv",
"=",
"'base'",
")",
":",
"cert_file",
"=",
"__salt__",
"[",
"'cp.cache_file'",
"]",
"(",
"source",
",",
"saltenv",
")",
"cmd",
"=",
"\"certutil.exe -addstore {0} {1}\"",
".",
"format",
"(",
"st... | Add the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to add the certificate to
saltenv
The salt environment to use this is ignored if the path
is local
CL... | [
"Add",
"the",
"given",
"cert",
"into",
"the",
"given",
"Certificate",
"Store"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L75-L98 | train |
saltstack/salt | salt/modules/win_certutil.py | del_store | def del_store(source, store, saltenv='base'):
'''
Delete the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to delete the certificate from
saltenv
The salt envir... | python | def del_store(source, store, saltenv='base'):
'''
Delete the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to delete the certificate from
saltenv
The salt envir... | [
"def",
"del_store",
"(",
"source",
",",
"store",
",",
"saltenv",
"=",
"'base'",
")",
":",
"cert_file",
"=",
"__salt__",
"[",
"'cp.cache_file'",
"]",
"(",
"source",
",",
"saltenv",
")",
"serial",
"=",
"get_cert_serial",
"(",
"cert_file",
")",
"cmd",
"=",
... | Delete the given cert into the given Certificate Store
source
The source certificate file this can be in the form
salt://path/to/file
store
The certificate store to delete the certificate from
saltenv
The salt environment to use this is ignored if the path
is local... | [
"Delete",
"the",
"given",
"cert",
"into",
"the",
"given",
"Certificate",
"Store"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_certutil.py#L101-L125 | train |
saltstack/salt | salt/states/ddns.py | present | def present(name, zone, ttl, data, rdtype='A', **kwargs):
'''
Ensures that the named DNS record is present with the given ttl.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so... | python | def present(name, zone, ttl, data, rdtype='A', **kwargs):
'''
Ensures that the named DNS record is present with the given ttl.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so... | [
"def",
"present",
"(",
"name",
",",
"zone",
",",
"ttl",
",",
"data",
",",
"rdtype",
"=",
"'A'",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'co... | Ensures that the named DNS record is present with the given ttl.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arg... | [
"Ensures",
"that",
"the",
"named",
"DNS",
"record",
"is",
"present",
"with",
"the",
"given",
"ttl",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ddns.py#L35-L91 | train |
saltstack/salt | salt/states/ddns.py | absent | def absent(name, zone, data=None, rdtype=None, **kwargs):
'''
Ensures that the named DNS record is absent.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that info... | python | def absent(name, zone, data=None, rdtype=None, **kwargs):
'''
Ensures that the named DNS record is absent.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that info... | [
"def",
"absent",
"(",
"name",
",",
"zone",
",",
"data",
"=",
"None",
",",
"rdtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'c... | Ensures that the named DNS record is absent.
name
The host portion of the DNS record, e.g., 'webserver'. Name and zone
are concatenated when the entry is created unless name includes a
trailing dot, so make sure that information is not duplicated in these
two arguments.
zone
... | [
"Ensures",
"that",
"the",
"named",
"DNS",
"record",
"is",
"absent",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ddns.py#L94-L145 | train |
saltstack/salt | salt/renderers/json.py | render | def render(json_data, saltenv='base', sls='', **kws):
'''
Accepts JSON as a string or as a file object and runs it through the JSON
parser.
:rtype: A Python data structure
'''
if not isinstance(json_data, six.string_types):
json_data = json_data.read()
if json_data.startswith('#!')... | python | def render(json_data, saltenv='base', sls='', **kws):
'''
Accepts JSON as a string or as a file object and runs it through the JSON
parser.
:rtype: A Python data structure
'''
if not isinstance(json_data, six.string_types):
json_data = json_data.read()
if json_data.startswith('#!')... | [
"def",
"render",
"(",
"json_data",
",",
"saltenv",
"=",
"'base'",
",",
"sls",
"=",
"''",
",",
"*",
"*",
"kws",
")",
":",
"if",
"not",
"isinstance",
"(",
"json_data",
",",
"six",
".",
"string_types",
")",
":",
"json_data",
"=",
"json_data",
".",
"read... | Accepts JSON as a string or as a file object and runs it through the JSON
parser.
:rtype: A Python data structure | [
"Accepts",
"JSON",
"as",
"a",
"string",
"or",
"as",
"a",
"file",
"object",
"and",
"runs",
"it",
"through",
"the",
"JSON",
"parser",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/json.py#L16-L30 | train |
saltstack/salt | salt/modules/at.py | _cmd | def _cmd(binary, *args):
'''
Wrapper to run at(1) or return None.
'''
binary = salt.utils.path.which(binary)
if not binary:
raise CommandNotFoundError('{0}: command not found'.format(binary))
cmd = [binary] + list(args)
return __salt__['cmd.run_stdout']([binary] + list(args),
... | python | def _cmd(binary, *args):
'''
Wrapper to run at(1) or return None.
'''
binary = salt.utils.path.which(binary)
if not binary:
raise CommandNotFoundError('{0}: command not found'.format(binary))
cmd = [binary] + list(args)
return __salt__['cmd.run_stdout']([binary] + list(args),
... | [
"def",
"_cmd",
"(",
"binary",
",",
"*",
"args",
")",
":",
"binary",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"binary",
")",
"if",
"not",
"binary",
":",
"raise",
"CommandNotFoundError",
"(",
"'{0}: command not found'",
".",
"format",
"("... | Wrapper to run at(1) or return None. | [
"Wrapper",
"to",
"run",
"at",
"(",
"1",
")",
"or",
"return",
"None",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L51-L60 | train |
saltstack/salt | salt/modules/at.py | atq | def atq(tag=None):
'''
List all queued and running jobs or only those with
an optional 'tag'.
CLI Example:
.. code-block:: bash
salt '*' at.atq
salt '*' at.atq [tag]
salt '*' at.atq [job number]
'''
jobs = []
# Shim to produce output similar to what __virtual_... | python | def atq(tag=None):
'''
List all queued and running jobs or only those with
an optional 'tag'.
CLI Example:
.. code-block:: bash
salt '*' at.atq
salt '*' at.atq [tag]
salt '*' at.atq [job number]
'''
jobs = []
# Shim to produce output similar to what __virtual_... | [
"def",
"atq",
"(",
"tag",
"=",
"None",
")",
":",
"jobs",
"=",
"[",
"]",
"# Shim to produce output similar to what __virtual__() should do",
"# but __salt__ isn't available in __virtual__()",
"# Tested on CentOS 5.8",
"if",
"__grains__",
"[",
"'os_family'",
"]",
"==",
"'RedH... | List all queued and running jobs or only those with
an optional 'tag'.
CLI Example:
.. code-block:: bash
salt '*' at.atq
salt '*' at.atq [tag]
salt '*' at.atq [job number] | [
"List",
"all",
"queued",
"and",
"running",
"jobs",
"or",
"only",
"those",
"with",
"an",
"optional",
"tag",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L63-L163 | train |
saltstack/salt | salt/modules/at.py | atrm | def atrm(*args):
'''
Remove jobs from the queue.
CLI Example:
.. code-block:: bash
salt '*' at.atrm <jobid> <jobid> .. <jobid>
salt '*' at.atrm all
salt '*' at.atrm all [tag]
'''
# Need to do this here also since we use atq()
if not salt.utils.path.which('at'):
... | python | def atrm(*args):
'''
Remove jobs from the queue.
CLI Example:
.. code-block:: bash
salt '*' at.atrm <jobid> <jobid> .. <jobid>
salt '*' at.atrm all
salt '*' at.atrm all [tag]
'''
# Need to do this here also since we use atq()
if not salt.utils.path.which('at'):
... | [
"def",
"atrm",
"(",
"*",
"args",
")",
":",
"# Need to do this here also since we use atq()",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'at'",
")",
":",
"return",
"'\\'at.atrm\\' is not available.'",
"if",
"not",
"args",
":",
"return",
... | Remove jobs from the queue.
CLI Example:
.. code-block:: bash
salt '*' at.atrm <jobid> <jobid> .. <jobid>
salt '*' at.atrm all
salt '*' at.atrm all [tag] | [
"Remove",
"jobs",
"from",
"the",
"queue",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L166-L207 | train |
saltstack/salt | salt/modules/at.py | at | def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' ... | python | def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' ... | [
"def",
"at",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0103",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"return",
"{",
"'jobs'",
":",
"[",
"]",
"}",
"# Shim to produce output similar to what __virtual__() should do",
"# but _... | Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscri... | [
"Add",
"a",
"job",
"to",
"the",
"queue",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L210-L263 | train |
saltstack/salt | salt/modules/at.py | atc | def atc(jobid):
'''
Print the at(1) script that will run for the passed job
id. This is mostly for debugging so the output will
just be text.
CLI Example:
.. code-block:: bash
salt '*' at.atc <jobid>
'''
# Shim to produce output similar to what __virtual__() should do
# bu... | python | def atc(jobid):
'''
Print the at(1) script that will run for the passed job
id. This is mostly for debugging so the output will
just be text.
CLI Example:
.. code-block:: bash
salt '*' at.atc <jobid>
'''
# Shim to produce output similar to what __virtual__() should do
# bu... | [
"def",
"atc",
"(",
"jobid",
")",
":",
"# Shim to produce output similar to what __virtual__() should do",
"# but __salt__ isn't available in __virtual__()",
"output",
"=",
"_cmd",
"(",
"'at'",
",",
"'-c'",
",",
"six",
".",
"text_type",
"(",
"jobid",
")",
")",
"if",
"o... | Print the at(1) script that will run for the passed job
id. This is mostly for debugging so the output will
just be text.
CLI Example:
.. code-block:: bash
salt '*' at.atc <jobid> | [
"Print",
"the",
"at",
"(",
"1",
")",
"script",
"that",
"will",
"run",
"for",
"the",
"passed",
"job",
"id",
".",
"This",
"is",
"mostly",
"for",
"debugging",
"so",
"the",
"output",
"will",
"just",
"be",
"text",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L266-L287 | train |
saltstack/salt | salt/modules/at.py | _atq | def _atq(**kwargs):
'''
Return match jobs list
'''
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get... | python | def _atq(**kwargs):
'''
Return match jobs list
'''
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get... | [
"def",
"_atq",
"(",
"*",
"*",
"kwargs",
")",
":",
"jobs",
"=",
"[",
"]",
"runas",
"=",
"kwargs",
".",
"get",
"(",
"'runas'",
",",
"None",
")",
"tag",
"=",
"kwargs",
".",
"get",
"(",
"'tag'",
",",
"None",
")",
"hour",
"=",
"kwargs",
".",
"get",
... | Return match jobs list | [
"Return",
"match",
"jobs",
"list"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at.py#L290-L368 | train |
saltstack/salt | salt/cli/support/__init__.py | _render_profile | def _render_profile(path, caller, runner):
'''
Render profile as Jinja2.
:param path:
:return:
'''
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)
return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner).strip() | python | def _render_profile(path, caller, runner):
'''
Render profile as Jinja2.
:param path:
:return:
'''
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)
return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner).strip() | [
"def",
"_render_profile",
"(",
"path",
",",
"caller",
",",
"runner",
")",
":",
"env",
"=",
"jinja2",
".",
"Environment",
"(",
"loader",
"=",
"jinja2",
".",
"FileSystemLoader",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
")",
",",
"trim_bl... | Render profile as Jinja2.
:param path:
:return: | [
"Render",
"profile",
"as",
"Jinja2",
".",
":",
"param",
"path",
":",
":",
"return",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L15-L22 | train |
saltstack/salt | salt/cli/support/__init__.py | get_profile | def get_profile(profile, caller, runner):
'''
Get profile.
:param profile:
:return:
'''
profiles = profile.split(',')
data = {}
for profile in profiles:
if os.path.basename(profile) == profile:
profile = profile.split('.')[0] # Trim extension if someone added it
... | python | def get_profile(profile, caller, runner):
'''
Get profile.
:param profile:
:return:
'''
profiles = profile.split(',')
data = {}
for profile in profiles:
if os.path.basename(profile) == profile:
profile = profile.split('.')[0] # Trim extension if someone added it
... | [
"def",
"get_profile",
"(",
"profile",
",",
"caller",
",",
"runner",
")",
":",
"profiles",
"=",
"profile",
".",
"split",
"(",
"','",
")",
"data",
"=",
"{",
"}",
"for",
"profile",
"in",
"profiles",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
... | Get profile.
:param profile:
:return: | [
"Get",
"profile",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L25-L52 | train |
saltstack/salt | salt/cli/support/__init__.py | get_profiles | def get_profiles(config):
'''
Get available profiles.
:return:
'''
profiles = []
for profile_name in os.listdir(os.path.join(os.path.dirname(__file__), 'profiles')):
if profile_name.endswith('.yml'):
profiles.append(profile_name.split('.')[0])
return sorted(profiles) | python | def get_profiles(config):
'''
Get available profiles.
:return:
'''
profiles = []
for profile_name in os.listdir(os.path.join(os.path.dirname(__file__), 'profiles')):
if profile_name.endswith('.yml'):
profiles.append(profile_name.split('.')[0])
return sorted(profiles) | [
"def",
"get_profiles",
"(",
"config",
")",
":",
"profiles",
"=",
"[",
"]",
"for",
"profile_name",
"in",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'profiles'",
")",
... | Get available profiles.
:return: | [
"Get",
"available",
"profiles",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L55-L66 | train |
saltstack/salt | salt/utils/user.py | get_user | def get_user():
'''
Get the current user
'''
if HAS_PWD:
ret = pwd.getpwuid(os.geteuid()).pw_name
elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:
ret = salt.utils.win_functions.get_current_user()
else:
raise CommandExecutionError(
'Required exte... | python | def get_user():
'''
Get the current user
'''
if HAS_PWD:
ret = pwd.getpwuid(os.geteuid()).pw_name
elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:
ret = salt.utils.win_functions.get_current_user()
else:
raise CommandExecutionError(
'Required exte... | [
"def",
"get_user",
"(",
")",
":",
"if",
"HAS_PWD",
":",
"ret",
"=",
"pwd",
".",
"getpwuid",
"(",
"os",
".",
"geteuid",
"(",
")",
")",
".",
"pw_name",
"elif",
"HAS_WIN_FUNCTIONS",
"and",
"salt",
".",
"utils",
".",
"win_functions",
".",
"HAS_WIN32",
":",... | Get the current user | [
"Get",
"the",
"current",
"user"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L54-L65 | train |
saltstack/salt | salt/utils/user.py | get_uid | def get_uid(user=None):
'''
Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned.
'''
if not HAS_PWD:
return None
elif user i... | python | def get_uid(user=None):
'''
Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned.
'''
if not HAS_PWD:
return None
elif user i... | [
"def",
"get_uid",
"(",
"user",
"=",
"None",
")",
":",
"if",
"not",
"HAS_PWD",
":",
"return",
"None",
"elif",
"user",
"is",
"None",
":",
"try",
":",
"return",
"os",
".",
"geteuid",
"(",
")",
"except",
"AttributeError",
":",
"return",
"None",
"else",
"... | Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned. | [
"Get",
"the",
"uid",
"for",
"a",
"given",
"user",
"name",
".",
"If",
"no",
"user",
"given",
"the",
"current",
"euid",
"will",
"be",
"returned",
".",
"If",
"the",
"user",
"does",
"not",
"exist",
"None",
"will",
"be",
"returned",
".",
"On",
"systems",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L69-L86 | train |
saltstack/salt | salt/utils/user.py | _win_user_token_is_admin | def _win_user_token_is_admin(user_token):
'''
Using the win32 api, determine if the user with token 'user_token' has
administrator rights.
See MSDN entry here:
http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx
'''
class SID_IDENTIFIER_AUTHORITY(ctypes.Structure):
_fie... | python | def _win_user_token_is_admin(user_token):
'''
Using the win32 api, determine if the user with token 'user_token' has
administrator rights.
See MSDN entry here:
http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx
'''
class SID_IDENTIFIER_AUTHORITY(ctypes.Structure):
_fie... | [
"def",
"_win_user_token_is_admin",
"(",
"user_token",
")",
":",
"class",
"SID_IDENTIFIER_AUTHORITY",
"(",
"ctypes",
".",
"Structure",
")",
":",
"_fields_",
"=",
"[",
"(",
"\"byte0\"",
",",
"ctypes",
".",
"c_byte",
")",
",",
"(",
"\"byte1\"",
",",
"ctypes",
"... | Using the win32 api, determine if the user with token 'user_token' has
administrator rights.
See MSDN entry here:
http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx | [
"Using",
"the",
"win32",
"api",
"determine",
"if",
"the",
"user",
"with",
"token",
"user_token",
"has",
"administrator",
"rights",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L89-L131 | train |
saltstack/salt | salt/utils/user.py | get_specific_user | def get_specific_user():
'''
Get a user name for publishing. If you find the user is "root" attempt to be
more specific
'''
user = get_user()
if salt.utils.platform.is_windows():
if _win_current_user_is_admin():
return 'sudo_{0}'.format(user)
else:
env_vars = ('SU... | python | def get_specific_user():
'''
Get a user name for publishing. If you find the user is "root" attempt to be
more specific
'''
user = get_user()
if salt.utils.platform.is_windows():
if _win_current_user_is_admin():
return 'sudo_{0}'.format(user)
else:
env_vars = ('SU... | [
"def",
"get_specific_user",
"(",
")",
":",
"user",
"=",
"get_user",
"(",
")",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"if",
"_win_current_user_is_admin",
"(",
")",
":",
"return",
"'sudo_{0}'",
".",
"format",
"(",
"u... | Get a user name for publishing. If you find the user is "root" attempt to be
more specific | [
"Get",
"a",
"user",
"name",
"for",
"publishing",
".",
"If",
"you",
"find",
"the",
"user",
"is",
"root",
"attempt",
"to",
"be",
"more",
"specific"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L142-L157 | train |
saltstack/salt | salt/utils/user.py | chugid | def chugid(runas, group=None):
'''
Change the current process to belong to the specified user (and the groups
to which it belongs)
'''
uinfo = pwd.getpwnam(runas)
supgroups = []
supgroups_seen = set()
if group:
try:
target_pw_gid = grp.getgrnam(group).gr_gid
... | python | def chugid(runas, group=None):
'''
Change the current process to belong to the specified user (and the groups
to which it belongs)
'''
uinfo = pwd.getpwnam(runas)
supgroups = []
supgroups_seen = set()
if group:
try:
target_pw_gid = grp.getgrnam(group).gr_gid
... | [
"def",
"chugid",
"(",
"runas",
",",
"group",
"=",
"None",
")",
":",
"uinfo",
"=",
"pwd",
".",
"getpwnam",
"(",
"runas",
")",
"supgroups",
"=",
"[",
"]",
"supgroups_seen",
"=",
"set",
"(",
")",
"if",
"group",
":",
"try",
":",
"target_pw_gid",
"=",
"... | Change the current process to belong to the specified user (and the groups
to which it belongs) | [
"Change",
"the",
"current",
"process",
"to",
"belong",
"to",
"the",
"specified",
"user",
"(",
"and",
"the",
"groups",
"to",
"which",
"it",
"belongs",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L160-L229 | train |
saltstack/salt | salt/utils/user.py | chugid_and_umask | def chugid_and_umask(runas, umask, group=None):
'''
Helper method for for subprocess.Popen to initialise uid/gid and umask
for the new process.
'''
set_runas = False
set_grp = False
current_user = getpass.getuser()
if runas and runas != current_user:
set_runas = True
run... | python | def chugid_and_umask(runas, umask, group=None):
'''
Helper method for for subprocess.Popen to initialise uid/gid and umask
for the new process.
'''
set_runas = False
set_grp = False
current_user = getpass.getuser()
if runas and runas != current_user:
set_runas = True
run... | [
"def",
"chugid_and_umask",
"(",
"runas",
",",
"umask",
",",
"group",
"=",
"None",
")",
":",
"set_runas",
"=",
"False",
"set_grp",
"=",
"False",
"current_user",
"=",
"getpass",
".",
"getuser",
"(",
")",
"if",
"runas",
"and",
"runas",
"!=",
"current_user",
... | Helper method for for subprocess.Popen to initialise uid/gid and umask
for the new process. | [
"Helper",
"method",
"for",
"for",
"subprocess",
".",
"Popen",
"to",
"initialise",
"uid",
"/",
"gid",
"and",
"umask",
"for",
"the",
"new",
"process",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L232-L257 | train |
saltstack/salt | salt/utils/user.py | get_default_group | def get_default_group(user):
'''
Returns the specified user's default group. If the user doesn't exist, a
KeyError will be raised.
'''
return grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name \
if HAS_GRP and HAS_PWD \
else None | python | def get_default_group(user):
'''
Returns the specified user's default group. If the user doesn't exist, a
KeyError will be raised.
'''
return grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name \
if HAS_GRP and HAS_PWD \
else None | [
"def",
"get_default_group",
"(",
"user",
")",
":",
"return",
"grp",
".",
"getgrgid",
"(",
"pwd",
".",
"getpwnam",
"(",
"user",
")",
".",
"pw_gid",
")",
".",
"gr_name",
"if",
"HAS_GRP",
"and",
"HAS_PWD",
"else",
"None"
] | Returns the specified user's default group. If the user doesn't exist, a
KeyError will be raised. | [
"Returns",
"the",
"specified",
"user",
"s",
"default",
"group",
".",
"If",
"the",
"user",
"doesn",
"t",
"exist",
"a",
"KeyError",
"will",
"be",
"raised",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L260-L267 | train |
saltstack/salt | salt/utils/user.py | get_group_list | def get_group_list(user, include_default=True):
'''
Returns a list of all of the system group names of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
group_names = None
ugroups = set()
if hasattr(os, 'getgrouplist'):
# Try os.getgroupli... | python | def get_group_list(user, include_default=True):
'''
Returns a list of all of the system group names of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
group_names = None
ugroups = set()
if hasattr(os, 'getgrouplist'):
# Try os.getgroupli... | [
"def",
"get_group_list",
"(",
"user",
",",
"include_default",
"=",
"True",
")",
":",
"if",
"HAS_GRP",
"is",
"False",
"or",
"HAS_PWD",
"is",
"False",
":",
"return",
"[",
"]",
"group_names",
"=",
"None",
"ugroups",
"=",
"set",
"(",
")",
"if",
"hasattr",
... | Returns a list of all of the system group names of which the user
is a member. | [
"Returns",
"a",
"list",
"of",
"all",
"of",
"the",
"system",
"group",
"names",
"of",
"which",
"the",
"user",
"is",
"a",
"member",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L270-L326 | train |
saltstack/salt | salt/utils/user.py | get_group_dict | def get_group_dict(user=None, include_default=True):
'''
Returns a dict of all of the system groups as keys, and group ids
as values, of which the user is a member.
E.g.: {'staff': 501, 'sudo': 27}
'''
if HAS_GRP is False or HAS_PWD is False:
return {}
group_dict = {}
group_names... | python | def get_group_dict(user=None, include_default=True):
'''
Returns a dict of all of the system groups as keys, and group ids
as values, of which the user is a member.
E.g.: {'staff': 501, 'sudo': 27}
'''
if HAS_GRP is False or HAS_PWD is False:
return {}
group_dict = {}
group_names... | [
"def",
"get_group_dict",
"(",
"user",
"=",
"None",
",",
"include_default",
"=",
"True",
")",
":",
"if",
"HAS_GRP",
"is",
"False",
"or",
"HAS_PWD",
"is",
"False",
":",
"return",
"{",
"}",
"group_dict",
"=",
"{",
"}",
"group_names",
"=",
"get_group_list",
... | Returns a dict of all of the system groups as keys, and group ids
as values, of which the user is a member.
E.g.: {'staff': 501, 'sudo': 27} | [
"Returns",
"a",
"dict",
"of",
"all",
"of",
"the",
"system",
"groups",
"as",
"keys",
"and",
"group",
"ids",
"as",
"values",
"of",
"which",
"the",
"user",
"is",
"a",
"member",
".",
"E",
".",
"g",
".",
":",
"{",
"staff",
":",
"501",
"sudo",
":",
"27... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L329-L341 | train |
saltstack/salt | salt/utils/user.py | get_gid_list | def get_gid_list(user, include_default=True):
'''
Returns a list of all of the system group IDs of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
gid_list = list(
six.itervalues(
get_group_dict(user, include_default=include_default)... | python | def get_gid_list(user, include_default=True):
'''
Returns a list of all of the system group IDs of which the user
is a member.
'''
if HAS_GRP is False or HAS_PWD is False:
return []
gid_list = list(
six.itervalues(
get_group_dict(user, include_default=include_default)... | [
"def",
"get_gid_list",
"(",
"user",
",",
"include_default",
"=",
"True",
")",
":",
"if",
"HAS_GRP",
"is",
"False",
"or",
"HAS_PWD",
"is",
"False",
":",
"return",
"[",
"]",
"gid_list",
"=",
"list",
"(",
"six",
".",
"itervalues",
"(",
"get_group_dict",
"("... | Returns a list of all of the system group IDs of which the user
is a member. | [
"Returns",
"a",
"list",
"of",
"all",
"of",
"the",
"system",
"group",
"IDs",
"of",
"which",
"the",
"user",
"is",
"a",
"member",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L344-L356 | train |
saltstack/salt | salt/utils/user.py | get_gid | def get_gid(group=None):
'''
Get the gid for a given group name. If no group given, the current egid
will be returned. If the group does not exist, None will be returned. On
systems which do not support grp or os.getegid it will return None.
'''
if not HAS_GRP:
return None
if group i... | python | def get_gid(group=None):
'''
Get the gid for a given group name. If no group given, the current egid
will be returned. If the group does not exist, None will be returned. On
systems which do not support grp or os.getegid it will return None.
'''
if not HAS_GRP:
return None
if group i... | [
"def",
"get_gid",
"(",
"group",
"=",
"None",
")",
":",
"if",
"not",
"HAS_GRP",
":",
"return",
"None",
"if",
"group",
"is",
"None",
":",
"try",
":",
"return",
"os",
".",
"getegid",
"(",
")",
"except",
"AttributeError",
":",
"return",
"None",
"else",
"... | Get the gid for a given group name. If no group given, the current egid
will be returned. If the group does not exist, None will be returned. On
systems which do not support grp or os.getegid it will return None. | [
"Get",
"the",
"gid",
"for",
"a",
"given",
"group",
"name",
".",
"If",
"no",
"group",
"given",
"the",
"current",
"egid",
"will",
"be",
"returned",
".",
"If",
"the",
"group",
"does",
"not",
"exist",
"None",
"will",
"be",
"returned",
".",
"On",
"systems",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L359-L376 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | html_override_tool | def html_override_tool():
'''
Bypass the normal handler and serve HTML for all URLs
The ``app_path`` setting must be non-empty and the request must ask for
``text/html`` in the ``Accept`` header.
'''
apiopts = cherrypy.config['apiopts']
request = cherrypy.request
url_blacklist = (
... | python | def html_override_tool():
'''
Bypass the normal handler and serve HTML for all URLs
The ``app_path`` setting must be non-empty and the request must ask for
``text/html`` in the ``Accept`` header.
'''
apiopts = cherrypy.config['apiopts']
request = cherrypy.request
url_blacklist = (
... | [
"def",
"html_override_tool",
"(",
")",
":",
"apiopts",
"=",
"cherrypy",
".",
"config",
"[",
"'apiopts'",
"]",
"request",
"=",
"cherrypy",
".",
"request",
"url_blacklist",
"=",
"(",
"apiopts",
".",
"get",
"(",
"'app_path'",
",",
"'/app'",
")",
",",
"apiopts... | Bypass the normal handler and serve HTML for all URLs
The ``app_path`` setting must be non-empty and the request must ask for
``text/html`` in the ``Accept`` header. | [
"Bypass",
"the",
"normal",
"handler",
"and",
"serve",
"HTML",
"for",
"all",
"URLs"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L649-L681 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_token_tool | def salt_token_tool():
'''
If the custom authentication header is supplied, put it in the cookie dict
so the rest of the session-based auth works as intended
'''
x_auth = cherrypy.request.headers.get('X-Auth-Token', None)
# X-Auth-Token header trumps session cookie
if x_auth:
cherry... | python | def salt_token_tool():
'''
If the custom authentication header is supplied, put it in the cookie dict
so the rest of the session-based auth works as intended
'''
x_auth = cherrypy.request.headers.get('X-Auth-Token', None)
# X-Auth-Token header trumps session cookie
if x_auth:
cherry... | [
"def",
"salt_token_tool",
"(",
")",
":",
"x_auth",
"=",
"cherrypy",
".",
"request",
".",
"headers",
".",
"get",
"(",
"'X-Auth-Token'",
",",
"None",
")",
"# X-Auth-Token header trumps session cookie",
"if",
"x_auth",
":",
"cherrypy",
".",
"request",
".",
"cookie"... | If the custom authentication header is supplied, put it in the cookie dict
so the rest of the session-based auth works as intended | [
"If",
"the",
"custom",
"authentication",
"header",
"is",
"supplied",
"put",
"it",
"in",
"the",
"cookie",
"dict",
"so",
"the",
"rest",
"of",
"the",
"session",
"-",
"based",
"auth",
"works",
"as",
"intended"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L684-L693 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_api_acl_tool | def salt_api_acl_tool(username, request):
'''
..versionadded:: 2016.3.0
Verifies user requests against the API whitelist. (User/IP pair)
in order to provide whitelisting for the API similar to the
master, but over the API.
..code-block:: yaml
rest_cherrypy:
api_acl:
... | python | def salt_api_acl_tool(username, request):
'''
..versionadded:: 2016.3.0
Verifies user requests against the API whitelist. (User/IP pair)
in order to provide whitelisting for the API similar to the
master, but over the API.
..code-block:: yaml
rest_cherrypy:
api_acl:
... | [
"def",
"salt_api_acl_tool",
"(",
"username",
",",
"request",
")",
":",
"failure_str",
"=",
"(",
"\"[api_acl] Authentication failed for \"",
"\"user %s from IP %s\"",
")",
"success_str",
"=",
"(",
"\"[api_acl] Authentication sucessful for \"",
"\"user %s from IP %s\"",
")",
"p... | ..versionadded:: 2016.3.0
Verifies user requests against the API whitelist. (User/IP pair)
in order to provide whitelisting for the API similar to the
master, but over the API.
..code-block:: yaml
rest_cherrypy:
api_acl:
users:
'*':
... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L696-L762 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | salt_ip_verify_tool | def salt_ip_verify_tool():
'''
If there is a list of restricted IPs, verify current
client is coming from one of those IPs.
'''
# This is overly cumbersome and crude,
# But, it's also safe... ish...
salt_config = cherrypy.config.get('saltopts', None)
if salt_config:
cherrypy_conf... | python | def salt_ip_verify_tool():
'''
If there is a list of restricted IPs, verify current
client is coming from one of those IPs.
'''
# This is overly cumbersome and crude,
# But, it's also safe... ish...
salt_config = cherrypy.config.get('saltopts', None)
if salt_config:
cherrypy_conf... | [
"def",
"salt_ip_verify_tool",
"(",
")",
":",
"# This is overly cumbersome and crude,",
"# But, it's also safe... ish...",
"salt_config",
"=",
"cherrypy",
".",
"config",
".",
"get",
"(",
"'saltopts'",
",",
"None",
")",
"if",
"salt_config",
":",
"cherrypy_conf",
"=",
"s... | If there is a list of restricted IPs, verify current
client is coming from one of those IPs. | [
"If",
"there",
"is",
"a",
"list",
"of",
"restricted",
"IPs",
"verify",
"current",
"client",
"is",
"coming",
"from",
"one",
"of",
"those",
"IPs",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L765-L783 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | cors_tool | def cors_tool():
'''
Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight
request swap out the default handler with a simple, single-purpose handler
that verifies the request and provides a valid CORS response.
'''
req_head = che... | python | def cors_tool():
'''
Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight
request swap out the default handler with a simple, single-purpose handler
that verifies the request and provides a valid CORS response.
'''
req_head = che... | [
"def",
"cors_tool",
"(",
")",
":",
"req_head",
"=",
"cherrypy",
".",
"request",
".",
"headers",
"resp_head",
"=",
"cherrypy",
".",
"response",
".",
"headers",
"# Always set response headers necessary for 'simple' CORS.",
"resp_head",
"[",
"'Access-Control-Allow-Origin'",
... | Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight
request swap out the default handler with a simple, single-purpose handler
that verifies the request and provides a valid CORS response. | [
"Handle",
"both",
"simple",
"and",
"complex",
"CORS",
"requests"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L798-L840 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_handler | def hypermedia_handler(*args, **kwargs):
'''
Determine the best output format based on the Accept header, execute the
regular handler, and transform the output to the request content type (even
if it's an error).
:param args: Pass args through to the main handler
:param kwargs: Pass kwargs thro... | python | def hypermedia_handler(*args, **kwargs):
'''
Determine the best output format based on the Accept header, execute the
regular handler, and transform the output to the request content type (even
if it's an error).
:param args: Pass args through to the main handler
:param kwargs: Pass kwargs thro... | [
"def",
"hypermedia_handler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Execute the real handler. Handle or pass-through any errors we know how",
"# to handle (auth & HTTP errors). Reformat any errors we don't know how to",
"# handle as a data structure.",
"try",
":",
"c... | Determine the best output format based on the Accept header, execute the
regular handler, and transform the output to the request content type (even
if it's an error).
:param args: Pass args through to the main handler
:param kwargs: Pass kwargs through to the main handler | [
"Determine",
"the",
"best",
"output",
"format",
"based",
"on",
"the",
"Accept",
"header",
"execute",
"the",
"regular",
"handler",
"and",
"transform",
"the",
"output",
"to",
"the",
"request",
"content",
"type",
"(",
"even",
"if",
"it",
"s",
"an",
"error",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L853-L918 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_out | def hypermedia_out():
'''
Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the
requested content type
'''
request = cherrypy.serving.request
request._hypermedia_inner_handler = request.handler
# If handler... | python | def hypermedia_out():
'''
Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the
requested content type
'''
request = cherrypy.serving.request
request._hypermedia_inner_handler = request.handler
# If handler... | [
"def",
"hypermedia_out",
"(",
")",
":",
"request",
"=",
"cherrypy",
".",
"serving",
".",
"request",
"request",
".",
"_hypermedia_inner_handler",
"=",
"request",
".",
"handler",
"# If handler has been explicitly set to None, don't override.",
"if",
"request",
".",
"handl... | Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the
requested content type | [
"Determine",
"the",
"best",
"handler",
"for",
"the",
"requested",
"content",
"type"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L921-L933 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | process_request_body | def process_request_body(fn):
'''
A decorator to skip a processor function if process_request_body is False
'''
@functools.wraps(fn)
def wrapped(*args, **kwargs): # pylint: disable=C0111
if cherrypy.request.process_request_body is not False:
fn(*args, **kwargs)
return wrappe... | python | def process_request_body(fn):
'''
A decorator to skip a processor function if process_request_body is False
'''
@functools.wraps(fn)
def wrapped(*args, **kwargs): # pylint: disable=C0111
if cherrypy.request.process_request_body is not False:
fn(*args, **kwargs)
return wrappe... | [
"def",
"process_request_body",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0111",
"if",
"cherrypy",
".",
"request",
".",
"process_request_bo... | A decorator to skip a processor function if process_request_body is False | [
"A",
"decorator",
"to",
"skip",
"a",
"processor",
"function",
"if",
"process_request_body",
"is",
"False"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L936-L944 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | urlencoded_processor | def urlencoded_processor(entity):
'''
Accept x-www-form-urlencoded data (run through CherryPy's formatter)
and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with
key-value pairs, any more complicated requirements (e.g. compound
commands... | python | def urlencoded_processor(entity):
'''
Accept x-www-form-urlencoded data (run through CherryPy's formatter)
and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with
key-value pairs, any more complicated requirements (e.g. compound
commands... | [
"def",
"urlencoded_processor",
"(",
"entity",
")",
":",
"# First call out to CherryPy's default processor",
"cherrypy",
".",
"_cpreqbody",
".",
"process_urlencoded",
"(",
"entity",
")",
"cherrypy",
".",
"_cpreqbody",
".",
"process_urlencoded",
"(",
"entity",
")",
"cherr... | Accept x-www-form-urlencoded data (run through CherryPy's formatter)
and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with
key-value pairs, any more complicated requirements (e.g. compound
commands) must instead be delivered via JSON or YAML.
... | [
"Accept",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"data",
"(",
"run",
"through",
"CherryPy",
"s",
"formatter",
")",
"and",
"reformat",
"it",
"into",
"a",
"Low",
"State",
"data",
"structure",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L947-L969 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | json_processor | def json_processor(entity):
'''
Unserialize raw POST data in JSON format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | python | def json_processor(entity):
'''
Unserialize raw POST data in JSON format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | [
"def",
"json_processor",
"(",
"entity",
")",
":",
"if",
"six",
".",
"PY2",
":",
"body",
"=",
"entity",
".",
"fp",
".",
"read",
"(",
")",
"else",
":",
"# https://github.com/cherrypy/cherrypy/pull/1572",
"contents",
"=",
"BytesIO",
"(",
")",
"body",
"=",
"en... | Unserialize raw POST data in JSON format to a Python data structure.
:param entity: raw POST data | [
"Unserialize",
"raw",
"POST",
"data",
"in",
"JSON",
"format",
"to",
"a",
"Python",
"data",
"structure",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L973-L993 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | yaml_processor | def yaml_processor(entity):
'''
Unserialize raw POST data in YAML format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | python | def yaml_processor(entity):
'''
Unserialize raw POST data in YAML format to a Python data structure.
:param entity: raw POST data
'''
if six.PY2:
body = entity.fp.read()
else:
# https://github.com/cherrypy/cherrypy/pull/1572
contents = BytesIO()
body = entity.fp.... | [
"def",
"yaml_processor",
"(",
"entity",
")",
":",
"if",
"six",
".",
"PY2",
":",
"body",
"=",
"entity",
".",
"fp",
".",
"read",
"(",
")",
"else",
":",
"# https://github.com/cherrypy/cherrypy/pull/1572",
"contents",
"=",
"BytesIO",
"(",
")",
"body",
"=",
"en... | Unserialize raw POST data in YAML format to a Python data structure.
:param entity: raw POST data | [
"Unserialize",
"raw",
"POST",
"data",
"in",
"YAML",
"format",
"to",
"a",
"Python",
"data",
"structure",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L997-L1016 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | hypermedia_in | def hypermedia_in():
'''
Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data
and will place that data structure into the request object.
:raises HTTPError: if the request contains a Content-Type that we do not
hav... | python | def hypermedia_in():
'''
Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data
and will place that data structure into the request object.
:raises HTTPError: if the request contains a Content-Type that we do not
hav... | [
"def",
"hypermedia_in",
"(",
")",
":",
"# Be liberal in what you accept",
"ct_in_map",
"=",
"{",
"'application/x-www-form-urlencoded'",
":",
"urlencoded_processor",
",",
"'application/json'",
":",
"json_processor",
",",
"'application/x-yaml'",
":",
"yaml_processor",
",",
"'... | Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data
and will place that data structure into the request object.
:raises HTTPError: if the request contains a Content-Type that we do not
have a processor for | [
"Unserialize",
"POST",
"/",
"PUT",
"data",
"of",
"a",
"specified",
"Content",
"-",
"Type",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1045-L1074 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | lowdata_fmt | def lowdata_fmt():
'''
Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run.
'''
if cherrypy.request.method.upper() != 'POST':
return
data = cherrypy.request.unserialized_data
# if the data was sen... | python | def lowdata_fmt():
'''
Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run.
'''
if cherrypy.request.method.upper() != 'POST':
return
data = cherrypy.request.unserialized_data
# if the data was sen... | [
"def",
"lowdata_fmt",
"(",
")",
":",
"if",
"cherrypy",
".",
"request",
".",
"method",
".",
"upper",
"(",
")",
"!=",
"'POST'",
":",
"return",
"data",
"=",
"cherrypy",
".",
"request",
".",
"unserialized_data",
"# if the data was sent as urlencoded, we need to make i... | Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run. | [
"Validate",
"and",
"format",
"lowdata",
"from",
"incoming",
"unserialized",
"request",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1077-L1100 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | get_app | def get_app(opts):
'''
Returns a WSGI app and a configuration dictionary
'''
apiopts = opts.get(__name__.rsplit('.', 2)[-2], {}) # rest_cherrypy opts
# Add Salt and salt-api config options to the main CherryPy config dict
cherrypy.config['saltopts'] = opts
cherrypy.config['apiopts'] = apio... | python | def get_app(opts):
'''
Returns a WSGI app and a configuration dictionary
'''
apiopts = opts.get(__name__.rsplit('.', 2)[-2], {}) # rest_cherrypy opts
# Add Salt and salt-api config options to the main CherryPy config dict
cherrypy.config['saltopts'] = opts
cherrypy.config['apiopts'] = apio... | [
"def",
"get_app",
"(",
"opts",
")",
":",
"apiopts",
"=",
"opts",
".",
"get",
"(",
"__name__",
".",
"rsplit",
"(",
"'.'",
",",
"2",
")",
"[",
"-",
"2",
"]",
",",
"{",
"}",
")",
"# rest_cherrypy opts",
"# Add Salt and salt-api config options to the main Cherry... | Returns a WSGI app and a configuration dictionary | [
"Returns",
"a",
"WSGI",
"app",
"and",
"a",
"configuration",
"dictionary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2927-L2940 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | LowDataAdapter.exec_lowstate | def exec_lowstate(self, client=None, token=None):
'''
Pull a Low State data structure from request and execute the low-data
chunks through Salt. The low-data chunks will be updated to include the
authorization token for the current session.
'''
lowstate = cherrypy.request... | python | def exec_lowstate(self, client=None, token=None):
'''
Pull a Low State data structure from request and execute the low-data
chunks through Salt. The low-data chunks will be updated to include the
authorization token for the current session.
'''
lowstate = cherrypy.request... | [
"def",
"exec_lowstate",
"(",
"self",
",",
"client",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"lowstate",
"=",
"cherrypy",
".",
"request",
".",
"lowstate",
"# Release the session lock before executing any potentially",
"# long-running Salt commands. This allows di... | Pull a Low State data structure from request and execute the low-data
chunks through Salt. The low-data chunks will be updated to include the
authorization token for the current session. | [
"Pull",
"a",
"Low",
"State",
"data",
"structure",
"from",
"request",
"and",
"execute",
"the",
"low",
"-",
"data",
"chunks",
"through",
"Salt",
".",
"The",
"low",
"-",
"data",
"chunks",
"will",
"be",
"updated",
"to",
"include",
"the",
"authorization",
"toke... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1155-L1208 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | LowDataAdapter.POST | def POST(self, **kwargs):
'''
Send one or more Salt commands in the request body
.. http:post:: /
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
... | python | def POST(self, **kwargs):
'''
Send one or more Salt commands in the request body
.. http:post:: /
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
... | [
"def",
"POST",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"'return'",
":",
"list",
"(",
"self",
".",
"exec_lowstate",
"(",
"token",
"=",
"cherrypy",
".",
"session",
".",
"get",
"(",
"'token'",
")",
")",
")",
"}"
] | Send one or more Salt commands in the request body
.. http:post:: /
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
:status 200: |200|
:status 400:... | [
"Send",
"one",
"or",
"more",
"Salt",
"commands",
"in",
"the",
"request",
"body"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1251-L1310 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Minions.GET | def GET(self, mid=None):
'''
A convenience URL for getting lists of minions or getting minion
details
.. http:get:: /minions/(mid)
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|... | python | def GET(self, mid=None):
'''
A convenience URL for getting lists of minions or getting minion
details
.. http:get:: /minions/(mid)
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|... | [
"def",
"GET",
"(",
"self",
",",
"mid",
"=",
"None",
")",
":",
"cherrypy",
".",
"request",
".",
"lowstate",
"=",
"[",
"{",
"'client'",
":",
"'local'",
",",
"'tgt'",
":",
"mid",
"or",
"'*'",
",",
"'fun'",
":",
"'grains.items'",
",",
"}",
"]",
"return... | A convenience URL for getting lists of minions or getting minion
details
.. http:get:: /minions/(mid)
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:status 401: |401|
:status 406: |406|
**Ex... | [
"A",
"convenience",
"URL",
"for",
"getting",
"lists",
"of",
"minions",
"or",
"getting",
"minion",
"details"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1321-L1366 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Minions.POST | def POST(self, **kwargs):
'''
Start an execution command and immediately return the job id
.. http:post:: /minions
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |r... | python | def POST(self, **kwargs):
'''
Start an execution command and immediately return the job id
.. http:post:: /minions
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |r... | [
"def",
"POST",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"job_data",
"=",
"list",
"(",
"self",
".",
"exec_lowstate",
"(",
"client",
"=",
"'local_async'",
",",
"token",
"=",
"cherrypy",
".",
"session",
".",
"get",
"(",
"'token'",
")",
")",
")",
... | Start an execution command and immediately return the job id
.. http:post:: /minions
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:resheader Content-Type: |res_ct|
:status 200: |200|
... | [
"Start",
"an",
"execution",
"command",
"and",
"immediately",
"return",
"the",
"job",
"id"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1368-L1432 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Jobs.GET | def GET(self, jid=None, timeout=''):
'''
A convenience URL for getting lists of previously run jobs or getting
the return from a single job
.. http:get:: /jobs/(jid)
List jobs or show a single job from the job cache.
:reqheader X-Auth-Token: |req_token|
... | python | def GET(self, jid=None, timeout=''):
'''
A convenience URL for getting lists of previously run jobs or getting
the return from a single job
.. http:get:: /jobs/(jid)
List jobs or show a single job from the job cache.
:reqheader X-Auth-Token: |req_token|
... | [
"def",
"GET",
"(",
"self",
",",
"jid",
"=",
"None",
",",
"timeout",
"=",
"''",
")",
":",
"lowstate",
"=",
"{",
"'client'",
":",
"'runner'",
"}",
"if",
"jid",
":",
"lowstate",
".",
"update",
"(",
"{",
"'fun'",
":",
"'jobs.list_job'",
",",
"'jid'",
"... | A convenience URL for getting lists of previously run jobs or getting
the return from a single job
.. http:get:: /jobs/(jid)
List jobs or show a single job from the job cache.
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status... | [
"A",
"convenience",
"URL",
"for",
"getting",
"lists",
"of",
"previously",
"run",
"jobs",
"or",
"getting",
"the",
"return",
"from",
"a",
"single",
"job"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1440-L1548 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Keys.GET | def GET(self, mid=None):
'''
Show the list of minion keys or detail on a specific key
.. versionadded:: 2014.7.0
.. http:get:: /keys/(mid)
List all keys or show a specific key
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
... | python | def GET(self, mid=None):
'''
Show the list of minion keys or detail on a specific key
.. versionadded:: 2014.7.0
.. http:get:: /keys/(mid)
List all keys or show a specific key
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
... | [
"def",
"GET",
"(",
"self",
",",
"mid",
"=",
"None",
")",
":",
"if",
"mid",
":",
"lowstate",
"=",
"[",
"{",
"'client'",
":",
"'wheel'",
",",
"'fun'",
":",
"'key.finger'",
",",
"'match'",
":",
"mid",
",",
"}",
"]",
"else",
":",
"lowstate",
"=",
"["... | Show the list of minion keys or detail on a specific key
.. versionadded:: 2014.7.0
.. http:get:: /keys/(mid)
List all keys or show a specific key
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:status 200: |200|
:sta... | [
"Show",
"the",
"list",
"of",
"minion",
"keys",
"or",
"detail",
"on",
"a",
"specific",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1561-L1646 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Keys.POST | def POST(self, **kwargs):
r'''
Easily generate keys for a minion and auto-accept the new key
Accepts all the same parameters as the :py:func:`key.gen_accept
<salt.wheel.key.gen_accept>`.
.. note:: A note about ``curl``
Avoid using the ``-i`` flag or HTTP headers will... | python | def POST(self, **kwargs):
r'''
Easily generate keys for a minion and auto-accept the new key
Accepts all the same parameters as the :py:func:`key.gen_accept
<salt.wheel.key.gen_accept>`.
.. note:: A note about ``curl``
Avoid using the ``-i`` flag or HTTP headers will... | [
"def",
"POST",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"lowstate",
"=",
"cherrypy",
".",
"request",
".",
"lowstate",
"lowstate",
"[",
"0",
"]",
".",
"update",
"(",
"{",
"'client'",
":",
"'wheel'",
",",
"'fun'",
":",
"'key.gen_accept'",
",",
"... | r'''
Easily generate keys for a minion and auto-accept the new key
Accepts all the same parameters as the :py:func:`key.gen_accept
<salt.wheel.key.gen_accept>`.
.. note:: A note about ``curl``
Avoid using the ``-i`` flag or HTTP headers will be written and
produce... | [
"r",
"Easily",
"generate",
"keys",
"for",
"a",
"minion",
"and",
"auto",
"-",
"accept",
"the",
"new",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1649-L1752 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Login.POST | def POST(self, **kwargs):
'''
:ref:`Authenticate <rest_cherrypy-auth>` against Salt's eauth system
.. http:post:: /login
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:form eauth: the eau... | python | def POST(self, **kwargs):
'''
:ref:`Authenticate <rest_cherrypy-auth>` against Salt's eauth system
.. http:post:: /login
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:form eauth: the eau... | [
"def",
"POST",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"api",
".",
"_is_master_running",
"(",
")",
":",
"raise",
"salt",
".",
"exceptions",
".",
"SaltDaemonNotRunning",
"(",
"'Salt Master is not available.'",
")",
"# the url... | :ref:`Authenticate <rest_cherrypy-auth>` against Salt's eauth system
.. http:post:: /login
:reqheader X-Auth-Token: |req_token|
:reqheader Accept: |req_accept|
:reqheader Content-Type: |req_ct|
:form eauth: the eauth backend configured for the user
... | [
":",
"ref",
":",
"Authenticate",
"<rest_cherrypy",
"-",
"auth",
">",
"against",
"Salt",
"s",
"eauth",
"system"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1805-L1932 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Token.POST | def POST(self, **kwargs):
r'''
.. http:post:: /token
Generate a Salt eauth token
:status 200: |200|
:status 400: |400|
:status 401: |401|
**Example request:**
.. code-block:: bash
curl -sSk https://localhost:8000/token \
... | python | def POST(self, **kwargs):
r'''
.. http:post:: /token
Generate a Salt eauth token
:status 200: |200|
:status 400: |400|
:status 401: |401|
**Example request:**
.. code-block:: bash
curl -sSk https://localhost:8000/token \
... | [
"def",
"POST",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"creds",
"in",
"cherrypy",
".",
"request",
".",
"lowstate",
":",
"try",
":",
"creds",
".",
"update",
"(",
"{",
"'client'",
":",
"'runner'",
",",
"'fun'",
":",
"'auth.mk_token'",
",... | r'''
.. http:post:: /token
Generate a Salt eauth token
:status 200: |200|
:status 400: |400|
:status 401: |401|
**Example request:**
.. code-block:: bash
curl -sSk https://localhost:8000/token \
-H 'Content-type: ap... | [
"r",
"..",
"http",
":",
"post",
"::",
"/",
"token"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1964-L2016 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Events._is_valid_token | def _is_valid_token(self, auth_token):
'''
Check if this is a valid salt-api token or valid Salt token
salt-api tokens are regular session tokens that tie back to a real Salt
token. Salt tokens are tokens generated by Salt's eauth system.
:return bool: True if valid, False if n... | python | def _is_valid_token(self, auth_token):
'''
Check if this is a valid salt-api token or valid Salt token
salt-api tokens are regular session tokens that tie back to a real Salt
token. Salt tokens are tokens generated by Salt's eauth system.
:return bool: True if valid, False if n... | [
"def",
"_is_valid_token",
"(",
"self",
",",
"auth_token",
")",
":",
"# Make sure that auth token is hex. If it's None, or something other",
"# than hex, this will raise a ValueError.",
"try",
":",
"int",
"(",
"auth_token",
",",
"16",
")",
"except",
"(",
"TypeError",
",",
... | Check if this is a valid salt-api token or valid Salt token
salt-api tokens are regular session tokens that tie back to a real Salt
token. Salt tokens are tokens generated by Salt's eauth system.
:return bool: True if valid, False if not valid. | [
"Check",
"if",
"this",
"is",
"a",
"valid",
"salt",
"-",
"api",
"token",
"or",
"valid",
"Salt",
"token"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2191-L2219 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Events.GET | def GET(self, token=None, salt_token=None):
r'''
An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each
event is formatted as JSON.
.. http:get:: /events
:status 200: |200|
:status 401: |401|
... | python | def GET(self, token=None, salt_token=None):
r'''
An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each
event is formatted as JSON.
.. http:get:: /events
:status 200: |200|
:status 401: |401|
... | [
"def",
"GET",
"(",
"self",
",",
"token",
"=",
"None",
",",
"salt_token",
"=",
"None",
")",
":",
"cookies",
"=",
"cherrypy",
".",
"request",
".",
"cookie",
"auth_token",
"=",
"token",
"or",
"salt_token",
"or",
"(",
"cookies",
"[",
"'session_id'",
"]",
"... | r'''
An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each
event is formatted as JSON.
.. http:get:: /events
:status 200: |200|
:status 401: |401|
:status 406: |406|
:query token... | [
"r",
"An",
"HTTP",
"stream",
"of",
"the",
"Salt",
"master",
"event",
"bus"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2221-L2380 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | WebsocketEndpoint.GET | def GET(self, token=None, **kwargs):
'''
Return a websocket connection of Salt's event stream
.. http:get:: /ws/(token)
:query format_events: The event stream will undergo server-side
formatting if the ``format_events`` URL parameter is included
in the request. ... | python | def GET(self, token=None, **kwargs):
'''
Return a websocket connection of Salt's event stream
.. http:get:: /ws/(token)
:query format_events: The event stream will undergo server-side
formatting if the ``format_events`` URL parameter is included
in the request. ... | [
"def",
"GET",
"(",
"self",
",",
"token",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Pulling the session token from an URL param is a workaround for",
"# browsers not supporting CORS in the EventSource API.",
"if",
"token",
":",
"orig_session",
",",
"_",
"=",
"ch... | Return a websocket connection of Salt's event stream
.. http:get:: /ws/(token)
:query format_events: The event stream will undergo server-side
formatting if the ``format_events`` URL parameter is included
in the request. This can be useful to avoid formatting on the
... | [
"Return",
"a",
"websocket",
"connection",
"of",
"Salt",
"s",
"event",
"stream"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2413-L2573 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | Webhook.POST | def POST(self, *args, **kwargs):
'''
Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
... | python | def POST(self, *args, **kwargs):
'''
Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
... | [
"def",
"POST",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tag",
"=",
"'/'",
".",
"join",
"(",
"itertools",
".",
"chain",
"(",
"self",
".",
"tag_base",
",",
"args",
")",
")",
"data",
"=",
"cherrypy",
".",
"serving",
".",
... | Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
.. code-block:: bash
curl -sS localhos... | [
"Fire",
"an",
"event",
"in",
"Salt",
"with",
"a",
"custom",
"event",
"tag",
"and",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2643-L2739 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | App.GET | def GET(self, *args):
'''
Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5
history API.
.. http::get:: /app
:reqheader X-Auth-Token: |req_token|
:status 200: |200|
... | python | def GET(self, *args):
'''
Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5
history API.
.. http::get:: /app
:reqheader X-Auth-Token: |req_token|
:status 200: |200|
... | [
"def",
"GET",
"(",
"self",
",",
"*",
"args",
")",
":",
"apiopts",
"=",
"cherrypy",
".",
"config",
"[",
"'apiopts'",
"]",
"default_index",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"d... | Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5
history API.
.. http::get:: /app
:reqheader X-Auth-Token: |req_token|
:status 200: |200|
:status 401: |401| | [
"Serve",
"a",
"single",
"static",
"file",
"ignoring",
"the",
"remaining",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2783-L2803 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API._setattr_url_map | def _setattr_url_map(self):
'''
Set an attribute on the local instance for each key/val in url_map
CherryPy uses class attributes to resolve URLs.
'''
if self.apiopts.get('enable_sessions', True) is False:
url_blacklist = ['login', 'logout', 'minions', 'jobs']
... | python | def _setattr_url_map(self):
'''
Set an attribute on the local instance for each key/val in url_map
CherryPy uses class attributes to resolve URLs.
'''
if self.apiopts.get('enable_sessions', True) is False:
url_blacklist = ['login', 'logout', 'minions', 'jobs']
... | [
"def",
"_setattr_url_map",
"(",
"self",
")",
":",
"if",
"self",
".",
"apiopts",
".",
"get",
"(",
"'enable_sessions'",
",",
"True",
")",
"is",
"False",
":",
"url_blacklist",
"=",
"[",
"'login'",
",",
"'logout'",
",",
"'minions'",
",",
"'jobs'",
"]",
"else... | Set an attribute on the local instance for each key/val in url_map
CherryPy uses class attributes to resolve URLs. | [
"Set",
"an",
"attribute",
"on",
"the",
"local",
"instance",
"for",
"each",
"key",
"/",
"val",
"in",
"url_map"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2823-L2838 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API._update_url_map | def _update_url_map(self):
'''
Assemble any dynamic or configurable URLs
'''
if HAS_WEBSOCKETS:
self.url_map.update({
'ws': WebsocketEndpoint,
})
# Allow the Webhook URL to be overridden from the conf.
self.url_map.update({
... | python | def _update_url_map(self):
'''
Assemble any dynamic or configurable URLs
'''
if HAS_WEBSOCKETS:
self.url_map.update({
'ws': WebsocketEndpoint,
})
# Allow the Webhook URL to be overridden from the conf.
self.url_map.update({
... | [
"def",
"_update_url_map",
"(",
"self",
")",
":",
"if",
"HAS_WEBSOCKETS",
":",
"self",
".",
"url_map",
".",
"update",
"(",
"{",
"'ws'",
":",
"WebsocketEndpoint",
",",
"}",
")",
"# Allow the Webhook URL to be overridden from the conf.",
"self",
".",
"url_map",
".",
... | Assemble any dynamic or configurable URLs | [
"Assemble",
"any",
"dynamic",
"or",
"configurable",
"URLs"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2840-L2857 | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | API.get_conf | def get_conf(self):
'''
Combine the CherryPy configuration with the rest_cherrypy config values
pulled from the master config and return the CherryPy configuration
'''
conf = {
'global': {
'server.socket_host': self.apiopts.get('host', '0.0.0.0'),
... | python | def get_conf(self):
'''
Combine the CherryPy configuration with the rest_cherrypy config values
pulled from the master config and return the CherryPy configuration
'''
conf = {
'global': {
'server.socket_host': self.apiopts.get('host', '0.0.0.0'),
... | [
"def",
"get_conf",
"(",
"self",
")",
":",
"conf",
"=",
"{",
"'global'",
":",
"{",
"'server.socket_host'",
":",
"self",
".",
"apiopts",
".",
"get",
"(",
"'host'",
",",
"'0.0.0.0'",
")",
",",
"'server.socket_port'",
":",
"self",
".",
"apiopts",
".",
"get",... | Combine the CherryPy configuration with the rest_cherrypy config values
pulled from the master config and return the CherryPy configuration | [
"Combine",
"the",
"CherryPy",
"configuration",
"with",
"the",
"rest_cherrypy",
"config",
"values",
"pulled",
"from",
"the",
"master",
"config",
"and",
"return",
"the",
"CherryPy",
"configuration"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2866-L2924 | train |
saltstack/salt | salt/modules/gentoo_service.py | get_disabled | def get_disabled():
'''
Return a set of services that are installed but disabled
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=False,
... | python | def get_disabled():
'''
Return a set of services that are installed but disabled
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=False,
... | [
"def",
"get_disabled",
"(",
")",
":",
"(",
"enabled_services",
",",
"disabled_services",
")",
"=",
"_get_service_list",
"(",
"include_enabled",
"=",
"False",
",",
"include_disabled",
"=",
"True",
")",
"return",
"sorted",
"(",
"disabled_services",
")"
] | Return a set of services that are installed but disabled
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled | [
"Return",
"a",
"set",
"of",
"services",
"that",
"are",
"installed",
"but",
"disabled"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L107-L119 | train |
saltstack/salt | salt/modules/gentoo_service.py | available | def available(name):
'''
Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
... | python | def available(name):
'''
Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
... | [
"def",
"available",
"(",
"name",
")",
":",
"(",
"enabled_services",
",",
"disabled_services",
")",
"=",
"_get_service_list",
"(",
"include_enabled",
"=",
"True",
",",
"include_disabled",
"=",
"True",
")",
"return",
"name",
"in",
"enabled_services",
"or",
"name",... | Returns ``True`` if the specified service is available, otherwise returns
``False``.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd | [
"Returns",
"True",
"if",
"the",
"specified",
"service",
"is",
"available",
"otherwise",
"returns",
"False",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L122-L135 | train |
saltstack/salt | salt/modules/gentoo_service.py | get_all | def get_all():
'''
Return all available boot services
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
include_disabled=True)
... | python | def get_all():
'''
Return all available boot services
CLI Example:
.. code-block:: bash
salt '*' service.get_all
'''
(enabled_services, disabled_services) = _get_service_list(include_enabled=True,
include_disabled=True)
... | [
"def",
"get_all",
"(",
")",
":",
"(",
"enabled_services",
",",
"disabled_services",
")",
"=",
"_get_service_list",
"(",
"include_enabled",
"=",
"True",
",",
"include_disabled",
"=",
"True",
")",
"enabled_services",
".",
"update",
"(",
"dict",
"(",
"[",
"(",
... | Return all available boot services
CLI Example:
.. code-block:: bash
salt '*' service.get_all | [
"Return",
"all",
"available",
"boot",
"services"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L153-L166 | train |
saltstack/salt | salt/modules/gentoo_service.py | status | def status(name, sig=None):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the servi... | python | def status(name, sig=None):
'''
Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the servi... | [
"def",
"status",
"(",
"name",
",",
"sig",
"=",
"None",
")",
":",
"if",
"sig",
":",
"return",
"bool",
"(",
"__salt__",
"[",
"'status.pid'",
"]",
"(",
"sig",
")",
")",
"contains_globbing",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'\\*|\\?|\\[.+\\]'"... | Return the status for a service.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of the service to check
sig (str): Signature... | [
"Return",
"the",
"status",
"for",
"a",
"service",
".",
"If",
"the",
"name",
"contains",
"globbing",
"a",
"dict",
"mapping",
"service",
"name",
"to",
"True",
"/",
"False",
"values",
"is",
"returned",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L239-L276 | train |
saltstack/salt | salt/modules/gentoo_service.py | enable | def enable(name, **kwargs):
'''
Enable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.enable <service name> <runlevels=single-runlevel>
salt '*' service.enable <service name> <runlevels=[runlevel1,runlevel2]>
'''
if 'runlevels' in kwargs:... | python | def enable(name, **kwargs):
'''
Enable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.enable <service name> <runlevels=single-runlevel>
salt '*' service.enable <service name> <runlevels=[runlevel1,runlevel2]>
'''
if 'runlevels' in kwargs:... | [
"def",
"enable",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'runlevels'",
"in",
"kwargs",
":",
"requested_levels",
"=",
"set",
"(",
"kwargs",
"[",
"'runlevels'",
"]",
"if",
"isinstance",
"(",
"kwargs",
"[",
"'runlevels'",
"]",
",",
"list",
... | Enable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.enable <service name> <runlevels=single-runlevel>
salt '*' service.enable <service name> <runlevels=[runlevel1,runlevel2]> | [
"Enable",
"the",
"named",
"service",
"to",
"start",
"at",
"boot"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L279-L306 | train |
saltstack/salt | salt/modules/gentoo_service.py | disable | def disable(name, **kwargs):
'''
Disable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.disable <service name> <runlevels=single-runlevel>
salt '*' service.disable <service name> <runlevels=[runlevel1,runlevel2]>
'''
levels = []
if 'r... | python | def disable(name, **kwargs):
'''
Disable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.disable <service name> <runlevels=single-runlevel>
salt '*' service.disable <service name> <runlevels=[runlevel1,runlevel2]>
'''
levels = []
if 'r... | [
"def",
"disable",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"levels",
"=",
"[",
"]",
"if",
"'runlevels'",
"in",
"kwargs",
":",
"requested_levels",
"=",
"set",
"(",
"kwargs",
"[",
"'runlevels'",
"]",
"if",
"isinstance",
"(",
"kwargs",
"[",
"'runle... | Disable the named service to start at boot
CLI Example:
.. code-block:: bash
salt '*' service.disable <service name> <runlevels=single-runlevel>
salt '*' service.disable <service name> <runlevels=[runlevel1,runlevel2]> | [
"Disable",
"the",
"named",
"service",
"to",
"start",
"at",
"boot"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L309-L328 | train |
saltstack/salt | salt/modules/gentoo_service.py | enabled | def enabled(name, **kwargs):
'''
Return True if the named service is enabled, false otherwise
CLI Example:
.. code-block:: bash
salt '*' service.enabled <service name> <runlevels=single-runlevel>
salt '*' service.enabled <service name> <runlevels=[runlevel1,runlevel2]>
'''
ena... | python | def enabled(name, **kwargs):
'''
Return True if the named service is enabled, false otherwise
CLI Example:
.. code-block:: bash
salt '*' service.enabled <service name> <runlevels=single-runlevel>
salt '*' service.enabled <service name> <runlevels=[runlevel1,runlevel2]>
'''
ena... | [
"def",
"enabled",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"enabled_services",
"=",
"get_enabled",
"(",
")",
"if",
"name",
"not",
"in",
"enabled_services",
":",
"return",
"False",
"if",
"'runlevels'",
"not",
"in",
"kwargs",
":",
"return",
"True",
... | Return True if the named service is enabled, false otherwise
CLI Example:
.. code-block:: bash
salt '*' service.enabled <service name> <runlevels=single-runlevel>
salt '*' service.enabled <service name> <runlevels=[runlevel1,runlevel2]> | [
"Return",
"True",
"if",
"the",
"named",
"service",
"is",
"enabled",
"false",
"otherwise"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gentoo_service.py#L331-L349 | train |
saltstack/salt | salt/states/virtualenv_mod.py | managed | def managed(name,
venv_bin=None,
requirements=None,
system_site_packages=False,
distribute=False,
use_wheel=False,
clear=False,
python=None,
extra_search_dir=None,
never_download=None,
prompt=None,
... | python | def managed(name,
venv_bin=None,
requirements=None,
system_site_packages=False,
distribute=False,
use_wheel=False,
clear=False,
python=None,
extra_search_dir=None,
never_download=None,
prompt=None,
... | [
"def",
"managed",
"(",
"name",
",",
"venv_bin",
"=",
"None",
",",
"requirements",
"=",
"None",
",",
"system_site_packages",
"=",
"False",
",",
"distribute",
"=",
"False",
",",
"use_wheel",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"python",
"=",
"No... | Create a virtualenv and optionally manage it with pip
name
Path to the virtualenv.
venv_bin: virtualenv
The name (and optionally path) of the virtualenv command. This can also
be set globally in the minion config file as ``virtualenv.venv_bin``.
requirements: None
Path to ... | [
"Create",
"a",
"virtualenv",
"and",
"optionally",
"manage",
"it",
"with",
"pip"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virtualenv_mod.py#L33-L337 | train |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_bond_1 | def _parse_settings_bond_1(opts, iface, bond_def):
'''
Filters given options and outputs valid settings for bond1.
If an option has a value that is not expected, this
function will log what the Interface, Setting and what it was
expecting.
'''
bond = {'mode': '1'}
for binding in ['miim... | python | def _parse_settings_bond_1(opts, iface, bond_def):
'''
Filters given options and outputs valid settings for bond1.
If an option has a value that is not expected, this
function will log what the Interface, Setting and what it was
expecting.
'''
bond = {'mode': '1'}
for binding in ['miim... | [
"def",
"_parse_settings_bond_1",
"(",
"opts",
",",
"iface",
",",
"bond_def",
")",
":",
"bond",
"=",
"{",
"'mode'",
":",
"'1'",
"}",
"for",
"binding",
"in",
"[",
"'miimon'",
",",
"'downdelay'",
",",
"'updelay'",
"]",
":",
"if",
"binding",
"in",
"opts",
... | Filters given options and outputs valid settings for bond1.
If an option has a value that is not expected, this
function will log what the Interface, Setting and what it was
expecting. | [
"Filters",
"given",
"options",
"and",
"outputs",
"valid",
"settings",
"for",
"bond1",
".",
"If",
"an",
"option",
"has",
"a",
"value",
"that",
"is",
"not",
"expected",
"this",
"function",
"will",
"log",
"what",
"the",
"Interface",
"Setting",
"and",
"what",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L320-L356 | train |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_vlan | def _parse_settings_vlan(opts, iface):
'''
Filters given options and outputs valid settings for a vlan
'''
vlan = {}
if 'reorder_hdr' in opts:
if opts['reorder_hdr'] in _CONFIG_TRUE + _CONFIG_FALSE:
vlan.update({'reorder_hdr': opts['reorder_hdr']})
else:
vali... | python | def _parse_settings_vlan(opts, iface):
'''
Filters given options and outputs valid settings for a vlan
'''
vlan = {}
if 'reorder_hdr' in opts:
if opts['reorder_hdr'] in _CONFIG_TRUE + _CONFIG_FALSE:
vlan.update({'reorder_hdr': opts['reorder_hdr']})
else:
vali... | [
"def",
"_parse_settings_vlan",
"(",
"opts",
",",
"iface",
")",
":",
"vlan",
"=",
"{",
"}",
"if",
"'reorder_hdr'",
"in",
"opts",
":",
"if",
"opts",
"[",
"'reorder_hdr'",
"]",
"in",
"_CONFIG_TRUE",
"+",
"_CONFIG_FALSE",
":",
"vlan",
".",
"update",
"(",
"{"... | Filters given options and outputs valid settings for a vlan | [
"Filters",
"given",
"options",
"and",
"outputs",
"valid",
"settings",
"for",
"a",
"vlan"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L571-L596 | train |
saltstack/salt | salt/modules/rh_ip.py | _parse_settings_eth | def _parse_settings_eth(opts, iface_type, enabled, iface):
'''
Filters given options and outputs valid settings for a
network interface.
'''
result = {'name': iface}
if 'proto' in opts:
valid = ['none', 'bootp', 'dhcp']
if opts['proto'] in valid:
result['proto'] = opt... | python | def _parse_settings_eth(opts, iface_type, enabled, iface):
'''
Filters given options and outputs valid settings for a
network interface.
'''
result = {'name': iface}
if 'proto' in opts:
valid = ['none', 'bootp', 'dhcp']
if opts['proto'] in valid:
result['proto'] = opt... | [
"def",
"_parse_settings_eth",
"(",
"opts",
",",
"iface_type",
",",
"enabled",
",",
"iface",
")",
":",
"result",
"=",
"{",
"'name'",
":",
"iface",
"}",
"if",
"'proto'",
"in",
"opts",
":",
"valid",
"=",
"[",
"'none'",
",",
"'bootp'",
",",
"'dhcp'",
"]",
... | Filters given options and outputs valid settings for a
network interface. | [
"Filters",
"given",
"options",
"and",
"outputs",
"valid",
"settings",
"for",
"a",
"network",
"interface",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L599-L816 | train |
saltstack/salt | salt/modules/rh_ip.py | _parse_network_settings | def _parse_network_settings(opts, current):
'''
Filters given options and outputs valid settings for
the global network settings file.
'''
# Normalize keys
opts = dict((k.lower(), v) for (k, v) in six.iteritems(opts))
current = dict((k.lower(), v) for (k, v) in six.iteritems(current))
#... | python | def _parse_network_settings(opts, current):
'''
Filters given options and outputs valid settings for
the global network settings file.
'''
# Normalize keys
opts = dict((k.lower(), v) for (k, v) in six.iteritems(opts))
current = dict((k.lower(), v) for (k, v) in six.iteritems(current))
#... | [
"def",
"_parse_network_settings",
"(",
"opts",
",",
"current",
")",
":",
"# Normalize keys",
"opts",
"=",
"dict",
"(",
"(",
"k",
".",
"lower",
"(",
")",
",",
"v",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"six",
".",
"iteritems",
"(",
"opts",
")",... | Filters given options and outputs valid settings for
the global network settings file. | [
"Filters",
"given",
"options",
"and",
"outputs",
"valid",
"settings",
"for",
"the",
"global",
"network",
"settings",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L836-L903 | train |
saltstack/salt | salt/modules/rh_ip.py | _read_file | def _read_file(path):
'''
Reads and returns the contents of a file
'''
try:
with salt.utils.files.fopen(path, 'rb') as rfh:
lines = salt.utils.stringutils.to_unicode(rfh.read()).splitlines()
try:
lines.remove('')
except ValueError:
... | python | def _read_file(path):
'''
Reads and returns the contents of a file
'''
try:
with salt.utils.files.fopen(path, 'rb') as rfh:
lines = salt.utils.stringutils.to_unicode(rfh.read()).splitlines()
try:
lines.remove('')
except ValueError:
... | [
"def",
"_read_file",
"(",
"path",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"path",
",",
"'rb'",
")",
"as",
"rfh",
":",
"lines",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
"rfh"... | Reads and returns the contents of a file | [
"Reads",
"and",
"returns",
"the",
"contents",
"of",
"a",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L933-L946 | train |
saltstack/salt | salt/modules/rh_ip.py | _write_file_iface | def _write_file_iface(iface, data, folder, pattern):
'''
Writes a file to disk
'''
filename = os.path.join(folder, pattern.format(iface))
if not os.path.exists(folder):
msg = '{0} cannot be written. {1} does not exist'
msg = msg.format(filename, folder)
log.error(msg)
... | python | def _write_file_iface(iface, data, folder, pattern):
'''
Writes a file to disk
'''
filename = os.path.join(folder, pattern.format(iface))
if not os.path.exists(folder):
msg = '{0} cannot be written. {1} does not exist'
msg = msg.format(filename, folder)
log.error(msg)
... | [
"def",
"_write_file_iface",
"(",
"iface",
",",
"data",
",",
"folder",
",",
"pattern",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"pattern",
".",
"format",
"(",
"iface",
")",
")",
"if",
"not",
"os",
".",
"path",
"... | Writes a file to disk | [
"Writes",
"a",
"file",
"to",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L949-L960 | train |
saltstack/salt | salt/modules/rh_ip.py | _write_file_network | def _write_file_network(data, filename):
'''
Writes a file to disk
'''
with salt.utils.files.fopen(filename, 'w') as fp_:
fp_.write(salt.utils.stringutils.to_str(data)) | python | def _write_file_network(data, filename):
'''
Writes a file to disk
'''
with salt.utils.files.fopen(filename, 'w') as fp_:
fp_.write(salt.utils.stringutils.to_str(data)) | [
"def",
"_write_file_network",
"(",
"data",
",",
"filename",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"filename",
",",
"'w'",
")",
"as",
"fp_",
":",
"fp_",
".",
"write",
"(",
"salt",
".",
"utils",
".",
"stringutils",
".... | Writes a file to disk | [
"Writes",
"a",
"file",
"to",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L963-L968 | train |
saltstack/salt | salt/modules/rh_ip.py | build_bond | def build_bond(iface, **settings):
'''
Create a bond script in /etc/modprobe.d with the passed settings
and load the bonding kernel module.
CLI Example:
.. code-block:: bash
salt '*' ip.build_bond bond0 mode=balance-alb
'''
rh_major = __grains__['osrelease'][:1]
opts = _parse... | python | def build_bond(iface, **settings):
'''
Create a bond script in /etc/modprobe.d with the passed settings
and load the bonding kernel module.
CLI Example:
.. code-block:: bash
salt '*' ip.build_bond bond0 mode=balance-alb
'''
rh_major = __grains__['osrelease'][:1]
opts = _parse... | [
"def",
"build_bond",
"(",
"iface",
",",
"*",
"*",
"settings",
")",
":",
"rh_major",
"=",
"__grains__",
"[",
"'osrelease'",
"]",
"[",
":",
"1",
"]",
"opts",
"=",
"_parse_settings_bond",
"(",
"settings",
",",
"iface",
")",
"try",
":",
"template",
"=",
"J... | Create a bond script in /etc/modprobe.d with the passed settings
and load the bonding kernel module.
CLI Example:
.. code-block:: bash
salt '*' ip.build_bond bond0 mode=balance-alb | [
"Create",
"a",
"bond",
"script",
"in",
"/",
"etc",
"/",
"modprobe",
".",
"d",
"with",
"the",
"passed",
"settings",
"and",
"load",
"the",
"bonding",
"kernel",
"module",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L980-L1017 | train |
saltstack/salt | salt/modules/rh_ip.py | build_interface | def build_interface(iface, iface_type, enabled, **settings):
'''
Build an interface script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_interface eth0 eth <settings>
'''
if __grains__['os'] == 'Fedora':
if __grains__['osmajorrelease'] >= 18:
... | python | def build_interface(iface, iface_type, enabled, **settings):
'''
Build an interface script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_interface eth0 eth <settings>
'''
if __grains__['os'] == 'Fedora':
if __grains__['osmajorrelease'] >= 18:
... | [
"def",
"build_interface",
"(",
"iface",
",",
"iface_type",
",",
"enabled",
",",
"*",
"*",
"settings",
")",
":",
"if",
"__grains__",
"[",
"'os'",
"]",
"==",
"'Fedora'",
":",
"if",
"__grains__",
"[",
"'osmajorrelease'",
"]",
">=",
"18",
":",
"rh_major",
"=... | Build an interface script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_interface eth0 eth <settings> | [
"Build",
"an",
"interface",
"script",
"for",
"a",
"network",
"interface",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1020-L1074 | train |
saltstack/salt | salt/modules/rh_ip.py | build_routes | def build_routes(iface, **settings):
'''
Build a route script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_routes eth0 <settings>
'''
template = 'rh6_route_eth.jinja'
try:
if int(__grains__['osrelease'][0]) < 6:
template = 'rout... | python | def build_routes(iface, **settings):
'''
Build a route script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_routes eth0 <settings>
'''
template = 'rh6_route_eth.jinja'
try:
if int(__grains__['osrelease'][0]) < 6:
template = 'rout... | [
"def",
"build_routes",
"(",
"iface",
",",
"*",
"*",
"settings",
")",
":",
"template",
"=",
"'rh6_route_eth.jinja'",
"try",
":",
"if",
"int",
"(",
"__grains__",
"[",
"'osrelease'",
"]",
"[",
"0",
"]",
")",
"<",
"6",
":",
"template",
"=",
"'route_eth.jinja... | Build a route script for a network interface.
CLI Example:
.. code-block:: bash
salt '*' ip.build_routes eth0 <settings> | [
"Build",
"a",
"route",
"script",
"for",
"a",
"network",
"interface",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1077-L1130 | train |
saltstack/salt | salt/modules/rh_ip.py | get_bond | def get_bond(iface):
'''
Return the content of a bond script
CLI Example:
.. code-block:: bash
salt '*' ip.get_bond bond0
'''
path = os.path.join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
return _read_file(path) | python | def get_bond(iface):
'''
Return the content of a bond script
CLI Example:
.. code-block:: bash
salt '*' ip.get_bond bond0
'''
path = os.path.join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
return _read_file(path) | [
"def",
"get_bond",
"(",
"iface",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_RH_NETWORK_CONF_FILES",
",",
"'{0}.conf'",
".",
"format",
"(",
"iface",
")",
")",
"return",
"_read_file",
"(",
"path",
")"
] | Return the content of a bond script
CLI Example:
.. code-block:: bash
salt '*' ip.get_bond bond0 | [
"Return",
"the",
"content",
"of",
"a",
"bond",
"script"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1149-L1160 | train |
saltstack/salt | salt/modules/rh_ip.py | get_interface | def get_interface(iface):
'''
Return the contents of an interface script
CLI Example:
.. code-block:: bash
salt '*' ip.get_interface eth0
'''
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
return _read_file(path) | python | def get_interface(iface):
'''
Return the contents of an interface script
CLI Example:
.. code-block:: bash
salt '*' ip.get_interface eth0
'''
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
return _read_file(path) | [
"def",
"get_interface",
"(",
"iface",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_RH_NETWORK_SCRIPT_DIR",
",",
"'ifcfg-{0}'",
".",
"format",
"(",
"iface",
")",
")",
"return",
"_read_file",
"(",
"path",
")"
] | Return the contents of an interface script
CLI Example:
.. code-block:: bash
salt '*' ip.get_interface eth0 | [
"Return",
"the",
"contents",
"of",
"an",
"interface",
"script"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1163-L1174 | train |
saltstack/salt | salt/modules/rh_ip.py | get_routes | def get_routes(iface):
'''
Return the contents of the interface routes script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_routes eth0
'''
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'route-{0}'.format(iface))
path6 = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'route6-{0}'.format(... | python | def get_routes(iface):
'''
Return the contents of the interface routes script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_routes eth0
'''
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'route-{0}'.format(iface))
path6 = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'route6-{0}'.format(... | [
"def",
"get_routes",
"(",
"iface",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_RH_NETWORK_SCRIPT_DIR",
",",
"'route-{0}'",
".",
"format",
"(",
"iface",
")",
")",
"path6",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_RH_NETWORK_SCRIPT_DIR... | Return the contents of the interface routes script.
CLI Example:
.. code-block:: bash
salt '*' ip.get_routes eth0 | [
"Return",
"the",
"contents",
"of",
"the",
"interface",
"routes",
"script",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1193-L1207 | train |
saltstack/salt | salt/modules/rh_ip.py | apply_network_settings | def apply_network_settings(**settings):
'''
Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings
'''
if 'require_reboot' not in settings:
settings['require_reboot'] = False
if 'apply_hostname' not in settings:
se... | python | def apply_network_settings(**settings):
'''
Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings
'''
if 'require_reboot' not in settings:
settings['require_reboot'] = False
if 'apply_hostname' not in settings:
se... | [
"def",
"apply_network_settings",
"(",
"*",
"*",
"settings",
")",
":",
"if",
"'require_reboot'",
"not",
"in",
"settings",
":",
"settings",
"[",
"'require_reboot'",
"]",
"=",
"False",
"if",
"'apply_hostname'",
"not",
"in",
"settings",
":",
"settings",
"[",
"'app... | Apply global network configuration.
CLI Example:
.. code-block:: bash
salt '*' ip.apply_network_settings | [
"Apply",
"global",
"network",
"configuration",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1223-L1260 | train |
saltstack/salt | salt/modules/rh_ip.py | build_network_settings | def build_network_settings(**settings):
'''
Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings>
'''
# Read current configuration and store default values
current_network_settings = _parse_rh_config(_RH_NETWORK_FILE)
... | python | def build_network_settings(**settings):
'''
Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings>
'''
# Read current configuration and store default values
current_network_settings = _parse_rh_config(_RH_NETWORK_FILE)
... | [
"def",
"build_network_settings",
"(",
"*",
"*",
"settings",
")",
":",
"# Read current configuration and store default values",
"current_network_settings",
"=",
"_parse_rh_config",
"(",
"_RH_NETWORK_FILE",
")",
"# Build settings",
"opts",
"=",
"_parse_network_settings",
"(",
"... | Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings> | [
"Build",
"the",
"global",
"network",
"script",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1263-L1291 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.