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/utils/zfs.py
from_bool
def from_bool(value): ''' Convert zfs bool to python bool ''' if value in ['on', 'yes']: value = True elif value in ['off', 'no']: value = False elif value == 'none': value = None return value
python
def from_bool(value): ''' Convert zfs bool to python bool ''' if value in ['on', 'yes']: value = True elif value in ['off', 'no']: value = False elif value == 'none': value = None return value
[ "def", "from_bool", "(", "value", ")", ":", "if", "value", "in", "[", "'on'", ",", "'yes'", "]", ":", "value", "=", "True", "elif", "value", "in", "[", "'off'", ",", "'no'", "]", ":", "value", "=", "False", "elif", "value", "==", "'none'", ":", "...
Convert zfs bool to python bool
[ "Convert", "zfs", "bool", "to", "python", "bool" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L430-L441
train
saltstack/salt
salt/utils/zfs.py
to_bool
def to_bool(value): ''' Convert python bool to zfs on/off bool ''' value = from_bool(value) if isinstance(value, bool): value = 'on' if value else 'off' elif value is None: value = 'none' return value
python
def to_bool(value): ''' Convert python bool to zfs on/off bool ''' value = from_bool(value) if isinstance(value, bool): value = 'on' if value else 'off' elif value is None: value = 'none' return value
[ "def", "to_bool", "(", "value", ")", ":", "value", "=", "from_bool", "(", "value", ")", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "value", "=", "'on'", "if", "value", "else", "'off'", "elif", "value", "is", "None", ":", "value", "=", ...
Convert python bool to zfs on/off bool
[ "Convert", "python", "bool", "to", "zfs", "on", "/", "off", "bool" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L451-L461
train
saltstack/salt
salt/utils/zfs.py
to_bool_alt
def to_bool_alt(value): ''' Convert python to zfs yes/no value ''' value = from_bool_alt(value) if isinstance(value, bool): value = 'yes' if value else 'no' elif value is None: value = 'none' return value
python
def to_bool_alt(value): ''' Convert python to zfs yes/no value ''' value = from_bool_alt(value) if isinstance(value, bool): value = 'yes' if value else 'no' elif value is None: value = 'none' return value
[ "def", "to_bool_alt", "(", "value", ")", ":", "value", "=", "from_bool_alt", "(", "value", ")", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "value", "=", "'yes'", "if", "value", "else", "'no'", "elif", "value", "is", "None", ":", "value", ...
Convert python to zfs yes/no value
[ "Convert", "python", "to", "zfs", "yes", "/", "no", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L464-L474
train
saltstack/salt
salt/utils/zfs.py
from_size
def from_size(value): ''' Convert zfs size (human readble) to python int (bytes) ''' match_size = re_zfs_size.match(str(value)) if match_size: v_unit = match_size.group(2).upper()[0] v_size = float(match_size.group(1)) v_multiplier = math.pow(1024, zfs_size.index(v_unit) + 1)...
python
def from_size(value): ''' Convert zfs size (human readble) to python int (bytes) ''' match_size = re_zfs_size.match(str(value)) if match_size: v_unit = match_size.group(2).upper()[0] v_size = float(match_size.group(1)) v_multiplier = math.pow(1024, zfs_size.index(v_unit) + 1)...
[ "def", "from_size", "(", "value", ")", ":", "match_size", "=", "re_zfs_size", ".", "match", "(", "str", "(", "value", ")", ")", "if", "match_size", ":", "v_unit", "=", "match_size", ".", "group", "(", "2", ")", ".", "upper", "(", ")", "[", "0", "]"...
Convert zfs size (human readble) to python int (bytes)
[ "Convert", "zfs", "size", "(", "human", "readble", ")", "to", "python", "int", "(", "bytes", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L477-L492
train
saltstack/salt
salt/utils/zfs.py
to_size
def to_size(value, convert_to_human=True): ''' Convert python int (bytes) to zfs size NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114 ''' value = from_size(value) if value is None: value = 'none' if isinstance(value, Number) and value > 10...
python
def to_size(value, convert_to_human=True): ''' Convert python int (bytes) to zfs size NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114 ''' value = from_size(value) if value is None: value = 'none' if isinstance(value, Number) and value > 10...
[ "def", "to_size", "(", "value", ",", "convert_to_human", "=", "True", ")", ":", "value", "=", "from_size", "(", "value", ")", "if", "value", "is", "None", ":", "value", "=", "'none'", "if", "isinstance", "(", "value", ",", "Number", ")", "and", "value"...
Convert python int (bytes) to zfs size NOTE: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py#114
[ "Convert", "python", "int", "(", "bytes", ")", "to", "zfs", "size" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L495-L527
train
saltstack/salt
salt/utils/zfs.py
from_str
def from_str(value): ''' Decode zfs safe string (used for name, path, ...) ''' if value == 'none': value = None if value: value = str(value) if value.startswith('"') and value.endswith('"'): value = value[1:-1] value = value.replace('\\"', '"') return...
python
def from_str(value): ''' Decode zfs safe string (used for name, path, ...) ''' if value == 'none': value = None if value: value = str(value) if value.startswith('"') and value.endswith('"'): value = value[1:-1] value = value.replace('\\"', '"') return...
[ "def", "from_str", "(", "value", ")", ":", "if", "value", "==", "'none'", ":", "value", "=", "None", "if", "value", ":", "value", "=", "str", "(", "value", ")", "if", "value", ".", "startswith", "(", "'\"'", ")", "and", "value", ".", "endswith", "(...
Decode zfs safe string (used for name, path, ...)
[ "Decode", "zfs", "safe", "string", "(", "used", "for", "name", "path", "...", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L530-L542
train
saltstack/salt
salt/utils/zfs.py
to_str
def to_str(value): ''' Encode zfs safe string (used for name, path, ...) ''' value = from_str(value) if value: value = value.replace('"', '\\"') if ' ' in value: value = '"' + value + '"' elif value is None: value = 'none' return value
python
def to_str(value): ''' Encode zfs safe string (used for name, path, ...) ''' value = from_str(value) if value: value = value.replace('"', '\\"') if ' ' in value: value = '"' + value + '"' elif value is None: value = 'none' return value
[ "def", "to_str", "(", "value", ")", ":", "value", "=", "from_str", "(", "value", ")", "if", "value", ":", "value", "=", "value", ".", "replace", "(", "'\"'", ",", "'\\\\\"'", ")", "if", "' '", "in", "value", ":", "value", "=", "'\"'", "+", "value",...
Encode zfs safe string (used for name, path, ...)
[ "Encode", "zfs", "safe", "string", "(", "used", "for", "name", "path", "...", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L545-L558
train
saltstack/salt
salt/utils/zfs.py
to_auto
def to_auto(name, value, source='auto', convert_to_human=True): ''' Convert python value to zfs value ''' return _auto('to', name, value, source, convert_to_human)
python
def to_auto(name, value, source='auto', convert_to_human=True): ''' Convert python value to zfs value ''' return _auto('to', name, value, source, convert_to_human)
[ "def", "to_auto", "(", "name", ",", "value", ",", "source", "=", "'auto'", ",", "convert_to_human", "=", "True", ")", ":", "return", "_auto", "(", "'to'", ",", "name", ",", "value", ",", "source", ",", "convert_to_human", ")" ]
Convert python value to zfs value
[ "Convert", "python", "value", "to", "zfs", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L568-L572
train
saltstack/salt
salt/utils/zfs.py
from_auto_dict
def from_auto_dict(values, source='auto'): ''' Pass an entire dictionary to from_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = from_auto(name, value, source) return values
python
def from_auto_dict(values, source='auto'): ''' Pass an entire dictionary to from_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = from_auto(name, value, source) return values
[ "def", "from_auto_dict", "(", "values", ",", "source", "=", "'auto'", ")", ":", "for", "name", ",", "value", "in", "values", ".", "items", "(", ")", ":", "values", "[", "name", "]", "=", "from_auto", "(", "name", ",", "value", ",", "source", ")", "...
Pass an entire dictionary to from_auto .. note:: The key will be passed as the name
[ "Pass", "an", "entire", "dictionary", "to", "from_auto" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L575-L586
train
saltstack/salt
salt/utils/zfs.py
to_auto_dict
def to_auto_dict(values, source='auto', convert_to_human=True): ''' Pass an entire dictionary to to_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = to_auto(name, value, source, convert_to_human) return values
python
def to_auto_dict(values, source='auto', convert_to_human=True): ''' Pass an entire dictionary to to_auto .. note:: The key will be passed as the name ''' for name, value in values.items(): values[name] = to_auto(name, value, source, convert_to_human) return values
[ "def", "to_auto_dict", "(", "values", ",", "source", "=", "'auto'", ",", "convert_to_human", "=", "True", ")", ":", "for", "name", ",", "value", "in", "values", ".", "items", "(", ")", ":", "values", "[", "name", "]", "=", "to_auto", "(", "name", ","...
Pass an entire dictionary to to_auto .. note:: The key will be passed as the name
[ "Pass", "an", "entire", "dictionary", "to", "to_auto" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L589-L599
train
saltstack/salt
salt/utils/zfs.py
zpool_command
def zpool_command(command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, pool_properties=None, target=None): ''' Build and properly escape a zpool command .. note:: Input is not considered safe and will be passed through to_au...
python
def zpool_command(command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, pool_properties=None, target=None): ''' Build and properly escape a zpool command .. note:: Input is not considered safe and will be passed through to_au...
[ "def", "zpool_command", "(", "command", ",", "flags", "=", "None", ",", "opts", "=", "None", ",", "property_name", "=", "None", ",", "property_value", "=", "None", ",", "filesystem_properties", "=", "None", ",", "pool_properties", "=", "None", ",", "target",...
Build and properly escape a zpool command .. note:: Input is not considered safe and will be passed through to_auto(from_auto('input_here')), you do not need to do so your self first.
[ "Build", "and", "properly", "escape", "a", "zpool", "command" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L648-L670
train
saltstack/salt
salt/utils/zfs.py
parse_command_result
def parse_command_result(res, label=None): ''' Parse the result of a zpool/zfs command .. note:: Output on failure is rather predicatable. - retcode > 0 - each 'error' is a line on stderr - optional 'Usage:' block under those with hits We simple check those and ret...
python
def parse_command_result(res, label=None): ''' Parse the result of a zpool/zfs command .. note:: Output on failure is rather predicatable. - retcode > 0 - each 'error' is a line on stderr - optional 'Usage:' block under those with hits We simple check those and ret...
[ "def", "parse_command_result", "(", "res", ",", "label", "=", "None", ")", ":", "ret", "=", "OrderedDict", "(", ")", "if", "label", ":", "ret", "[", "label", "]", "=", "res", "[", "'retcode'", "]", "==", "0", "if", "res", "[", "'retcode'", "]", "!=...
Parse the result of a zpool/zfs command .. note:: Output on failure is rather predicatable. - retcode > 0 - each 'error' is a line on stderr - optional 'Usage:' block under those with hits We simple check those and return a OrderedDict were we set label = True|Fals...
[ "Parse", "the", "result", "of", "a", "zpool", "/", "zfs", "command" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L673-L709
train
saltstack/salt
salt/beacons/logs.py
beacon
def beacon(config): ''' Read the log file and return match whole string .. code-block:: yaml beacons: log: - file: <path> - tags: <tag>: regex: <pattern> .. note:: regex matching is based on the `re`_ modul...
python
def beacon(config): ''' Read the log file and return match whole string .. code-block:: yaml beacons: log: - file: <path> - tags: <tag>: regex: <pattern> .. note:: regex matching is based on the `re`_ modul...
[ "def", "beacon", "(", "config", ")", ":", "_config", "=", "{", "}", "list", "(", "map", "(", "_config", ".", "update", ",", "config", ")", ")", "ret", "=", "[", "]", "if", "'file'", "not", "in", "_config", ":", "event", "=", "SKEL", ".", "copy", ...
Read the log file and return match whole string .. code-block:: yaml beacons: log: - file: <path> - tags: <tag>: regex: <pattern> .. note:: regex matching is based on the `re`_ module .. _re: https://docs.pyth...
[ "Read", "the", "log", "file", "and", "return", "match", "whole", "string" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/logs.py#L70-L157
train
saltstack/salt
salt/pillar/pepa.py
key_value_to_tree
def key_value_to_tree(data): ''' Convert key/value to tree ''' tree = {} for flatkey, value in six.iteritems(data): t = tree keys = flatkey.split(__opts__['pepa_delimiter']) for i, key in enumerate(keys, 1): if i == len(keys): t[key] = value ...
python
def key_value_to_tree(data): ''' Convert key/value to tree ''' tree = {} for flatkey, value in six.iteritems(data): t = tree keys = flatkey.split(__opts__['pepa_delimiter']) for i, key in enumerate(keys, 1): if i == len(keys): t[key] = value ...
[ "def", "key_value_to_tree", "(", "data", ")", ":", "tree", "=", "{", "}", "for", "flatkey", ",", "value", "in", "six", ".", "iteritems", "(", "data", ")", ":", "t", "=", "tree", "keys", "=", "flatkey", ".", "split", "(", "__opts__", "[", "'pepa_delim...
Convert key/value to tree
[ "Convert", "key", "/", "value", "to", "tree" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L359-L372
train
saltstack/salt
salt/pillar/pepa.py
ext_pillar
def ext_pillar(minion_id, pillar, resource, sequence, subkey=False, subkey_only=False): ''' Evaluate Pepa templates ''' roots = __opts__['pepa_roots'] # Default input inp = {} inp['default'] = 'default' inp['hostname'] = minion_id if 'environment' in pillar: inp['environmen...
python
def ext_pillar(minion_id, pillar, resource, sequence, subkey=False, subkey_only=False): ''' Evaluate Pepa templates ''' roots = __opts__['pepa_roots'] # Default input inp = {} inp['default'] = 'default' inp['hostname'] = minion_id if 'environment' in pillar: inp['environmen...
[ "def", "ext_pillar", "(", "minion_id", ",", "pillar", ",", "resource", ",", "sequence", ",", "subkey", "=", "False", ",", "subkey_only", "=", "False", ")", ":", "roots", "=", "__opts__", "[", "'pepa_roots'", "]", "# Default input", "inp", "=", "{", "}", ...
Evaluate Pepa templates
[ "Evaluate", "Pepa", "templates" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L375-L506
train
saltstack/salt
salt/pillar/pepa.py
validate
def validate(output, resource): ''' Validate Pepa templates ''' try: import cerberus # pylint: disable=import-error except ImportError: log.critical('You need module cerberus in order to use validation') return roots = __opts__['pepa_roots'] valdir = os.path.join(r...
python
def validate(output, resource): ''' Validate Pepa templates ''' try: import cerberus # pylint: disable=import-error except ImportError: log.critical('You need module cerberus in order to use validation') return roots = __opts__['pepa_roots'] valdir = os.path.join(r...
[ "def", "validate", "(", "output", ",", "resource", ")", ":", "try", ":", "import", "cerberus", "# pylint: disable=import-error", "except", "ImportError", ":", "log", ".", "critical", "(", "'You need module cerberus in order to use validation'", ")", "return", "roots", ...
Validate Pepa templates
[ "Validate", "Pepa", "templates" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pepa.py#L509-L542
train
saltstack/salt
salt/grains/disks.py
disks
def disks(): ''' Return list of disk devices ''' if salt.utils.platform.is_freebsd(): return _freebsd_geom() elif salt.utils.platform.is_linux(): return _linux_disks() elif salt.utils.platform.is_windows(): return _windows_disks() else: log.trace('Disk grain d...
python
def disks(): ''' Return list of disk devices ''' if salt.utils.platform.is_freebsd(): return _freebsd_geom() elif salt.utils.platform.is_linux(): return _linux_disks() elif salt.utils.platform.is_windows(): return _windows_disks() else: log.trace('Disk grain d...
[ "def", "disks", "(", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_freebsd", "(", ")", ":", "return", "_freebsd_geom", "(", ")", "elif", "salt", ".", "utils", ".", "platform", ".", "is_linux", "(", ")", ":", "return", "_linux_disks", ...
Return list of disk devices
[ "Return", "list", "of", "disk", "devices" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/disks.py#L29-L40
train
saltstack/salt
salt/grains/disks.py
_linux_disks
def _linux_disks(): ''' Return list of disk devices and work out if they are SSD or HDD. ''' ret = {'disks': [], 'SSDs': []} for entry in glob.glob('/sys/block/*/queue/rotational'): try: with salt.utils.files.fopen(entry) as entry_fp: device = entry.split('/')[3]...
python
def _linux_disks(): ''' Return list of disk devices and work out if they are SSD or HDD. ''' ret = {'disks': [], 'SSDs': []} for entry in glob.glob('/sys/block/*/queue/rotational'): try: with salt.utils.files.fopen(entry) as entry_fp: device = entry.split('/')[3]...
[ "def", "_linux_disks", "(", ")", ":", "ret", "=", "{", "'disks'", ":", "[", "]", ",", "'SSDs'", ":", "[", "]", "}", "for", "entry", "in", "glob", ".", "glob", "(", "'/sys/block/*/queue/rotational'", ")", ":", "try", ":", "with", "salt", ".", "utils",...
Return list of disk devices and work out if they are SSD or HDD.
[ "Return", "list", "of", "disk", "devices", "and", "work", "out", "if", "they", "are", "SSD", "or", "HDD", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/disks.py#L128-L152
train
saltstack/salt
salt/states/vbox_guest.py
additions_installed
def additions_installed(name, reboot=False, upgrade_os=False): ''' Ensure that the VirtualBox Guest Additions are installed. Uses the CD, connected by VirtualBox. name The name has no functional value and is only used as a tracking reference. reboot : False Restart OS to com...
python
def additions_installed(name, reboot=False, upgrade_os=False): ''' Ensure that the VirtualBox Guest Additions are installed. Uses the CD, connected by VirtualBox. name The name has no functional value and is only used as a tracking reference. reboot : False Restart OS to com...
[ "def", "additions_installed", "(", "name", ",", "reboot", "=", "False", ",", "upgrade_os", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", "}...
Ensure that the VirtualBox Guest Additions are installed. Uses the CD, connected by VirtualBox. name The name has no functional value and is only used as a tracking reference. reboot : False Restart OS to complete installation. upgrade_os : False Upgrade OS (to ensure th...
[ "Ensure", "that", "the", "VirtualBox", "Guest", "Additions", "are", "installed", ".", "Uses", "the", "CD", "connected", "by", "VirtualBox", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L13-L52
train
saltstack/salt
salt/states/vbox_guest.py
additions_removed
def additions_removed(name, force=False): ''' Ensure that the VirtualBox Guest Additions are removed. Uses the CD, connected by VirtualBox. To connect VirtualBox Guest Additions via VirtualBox graphical interface press 'Host+D' ('Host' is usually 'Right Ctrl'). name The name has no fun...
python
def additions_removed(name, force=False): ''' Ensure that the VirtualBox Guest Additions are removed. Uses the CD, connected by VirtualBox. To connect VirtualBox Guest Additions via VirtualBox graphical interface press 'Host+D' ('Host' is usually 'Right Ctrl'). name The name has no fun...
[ "def", "additions_removed", "(", "name", ",", "force", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", "}", "current_state", "=", "__salt__", ...
Ensure that the VirtualBox Guest Additions are removed. Uses the CD, connected by VirtualBox. To connect VirtualBox Guest Additions via VirtualBox graphical interface press 'Host+D' ('Host' is usually 'Right Ctrl'). name The name has no functional value and is only used as a tracking r...
[ "Ensure", "that", "the", "VirtualBox", "Guest", "Additions", "are", "removed", ".", "Uses", "the", "CD", "connected", "by", "VirtualBox", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L55-L93
train
saltstack/salt
salt/states/vbox_guest.py
grant_access_to_shared_folders_to
def grant_access_to_shared_folders_to(name, users=None): ''' Grant access to auto-mounted shared folders to the users. User is specified by it's name. To grant access for several users use argument `users`. name Name of the user to grant access to auto-mounted shared folders to. users ...
python
def grant_access_to_shared_folders_to(name, users=None): ''' Grant access to auto-mounted shared folders to the users. User is specified by it's name. To grant access for several users use argument `users`. name Name of the user to grant access to auto-mounted shared folders to. users ...
[ "def", "grant_access_to_shared_folders_to", "(", "name", ",", "users", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", "}", "current_state", "=", ...
Grant access to auto-mounted shared folders to the users. User is specified by it's name. To grant access for several users use argument `users`. name Name of the user to grant access to auto-mounted shared folders to. users List of names of users to grant access to auto-mounted shared...
[ "Grant", "access", "to", "auto", "-", "mounted", "shared", "folders", "to", "the", "users", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vbox_guest.py#L96-L137
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient._is_master_running
def _is_master_running(self): ''' Perform a lightweight check to see if the master daemon is running Note, this will return an invalid success if the master crashed or was not shut down cleanly. ''' # Windows doesn't have IPC. Assume the master is running. # At w...
python
def _is_master_running(self): ''' Perform a lightweight check to see if the master daemon is running Note, this will return an invalid success if the master crashed or was not shut down cleanly. ''' # Windows doesn't have IPC. Assume the master is running. # At w...
[ "def", "_is_master_running", "(", "self", ")", ":", "# Windows doesn't have IPC. Assume the master is running.", "# At worse, it will error 500.", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ":", "return", "True", "if", "self", ".", "opts...
Perform a lightweight check to see if the master daemon is running Note, this will return an invalid success if the master crashed or was not shut down cleanly.
[ "Perform", "a", "lightweight", "check", "to", "see", "if", "the", "master", "daemon", "is", "running" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L38-L56
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.run
def run(self, low): ''' Execute the specified function in the specified client by passing the lowstate ''' # Eauth currently requires a running daemon and commands run through # this method require eauth so perform a quick check to raise a # more meaningful error....
python
def run(self, low): ''' Execute the specified function in the specified client by passing the lowstate ''' # Eauth currently requires a running daemon and commands run through # this method require eauth so perform a quick check to raise a # more meaningful error....
[ "def", "run", "(", "self", ",", "low", ")", ":", "# Eauth currently requires a running daemon and commands run through", "# this method require eauth so perform a quick check to raise a", "# more meaningful error.", "if", "not", "self", ".", "_is_master_running", "(", ")", ":", ...
Execute the specified function in the specified client by passing the lowstate
[ "Execute", "the", "specified", "function", "in", "the", "specified", "client", "by", "passing", "the", "lowstate" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L58-L80
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.local_async
def local_async(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` asynchronously Wraps :py:meth:`salt.client.LocalClient.run_job`. :return: job ID ''' local = salt.client.get_local_client(mopts=self.opts) ret = local.run_job(*args, **kw...
python
def local_async(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` asynchronously Wraps :py:meth:`salt.client.LocalClient.run_job`. :return: job ID ''' local = salt.client.get_local_client(mopts=self.opts) ret = local.run_job(*args, **kw...
[ "def", "local_async", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "local", "=", "salt", ".", "client", ".", "get_local_client", "(", "mopts", "=", "self", ".", "opts", ")", "ret", "=", "local", ".", "run_job", "(", "*", "args"...
Run :ref:`execution modules <all-salt.modules>` asynchronously Wraps :py:meth:`salt.client.LocalClient.run_job`. :return: job ID
[ "Run", ":", "ref", ":", "execution", "modules", "<all", "-", "salt", ".", "modules", ">", "asynchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L82-L92
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.local
def local(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` synchronously See :py:meth:`salt.client.LocalClient.cmd` for all available parameters. Sends a command from the master to the targeted minions. This is the same interface that Salt's o...
python
def local(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` synchronously See :py:meth:`salt.client.LocalClient.cmd` for all available parameters. Sends a command from the master to the targeted minions. This is the same interface that Salt's o...
[ "def", "local", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "local", "=", "salt", ".", "client", ".", "get_local_client", "(", "mopts", "=", "self", ".", "opts", ")", "return", "local", ".", "cmd", "(", "*", "args", ",", "*"...
Run :ref:`execution modules <all-salt.modules>` synchronously See :py:meth:`salt.client.LocalClient.cmd` for all available parameters. Sends a command from the master to the targeted minions. This is the same interface that Salt's own CLI uses. Note the ``arg`` and ``kwarg`` pa...
[ "Run", ":", "ref", ":", "execution", "modules", "<all", "-", "salt", ".", "modules", ">", "synchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L94-L109
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.local_subset
def local_subset(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` against subsets of minions .. versionadded:: 2016.3.0 Wraps :py:meth:`salt.client.LocalClient.cmd_subset` ''' local = salt.client.get_local_client(mopts=self.opts) retur...
python
def local_subset(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` against subsets of minions .. versionadded:: 2016.3.0 Wraps :py:meth:`salt.client.LocalClient.cmd_subset` ''' local = salt.client.get_local_client(mopts=self.opts) retur...
[ "def", "local_subset", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "local", "=", "salt", ".", "client", ".", "get_local_client", "(", "mopts", "=", "self", ".", "opts", ")", "return", "local", ".", "cmd_subset", "(", "*", "args"...
Run :ref:`execution modules <all-salt.modules>` against subsets of minions .. versionadded:: 2016.3.0 Wraps :py:meth:`salt.client.LocalClient.cmd_subset`
[ "Run", ":", "ref", ":", "execution", "modules", "<all", "-", "salt", ".", "modules", ">", "against", "subsets", "of", "minions" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L111-L120
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.local_batch
def local_batch(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` against batches of minions .. versionadded:: 0.8.4 Wraps :py:meth:`salt.client.LocalClient.cmd_batch` :return: Returns the result from the exeuction module for each batch of ...
python
def local_batch(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` against batches of minions .. versionadded:: 0.8.4 Wraps :py:meth:`salt.client.LocalClient.cmd_batch` :return: Returns the result from the exeuction module for each batch of ...
[ "def", "local_batch", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "local", "=", "salt", ".", "client", ".", "get_local_client", "(", "mopts", "=", "self", ".", "opts", ")", "return", "local", ".", "cmd_batch", "(", "*", "args", ...
Run :ref:`execution modules <all-salt.modules>` against batches of minions .. versionadded:: 0.8.4 Wraps :py:meth:`salt.client.LocalClient.cmd_batch` :return: Returns the result from the exeuction module for each batch of returns
[ "Run", ":", "ref", ":", "execution", "modules", "<all", "-", "salt", ".", "modules", ">", "against", "batches", "of", "minions" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L122-L134
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.ssh
def ssh(self, *args, **kwargs): ''' Run salt-ssh commands synchronously Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`. :return: Returns the result from the salt-ssh command ''' ssh_client = salt.client.ssh.client.SSHClient(mopts=self.opts, ...
python
def ssh(self, *args, **kwargs): ''' Run salt-ssh commands synchronously Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`. :return: Returns the result from the salt-ssh command ''' ssh_client = salt.client.ssh.client.SSHClient(mopts=self.opts, ...
[ "def", "ssh", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ssh_client", "=", "salt", ".", "client", ".", "ssh", ".", "client", ".", "SSHClient", "(", "mopts", "=", "self", ".", "opts", ",", "disable_custom_roster", "=", "True", ...
Run salt-ssh commands synchronously Wraps :py:meth:`salt.client.ssh.client.SSHClient.cmd_sync`. :return: Returns the result from the salt-ssh command
[ "Run", "salt", "-", "ssh", "commands", "synchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L136-L146
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.runner
def runner(self, fun, timeout=None, full_return=False, **kwargs): ''' Run `runner modules <all-salt.runners>` synchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`. Note that runner functions must be called using keyword arguments. Positional arguments are not suppor...
python
def runner(self, fun, timeout=None, full_return=False, **kwargs): ''' Run `runner modules <all-salt.runners>` synchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`. Note that runner functions must be called using keyword arguments. Positional arguments are not suppor...
[ "def", "runner", "(", "self", ",", "fun", ",", "timeout", "=", "None", ",", "full_return", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'fun'", "]", "=", "fun", "runner", "=", "salt", ".", "runner", ".", "RunnerClient", "(", "se...
Run `runner modules <all-salt.runners>` synchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_sync`. Note that runner functions must be called using keyword arguments. Positional arguments are not supported. :return: Returns the result from the runner module
[ "Run", "runner", "modules", "<all", "-", "salt", ".", "runners", ">", "synchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L148-L161
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.runner_async
def runner_async(self, fun, **kwargs): ''' Run `runner modules <all-salt.runners>` asynchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`. Note that runner functions must be called using keyword arguments. Positional arguments are not supported. :return: ev...
python
def runner_async(self, fun, **kwargs): ''' Run `runner modules <all-salt.runners>` asynchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`. Note that runner functions must be called using keyword arguments. Positional arguments are not supported. :return: ev...
[ "def", "runner_async", "(", "self", ",", "fun", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'fun'", "]", "=", "fun", "runner", "=", "salt", ".", "runner", ".", "RunnerClient", "(", "self", ".", "opts", ")", "return", "runner", ".", "cmd_async"...
Run `runner modules <all-salt.runners>` asynchronously Wraps :py:meth:`salt.runner.RunnerClient.cmd_async`. Note that runner functions must be called using keyword arguments. Positional arguments are not supported. :return: event data and a job ID for the executed function.
[ "Run", "runner", "modules", "<all", "-", "salt", ".", "runners", ">", "asynchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L163-L176
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.wheel
def wheel(self, fun, **kwargs): ''' Run :ref:`wheel modules <all-salt.wheel>` synchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Returns t...
python
def wheel(self, fun, **kwargs): ''' Run :ref:`wheel modules <all-salt.wheel>` synchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Returns t...
[ "def", "wheel", "(", "self", ",", "fun", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'fun'", "]", "=", "fun", "wheel", "=", "salt", ".", "wheel", ".", "WheelClient", "(", "self", ".", "opts", ")", "return", "wheel", ".", "cmd_sync", "(", "...
Run :ref:`wheel modules <all-salt.wheel>` synchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Returns the result from the wheel module
[ "Run", ":", "ref", ":", "wheel", "modules", "<all", "-", "salt", ".", "wheel", ">", "synchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L178-L191
train
saltstack/salt
salt/netapi/__init__.py
NetapiClient.wheel_async
def wheel_async(self, fun, **kwargs): ''' Run :ref:`wheel modules <all-salt.wheel>` asynchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Re...
python
def wheel_async(self, fun, **kwargs): ''' Run :ref:`wheel modules <all-salt.wheel>` asynchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Re...
[ "def", "wheel_async", "(", "self", ",", "fun", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'fun'", "]", "=", "fun", "wheel", "=", "salt", ".", "wheel", ".", "WheelClient", "(", "self", ".", "opts", ")", "return", "wheel", ".", "cmd_async", "...
Run :ref:`wheel modules <all-salt.wheel>` asynchronously Wraps :py:meth:`salt.wheel.WheelClient.master_call`. Note that wheel functions must be called using keyword arguments. Positional arguments are not supported. :return: Returns the result from the wheel module
[ "Run", ":", "ref", ":", "wheel", "modules", "<all", "-", "salt", ".", "wheel", ">", "asynchronously" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L193-L206
train
saltstack/salt
salt/utils/json.py
find_json
def find_json(raw): ''' Pass in a raw string and load the json when it starts. This allows for a string to start with garbage and end with json but be cleanly loaded ''' ret = {} lines = __split(raw) for ind, _ in enumerate(lines): try: working = '\n'.join(lines[ind:]) ...
python
def find_json(raw): ''' Pass in a raw string and load the json when it starts. This allows for a string to start with garbage and end with json but be cleanly loaded ''' ret = {} lines = __split(raw) for ind, _ in enumerate(lines): try: working = '\n'.join(lines[ind:]) ...
[ "def", "find_json", "(", "raw", ")", ":", "ret", "=", "{", "}", "lines", "=", "__split", "(", "raw", ")", "for", "ind", ",", "_", "in", "enumerate", "(", "lines", ")", ":", "try", ":", "working", "=", "'\\n'", ".", "join", "(", "lines", "[", "i...
Pass in a raw string and load the json when it starts. This allows for a string to start with garbage and end with json but be cleanly loaded
[ "Pass", "in", "a", "raw", "string", "and", "load", "the", "json", "when", "it", "starts", ".", "This", "allows", "for", "a", "string", "to", "start", "with", "garbage", "and", "end", "with", "json", "but", "be", "cleanly", "loaded" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L32-L53
train
saltstack/salt
salt/utils/json.py
import_json
def import_json(): ''' Import a json module, starting with the quick ones and going down the list) ''' for fast_json in ('ujson', 'yajl', 'json'): try: mod = __import__(fast_json) log.trace('loaded %s json lib', fast_json) return mod except ImportError...
python
def import_json(): ''' Import a json module, starting with the quick ones and going down the list) ''' for fast_json in ('ujson', 'yajl', 'json'): try: mod = __import__(fast_json) log.trace('loaded %s json lib', fast_json) return mod except ImportError...
[ "def", "import_json", "(", ")", ":", "for", "fast_json", "in", "(", "'ujson'", ",", "'yajl'", ",", "'json'", ")", ":", "try", ":", "mod", "=", "__import__", "(", "fast_json", ")", "log", ".", "trace", "(", "'loaded %s json lib'", ",", "fast_json", ")", ...
Import a json module, starting with the quick ones and going down the list)
[ "Import", "a", "json", "module", "starting", "with", "the", "quick", "ones", "and", "going", "down", "the", "list", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L56-L66
train
saltstack/salt
salt/utils/json.py
loads
def loads(s, **kwargs): ''' .. versionadded:: 2018.3.0 Wraps json.loads and prevents a traceback in the event that a bytestring is passed to the function. (Python < 3.6 cannot load bytestrings) You can pass an alternate json module (loaded via import_json() above) using the _json_module argume...
python
def loads(s, **kwargs): ''' .. versionadded:: 2018.3.0 Wraps json.loads and prevents a traceback in the event that a bytestring is passed to the function. (Python < 3.6 cannot load bytestrings) You can pass an alternate json module (loaded via import_json() above) using the _json_module argume...
[ "def", "loads", "(", "s", ",", "*", "*", "kwargs", ")", ":", "json_module", "=", "kwargs", ".", "pop", "(", "'_json_module'", ",", "json", ")", "try", ":", "return", "json_module", ".", "loads", "(", "s", ",", "*", "*", "kwargs", ")", "except", "Ty...
.. versionadded:: 2018.3.0 Wraps json.loads and prevents a traceback in the event that a bytestring is passed to the function. (Python < 3.6 cannot load bytestrings) You can pass an alternate json module (loaded via import_json() above) using the _json_module argument)
[ "..", "versionadded", "::", "2018", ".", "3", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L81-L99
train
saltstack/salt
salt/utils/json.py
dump
def dump(obj, fp, **kwargs): ''' .. versionadded:: 2018.3.0 Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly passed as True) for unicode compatibility. Note that setting it to True will mess up any unicode characters, as they will be dumped as the string literal versio...
python
def dump(obj, fp, **kwargs): ''' .. versionadded:: 2018.3.0 Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly passed as True) for unicode compatibility. Note that setting it to True will mess up any unicode characters, as they will be dumped as the string literal versio...
[ "def", "dump", "(", "obj", ",", "fp", ",", "*", "*", "kwargs", ")", ":", "json_module", "=", "kwargs", ".", "pop", "(", "'_json_module'", ",", "json", ")", "orig_enc_func", "=", "kwargs", ".", "pop", "(", "'default'", ",", "lambda", "x", ":", "x", ...
.. versionadded:: 2018.3.0 Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly passed as True) for unicode compatibility. Note that setting it to True will mess up any unicode characters, as they will be dumped as the string literal version of the unicode code point. On Pyth...
[ "..", "versionadded", "::", "2018", ".", "3", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L102-L128
train
saltstack/salt
salt/grains/mdata.py
_user_mdata
def _user_mdata(mdata_list=None, mdata_get=None): ''' User Metadata ''' grains = {} if not mdata_list: mdata_list = salt.utils.path.which('mdata-list') if not mdata_get: mdata_get = salt.utils.path.which('mdata-get') if not mdata_list or not mdata_get: return grain...
python
def _user_mdata(mdata_list=None, mdata_get=None): ''' User Metadata ''' grains = {} if not mdata_list: mdata_list = salt.utils.path.which('mdata-list') if not mdata_get: mdata_get = salt.utils.path.which('mdata-get') if not mdata_list or not mdata_get: return grain...
[ "def", "_user_mdata", "(", "mdata_list", "=", "None", ",", "mdata_get", "=", "None", ")", ":", "grains", "=", "{", "}", "if", "not", "mdata_list", ":", "mdata_list", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'mdata-list'", ")", "if", ...
User Metadata
[ "User", "Metadata" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L50-L77
train
saltstack/salt
salt/grains/mdata.py
_sdc_mdata
def _sdc_mdata(mdata_list=None, mdata_get=None): ''' SDC Metadata specified by there specs https://eng.joyent.com/mdata/datadict.html ''' grains = {} sdc_text_keys = [ 'uuid', 'server_uuid', 'datacenter_name', 'hostname', 'dns_domain', ] sdc_json_k...
python
def _sdc_mdata(mdata_list=None, mdata_get=None): ''' SDC Metadata specified by there specs https://eng.joyent.com/mdata/datadict.html ''' grains = {} sdc_text_keys = [ 'uuid', 'server_uuid', 'datacenter_name', 'hostname', 'dns_domain', ] sdc_json_k...
[ "def", "_sdc_mdata", "(", "mdata_list", "=", "None", ",", "mdata_get", "=", "None", ")", ":", "grains", "=", "{", "}", "sdc_text_keys", "=", "[", "'uuid'", ",", "'server_uuid'", ",", "'datacenter_name'", ",", "'hostname'", ",", "'dns_domain'", ",", "]", "s...
SDC Metadata specified by there specs https://eng.joyent.com/mdata/datadict.html
[ "SDC", "Metadata", "specified", "by", "there", "specs", "https", ":", "//", "eng", ".", "joyent", ".", "com", "/", "mdata", "/", "datadict", ".", "html" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L80-L125
train
saltstack/salt
salt/grains/mdata.py
_legacy_grains
def _legacy_grains(grains): ''' Grains for backwards compatibility Remove this function in Neon ''' # parse legacy sdc grains if 'mdata' in grains and 'sdc' in grains['mdata']: if 'server_uuid' not in grains['mdata']['sdc'] or 'FAILURE' in grains['mdata']['sdc']['server_uuid']: ...
python
def _legacy_grains(grains): ''' Grains for backwards compatibility Remove this function in Neon ''' # parse legacy sdc grains if 'mdata' in grains and 'sdc' in grains['mdata']: if 'server_uuid' not in grains['mdata']['sdc'] or 'FAILURE' in grains['mdata']['sdc']['server_uuid']: ...
[ "def", "_legacy_grains", "(", "grains", ")", ":", "# parse legacy sdc grains", "if", "'mdata'", "in", "grains", "and", "'sdc'", "in", "grains", "[", "'mdata'", "]", ":", "if", "'server_uuid'", "not", "in", "grains", "[", "'mdata'", "]", "[", "'sdc'", "]", ...
Grains for backwards compatibility Remove this function in Neon
[ "Grains", "for", "backwards", "compatibility", "Remove", "this", "function", "in", "Neon" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L128-L149
train
saltstack/salt
salt/grains/mdata.py
mdata
def mdata(): ''' Provide grains from the SmartOS metadata ''' grains = {} mdata_list = salt.utils.path.which('mdata-list') mdata_get = salt.utils.path.which('mdata-get') grains = salt.utils.dictupdate.update(grains, _user_mdata(mdata_list, mdata_get), merge_lists=True) grains = salt.uti...
python
def mdata(): ''' Provide grains from the SmartOS metadata ''' grains = {} mdata_list = salt.utils.path.which('mdata-list') mdata_get = salt.utils.path.which('mdata-get') grains = salt.utils.dictupdate.update(grains, _user_mdata(mdata_list, mdata_get), merge_lists=True) grains = salt.uti...
[ "def", "mdata", "(", ")", ":", "grains", "=", "{", "}", "mdata_list", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'mdata-list'", ")", "mdata_get", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'mdata-get'", ")", "grains"...
Provide grains from the SmartOS metadata
[ "Provide", "grains", "from", "the", "SmartOS", "metadata" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/mdata.py#L152-L165
train
saltstack/salt
salt/utils/xdg.py
xdg_config_dir
def xdg_config_dir(): ''' Check xdg locations for config files ''' xdg_config = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config')) xdg_config_directory = os.path.join(xdg_config, 'salt') return xdg_config_directory
python
def xdg_config_dir(): ''' Check xdg locations for config files ''' xdg_config = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config')) xdg_config_directory = os.path.join(xdg_config, 'salt') return xdg_config_directory
[ "def", "xdg_config_dir", "(", ")", ":", "xdg_config", "=", "os", ".", "getenv", "(", "'XDG_CONFIG_HOME'", ",", "os", ".", "path", ".", "expanduser", "(", "'~/.config'", ")", ")", "xdg_config_directory", "=", "os", ".", "path", ".", "join", "(", "xdg_config...
Check xdg locations for config files
[ "Check", "xdg", "locations", "for", "config", "files" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/xdg.py#L9-L15
train
saltstack/salt
salt/states/boto3_sns.py
topic_present
def topic_present(name, subscriptions=None, attributes=None, region=None, key=None, keyid=None, profile=None): ''' Ensure the SNS topic exists. name Name of the SNS topic. subscriptions List of SNS subscriptions. Each subscription is a dictionary with a proto...
python
def topic_present(name, subscriptions=None, attributes=None, region=None, key=None, keyid=None, profile=None): ''' Ensure the SNS topic exists. name Name of the SNS topic. subscriptions List of SNS subscriptions. Each subscription is a dictionary with a proto...
[ "def", "topic_present", "(", "name", ",", "subscriptions", "=", "None", ",", "attributes", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "ret", "=", "{", "'name'", ...
Ensure the SNS topic exists. name Name of the SNS topic. subscriptions List of SNS subscriptions. Each subscription is a dictionary with a protocol and endpoint key: .. code-block:: yaml subscriptions: - Protocol: https Endpoint: https:/...
[ "Ensure", "the", "SNS", "topic", "exists", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto3_sns.py#L75-L237
train
saltstack/salt
salt/states/boto3_sns.py
topic_absent
def topic_absent(name, unsubscribe=False, region=None, key=None, keyid=None, profile=None): ''' Ensure the named sns topic is deleted. name Name of the SNS topic. unsubscribe If True, unsubscribe all subcriptions to the SNS topic before deleting the SNS topic region ...
python
def topic_absent(name, unsubscribe=False, region=None, key=None, keyid=None, profile=None): ''' Ensure the named sns topic is deleted. name Name of the SNS topic. unsubscribe If True, unsubscribe all subcriptions to the SNS topic before deleting the SNS topic region ...
[ "def", "topic_absent", "(", "name", ",", "unsubscribe", "=", "False", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":...
Ensure the named sns topic is deleted. name Name of the SNS topic. unsubscribe If True, unsubscribe all subcriptions to the SNS topic before deleting the SNS topic region Region to connect to. key Secret key to be used. keyid Access key to be used...
[ "Ensure", "the", "named", "sns", "topic", "is", "deleted", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto3_sns.py#L314-L386
train
saltstack/salt
salt/netapi/rest_tornado/__init__.py
start
def start(): ''' Start the saltnado! ''' mod_opts = __opts__.get(__virtualname__, {}) if 'num_processes' not in mod_opts: mod_opts['num_processes'] = 1 if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True: raise Exception(( 'Tornado\'s debug imp...
python
def start(): ''' Start the saltnado! ''' mod_opts = __opts__.get(__virtualname__, {}) if 'num_processes' not in mod_opts: mod_opts['num_processes'] = 1 if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True: raise Exception(( 'Tornado\'s debug imp...
[ "def", "start", "(", ")", ":", "mod_opts", "=", "__opts__", ".", "get", "(", "__virtualname__", ",", "{", "}", ")", "if", "'num_processes'", "not", "in", "mod_opts", ":", "mod_opts", "[", "'num_processes'", "]", "=", "1", "if", "mod_opts", "[", "'num_pro...
Start the saltnado!
[ "Start", "the", "saltnado!" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/__init__.py#L87-L133
train
saltstack/salt
salt/states/file.py
_check_user
def _check_user(user, group): ''' Checks if the named user and group are present on the minion ''' err = '' if user: uid = __salt__['file.user_to_uid'](user) if uid == '': err += 'User {0} is not available '.format(user) if group: gid = __salt__['file.group_to...
python
def _check_user(user, group): ''' Checks if the named user and group are present on the minion ''' err = '' if user: uid = __salt__['file.user_to_uid'](user) if uid == '': err += 'User {0} is not available '.format(user) if group: gid = __salt__['file.group_to...
[ "def", "_check_user", "(", "user", ",", "group", ")", ":", "err", "=", "''", "if", "user", ":", "uid", "=", "__salt__", "[", "'file.user_to_uid'", "]", "(", "user", ")", "if", "uid", "==", "''", ":", "err", "+=", "'User {0} is not available '", ".", "f...
Checks if the named user and group are present on the minion
[ "Checks", "if", "the", "named", "user", "and", "group", "are", "present", "on", "the", "minion" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L380-L393
train
saltstack/salt
salt/states/file.py
_is_valid_relpath
def _is_valid_relpath( relpath, maxdepth=None): ''' Performs basic sanity checks on a relative path. Requires POSIX-compatible paths (i.e. the kind obtained through cp.list_master or other such calls). Ensures that the path does not contain directory transversal, and that it do...
python
def _is_valid_relpath( relpath, maxdepth=None): ''' Performs basic sanity checks on a relative path. Requires POSIX-compatible paths (i.e. the kind obtained through cp.list_master or other such calls). Ensures that the path does not contain directory transversal, and that it do...
[ "def", "_is_valid_relpath", "(", "relpath", ",", "maxdepth", "=", "None", ")", ":", "# Check relpath surrounded by slashes, so that `..` can be caught as", "# a path component at the start, end, and in the middle of the path.", "sep", ",", "pardir", "=", "posixpath", ".", "sep", ...
Performs basic sanity checks on a relative path. Requires POSIX-compatible paths (i.e. the kind obtained through cp.list_master or other such calls). Ensures that the path does not contain directory transversal, and that it does not exceed a stated maximum depth (if specified).
[ "Performs", "basic", "sanity", "checks", "on", "a", "relative", "path", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L396-L420
train
saltstack/salt
salt/states/file.py
_salt_to_os_path
def _salt_to_os_path(path): ''' Converts a path from the form received via salt master to the OS's native path format. ''' return os.path.normpath(path.replace(posixpath.sep, os.path.sep))
python
def _salt_to_os_path(path): ''' Converts a path from the form received via salt master to the OS's native path format. ''' return os.path.normpath(path.replace(posixpath.sep, os.path.sep))
[ "def", "_salt_to_os_path", "(", "path", ")", ":", "return", "os", ".", "path", ".", "normpath", "(", "path", ".", "replace", "(", "posixpath", ".", "sep", ",", "os", ".", "path", ".", "sep", ")", ")" ]
Converts a path from the form received via salt master to the OS's native path format.
[ "Converts", "a", "path", "from", "the", "form", "received", "via", "salt", "master", "to", "the", "OS", "s", "native", "path", "format", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L423-L428
train
saltstack/salt
salt/states/file.py
_gen_recurse_managed_files
def _gen_recurse_managed_files( name, source, keep_symlinks=False, include_pat=None, exclude_pat=None, maxdepth=None, include_empty=False, **kwargs): ''' Generate the list of files managed by a recurse state ''' # Convert a relative path g...
python
def _gen_recurse_managed_files( name, source, keep_symlinks=False, include_pat=None, exclude_pat=None, maxdepth=None, include_empty=False, **kwargs): ''' Generate the list of files managed by a recurse state ''' # Convert a relative path g...
[ "def", "_gen_recurse_managed_files", "(", "name", ",", "source", ",", "keep_symlinks", "=", "False", ",", "include_pat", "=", "None", ",", "exclude_pat", "=", "None", ",", "maxdepth", "=", "None", ",", "include_empty", "=", "False", ",", "*", "*", "kwargs", ...
Generate the list of files managed by a recurse state
[ "Generate", "the", "list", "of", "files", "managed", "by", "a", "recurse", "state" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L431-L556
train
saltstack/salt
salt/states/file.py
_gen_keep_files
def _gen_keep_files(name, require, walk_d=None): ''' Generate the list of files that need to be kept when a dir based function like directory or recurse has a clean. ''' def _is_child(path, directory): ''' Check whether ``path`` is child of ``directory`` ''' path = os...
python
def _gen_keep_files(name, require, walk_d=None): ''' Generate the list of files that need to be kept when a dir based function like directory or recurse has a clean. ''' def _is_child(path, directory): ''' Check whether ``path`` is child of ``directory`` ''' path = os...
[ "def", "_gen_keep_files", "(", "name", ",", "require", ",", "walk_d", "=", "None", ")", ":", "def", "_is_child", "(", "path", ",", "directory", ")", ":", "'''\n Check whether ``path`` is child of ``directory``\n '''", "path", "=", "os", ".", "path", ...
Generate the list of files that need to be kept when a dir based function like directory or recurse has a clean.
[ "Generate", "the", "list", "of", "files", "that", "need", "to", "be", "kept", "when", "a", "dir", "based", "function", "like", "directory", "or", "recurse", "has", "a", "clean", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L559-L631
train
saltstack/salt
salt/states/file.py
_find_keep_files
def _find_keep_files(root, keep): ''' Compile a list of valid keep files (and directories). Used by _clean_dir() ''' real_keep = set() real_keep.add(root) if isinstance(keep, list): for fn_ in keep: if not os.path.isabs(fn_): continue fn_ = os....
python
def _find_keep_files(root, keep): ''' Compile a list of valid keep files (and directories). Used by _clean_dir() ''' real_keep = set() real_keep.add(root) if isinstance(keep, list): for fn_ in keep: if not os.path.isabs(fn_): continue fn_ = os....
[ "def", "_find_keep_files", "(", "root", ",", "keep", ")", ":", "real_keep", "=", "set", "(", ")", "real_keep", ".", "add", "(", "root", ")", "if", "isinstance", "(", "keep", ",", "list", ")", ":", "for", "fn_", "in", "keep", ":", "if", "not", "os",...
Compile a list of valid keep files (and directories). Used by _clean_dir()
[ "Compile", "a", "list", "of", "valid", "keep", "files", "(", "and", "directories", ")", ".", "Used", "by", "_clean_dir", "()" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L648-L667
train
saltstack/salt
salt/states/file.py
_clean_dir
def _clean_dir(root, keep, exclude_pat): ''' Clean out all of the files and directories in a directory (root) while preserving the files in a list (keep) and part of exclude_pat ''' root = os.path.normcase(root) real_keep = _find_keep_files(root, keep) removed = set() def _delete_not_ke...
python
def _clean_dir(root, keep, exclude_pat): ''' Clean out all of the files and directories in a directory (root) while preserving the files in a list (keep) and part of exclude_pat ''' root = os.path.normcase(root) real_keep = _find_keep_files(root, keep) removed = set() def _delete_not_ke...
[ "def", "_clean_dir", "(", "root", ",", "keep", ",", "exclude_pat", ")", ":", "root", "=", "os", ".", "path", ".", "normcase", "(", "root", ")", "real_keep", "=", "_find_keep_files", "(", "root", ",", "keep", ")", "removed", "=", "set", "(", ")", "def...
Clean out all of the files and directories in a directory (root) while preserving the files in a list (keep) and part of exclude_pat
[ "Clean", "out", "all", "of", "the", "files", "and", "directories", "in", "a", "directory", "(", "root", ")", "while", "preserving", "the", "files", "in", "a", "list", "(", "keep", ")", "and", "part", "of", "exclude_pat" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L670-L696
train
saltstack/salt
salt/states/file.py
_check_directory
def _check_directory(name, user=None, group=None, recurse=False, mode=None, file_mode=None, clean=False, require=False, exclude_pat=None, ...
python
def _check_directory(name, user=None, group=None, recurse=False, mode=None, file_mode=None, clean=False, require=False, exclude_pat=None, ...
[ "def", "_check_directory", "(", "name", ",", "user", "=", "None", ",", "group", "=", "None", ",", "recurse", "=", "False", ",", "mode", "=", "None", ",", "file_mode", "=", "None", ",", "clean", "=", "False", ",", "require", "=", "False", ",", "exclud...
Check what changes need to be made on a directory
[ "Check", "what", "changes", "need", "to", "be", "made", "on", "a", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L705-L803
train
saltstack/salt
salt/states/file.py
_check_directory_win
def _check_directory_win(name, win_owner=None, win_perms=None, win_deny_perms=None, win_inheritance=None, win_perms_reset=None): ''' Check what changes need to be made on a directory ...
python
def _check_directory_win(name, win_owner=None, win_perms=None, win_deny_perms=None, win_inheritance=None, win_perms_reset=None): ''' Check what changes need to be made on a directory ...
[ "def", "_check_directory_win", "(", "name", ",", "win_owner", "=", "None", ",", "win_perms", "=", "None", ",", "win_deny_perms", "=", "None", ",", "win_inheritance", "=", "None", ",", "win_perms_reset", "=", "None", ")", ":", "changes", "=", "{", "}", "if"...
Check what changes need to be made on a directory
[ "Check", "what", "changes", "need", "to", "be", "made", "on", "a", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L806-L949
train
saltstack/salt
salt/states/file.py
_check_dir_meta
def _check_dir_meta(name, user, group, mode, follow_symlinks=False): ''' Check the changes in directory metadata ''' try: stats = __salt__['file.stats'](name, None, follow_symlinks) except CommandExecutionError: ...
python
def _check_dir_meta(name, user, group, mode, follow_symlinks=False): ''' Check the changes in directory metadata ''' try: stats = __salt__['file.stats'](name, None, follow_symlinks) except CommandExecutionError: ...
[ "def", "_check_dir_meta", "(", "name", ",", "user", ",", "group", ",", "mode", ",", "follow_symlinks", "=", "False", ")", ":", "try", ":", "stats", "=", "__salt__", "[", "'file.stats'", "]", "(", "name", ",", "None", ",", "follow_symlinks", ")", "except"...
Check the changes in directory metadata
[ "Check", "the", "changes", "in", "directory", "metadata" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L952-L982
train
saltstack/salt
salt/states/file.py
_check_touch
def _check_touch(name, atime, mtime): ''' Check to see if a file needs to be updated or created ''' ret = { 'result': None, 'comment': '', 'changes': {'new': name}, } if not os.path.exists(name): ret['comment'] = 'File {0} is set to be created'.format(name) el...
python
def _check_touch(name, atime, mtime): ''' Check to see if a file needs to be updated or created ''' ret = { 'result': None, 'comment': '', 'changes': {'new': name}, } if not os.path.exists(name): ret['comment'] = 'File {0} is set to be created'.format(name) el...
[ "def", "_check_touch", "(", "name", ",", "atime", ",", "mtime", ")", ":", "ret", "=", "{", "'result'", ":", "None", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "'new'", ":", "name", "}", ",", "}", "if", "not", "os", ".", "path", ".",...
Check to see if a file needs to be updated or created
[ "Check", "to", "see", "if", "a", "file", "needs", "to", "be", "updated", "or", "created" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L985-L1007
train
saltstack/salt
salt/states/file.py
_check_symlink_ownership
def _check_symlink_ownership(path, user, group, win_owner): ''' Check if the symlink ownership matches the specified user and group ''' cur_user, cur_group = _get_symlink_ownership(path) if salt.utils.platform.is_windows(): return win_owner == cur_user else: return (cur_user == u...
python
def _check_symlink_ownership(path, user, group, win_owner): ''' Check if the symlink ownership matches the specified user and group ''' cur_user, cur_group = _get_symlink_ownership(path) if salt.utils.platform.is_windows(): return win_owner == cur_user else: return (cur_user == u...
[ "def", "_check_symlink_ownership", "(", "path", ",", "user", ",", "group", ",", "win_owner", ")", ":", "cur_user", ",", "cur_group", "=", "_get_symlink_ownership", "(", "path", ")", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ...
Check if the symlink ownership matches the specified user and group
[ "Check", "if", "the", "symlink", "ownership", "matches", "the", "specified", "user", "and", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1021-L1029
train
saltstack/salt
salt/states/file.py
_set_symlink_ownership
def _set_symlink_ownership(path, user, group, win_owner): ''' Set the ownership of a symlink and return a boolean indicating success/failure ''' if salt.utils.platform.is_windows(): try: salt.utils.win_dacl.set_owner(path, win_owner) except CommandExecutionError: ...
python
def _set_symlink_ownership(path, user, group, win_owner): ''' Set the ownership of a symlink and return a boolean indicating success/failure ''' if salt.utils.platform.is_windows(): try: salt.utils.win_dacl.set_owner(path, win_owner) except CommandExecutionError: ...
[ "def", "_set_symlink_ownership", "(", "path", ",", "user", ",", "group", ",", "win_owner", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ":", "try", ":", "salt", ".", "utils", ".", "win_dacl", ".", "set_owner", "("...
Set the ownership of a symlink and return a boolean indicating success/failure
[ "Set", "the", "ownership", "of", "a", "symlink", "and", "return", "a", "boolean", "indicating", "success", "/", "failure" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1032-L1047
train
saltstack/salt
salt/states/file.py
_symlink_check
def _symlink_check(name, target, force, user, group, win_owner): ''' Check the symlink function ''' changes = {} if not os.path.exists(name) and not __salt__['file.is_link'](name): changes['new'] = name return None, 'Symlink {0} to {1} is set for creation'.format( name, t...
python
def _symlink_check(name, target, force, user, group, win_owner): ''' Check the symlink function ''' changes = {} if not os.path.exists(name) and not __salt__['file.is_link'](name): changes['new'] = name return None, 'Symlink {0} to {1} is set for creation'.format( name, t...
[ "def", "_symlink_check", "(", "name", ",", "target", ",", "force", ",", "user", ",", "group", ",", "win_owner", ")", ":", "changes", "=", "{", "}", "if", "not", "os", ".", "path", ".", "exists", "(", "name", ")", "and", "not", "__salt__", "[", "'fi...
Check the symlink function
[ "Check", "the", "symlink", "function" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1050-L1083
train
saltstack/salt
salt/states/file.py
_unify_sources_and_hashes
def _unify_sources_and_hashes(source=None, source_hash=None, sources=None, source_hashes=None): ''' Silly little function to give us a standard tuple list for sources and source_hashes ''' if sources is None: sources = [] if source_hashes is None: s...
python
def _unify_sources_and_hashes(source=None, source_hash=None, sources=None, source_hashes=None): ''' Silly little function to give us a standard tuple list for sources and source_hashes ''' if sources is None: sources = [] if source_hashes is None: s...
[ "def", "_unify_sources_and_hashes", "(", "source", "=", "None", ",", "source_hash", "=", "None", ",", "sources", "=", "None", ",", "source_hashes", "=", "None", ")", ":", "if", "sources", "is", "None", ":", "sources", "=", "[", "]", "if", "source_hashes", ...
Silly little function to give us a standard tuple list for sources and source_hashes
[ "Silly", "little", "function", "to", "give", "us", "a", "standard", "tuple", "list", "for", "sources", "and", "source_hashes" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1104-L1128
train
saltstack/salt
salt/states/file.py
_get_template_texts
def _get_template_texts(source_list=None, template='jinja', defaults=None, context=None, **kwargs): ''' Iterate a list of sources and process them as templates. Returns a list of 'chunks' containing the rendered ...
python
def _get_template_texts(source_list=None, template='jinja', defaults=None, context=None, **kwargs): ''' Iterate a list of sources and process them as templates. Returns a list of 'chunks' containing the rendered ...
[ "def", "_get_template_texts", "(", "source_list", "=", "None", ",", "template", "=", "'jinja'", ",", "defaults", "=", "None", ",", "context", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "'_get_template_texts'", ",", "'...
Iterate a list of sources and process them as templates. Returns a list of 'chunks' containing the rendered templates.
[ "Iterate", "a", "list", "of", "sources", "and", "process", "them", "as", "templates", ".", "Returns", "a", "list", "of", "chunks", "containing", "the", "rendered", "templates", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1131-L1189
train
saltstack/salt
salt/states/file.py
_validate_str_list
def _validate_str_list(arg): ''' ensure ``arg`` is a list of strings ''' if isinstance(arg, six.binary_type): ret = [salt.utils.stringutils.to_unicode(arg)] elif isinstance(arg, six.string_types): ret = [arg] elif isinstance(arg, Iterable) and not isinstance(arg, Mapping): ...
python
def _validate_str_list(arg): ''' ensure ``arg`` is a list of strings ''' if isinstance(arg, six.binary_type): ret = [salt.utils.stringutils.to_unicode(arg)] elif isinstance(arg, six.string_types): ret = [arg] elif isinstance(arg, Iterable) and not isinstance(arg, Mapping): ...
[ "def", "_validate_str_list", "(", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "six", ".", "binary_type", ")", ":", "ret", "=", "[", "salt", ".", "utils", ".", "stringutils", ".", "to_unicode", "(", "arg", ")", "]", "elif", "isinstance", "(", ...
ensure ``arg`` is a list of strings
[ "ensure", "arg", "is", "a", "list", "of", "strings" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1192-L1209
train
saltstack/salt
salt/states/file.py
_set_shortcut_ownership
def _set_shortcut_ownership(path, user): ''' Set the ownership of a shortcut and return a boolean indicating success/failure ''' try: __salt__['file.lchown'](path, user) except OSError: pass return _check_shortcut_ownership(path, user)
python
def _set_shortcut_ownership(path, user): ''' Set the ownership of a shortcut and return a boolean indicating success/failure ''' try: __salt__['file.lchown'](path, user) except OSError: pass return _check_shortcut_ownership(path, user)
[ "def", "_set_shortcut_ownership", "(", "path", ",", "user", ")", ":", "try", ":", "__salt__", "[", "'file.lchown'", "]", "(", "path", ",", "user", ")", "except", "OSError", ":", "pass", "return", "_check_shortcut_ownership", "(", "path", ",", "user", ")" ]
Set the ownership of a shortcut and return a boolean indicating success/failure
[ "Set", "the", "ownership", "of", "a", "shortcut", "and", "return", "a", "boolean", "indicating", "success", "/", "failure" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1224-L1233
train
saltstack/salt
salt/states/file.py
_shortcut_check
def _shortcut_check(name, target, arguments, working_dir, description, icon_location, force, user): ''' Check the shortcut function ''' changes = {} if not os.p...
python
def _shortcut_check(name, target, arguments, working_dir, description, icon_location, force, user): ''' Check the shortcut function ''' changes = {} if not os.p...
[ "def", "_shortcut_check", "(", "name", ",", "target", ",", "arguments", ",", "working_dir", ",", "description", ",", "icon_location", ",", "force", ",", "user", ")", ":", "changes", "=", "{", "}", "if", "not", "os", ".", "path", ".", "exists", "(", "na...
Check the shortcut function
[ "Check", "the", "shortcut", "function" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1236-L1294
train
saltstack/salt
salt/states/file.py
_makedirs
def _makedirs(name, user=None, group=None, dir_mode=None, win_owner=None, win_perms=None, win_deny_perms=None, win_inheritance=None): ''' Helper function for creating directories when the ``makedirs`` option is set...
python
def _makedirs(name, user=None, group=None, dir_mode=None, win_owner=None, win_perms=None, win_deny_perms=None, win_inheritance=None): ''' Helper function for creating directories when the ``makedirs`` option is set...
[ "def", "_makedirs", "(", "name", ",", "user", "=", "None", ",", "group", "=", "None", ",", "dir_mode", "=", "None", ",", "win_owner", "=", "None", ",", "win_perms", "=", "None", ",", "win_deny_perms", "=", "None", ",", "win_inheritance", "=", "None", "...
Helper function for creating directories when the ``makedirs`` option is set to ``True``. Handles Unix and Windows based systems .. versionadded:: 2017.7.8 Args: name (str): The directory path to create user (str): The linux user to own the directory group (str): The linux group to...
[ "Helper", "function", "for", "creating", "directories", "when", "the", "makedirs", "option", "is", "set", "to", "True", ".", "Handles", "Unix", "and", "Windows", "based", "systems" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1297-L1345
train
saltstack/salt
salt/states/file.py
symlink
def symlink( name, target, force=False, backupname=None, makedirs=False, user=None, group=None, copy_target_user=False, copy_target_group=False, mode=None, win_owner=None, win_perms=None, win_deny_perms=None, ...
python
def symlink( name, target, force=False, backupname=None, makedirs=False, user=None, group=None, copy_target_user=False, copy_target_group=False, mode=None, win_owner=None, win_perms=None, win_deny_perms=None, ...
[ "def", "symlink", "(", "name", ",", "target", ",", "force", "=", "False", ",", "backupname", "=", "None", ",", "makedirs", "=", "False", ",", "user", "=", "None", ",", "group", "=", "None", ",", "copy_target_user", "=", "False", ",", "copy_target_group",...
Create a symbolic link (symlink, soft link) If the file already exists and is a symlink pointing to any location other than the specified target, the symlink will be replaced. If the symlink is a regular file or directory then the state will return False. If the regular file or directory is desired to ...
[ "Create", "a", "symbolic", "link", "(", "symlink", "soft", "link", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1348-L1714
train
saltstack/salt
salt/states/file.py
absent
def absent(name, **kwargs): ''' Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should ...
python
def absent(name, **kwargs): ''' Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should ...
[ "def", "absent", "(", "name", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'...
Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted
[ "Make", "sure", "that", "the", "named", "file", "or", "directory", "is", "absent", ".", "If", "it", "exists", "it", "will", "be", "deleted", ".", "This", "will", "work", "to", "reverse", "any", "of", "the", "functions", "in", "the", "file", "state", "m...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1717-L1770
train
saltstack/salt
salt/states/file.py
tidied
def tidied(name, age=0, matches=None, rmdirs=False, size=0, **kwargs): ''' Remove unwanted files based on specific criteria. Multiple criteria are OR’d together, so a file that is too large but is not old enough will still get tidied. If neithe...
python
def tidied(name, age=0, matches=None, rmdirs=False, size=0, **kwargs): ''' Remove unwanted files based on specific criteria. Multiple criteria are OR’d together, so a file that is too large but is not old enough will still get tidied. If neithe...
[ "def", "tidied", "(", "name", ",", "age", "=", "0", ",", "matches", "=", "None", ",", "rmdirs", "=", "False", ",", "size", "=", "0", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", ...
Remove unwanted files based on specific criteria. Multiple criteria are OR’d together, so a file that is too large but is not old enough will still get tidied. If neither age nor size is given all files which match a pattern in matches will be removed. name The directory tree that should b...
[ "Remove", "unwanted", "files", "based", "on", "specific", "criteria", ".", "Multiple", "criteria", "are", "OR’d", "together", "so", "a", "file", "that", "is", "too", "large", "but", "is", "not", "old", "enough", "will", "still", "get", "tidied", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1773-L1889
train
saltstack/salt
salt/states/file.py
exists
def exists(name, **kwargs): ''' Verify that the named file or directory is present or exists. Ensures pre-requisites outside of Salt's purview (e.g., keytabs, private keys, etc.) have been previously satisfied before deployment. This function does not create the file if it doesn't ex...
python
def exists(name, **kwargs): ''' Verify that the named file or directory is present or exists. Ensures pre-requisites outside of Salt's purview (e.g., keytabs, private keys, etc.) have been previously satisfied before deployment. This function does not create the file if it doesn't ex...
[ "def", "exists", "(", "name", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'...
Verify that the named file or directory is present or exists. Ensures pre-requisites outside of Salt's purview (e.g., keytabs, private keys, etc.) have been previously satisfied before deployment. This function does not create the file if it doesn't exist, it will return an error. name ...
[ "Verify", "that", "the", "named", "file", "or", "directory", "is", "present", "or", "exists", ".", "Ensures", "pre", "-", "requisites", "outside", "of", "Salt", "s", "purview", "(", "e", ".", "g", ".", "keytabs", "private", "keys", "etc", ".", ")", "ha...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1892-L1918
train
saltstack/salt
salt/states/file.py
managed
def managed(name, source=None, source_hash='', source_hash_name=None, keep_source=True, user=None, group=None, mode=None, attrs=None, template=None, makedirs=False, dir_mode=None, ...
python
def managed(name, source=None, source_hash='', source_hash_name=None, keep_source=True, user=None, group=None, mode=None, attrs=None, template=None, makedirs=False, dir_mode=None, ...
[ "def", "managed", "(", "name", ",", "source", "=", "None", ",", "source_hash", "=", "''", ",", "source_hash_name", "=", "None", ",", "keep_source", "=", "True", ",", "user", "=", "None", ",", "group", "=", "None", ",", "mode", "=", "None", ",", "attr...
r''' Manage a given file, this function allows for a file to be downloaded from the salt master and potentially run through a templating system. name The location of the file to manage, as an absolute path. source The source file to download to the minion, this source file can be ...
[ "r", "Manage", "a", "given", "file", "this", "function", "allows", "for", "a", "file", "to", "be", "downloaded", "from", "the", "salt", "master", "and", "potentially", "run", "through", "a", "templating", "system", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1945-L3062
train
saltstack/salt
salt/states/file.py
_get_recurse_set
def _get_recurse_set(recurse): ''' Converse *recurse* definition to a set of strings. Raises TypeError or ValueError when *recurse* has wrong structure. ''' if not recurse: return set() if not isinstance(recurse, list): raise TypeError('"recurse" must be formed as a list of stri...
python
def _get_recurse_set(recurse): ''' Converse *recurse* definition to a set of strings. Raises TypeError or ValueError when *recurse* has wrong structure. ''' if not recurse: return set() if not isinstance(recurse, list): raise TypeError('"recurse" must be formed as a list of stri...
[ "def", "_get_recurse_set", "(", "recurse", ")", ":", "if", "not", "recurse", ":", "return", "set", "(", ")", "if", "not", "isinstance", "(", "recurse", ",", "list", ")", ":", "raise", "TypeError", "(", "'\"recurse\" must be formed as a list of strings'", ")", ...
Converse *recurse* definition to a set of strings. Raises TypeError or ValueError when *recurse* has wrong structure.
[ "Converse", "*", "recurse", "*", "definition", "to", "a", "set", "of", "strings", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3068-L3088
train
saltstack/salt
salt/states/file.py
_depth_limited_walk
def _depth_limited_walk(top, max_depth=None): ''' Walk the directory tree under root up till reaching max_depth. With max_depth=None (default), do not limit depth. ''' for root, dirs, files in salt.utils.path.os_walk(top): if max_depth is not None: rel_depth = root.count(os.path....
python
def _depth_limited_walk(top, max_depth=None): ''' Walk the directory tree under root up till reaching max_depth. With max_depth=None (default), do not limit depth. ''' for root, dirs, files in salt.utils.path.os_walk(top): if max_depth is not None: rel_depth = root.count(os.path....
[ "def", "_depth_limited_walk", "(", "top", ",", "max_depth", "=", "None", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "salt", ".", "utils", ".", "path", ".", "os_walk", "(", "top", ")", ":", "if", "max_depth", "is", "not", "None", ":", ...
Walk the directory tree under root up till reaching max_depth. With max_depth=None (default), do not limit depth.
[ "Walk", "the", "directory", "tree", "under", "root", "up", "till", "reaching", "max_depth", ".", "With", "max_depth", "=", "None", "(", "default", ")", "do", "not", "limit", "depth", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3091-L3101
train
saltstack/salt
salt/states/file.py
directory
def directory(name, user=None, group=None, recurse=None, max_depth=None, dir_mode=None, file_mode=None, makedirs=False, clean=False, require=None, exclude_pat=None, f...
python
def directory(name, user=None, group=None, recurse=None, max_depth=None, dir_mode=None, file_mode=None, makedirs=False, clean=False, require=None, exclude_pat=None, f...
[ "def", "directory", "(", "name", ",", "user", "=", "None", ",", "group", "=", "None", ",", "recurse", "=", "None", ",", "max_depth", "=", "None", ",", "dir_mode", "=", "None", ",", "file_mode", "=", "None", ",", "makedirs", "=", "False", ",", "clean"...
r''' Ensure that a named directory is present and has the right perms name The location to create or manage a directory, as an absolute path user The user to own the directory; this defaults to the user salt is running as on the minion group The group ownership set for...
[ "r", "Ensure", "that", "a", "named", "directory", "is", "present", "and", "has", "the", "right", "perms" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3104-L3638
train
saltstack/salt
salt/states/file.py
recurse
def recurse(name, source, keep_source=True, clean=False, require=None, user=None, group=None, dir_mode=None, file_mode=None, sym_mode=None, template=None, context=None, replace...
python
def recurse(name, source, keep_source=True, clean=False, require=None, user=None, group=None, dir_mode=None, file_mode=None, sym_mode=None, template=None, context=None, replace...
[ "def", "recurse", "(", "name", ",", "source", ",", "keep_source", "=", "True", ",", "clean", "=", "False", ",", "require", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "dir_mode", "=", "None", ",", "file_mode", "=", "None", ...
Recurse through a subdirectory on the master and copy said subdirectory over to the specified path. name The directory to set the recursion in source The source directory, this directory is located on the salt master file server and is specified with the salt:// protocol. If the di...
[ "Recurse", "through", "a", "subdirectory", "on", "the", "master", "and", "copy", "said", "subdirectory", "over", "to", "the", "specified", "path", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L3641-L4111
train
saltstack/salt
salt/states/file.py
retention_schedule
def retention_schedule(name, retain, strptime_format=None, timezone=None): ''' Apply retention scheduling to backup storage directory. .. versionadded:: 2016.11.0 :param name: The filesystem path to the directory containing backups to be managed. :param retain: Delete the backups,...
python
def retention_schedule(name, retain, strptime_format=None, timezone=None): ''' Apply retention scheduling to backup storage directory. .. versionadded:: 2016.11.0 :param name: The filesystem path to the directory containing backups to be managed. :param retain: Delete the backups,...
[ "def", "retention_schedule", "(", "name", ",", "retain", ",", "strptime_format", "=", "None", ",", "timezone", "=", "None", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'...
Apply retention scheduling to backup storage directory. .. versionadded:: 2016.11.0 :param name: The filesystem path to the directory containing backups to be managed. :param retain: Delete the backups, except for the ones we want to keep. The N below should be an integer but may ...
[ "Apply", "retention", "scheduling", "to", "backup", "storage", "directory", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4114-L4303
train
saltstack/salt
salt/states/file.py
line
def line(name, content=None, match=None, mode=None, location=None, before=None, after=None, show_changes=True, backup=False, quiet=False, indent=True, create=False, user=None, group=None, file_mode=None): ''' Line-based editing of a file. .. versionadded:: 2015.8.0 :param na...
python
def line(name, content=None, match=None, mode=None, location=None, before=None, after=None, show_changes=True, backup=False, quiet=False, indent=True, create=False, user=None, group=None, file_mode=None): ''' Line-based editing of a file. .. versionadded:: 2015.8.0 :param na...
[ "def", "line", "(", "name", ",", "content", "=", "None", ",", "match", "=", "None", ",", "mode", "=", "None", ",", "location", "=", "None", ",", "before", "=", "None", ",", "after", "=", "None", ",", "show_changes", "=", "True", ",", "backup", "=",...
Line-based editing of a file. .. versionadded:: 2015.8.0 :param name: Filesystem path to the file to be edited. :param content: Content of the line. Allowed to be empty if mode=delete. :param match: Match the target line for an action by a fragment of a string or regu...
[ "Line", "-", "based", "editing", "of", "a", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4306-L4475
train
saltstack/salt
salt/states/file.py
replace
def replace(name, pattern, repl, count=0, flags=8, bufsize=1, append_if_not_found=False, prepend_if_not_found=False, not_found_content=None, backup='.bak', show_changes=True, ignore_if_mis...
python
def replace(name, pattern, repl, count=0, flags=8, bufsize=1, append_if_not_found=False, prepend_if_not_found=False, not_found_content=None, backup='.bak', show_changes=True, ignore_if_mis...
[ "def", "replace", "(", "name", ",", "pattern", ",", "repl", ",", "count", "=", "0", ",", "flags", "=", "8", ",", "bufsize", "=", "1", ",", "append_if_not_found", "=", "False", ",", "prepend_if_not_found", "=", "False", ",", "not_found_content", "=", "Non...
r''' Maintain an edit in a file. .. versionadded:: 0.17.0 name Filesystem path to the file to be edited. If a symlink is specified, it will be resolved to its target. pattern A regular expression, to be matched using Python's :py:func:`re.search`. .. note:: ...
[ "r", "Maintain", "an", "edit", "in", "a", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4478-L4676
train
saltstack/salt
salt/states/file.py
keyvalue
def keyvalue( name, key=None, value=None, key_values=None, separator="=", append_if_not_found=False, prepend_if_not_found=False, search_only=False, show_changes=True, ignore_if_missing=False, count=1, uncomment=None, ...
python
def keyvalue( name, key=None, value=None, key_values=None, separator="=", append_if_not_found=False, prepend_if_not_found=False, search_only=False, show_changes=True, ignore_if_missing=False, count=1, uncomment=None, ...
[ "def", "keyvalue", "(", "name", ",", "key", "=", "None", ",", "value", "=", "None", ",", "key_values", "=", "None", ",", "separator", "=", "\"=\"", ",", "append_if_not_found", "=", "False", ",", "prepend_if_not_found", "=", "False", ",", "search_only", "="...
Key/Value based editing of a file. .. versionadded:: Neon This function differs from ``file.replace`` in that it is able to search for keys, followed by a customizable separator, and replace the value with the given value. Should the value be the same as the one already in the file, no changes wil...
[ "Key", "/", "Value", "based", "editing", "of", "a", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4679-L5036
train
saltstack/salt
salt/states/file.py
blockreplace
def blockreplace( name, marker_start='#-- start managed zone --', marker_end='#-- end managed zone --', source=None, source_hash=None, template='jinja', sources=None, source_hashes=None, defaults=None, context=None, content='', ...
python
def blockreplace( name, marker_start='#-- start managed zone --', marker_end='#-- end managed zone --', source=None, source_hash=None, template='jinja', sources=None, source_hashes=None, defaults=None, context=None, content='', ...
[ "def", "blockreplace", "(", "name", ",", "marker_start", "=", "'#-- start managed zone --'", ",", "marker_end", "=", "'#-- end managed zone --'", ",", "source", "=", "None", ",", "source_hash", "=", "None", ",", "template", "=", "'jinja'", ",", "sources", "=", "...
Maintain an edit in a file in a zone delimited by two line markers .. versionadded:: 2014.1.0 .. versionchanged:: 2017.7.5,2018.3.1 ``append_newline`` argument added. Additionally, to improve idempotence, if the string represented by ``marker_end`` is found in the middle of the line, th...
[ "Maintain", "an", "edit", "in", "a", "file", "in", "a", "zone", "delimited", "by", "two", "line", "markers" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5039-L5352
train
saltstack/salt
salt/states/file.py
comment
def comment(name, regex, char='#', backup='.bak'): ''' Comment out specified lines in a file. name The full path to the file to be edited regex A regular expression used to find the lines that are to be commented; this pattern will be wrapped in parenthesis and will move any ...
python
def comment(name, regex, char='#', backup='.bak'): ''' Comment out specified lines in a file. name The full path to the file to be edited regex A regular expression used to find the lines that are to be commented; this pattern will be wrapped in parenthesis and will move any ...
[ "def", "comment", "(", "name", ",", "regex", ",", "char", "=", "'#'", ",", "backup", "=", "'.bak'", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{",...
Comment out specified lines in a file. name The full path to the file to be edited regex A regular expression used to find the lines that are to be commented; this pattern will be wrapped in parenthesis and will move any preceding/trailing ``^`` or ``$`` characters outside the p...
[ "Comment", "out", "specified", "lines", "in", "a", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5355-L5456
train
saltstack/salt
salt/states/file.py
uncomment
def uncomment(name, regex, char='#', backup='.bak'): ''' Uncomment specified commented lines in a file name The full path to the file to be edited regex A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A...
python
def uncomment(name, regex, char='#', backup='.bak'): ''' Uncomment specified commented lines in a file name The full path to the file to be edited regex A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A...
[ "def", "uncomment", "(", "name", ",", "regex", ",", "char", "=", "'#'", ",", "backup", "=", "'.bak'", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{...
Uncomment specified commented lines in a file name The full path to the file to be edited regex A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A leading ``^`` character will be stripped for convenience...
[ "Uncomment", "specified", "commented", "lines", "in", "a", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5459-L5561
train
saltstack/salt
salt/states/file.py
append
def append(name, text=None, makedirs=False, source=None, source_hash=None, template='jinja', sources=None, source_hashes=None, defaults=None, context=None, ignore_whitespace=True): ''' Ensure that some ...
python
def append(name, text=None, makedirs=False, source=None, source_hash=None, template='jinja', sources=None, source_hashes=None, defaults=None, context=None, ignore_whitespace=True): ''' Ensure that some ...
[ "def", "append", "(", "name", ",", "text", "=", "None", ",", "makedirs", "=", "False", ",", "source", "=", "None", ",", "source_hash", "=", "None", ",", "template", "=", "'jinja'", ",", "sources", "=", "None", ",", "source_hashes", "=", "None", ",", ...
Ensure that some text appears at the end of a file. The text will not be appended if it already exists in the file. A single string of text or a list of strings may be appended. name The location of the file to append to. text The text to be appended, which can be a single string or a...
[ "Ensure", "that", "some", "text", "appears", "at", "the", "end", "of", "a", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L5564-L5836
train
saltstack/salt
salt/states/file.py
patch
def patch(name, source=None, source_hash=None, source_hash_name=None, skip_verify=False, template=None, context=None, defaults=None, options='', reject_file=None, strip=None, saltenv=None, **kwargs): ...
python
def patch(name, source=None, source_hash=None, source_hash_name=None, skip_verify=False, template=None, context=None, defaults=None, options='', reject_file=None, strip=None, saltenv=None, **kwargs): ...
[ "def", "patch", "(", "name", ",", "source", "=", "None", ",", "source_hash", "=", "None", ",", "source_hash_name", "=", "None", ",", "skip_verify", "=", "False", ",", "template", "=", "None", ",", "context", "=", "None", ",", "defaults", "=", "None", "...
Ensure that a patch has been applied to the specified file or directory .. versionchanged:: 2019.2.0 The ``hash`` and ``dry_run_first`` options are now ignored, as the logic which determines whether or not the patch has already been applied no longer requires them. Additionally, this state ...
[ "Ensure", "that", "a", "patch", "has", "been", "applied", "to", "the", "specified", "file", "or", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6145-L6566
train
saltstack/salt
salt/states/file.py
touch
def touch(name, atime=None, mtime=None, makedirs=False): ''' Replicate the 'nix "touch" command to create a new empty file or update the atime and mtime of an existing file. Note that if you just want to create a file and don't care about atime or mtime, you should use ``file.managed`` instead, as ...
python
def touch(name, atime=None, mtime=None, makedirs=False): ''' Replicate the 'nix "touch" command to create a new empty file or update the atime and mtime of an existing file. Note that if you just want to create a file and don't care about atime or mtime, you should use ``file.managed`` instead, as ...
[ "def", "touch", "(", "name", ",", "atime", "=", "None", ",", "mtime", "=", "None", ",", "makedirs", "=", "False", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'change...
Replicate the 'nix "touch" command to create a new empty file or update the atime and mtime of an existing file. Note that if you just want to create a file and don't care about atime or mtime, you should use ``file.managed`` instead, as it is more feature-complete. (Just leave out the ``source``/``te...
[ "Replicate", "the", "nix", "touch", "command", "to", "create", "a", "new", "empty", "file", "or", "update", "the", "atime", "and", "mtime", "of", "an", "existing", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6569-L6641
train
saltstack/salt
salt/states/file.py
copy_
def copy_(name, source, force=False, makedirs=False, preserve=False, user=None, group=None, mode=None, subdir=False, **kwargs): ''' If the file defined by the ``source`` option exists on the minion, copy it to the name...
python
def copy_(name, source, force=False, makedirs=False, preserve=False, user=None, group=None, mode=None, subdir=False, **kwargs): ''' If the file defined by the ``source`` option exists on the minion, copy it to the name...
[ "def", "copy_", "(", "name", ",", "source", ",", "force", "=", "False", ",", "makedirs", "=", "False", ",", "preserve", "=", "False", ",", "user", "=", "None", ",", "group", "=", "None", ",", "mode", "=", "None", ",", "subdir", "=", "False", ",", ...
If the file defined by the ``source`` option exists on the minion, copy it to the named path. The file will not be overwritten if it already exists, unless the ``force`` option is set to ``True``. .. note:: This state only copies files from one location on a minion to another location on th...
[ "If", "the", "file", "defined", "by", "the", "source", "option", "exists", "on", "the", "minion", "copy", "it", "to", "the", "named", "path", ".", "The", "file", "will", "not", "be", "overwritten", "if", "it", "already", "exists", "unless", "the", "force...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6644-L6849
train
saltstack/salt
salt/states/file.py
rename
def rename(name, source, force=False, makedirs=False, **kwargs): ''' If the source file exists on the system, rename it to the named file. The named file will not be overwritten if it already exists unless the force option is set to True. name The location of the file to rename to sour...
python
def rename(name, source, force=False, makedirs=False, **kwargs): ''' If the source file exists on the system, rename it to the named file. The named file will not be overwritten if it already exists unless the force option is set to True. name The location of the file to rename to sour...
[ "def", "rename", "(", "name", ",", "source", ",", "force", "=", "False", ",", "makedirs", "=", "False", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "source", "=", "os", ".", "path", ".",...
If the source file exists on the system, rename it to the named file. The named file will not be overwritten if it already exists unless the force option is set to True. name The location of the file to rename to source The location of the file to move to the location specified with na...
[ "If", "the", "source", "file", "exists", "on", "the", "system", "rename", "it", "to", "the", "named", "file", ".", "The", "named", "file", "will", "not", "be", "overwritten", "if", "it", "already", "exists", "unless", "the", "force", "option", "is", "set...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6852-L6942
train
saltstack/salt
salt/states/file.py
accumulated
def accumulated(name, filename, text, **kwargs): ''' Prepare accumulator which can be used in template in file.managed state. Accumulator dictionary becomes available in template. It can also be used in file.blockreplace. name Accumulator name filename Filename which would rece...
python
def accumulated(name, filename, text, **kwargs): ''' Prepare accumulator which can be used in template in file.managed state. Accumulator dictionary becomes available in template. It can also be used in file.blockreplace. name Accumulator name filename Filename which would rece...
[ "def", "accumulated", "(", "name", ",", "filename", ",", "text", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}", "if", "no...
Prepare accumulator which can be used in template in file.managed state. Accumulator dictionary becomes available in template. It can also be used in file.blockreplace. name Accumulator name filename Filename which would receive this accumulator (see file.managed state document...
[ "Prepare", "accumulator", "which", "can", "be", "used", "in", "template", "in", "file", ".", "managed", "state", ".", "Accumulator", "dictionary", "becomes", "available", "in", "template", ".", "It", "can", "also", "be", "used", "in", "file", ".", "blockrepl...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L6945-L7046
train
saltstack/salt
salt/states/file.py
serialize
def serialize(name, dataset=None, dataset_pillar=None, user=None, group=None, mode=None, backup='', makedirs=False, show_changes=True, create=True, merge_if_exists=False, ...
python
def serialize(name, dataset=None, dataset_pillar=None, user=None, group=None, mode=None, backup='', makedirs=False, show_changes=True, create=True, merge_if_exists=False, ...
[ "def", "serialize", "(", "name", ",", "dataset", "=", "None", ",", "dataset_pillar", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "mode", "=", "None", ",", "backup", "=", "''", ",", "makedirs", "=", "False", ",", "show_chang...
Serializes dataset and store it into managed file. Useful for sharing simple configuration files. name The location of the file to create dataset The dataset that will be serialized dataset_pillar Operates like ``dataset``, but draws from a value stored in pillar, usin...
[ "Serializes", "dataset", "and", "store", "it", "into", "managed", "file", ".", "Useful", "for", "sharing", "simple", "configuration", "files", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7049-L7426
train
saltstack/salt
salt/states/file.py
mknod
def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'): ''' Create a special file similar to the 'nix mknod command. The supported device types are ``p`` (fifo pipe), ``c`` (character device), and ``b`` (block device). Provide the major and minor numbers when specifying a chara...
python
def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'): ''' Create a special file similar to the 'nix mknod command. The supported device types are ``p`` (fifo pipe), ``c`` (character device), and ``b`` (block device). Provide the major and minor numbers when specifying a chara...
[ "def", "mknod", "(", "name", ",", "ntype", ",", "major", "=", "0", ",", "minor", "=", "0", ",", "user", "=", "None", ",", "group", "=", "None", ",", "mode", "=", "'0600'", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name"...
Create a special file similar to the 'nix mknod command. The supported device types are ``p`` (fifo pipe), ``c`` (character device), and ``b`` (block device). Provide the major and minor numbers when specifying a character device or block device. A fifo pipe does not require this information. The comman...
[ "Create", "a", "special", "file", "similar", "to", "the", "nix", "mknod", "command", ".", "The", "supported", "device", "types", "are", "p", "(", "fifo", "pipe", ")", "c", "(", "character", "device", ")", "and", "b", "(", "block", "device", ")", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7429-L7640
train
saltstack/salt
salt/states/file.py
mod_run_check_cmd
def mod_run_check_cmd(cmd, filename, **check_cmd_opts): ''' Execute the check_cmd logic. Return a result dict if ``check_cmd`` succeeds (check_cmd == 0) otherwise return True ''' log.debug('running our check_cmd') _cmd = '{0} {1}'.format(cmd, filename) cret = __salt__['cmd.run_all'](_c...
python
def mod_run_check_cmd(cmd, filename, **check_cmd_opts): ''' Execute the check_cmd logic. Return a result dict if ``check_cmd`` succeeds (check_cmd == 0) otherwise return True ''' log.debug('running our check_cmd') _cmd = '{0} {1}'.format(cmd, filename) cret = __salt__['cmd.run_all'](_c...
[ "def", "mod_run_check_cmd", "(", "cmd", ",", "filename", ",", "*", "*", "check_cmd_opts", ")", ":", "log", ".", "debug", "(", "'running our check_cmd'", ")", "_cmd", "=", "'{0} {1}'", ".", "format", "(", "cmd", ",", "filename", ")", "cret", "=", "__salt__"...
Execute the check_cmd logic. Return a result dict if ``check_cmd`` succeeds (check_cmd == 0) otherwise return True
[ "Execute", "the", "check_cmd", "logic", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7643-L7667
train
saltstack/salt
salt/states/file.py
decode
def decode(name, encoded_data=None, contents_pillar=None, encoding_type='base64', checksum='md5'): ''' Decode an encoded file and write it to disk .. versionadded:: 2016.3.0 name Path of the file to be written. encoded_data The encoded file. Either t...
python
def decode(name, encoded_data=None, contents_pillar=None, encoding_type='base64', checksum='md5'): ''' Decode an encoded file and write it to disk .. versionadded:: 2016.3.0 name Path of the file to be written. encoded_data The encoded file. Either t...
[ "def", "decode", "(", "name", ",", "encoded_data", "=", "None", ",", "contents_pillar", "=", "None", ",", "encoding_type", "=", "'base64'", ",", "checksum", "=", "'md5'", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}"...
Decode an encoded file and write it to disk .. versionadded:: 2016.3.0 name Path of the file to be written. encoded_data The encoded file. Either this option or ``contents_pillar`` must be specified. contents_pillar A Pillar path to the encoded file. Uses the same path ...
[ "Decode", "an", "encoded", "file", "and", "write", "it", "to", "disk" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7670-L7779
train
saltstack/salt
salt/states/file.py
shortcut
def shortcut( name, target, arguments=None, working_dir=None, description=None, icon_location=None, force=False, backupname=None, makedirs=False, user=None, **kwargs): ''' Create a Windows shortcut If the file already e...
python
def shortcut( name, target, arguments=None, working_dir=None, description=None, icon_location=None, force=False, backupname=None, makedirs=False, user=None, **kwargs): ''' Create a Windows shortcut If the file already e...
[ "def", "shortcut", "(", "name", ",", "target", ",", "arguments", "=", "None", ",", "working_dir", "=", "None", ",", "description", "=", "None", ",", "icon_location", "=", "None", ",", "force", "=", "False", ",", "backupname", "=", "None", ",", "makedirs"...
Create a Windows shortcut If the file already exists and is a shortcut pointing to any location other than the specified target, the shortcut will be replaced. If it is a regular file or directory then the state will return False. If the regular file or directory is desired to be replaced with a shortc...
[ "Create", "a", "Windows", "shortcut" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L7782-L8035
train
saltstack/salt
salt/states/file.py
cached
def cached(name, source_hash='', source_hash_name=None, skip_verify=False, saltenv='base'): ''' .. versionadded:: 2017.7.3 Ensures that a file is saved to the minion's cache. This state is primarily invoked by other states to ensure that we do not re-download...
python
def cached(name, source_hash='', source_hash_name=None, skip_verify=False, saltenv='base'): ''' .. versionadded:: 2017.7.3 Ensures that a file is saved to the minion's cache. This state is primarily invoked by other states to ensure that we do not re-download...
[ "def", "cached", "(", "name", ",", "source_hash", "=", "''", ",", "source_hash_name", "=", "None", ",", "skip_verify", "=", "False", ",", "saltenv", "=", "'base'", ")", ":", "ret", "=", "{", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", ",...
.. versionadded:: 2017.7.3 Ensures that a file is saved to the minion's cache. This state is primarily invoked by other states to ensure that we do not re-download a source file if we do not need to. name The URL of the file to be cached. To cache a file from an environment other than ...
[ "..", "versionadded", "::", "2017", ".", "7", ".", "3" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L8038-L8313
train
saltstack/salt
salt/states/file.py
not_cached
def not_cached(name, saltenv='base'): ''' .. versionadded:: 2017.7.3 Ensures that a file is not present in the minion's cache, deleting it if found. This state is primarily invoked by other states to ensure that a fresh copy is fetched. name The URL of the file to be removed from cache...
python
def not_cached(name, saltenv='base'): ''' .. versionadded:: 2017.7.3 Ensures that a file is not present in the minion's cache, deleting it if found. This state is primarily invoked by other states to ensure that a fresh copy is fetched. name The URL of the file to be removed from cache...
[ "def", "not_cached", "(", "name", ",", "saltenv", "=", "'base'", ")", ":", "ret", "=", "{", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", ",", "'name'", ":", "name", ",", "'result'", ":", "False", "}", "try", ":", "parsed", "=", "_urlpar...
.. versionadded:: 2017.7.3 Ensures that a file is not present in the minion's cache, deleting it if found. This state is primarily invoked by other states to ensure that a fresh copy is fetched. name The URL of the file to be removed from cache. To remove a file from cache in an enviro...
[ "..", "versionadded", "::", "2017", ".", "7", ".", "3" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L8316-L8375
train
saltstack/salt
salt/utils/cloud.py
__render_script
def __render_script(path, vm_=None, opts=None, minion=''): ''' Return the rendered script ''' log.info('Rendering deploy script: %s', path) try: with salt.utils.files.fopen(path, 'r') as fp_: template = Template(salt.utils.stringutils.to_unicode(fp_.read())) return si...
python
def __render_script(path, vm_=None, opts=None, minion=''): ''' Return the rendered script ''' log.info('Rendering deploy script: %s', path) try: with salt.utils.files.fopen(path, 'r') as fp_: template = Template(salt.utils.stringutils.to_unicode(fp_.read())) return si...
[ "def", "__render_script", "(", "path", ",", "vm_", "=", "None", ",", "opts", "=", "None", ",", "minion", "=", "''", ")", ":", "log", ".", "info", "(", "'Rendering deploy script: %s'", ",", "path", ")", "try", ":", "with", "salt", ".", "utils", ".", "...
Return the rendered script
[ "Return", "the", "rendered", "script" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L128-L140
train
saltstack/salt
salt/utils/cloud.py
__ssh_gateway_config_dict
def __ssh_gateway_config_dict(gateway): ''' Return a dictionary with gateway options. The result is used to provide arguments to __ssh_gateway_arguments method. ''' extended_kwargs = {} if gateway: extended_kwargs['ssh_gateway'] = gateway['ssh_gateway'] extended_kwargs['ssh_gatew...
python
def __ssh_gateway_config_dict(gateway): ''' Return a dictionary with gateway options. The result is used to provide arguments to __ssh_gateway_arguments method. ''' extended_kwargs = {} if gateway: extended_kwargs['ssh_gateway'] = gateway['ssh_gateway'] extended_kwargs['ssh_gatew...
[ "def", "__ssh_gateway_config_dict", "(", "gateway", ")", ":", "extended_kwargs", "=", "{", "}", "if", "gateway", ":", "extended_kwargs", "[", "'ssh_gateway'", "]", "=", "gateway", "[", "'ssh_gateway'", "]", "extended_kwargs", "[", "'ssh_gateway_key'", "]", "=", ...
Return a dictionary with gateway options. The result is used to provide arguments to __ssh_gateway_arguments method.
[ "Return", "a", "dictionary", "with", "gateway", "options", ".", "The", "result", "is", "used", "to", "provide", "arguments", "to", "__ssh_gateway_arguments", "method", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L143-L154
train
saltstack/salt
salt/utils/cloud.py
__ssh_gateway_arguments
def __ssh_gateway_arguments(kwargs): ''' Return ProxyCommand configuration string for ssh/scp command. All gateway options should not include quotes (' or "). To support future user configuration, please make sure to update the dictionary from __ssh_gateway_config_dict and get_ssh_gateway_config (e...
python
def __ssh_gateway_arguments(kwargs): ''' Return ProxyCommand configuration string for ssh/scp command. All gateway options should not include quotes (' or "). To support future user configuration, please make sure to update the dictionary from __ssh_gateway_config_dict and get_ssh_gateway_config (e...
[ "def", "__ssh_gateway_arguments", "(", "kwargs", ")", ":", "extended_arguments", "=", "\"\"", "ssh_gateway", "=", "kwargs", ".", "get", "(", "'ssh_gateway'", ",", "''", ")", "ssh_gateway_port", "=", "22", "if", "':'", "in", "ssh_gateway", ":", "ssh_gateway", "...
Return ProxyCommand configuration string for ssh/scp command. All gateway options should not include quotes (' or "). To support future user configuration, please make sure to update the dictionary from __ssh_gateway_config_dict and get_ssh_gateway_config (ec2.py)
[ "Return", "ProxyCommand", "configuration", "string", "for", "ssh", "/", "scp", "command", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L157-L198
train
saltstack/salt
salt/utils/cloud.py
os_script
def os_script(os_, vm_=None, opts=None, minion=''): ''' Return the script as a string for the specific os ''' if minion: minion = salt_config_to_yaml(minion) if os.path.isabs(os_): # The user provided an absolute path to the deploy script, let's use it return __render_script...
python
def os_script(os_, vm_=None, opts=None, minion=''): ''' Return the script as a string for the specific os ''' if minion: minion = salt_config_to_yaml(minion) if os.path.isabs(os_): # The user provided an absolute path to the deploy script, let's use it return __render_script...
[ "def", "os_script", "(", "os_", ",", "vm_", "=", "None", ",", "opts", "=", "None", ",", "minion", "=", "''", ")", ":", "if", "minion", ":", "minion", "=", "salt_config_to_yaml", "(", "minion", ")", "if", "os", ".", "path", ".", "isabs", "(", "os_",...
Return the script as a string for the specific os
[ "Return", "the", "script", "as", "a", "string", "for", "the", "specific", "os" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L208-L236
train
saltstack/salt
salt/utils/cloud.py
gen_keys
def gen_keys(keysize=2048): ''' Generate Salt minion keys and return them as PEM file strings ''' # Mandate that keys are at least 2048 in size if keysize < 2048: keysize = 2048 tdir = tempfile.mkdtemp() salt.crypt.gen_keys(tdir, 'minion', keysize) priv_path = os.path.join(tdir,...
python
def gen_keys(keysize=2048): ''' Generate Salt minion keys and return them as PEM file strings ''' # Mandate that keys are at least 2048 in size if keysize < 2048: keysize = 2048 tdir = tempfile.mkdtemp() salt.crypt.gen_keys(tdir, 'minion', keysize) priv_path = os.path.join(tdir,...
[ "def", "gen_keys", "(", "keysize", "=", "2048", ")", ":", "# Mandate that keys are at least 2048 in size", "if", "keysize", "<", "2048", ":", "keysize", "=", "2048", "tdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "salt", ".", "crypt", ".", "gen_keys", "(...
Generate Salt minion keys and return them as PEM file strings
[ "Generate", "Salt", "minion", "keys", "and", "return", "them", "as", "PEM", "file", "strings" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L239-L256
train
saltstack/salt
salt/utils/cloud.py
accept_key
def accept_key(pki_dir, pub, id_): ''' If the master config was available then we will have a pki_dir key in the opts directory, this method places the pub key in the accepted keys dir and removes it from the unaccepted keys dir if that is the case. ''' for key_dir in 'minions', 'minions_pre', '...
python
def accept_key(pki_dir, pub, id_): ''' If the master config was available then we will have a pki_dir key in the opts directory, this method places the pub key in the accepted keys dir and removes it from the unaccepted keys dir if that is the case. ''' for key_dir in 'minions', 'minions_pre', '...
[ "def", "accept_key", "(", "pki_dir", ",", "pub", ",", "id_", ")", ":", "for", "key_dir", "in", "'minions'", ",", "'minions_pre'", ",", "'minions_rejected'", ":", "key_path", "=", "os", ".", "path", ".", "join", "(", "pki_dir", ",", "key_dir", ")", "if", ...
If the master config was available then we will have a pki_dir key in the opts directory, this method places the pub key in the accepted keys dir and removes it from the unaccepted keys dir if that is the case.
[ "If", "the", "master", "config", "was", "available", "then", "we", "will", "have", "a", "pki_dir", "key", "in", "the", "opts", "directory", "this", "method", "places", "the", "pub", "key", "in", "the", "accepted", "keys", "dir", "and", "removes", "it", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L259-L278
train
saltstack/salt
salt/utils/cloud.py
remove_key
def remove_key(pki_dir, id_): ''' This method removes a specified key from the accepted keys dir ''' key = os.path.join(pki_dir, 'minions', id_) if os.path.isfile(key): os.remove(key) log.debug('Deleted \'%s\'', key)
python
def remove_key(pki_dir, id_): ''' This method removes a specified key from the accepted keys dir ''' key = os.path.join(pki_dir, 'minions', id_) if os.path.isfile(key): os.remove(key) log.debug('Deleted \'%s\'', key)
[ "def", "remove_key", "(", "pki_dir", ",", "id_", ")", ":", "key", "=", "os", ".", "path", ".", "join", "(", "pki_dir", ",", "'minions'", ",", "id_", ")", "if", "os", ".", "path", ".", "isfile", "(", "key", ")", ":", "os", ".", "remove", "(", "k...
This method removes a specified key from the accepted keys dir
[ "This", "method", "removes", "a", "specified", "key", "from", "the", "accepted", "keys", "dir" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L281-L288
train