id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
34,900
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
34,901
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
34,902
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
34,903
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
34,904
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
34,905
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
34,906
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
34,907
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
34,908
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
34,909
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
34,910
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
34,911
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
34,912
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
34,913
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
34,914
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
34,915
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
34,916
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
34,917
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
34,918
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
34,919
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
34,920
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
34,921
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
34,922
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
34,923
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
34,924
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
34,925
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
34,926
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
34,927
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
34,928
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
34,929
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
34,930
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
34,931
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
34,932
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
34,933
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
34,934
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
34,935
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
34,936
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
34,937
saltstack/salt
salt/utils/cloud.py
rename_key
def rename_key(pki_dir, id_, new_id): ''' Rename a key, when an instance has also been renamed ''' oldkey = os.path.join(pki_dir, 'minions', id_) newkey = os.path.join(pki_dir, 'minions', new_id) if os.path.isfile(oldkey): os.rename(oldkey, newkey)
python
def rename_key(pki_dir, id_, new_id): ''' Rename a key, when an instance has also been renamed ''' oldkey = os.path.join(pki_dir, 'minions', id_) newkey = os.path.join(pki_dir, 'minions', new_id) if os.path.isfile(oldkey): os.rename(oldkey, newkey)
[ "def", "rename_key", "(", "pki_dir", ",", "id_", ",", "new_id", ")", ":", "oldkey", "=", "os", ".", "path", ".", "join", "(", "pki_dir", ",", "'minions'", ",", "id_", ")", "newkey", "=", "os", ".", "path", ".", "join", "(", "pki_dir", ",", "'minion...
Rename a key, when an instance has also been renamed
[ "Rename", "a", "key", "when", "an", "instance", "has", "also", "been", "renamed" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L291-L298
34,938
saltstack/salt
salt/utils/cloud.py
minion_config
def minion_config(opts, vm_): ''' Return a minion's configuration for the provided options and VM ''' # Don't start with a copy of the default minion opts; they're not always # what we need. Some default options are Null, let's set a reasonable default minion = { 'master': 'salt', ...
python
def minion_config(opts, vm_): ''' Return a minion's configuration for the provided options and VM ''' # Don't start with a copy of the default minion opts; they're not always # what we need. Some default options are Null, let's set a reasonable default minion = { 'master': 'salt', ...
[ "def", "minion_config", "(", "opts", ",", "vm_", ")", ":", "# Don't start with a copy of the default minion opts; they're not always", "# what we need. Some default options are Null, let's set a reasonable default", "minion", "=", "{", "'master'", ":", "'salt'", ",", "'log_level'",...
Return a minion's configuration for the provided options and VM
[ "Return", "a", "minion", "s", "configuration", "for", "the", "provided", "options", "and", "VM" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L301-L344
34,939
saltstack/salt
salt/utils/cloud.py
master_config
def master_config(opts, vm_): ''' Return a master's configuration for the provided options and VM ''' # Let's get a copy of the salt master default options master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS) # Some default options are Null, let's set a reasonable default master.update( ...
python
def master_config(opts, vm_): ''' Return a master's configuration for the provided options and VM ''' # Let's get a copy of the salt master default options master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS) # Some default options are Null, let's set a reasonable default master.update( ...
[ "def", "master_config", "(", "opts", ",", "vm_", ")", ":", "# Let's get a copy of the salt master default options", "master", "=", "copy", ".", "deepcopy", "(", "salt", ".", "config", ".", "DEFAULT_MASTER_OPTS", ")", "# Some default options are Null, let's set a reasonable ...
Return a master's configuration for the provided options and VM
[ "Return", "a", "master", "s", "configuration", "for", "the", "provided", "options", "and", "VM" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L347-L369
34,940
saltstack/salt
salt/utils/cloud.py
salt_config_to_yaml
def salt_config_to_yaml(configuration, line_break='\n'): ''' Return a salt configuration dictionary, master or minion, as a yaml dump ''' return salt.utils.yaml.safe_dump( configuration, line_break=line_break, default_flow_style=False)
python
def salt_config_to_yaml(configuration, line_break='\n'): ''' Return a salt configuration dictionary, master or minion, as a yaml dump ''' return salt.utils.yaml.safe_dump( configuration, line_break=line_break, default_flow_style=False)
[ "def", "salt_config_to_yaml", "(", "configuration", ",", "line_break", "=", "'\\n'", ")", ":", "return", "salt", ".", "utils", ".", "yaml", ".", "safe_dump", "(", "configuration", ",", "line_break", "=", "line_break", ",", "default_flow_style", "=", "False", "...
Return a salt configuration dictionary, master or minion, as a yaml dump
[ "Return", "a", "salt", "configuration", "dictionary", "master", "or", "minion", "as", "a", "yaml", "dump" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L372-L379
34,941
saltstack/salt
salt/utils/cloud.py
ssh_usernames
def ssh_usernames(vm_, opts, default_users=None): ''' Return the ssh_usernames. Defaults to a built-in list of users for trying. ''' if default_users is None: default_users = ['root'] usernames = salt.config.get_cloud_config_value( 'ssh_username', vm_, opts ) if not isinsta...
python
def ssh_usernames(vm_, opts, default_users=None): ''' Return the ssh_usernames. Defaults to a built-in list of users for trying. ''' if default_users is None: default_users = ['root'] usernames = salt.config.get_cloud_config_value( 'ssh_username', vm_, opts ) if not isinsta...
[ "def", "ssh_usernames", "(", "vm_", ",", "opts", ",", "default_users", "=", "None", ")", ":", "if", "default_users", "is", "None", ":", "default_users", "=", "[", "'root'", "]", "usernames", "=", "salt", ".", "config", ".", "get_cloud_config_value", "(", "...
Return the ssh_usernames. Defaults to a built-in list of users for trying.
[ "Return", "the", "ssh_usernames", ".", "Defaults", "to", "a", "built", "-", "in", "list", "of", "users", "for", "trying", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L671-L699
34,942
saltstack/salt
salt/utils/cloud.py
wait_for_fun
def wait_for_fun(fun, timeout=900, **kwargs): ''' Wait until a function finishes, or times out ''' start = time.time() log.debug('Attempting function %s', fun) trycount = 0 while True: trycount += 1 try: response = fun(**kwargs) if not isinstance(respo...
python
def wait_for_fun(fun, timeout=900, **kwargs): ''' Wait until a function finishes, or times out ''' start = time.time() log.debug('Attempting function %s', fun) trycount = 0 while True: trycount += 1 try: response = fun(**kwargs) if not isinstance(respo...
[ "def", "wait_for_fun", "(", "fun", ",", "timeout", "=", "900", ",", "*", "*", "kwargs", ")", ":", "start", "=", "time", ".", "time", "(", ")", "log", ".", "debug", "(", "'Attempting function %s'", ",", "fun", ")", "trycount", "=", "0", "while", "True...
Wait until a function finishes, or times out
[ "Wait", "until", "a", "function", "finishes", "or", "times", "out" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L702-L721
34,943
saltstack/salt
salt/utils/cloud.py
run_winexe_command
def run_winexe_command(cmd, args, host, username, password, port=445): ''' Run a command remotly via the winexe executable ''' creds = "-U '{0}%{1}' //{2}".format( username, password, host ) logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format( username, ...
python
def run_winexe_command(cmd, args, host, username, password, port=445): ''' Run a command remotly via the winexe executable ''' creds = "-U '{0}%{1}' //{2}".format( username, password, host ) logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format( username, ...
[ "def", "run_winexe_command", "(", "cmd", ",", "args", ",", "host", ",", "username", ",", "password", ",", "port", "=", "445", ")", ":", "creds", "=", "\"-U '{0}%{1}' //{2}\"", ".", "format", "(", "username", ",", "password", ",", "host", ")", "logging_cred...
Run a command remotly via the winexe executable
[ "Run", "a", "command", "remotly", "via", "the", "winexe", "executable" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L938-L953
34,944
saltstack/salt
salt/utils/cloud.py
run_psexec_command
def run_psexec_command(cmd, args, host, username, password, port=445): ''' Run a command remotly using the psexec protocol ''' if has_winexe() and not HAS_PSEXEC: ret_code = run_winexe_command(cmd, args, host, username, password, port) return None, None, ret_code service_name = 'PS-E...
python
def run_psexec_command(cmd, args, host, username, password, port=445): ''' Run a command remotly using the psexec protocol ''' if has_winexe() and not HAS_PSEXEC: ret_code = run_winexe_command(cmd, args, host, username, password, port) return None, None, ret_code service_name = 'PS-E...
[ "def", "run_psexec_command", "(", "cmd", ",", "args", ",", "host", ",", "username", ",", "password", ",", "port", "=", "445", ")", ":", "if", "has_winexe", "(", ")", "and", "not", "HAS_PSEXEC", ":", "ret_code", "=", "run_winexe_command", "(", "cmd", ",",...
Run a command remotly using the psexec protocol
[ "Run", "a", "command", "remotly", "using", "the", "psexec", "protocol" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L956-L973
34,945
saltstack/salt
salt/utils/cloud.py
wait_for_winexe
def wait_for_winexe(host, port, username, password, timeout=900): ''' Wait until winexe connection can be established. ''' start = time.time() log.debug( 'Attempting winexe connection to host %s on port %s', host, port ) try_count = 0 while True: try_count += 1 ...
python
def wait_for_winexe(host, port, username, password, timeout=900): ''' Wait until winexe connection can be established. ''' start = time.time() log.debug( 'Attempting winexe connection to host %s on port %s', host, port ) try_count = 0 while True: try_count += 1 ...
[ "def", "wait_for_winexe", "(", "host", ",", "port", ",", "username", ",", "password", ",", "timeout", "=", "900", ")", ":", "start", "=", "time", ".", "time", "(", ")", "log", ".", "debug", "(", "'Attempting winexe connection to host %s on port %s'", ",", "h...
Wait until winexe connection can be established.
[ "Wait", "until", "winexe", "connection", "can", "be", "established", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L976-L1002
34,946
saltstack/salt
salt/utils/cloud.py
wait_for_psexecsvc
def wait_for_psexecsvc(host, port, username, password, timeout=900): ''' Wait until psexec connection can be established. ''' if has_winexe() and not HAS_PSEXEC: return wait_for_winexe(host, port, username, password, timeout) start = time.time() try_count = 0 while True: try_...
python
def wait_for_psexecsvc(host, port, username, password, timeout=900): ''' Wait until psexec connection can be established. ''' if has_winexe() and not HAS_PSEXEC: return wait_for_winexe(host, port, username, password, timeout) start = time.time() try_count = 0 while True: try_...
[ "def", "wait_for_psexecsvc", "(", "host", ",", "port", ",", "username", ",", "password", ",", "timeout", "=", "900", ")", ":", "if", "has_winexe", "(", ")", "and", "not", "HAS_PSEXEC", ":", "return", "wait_for_winexe", "(", "host", ",", "port", ",", "use...
Wait until psexec connection can be established.
[ "Wait", "until", "psexec", "connection", "can", "be", "established", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1005-L1031
34,947
saltstack/salt
salt/utils/cloud.py
wait_for_winrm
def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True): ''' Wait until WinRM connection can be established. ''' # Ensure the winrm service is listening before attempting to connect wait_for_port(host=host, port=port, timeout=timeout) start = time.time() l...
python
def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True): ''' Wait until WinRM connection can be established. ''' # Ensure the winrm service is listening before attempting to connect wait_for_port(host=host, port=port, timeout=timeout) start = time.time() l...
[ "def", "wait_for_winrm", "(", "host", ",", "port", ",", "username", ",", "password", ",", "timeout", "=", "900", ",", "use_ssl", "=", "True", ",", "verify", "=", "True", ")", ":", "# Ensure the winrm service is listening before attempting to connect", "wait_for_port...
Wait until WinRM connection can be established.
[ "Wait", "until", "WinRM", "connection", "can", "be", "established", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1034-L1096
34,948
saltstack/salt
salt/utils/cloud.py
wait_for_passwd
def wait_for_passwd(host, port=22, ssh_timeout=15, username='root', password=None, key_filename=None, maxtries=15, trysleep=1, display_ssh_output=True, gateway=None, known_hosts_file='/dev/null', hard_timeout=None): ''' Wait until ssh connection can be...
python
def wait_for_passwd(host, port=22, ssh_timeout=15, username='root', password=None, key_filename=None, maxtries=15, trysleep=1, display_ssh_output=True, gateway=None, known_hosts_file='/dev/null', hard_timeout=None): ''' Wait until ssh connection can be...
[ "def", "wait_for_passwd", "(", "host", ",", "port", "=", "22", ",", "ssh_timeout", "=", "15", ",", "username", "=", "'root'", ",", "password", "=", "None", ",", "key_filename", "=", "None", ",", "maxtries", "=", "15", ",", "trysleep", "=", "1", ",", ...
Wait until ssh connection can be accessed via password or ssh key
[ "Wait", "until", "ssh", "connection", "can", "be", "accessed", "via", "password", "or", "ssh", "key" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1146-L1204
34,949
saltstack/salt
salt/utils/cloud.py
filter_event
def filter_event(tag, data, defaults): ''' Accept a tag, a dict and a list of default keys to return from the dict, and check them against the cloud configuration for that tag ''' ret = {} keys = [] use_defaults = True for ktag in __opts__.get('filter_events', {}): if tag != kta...
python
def filter_event(tag, data, defaults): ''' Accept a tag, a dict and a list of default keys to return from the dict, and check them against the cloud configuration for that tag ''' ret = {} keys = [] use_defaults = True for ktag in __opts__.get('filter_events', {}): if tag != kta...
[ "def", "filter_event", "(", "tag", ",", "data", ",", "defaults", ")", ":", "ret", "=", "{", "}", "keys", "=", "[", "]", "use_defaults", "=", "True", "for", "ktag", "in", "__opts__", ".", "get", "(", "'filter_events'", ",", "{", "}", ")", ":", "if",...
Accept a tag, a dict and a list of default keys to return from the dict, and check them against the cloud configuration for that tag
[ "Accept", "a", "tag", "a", "dict", "and", "a", "list", "of", "default", "keys", "to", "return", "from", "the", "dict", "and", "check", "them", "against", "the", "cloud", "configuration", "for", "that", "tag" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1964-L1994
34,950
saltstack/salt
salt/utils/cloud.py
fire_event
def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'): ''' Fire deploy action ''' event = salt.utils.event.get_event( 'master', sock_dir, transport, listen=False) try: event.fire_event(msg, tag) except ValueError: # We're using at...
python
def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'): ''' Fire deploy action ''' event = salt.utils.event.get_event( 'master', sock_dir, transport, listen=False) try: event.fire_event(msg, tag) except ValueError: # We're using at...
[ "def", "fire_event", "(", "key", ",", "msg", ",", "tag", ",", "sock_dir", ",", "args", "=", "None", ",", "transport", "=", "'zeromq'", ")", ":", "event", "=", "salt", ".", "utils", ".", "event", ".", "get_event", "(", "'master'", ",", "sock_dir", ","...
Fire deploy action
[ "Fire", "deploy", "action" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1997-L2019
34,951
saltstack/salt
salt/utils/cloud.py
scp_file
def scp_file(dest_path, contents=None, kwargs=None, local_file=None): ''' Use scp or sftp to copy a file to a server ''' file_to_upload = None try: if contents is not None: try: tmpfd, file_to_upload = tempfile.mkstemp() os.write(tmpfd, contents) ...
python
def scp_file(dest_path, contents=None, kwargs=None, local_file=None): ''' Use scp or sftp to copy a file to a server ''' file_to_upload = None try: if contents is not None: try: tmpfd, file_to_upload = tempfile.mkstemp() os.write(tmpfd, contents) ...
[ "def", "scp_file", "(", "dest_path", ",", "contents", "=", "None", ",", "kwargs", "=", "None", ",", "local_file", "=", "None", ")", ":", "file_to_upload", "=", "None", "try", ":", "if", "contents", "is", "not", "None", ":", "try", ":", "tmpfd", ",", ...
Use scp or sftp to copy a file to a server
[ "Use", "scp", "or", "sftp", "to", "copy", "a", "file", "to", "a", "server" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2077-L2164
34,952
saltstack/salt
salt/utils/cloud.py
ssh_file
def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None): ''' Copies a file to the remote SSH target using either sftp or scp, as configured. ''' if opts.get('file_transport', 'sftp') == 'sftp': return sftp_file(dest_path, contents, kwargs, local_file) return scp_file(d...
python
def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None): ''' Copies a file to the remote SSH target using either sftp or scp, as configured. ''' if opts.get('file_transport', 'sftp') == 'sftp': return sftp_file(dest_path, contents, kwargs, local_file) return scp_file(d...
[ "def", "ssh_file", "(", "opts", ",", "dest_path", ",", "contents", "=", "None", ",", "kwargs", "=", "None", ",", "local_file", "=", "None", ")", ":", "if", "opts", ".", "get", "(", "'file_transport'", ",", "'sftp'", ")", "==", "'sftp'", ":", "return", ...
Copies a file to the remote SSH target using either sftp or scp, as configured.
[ "Copies", "a", "file", "to", "the", "remote", "SSH", "target", "using", "either", "sftp", "or", "scp", "as", "configured", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2167-L2174
34,953
saltstack/salt
salt/utils/cloud.py
win_cmd
def win_cmd(command, **kwargs): ''' Wrapper for commands to be run against Windows boxes ''' logging_command = kwargs.get('logging_command', None) try: proc = NonBlockingPopen( command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIP...
python
def win_cmd(command, **kwargs): ''' Wrapper for commands to be run against Windows boxes ''' logging_command = kwargs.get('logging_command', None) try: proc = NonBlockingPopen( command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIP...
[ "def", "win_cmd", "(", "command", ",", "*", "*", "kwargs", ")", ":", "logging_command", "=", "kwargs", ".", "get", "(", "'logging_command'", ",", "None", ")", "try", ":", "proc", "=", "NonBlockingPopen", "(", "command", ",", "shell", "=", "True", ",", ...
Wrapper for commands to be run against Windows boxes
[ "Wrapper", "for", "commands", "to", "be", "run", "against", "Windows", "boxes" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2269-L2302
34,954
saltstack/salt
salt/utils/cloud.py
winrm_cmd
def winrm_cmd(session, command, flags, **kwargs): ''' Wrapper for commands to be run against Windows boxes using WinRM. ''' log.debug('Executing WinRM command: %s %s', command, flags) # rebuild the session to ensure we haven't timed out session.protocol.transport.build_session() r = session....
python
def winrm_cmd(session, command, flags, **kwargs): ''' Wrapper for commands to be run against Windows boxes using WinRM. ''' log.debug('Executing WinRM command: %s %s', command, flags) # rebuild the session to ensure we haven't timed out session.protocol.transport.build_session() r = session....
[ "def", "winrm_cmd", "(", "session", ",", "command", ",", "flags", ",", "*", "*", "kwargs", ")", ":", "log", ".", "debug", "(", "'Executing WinRM command: %s %s'", ",", "command", ",", "flags", ")", "# rebuild the session to ensure we haven't timed out", "session", ...
Wrapper for commands to be run against Windows boxes using WinRM.
[ "Wrapper", "for", "commands", "to", "be", "run", "against", "Windows", "boxes", "using", "WinRM", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2305-L2313
34,955
saltstack/salt
salt/utils/cloud.py
root_cmd
def root_cmd(command, tty, sudo, allow_failure=False, **kwargs): ''' Wrapper for commands to be run as root ''' logging_command = command sudo_password = kwargs.get('sudo_password', None) if sudo: if sudo_password is None: command = 'sudo {0}'.format(command) log...
python
def root_cmd(command, tty, sudo, allow_failure=False, **kwargs): ''' Wrapper for commands to be run as root ''' logging_command = command sudo_password = kwargs.get('sudo_password', None) if sudo: if sudo_password is None: command = 'sudo {0}'.format(command) log...
[ "def", "root_cmd", "(", "command", ",", "tty", ",", "sudo", ",", "allow_failure", "=", "False", ",", "*", "*", "kwargs", ")", ":", "logging_command", "=", "command", "sudo_password", "=", "kwargs", ".", "get", "(", "'sudo_password'", ",", "None", ")", "i...
Wrapper for commands to be run as root
[ "Wrapper", "for", "commands", "to", "be", "run", "as", "root" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2316-L2392
34,956
saltstack/salt
salt/utils/cloud.py
check_auth
def check_auth(name, sock_dir=None, queue=None, timeout=300): ''' This function is called from a multiprocess instance, to wait for a minion to become available to receive salt commands ''' event = salt.utils.event.SaltEvent('master', sock_dir, listen=True) starttime = time.mktime(time.localtime...
python
def check_auth(name, sock_dir=None, queue=None, timeout=300): ''' This function is called from a multiprocess instance, to wait for a minion to become available to receive salt commands ''' event = salt.utils.event.SaltEvent('master', sock_dir, listen=True) starttime = time.mktime(time.localtime...
[ "def", "check_auth", "(", "name", ",", "sock_dir", "=", "None", ",", "queue", "=", "None", ",", "timeout", "=", "300", ")", ":", "event", "=", "salt", ".", "utils", ".", "event", ".", "SaltEvent", "(", "'master'", ",", "sock_dir", ",", "listen", "=",...
This function is called from a multiprocess instance, to wait for a minion to become available to receive salt commands
[ "This", "function", "is", "called", "from", "a", "multiprocess", "instance", "to", "wait", "for", "a", "minion", "to", "become", "available", "to", "receive", "salt", "commands" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2395-L2412
34,957
saltstack/salt
salt/utils/cloud.py
ip_to_int
def ip_to_int(ip): ''' Converts an IP address to an integer ''' ret = 0 for octet in ip.split('.'): ret = ret * 256 + int(octet) return ret
python
def ip_to_int(ip): ''' Converts an IP address to an integer ''' ret = 0 for octet in ip.split('.'): ret = ret * 256 + int(octet) return ret
[ "def", "ip_to_int", "(", "ip", ")", ":", "ret", "=", "0", "for", "octet", "in", "ip", ".", "split", "(", "'.'", ")", ":", "ret", "=", "ret", "*", "256", "+", "int", "(", "octet", ")", "return", "ret" ]
Converts an IP address to an integer
[ "Converts", "an", "IP", "address", "to", "an", "integer" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2415-L2422
34,958
saltstack/salt
salt/utils/cloud.py
is_public_ip
def is_public_ip(ip): ''' Determines whether an IP address falls within one of the private IP ranges ''' if ':' in ip: # ipv6 if ip.startswith('fe80:'): # ipv6 link local return False return True addr = ip_to_int(ip) if 167772160 < addr < 184549375...
python
def is_public_ip(ip): ''' Determines whether an IP address falls within one of the private IP ranges ''' if ':' in ip: # ipv6 if ip.startswith('fe80:'): # ipv6 link local return False return True addr = ip_to_int(ip) if 167772160 < addr < 184549375...
[ "def", "is_public_ip", "(", "ip", ")", ":", "if", "':'", "in", "ip", ":", "# ipv6", "if", "ip", ".", "startswith", "(", "'fe80:'", ")", ":", "# ipv6 link local", "return", "False", "return", "True", "addr", "=", "ip_to_int", "(", "ip", ")", "if", "1677...
Determines whether an IP address falls within one of the private IP ranges
[ "Determines", "whether", "an", "IP", "address", "falls", "within", "one", "of", "the", "private", "IP", "ranges" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2425-L2448
34,959
saltstack/salt
salt/utils/cloud.py
check_name
def check_name(name, safe_chars): ''' Check whether the specified name contains invalid characters ''' regexp = re.compile('[^{0}]'.format(safe_chars)) if regexp.search(name): raise SaltCloudException( '{0} contains characters not supported by this cloud provider. ' '...
python
def check_name(name, safe_chars): ''' Check whether the specified name contains invalid characters ''' regexp = re.compile('[^{0}]'.format(safe_chars)) if regexp.search(name): raise SaltCloudException( '{0} contains characters not supported by this cloud provider. ' '...
[ "def", "check_name", "(", "name", ",", "safe_chars", ")", ":", "regexp", "=", "re", ".", "compile", "(", "'[^{0}]'", ".", "format", "(", "safe_chars", ")", ")", "if", "regexp", ".", "search", "(", "name", ")", ":", "raise", "SaltCloudException", "(", "...
Check whether the specified name contains invalid characters
[ "Check", "whether", "the", "specified", "name", "contains", "invalid", "characters" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2451-L2462
34,960
saltstack/salt
salt/utils/cloud.py
remove_sshkey
def remove_sshkey(host, known_hosts=None): ''' Remove a host from the known_hosts file ''' if known_hosts is None: if 'HOME' in os.environ: known_hosts = '{0}/.ssh/known_hosts'.format(os.environ['HOME']) else: try: known_hosts = '{0}/.ssh/known_hos...
python
def remove_sshkey(host, known_hosts=None): ''' Remove a host from the known_hosts file ''' if known_hosts is None: if 'HOME' in os.environ: known_hosts = '{0}/.ssh/known_hosts'.format(os.environ['HOME']) else: try: known_hosts = '{0}/.ssh/known_hos...
[ "def", "remove_sshkey", "(", "host", ",", "known_hosts", "=", "None", ")", ":", "if", "known_hosts", "is", "None", ":", "if", "'HOME'", "in", "os", ".", "environ", ":", "known_hosts", "=", "'{0}/.ssh/known_hosts'", ".", "format", "(", "os", ".", "environ",...
Remove a host from the known_hosts file
[ "Remove", "a", "host", "from", "the", "known_hosts", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2465-L2489
34,961
saltstack/salt
salt/utils/cloud.py
lock_file
def lock_file(filename, interval=.5, timeout=15): ''' Lock a file; if it is already locked, then wait for it to become available before locking it. Note that these locks are only recognized by Salt Cloud, and not other programs or platforms. ''' log.trace('Attempting to obtain lock for %s',...
python
def lock_file(filename, interval=.5, timeout=15): ''' Lock a file; if it is already locked, then wait for it to become available before locking it. Note that these locks are only recognized by Salt Cloud, and not other programs or platforms. ''' log.trace('Attempting to obtain lock for %s',...
[ "def", "lock_file", "(", "filename", ",", "interval", "=", ".5", ",", "timeout", "=", "15", ")", ":", "log", ".", "trace", "(", "'Attempting to obtain lock for %s'", ",", "filename", ")", "lock", "=", "filename", "+", "'.lock'", "start", "=", "time", ".", ...
Lock a file; if it is already locked, then wait for it to become available before locking it. Note that these locks are only recognized by Salt Cloud, and not other programs or platforms.
[ "Lock", "a", "file", ";", "if", "it", "is", "already", "locked", "then", "wait", "for", "it", "to", "become", "available", "before", "locking", "it", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2595-L2616
34,962
saltstack/salt
salt/utils/cloud.py
unlock_file
def unlock_file(filename): ''' Unlock a locked file Note that these locks are only recognized by Salt Cloud, and not other programs or platforms. ''' log.trace('Removing lock for %s', filename) lock = filename + '.lock' try: os.remove(lock) except OSError as exc: log...
python
def unlock_file(filename): ''' Unlock a locked file Note that these locks are only recognized by Salt Cloud, and not other programs or platforms. ''' log.trace('Removing lock for %s', filename) lock = filename + '.lock' try: os.remove(lock) except OSError as exc: log...
[ "def", "unlock_file", "(", "filename", ")", ":", "log", ".", "trace", "(", "'Removing lock for %s'", ",", "filename", ")", "lock", "=", "filename", "+", "'.lock'", "try", ":", "os", ".", "remove", "(", "lock", ")", "except", "OSError", "as", "exc", ":", ...
Unlock a locked file Note that these locks are only recognized by Salt Cloud, and not other programs or platforms.
[ "Unlock", "a", "locked", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2619-L2631
34,963
saltstack/salt
salt/utils/cloud.py
cachedir_index_del
def cachedir_index_del(minion_id, base=None): ''' Delete an entry from the cachedir index. This generally only needs to happen when an instance is deleted. ''' base = init_cachedir(base) index_file = os.path.join(base, 'index.p') lock_file(index_file) if os.path.exists(index_file): ...
python
def cachedir_index_del(minion_id, base=None): ''' Delete an entry from the cachedir index. This generally only needs to happen when an instance is deleted. ''' base = init_cachedir(base) index_file = os.path.join(base, 'index.p') lock_file(index_file) if os.path.exists(index_file): ...
[ "def", "cachedir_index_del", "(", "minion_id", ",", "base", "=", "None", ")", ":", "base", "=", "init_cachedir", "(", "base", ")", "index_file", "=", "os", ".", "path", ".", "join", "(", "base", ",", "'index.p'", ")", "lock_file", "(", "index_file", ")",...
Delete an entry from the cachedir index. This generally only needs to happen when an instance is deleted.
[ "Delete", "an", "entry", "from", "the", "cachedir", "index", ".", "This", "generally", "only", "needs", "to", "happen", "when", "an", "instance", "is", "deleted", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2680-L2704
34,964
saltstack/salt
salt/utils/cloud.py
init_cachedir
def init_cachedir(base=None): ''' Initialize the cachedir needed for Salt Cloud to keep track of minions ''' if base is None: base = __opts__['cachedir'] needed_dirs = (base, os.path.join(base, 'requested'), os.path.join(base, 'active')) for dir_ in ...
python
def init_cachedir(base=None): ''' Initialize the cachedir needed for Salt Cloud to keep track of minions ''' if base is None: base = __opts__['cachedir'] needed_dirs = (base, os.path.join(base, 'requested'), os.path.join(base, 'active')) for dir_ in ...
[ "def", "init_cachedir", "(", "base", "=", "None", ")", ":", "if", "base", "is", "None", ":", "base", "=", "__opts__", "[", "'cachedir'", "]", "needed_dirs", "=", "(", "base", ",", "os", ".", "path", ".", "join", "(", "base", ",", "'requested'", ")", ...
Initialize the cachedir needed for Salt Cloud to keep track of minions
[ "Initialize", "the", "cachedir", "needed", "for", "Salt", "Cloud", "to", "keep", "track", "of", "minions" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2707-L2721
34,965
saltstack/salt
salt/utils/cloud.py
delete_minion_cachedir
def delete_minion_cachedir(minion_id, provider, opts, base=None): ''' Deletes a minion's entry from the cloud cachedir. It will search through all cachedirs to find the minion's cache file. Needs `update_cachedir` set to True. ''' if isinstance(opts, dict): __opts__.update(opts) if ...
python
def delete_minion_cachedir(minion_id, provider, opts, base=None): ''' Deletes a minion's entry from the cloud cachedir. It will search through all cachedirs to find the minion's cache file. Needs `update_cachedir` set to True. ''' if isinstance(opts, dict): __opts__.update(opts) if ...
[ "def", "delete_minion_cachedir", "(", "minion_id", ",", "provider", ",", "opts", ",", "base", "=", "None", ")", ":", "if", "isinstance", "(", "opts", ",", "dict", ")", ":", "__opts__", ".", "update", "(", "opts", ")", "if", "__opts__", ".", "get", "(",...
Deletes a minion's entry from the cloud cachedir. It will search through all cachedirs to find the minion's cache file. Needs `update_cachedir` set to True.
[ "Deletes", "a", "minion", "s", "entry", "from", "the", "cloud", "cachedir", ".", "It", "will", "search", "through", "all", "cachedirs", "to", "find", "the", "minion", "s", "cache", "file", ".", "Needs", "update_cachedir", "set", "to", "True", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2816-L2837
34,966
saltstack/salt
salt/utils/cloud.py
cache_node_list
def cache_node_list(nodes, provider, opts): ''' If configured to do so, update the cloud cachedir with the current list of nodes. Also fires configured events pertaining to the node list. .. versionadded:: 2014.7.0 ''' if 'update_cachedir' not in opts or not opts['update_cachedir']: ret...
python
def cache_node_list(nodes, provider, opts): ''' If configured to do so, update the cloud cachedir with the current list of nodes. Also fires configured events pertaining to the node list. .. versionadded:: 2014.7.0 ''' if 'update_cachedir' not in opts or not opts['update_cachedir']: ret...
[ "def", "cache_node_list", "(", "nodes", ",", "provider", ",", "opts", ")", ":", "if", "'update_cachedir'", "not", "in", "opts", "or", "not", "opts", "[", "'update_cachedir'", "]", ":", "return", "base", "=", "os", ".", "path", ".", "join", "(", "init_cac...
If configured to do so, update the cloud cachedir with the current list of nodes. Also fires configured events pertaining to the node list. .. versionadded:: 2014.7.0
[ "If", "configured", "to", "do", "so", "update", "the", "cloud", "cachedir", "with", "the", "current", "list", "of", "nodes", ".", "Also", "fires", "configured", "events", "pertaining", "to", "the", "node", "list", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3010-L3034
34,967
saltstack/salt
salt/utils/cloud.py
cache_node
def cache_node(node, provider, opts): ''' Cache node individually .. versionadded:: 2014.7.0 ''' if isinstance(opts, dict): __opts__.update(opts) if 'update_cachedir' not in __opts__ or not __opts__['update_cachedir']: return if not os.path.exists(os.path.join(__opts__['ca...
python
def cache_node(node, provider, opts): ''' Cache node individually .. versionadded:: 2014.7.0 ''' if isinstance(opts, dict): __opts__.update(opts) if 'update_cachedir' not in __opts__ or not __opts__['update_cachedir']: return if not os.path.exists(os.path.join(__opts__['ca...
[ "def", "cache_node", "(", "node", ",", "provider", ",", "opts", ")", ":", "if", "isinstance", "(", "opts", ",", "dict", ")", ":", "__opts__", ".", "update", "(", "opts", ")", "if", "'update_cachedir'", "not", "in", "__opts__", "or", "not", "__opts__", ...
Cache node individually .. versionadded:: 2014.7.0
[ "Cache", "node", "individually" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3037-L3060
34,968
saltstack/salt
salt/utils/cloud.py
missing_node_cache
def missing_node_cache(prov_dir, node_list, provider, opts): ''' Check list of nodes to see if any nodes which were previously known about in the cache have been removed from the node list. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/s...
python
def missing_node_cache(prov_dir, node_list, provider, opts): ''' Check list of nodes to see if any nodes which were previously known about in the cache have been removed from the node list. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/s...
[ "def", "missing_node_cache", "(", "prov_dir", ",", "node_list", ",", "provider", ",", "opts", ")", ":", "cached_nodes", "=", "[", "]", "for", "node", "in", "os", ".", "listdir", "(", "prov_dir", ")", ":", "cached_nodes", ".", "append", "(", "os", ".", ...
Check list of nodes to see if any nodes which were previously known about in the cache have been removed from the node list. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/salt/cloud). .. code-block:: yaml diff_cache_events: True ...
[ "Check", "list", "of", "nodes", "to", "see", "if", "any", "nodes", "which", "were", "previously", "known", "about", "in", "the", "cache", "have", "been", "removed", "from", "the", "node", "list", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3063-L3094
34,969
saltstack/salt
salt/utils/cloud.py
diff_node_cache
def diff_node_cache(prov_dir, node, new_data, opts): ''' Check new node data against current cache. If data differ, fire an event which consists of the new node data. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/salt/cloud). .. cod...
python
def diff_node_cache(prov_dir, node, new_data, opts): ''' Check new node data against current cache. If data differ, fire an event which consists of the new node data. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/salt/cloud). .. cod...
[ "def", "diff_node_cache", "(", "prov_dir", ",", "node", ",", "new_data", ",", "opts", ")", ":", "if", "'diff_cache_events'", "not", "in", "opts", "or", "not", "opts", "[", "'diff_cache_events'", "]", ":", "return", "if", "node", "is", "None", ":", "return"...
Check new node data against current cache. If data differ, fire an event which consists of the new node data. This function will only run if configured to do so in the main Salt Cloud configuration file (normally /etc/salt/cloud). .. code-block:: yaml diff_cache_events: True .. versionad...
[ "Check", "new", "node", "data", "against", "current", "cache", ".", "If", "data", "differ", "fire", "an", "event", "which", "consists", "of", "the", "new", "node", "data", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3097-L3158
34,970
saltstack/salt
salt/utils/cloud.py
_salt_cloud_force_ascii
def _salt_cloud_force_ascii(exc): ''' Helper method to try its best to convert any Unicode text into ASCII without stack tracing since salt internally does not handle Unicode strings This method is not supposed to be used directly. Once `py:module: salt.utils.cloud` is imported this method register...
python
def _salt_cloud_force_ascii(exc): ''' Helper method to try its best to convert any Unicode text into ASCII without stack tracing since salt internally does not handle Unicode strings This method is not supposed to be used directly. Once `py:module: salt.utils.cloud` is imported this method register...
[ "def", "_salt_cloud_force_ascii", "(", "exc", ")", ":", "if", "not", "isinstance", "(", "exc", ",", "(", "UnicodeEncodeError", ",", "UnicodeTranslateError", ")", ")", ":", "raise", "TypeError", "(", "'Can\\'t handle {0}'", ".", "format", "(", "exc", ")", ")", ...
Helper method to try its best to convert any Unicode text into ASCII without stack tracing since salt internally does not handle Unicode strings This method is not supposed to be used directly. Once `py:module: salt.utils.cloud` is imported this method register's with python's codecs module for proper ...
[ "Helper", "method", "to", "try", "its", "best", "to", "convert", "any", "Unicode", "text", "into", "ASCII", "without", "stack", "tracing", "since", "salt", "internally", "does", "not", "handle", "Unicode", "strings" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3184-L3208
34,971
saltstack/salt
salt/utils/cloud.py
retrieve_password_from_keyring
def retrieve_password_from_keyring(credential_id, username): ''' Retrieve particular user's password for a specified credential set from system keyring. ''' try: import keyring # pylint: disable=import-error return keyring.get_password(credential_id, username) except ImportError: ...
python
def retrieve_password_from_keyring(credential_id, username): ''' Retrieve particular user's password for a specified credential set from system keyring. ''' try: import keyring # pylint: disable=import-error return keyring.get_password(credential_id, username) except ImportError: ...
[ "def", "retrieve_password_from_keyring", "(", "credential_id", ",", "username", ")", ":", "try", ":", "import", "keyring", "# pylint: disable=import-error", "return", "keyring", ".", "get_password", "(", "credential_id", ",", "username", ")", "except", "ImportError", ...
Retrieve particular user's password for a specified credential set from system keyring.
[ "Retrieve", "particular", "user", "s", "password", "for", "a", "specified", "credential", "set", "from", "system", "keyring", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3214-L3223
34,972
saltstack/salt
salt/utils/cloud.py
_save_password_in_keyring
def _save_password_in_keyring(credential_id, username, password): ''' Saves provider password in system keyring ''' try: import keyring # pylint: disable=import-error return keyring.set_password(credential_id, username, password) except ImportError: log.error('Tried to store...
python
def _save_password_in_keyring(credential_id, username, password): ''' Saves provider password in system keyring ''' try: import keyring # pylint: disable=import-error return keyring.set_password(credential_id, username, password) except ImportError: log.error('Tried to store...
[ "def", "_save_password_in_keyring", "(", "credential_id", ",", "username", ",", "password", ")", ":", "try", ":", "import", "keyring", "# pylint: disable=import-error", "return", "keyring", ".", "set_password", "(", "credential_id", ",", "username", ",", "password", ...
Saves provider password in system keyring
[ "Saves", "provider", "password", "in", "system", "keyring" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3226-L3235
34,973
saltstack/salt
salt/utils/cloud.py
store_password_in_keyring
def store_password_in_keyring(credential_id, username, password=None): ''' Interactively prompts user for a password and stores it in system keyring ''' try: # pylint: disable=import-error import keyring import keyring.errors # pylint: enable=import-error if passw...
python
def store_password_in_keyring(credential_id, username, password=None): ''' Interactively prompts user for a password and stores it in system keyring ''' try: # pylint: disable=import-error import keyring import keyring.errors # pylint: enable=import-error if passw...
[ "def", "store_password_in_keyring", "(", "credential_id", ",", "username", ",", "password", "=", "None", ")", ":", "try", ":", "# pylint: disable=import-error", "import", "keyring", "import", "keyring", ".", "errors", "# pylint: enable=import-error", "if", "password", ...
Interactively prompts user for a password and stores it in system keyring
[ "Interactively", "prompts", "user", "for", "a", "password", "and", "stores", "it", "in", "system", "keyring" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3238-L3265
34,974
saltstack/salt
salt/utils/cloud.py
check_key_path_and_mode
def check_key_path_and_mode(provider, key_path): ''' Checks that the key_path exists and the key_mode is either 0400 or 0600. Returns True or False. .. versionadded:: 2016.3.0 provider The provider name that the key_path to check belongs to. key_path The key_path to ensure th...
python
def check_key_path_and_mode(provider, key_path): ''' Checks that the key_path exists and the key_mode is either 0400 or 0600. Returns True or False. .. versionadded:: 2016.3.0 provider The provider name that the key_path to check belongs to. key_path The key_path to ensure th...
[ "def", "check_key_path_and_mode", "(", "provider", ",", "key_path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "key_path", ")", ":", "log", ".", "error", "(", "'The key file \\'%s\\' used in the \\'%s\\' provider configuration '", "'does not exist.\...
Checks that the key_path exists and the key_mode is either 0400 or 0600. Returns True or False. .. versionadded:: 2016.3.0 provider The provider name that the key_path to check belongs to. key_path The key_path to ensure that it exists and to check adequate permissions agains...
[ "Checks", "that", "the", "key_path", "exists", "and", "the", "key_mode", "is", "either", "0400", "or", "0600", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3327-L3357
34,975
saltstack/salt
salt/utils/cloud.py
userdata_template
def userdata_template(opts, vm_, userdata): ''' Use the configured templating engine to template the userdata file ''' # No userdata, no need to template anything if userdata is None: return userdata userdata_template = salt.config.get_cloud_config_value( 'userdata_template', vm...
python
def userdata_template(opts, vm_, userdata): ''' Use the configured templating engine to template the userdata file ''' # No userdata, no need to template anything if userdata is None: return userdata userdata_template = salt.config.get_cloud_config_value( 'userdata_template', vm...
[ "def", "userdata_template", "(", "opts", ",", "vm_", ",", "userdata", ")", ":", "# No userdata, no need to template anything", "if", "userdata", "is", "None", ":", "return", "userdata", "userdata_template", "=", "salt", ".", "config", ".", "get_cloud_config_value", ...
Use the configured templating engine to template the userdata file
[ "Use", "the", "configured", "templating", "engine", "to", "template", "the", "userdata", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3360-L3405
34,976
saltstack/salt
salt/crypt.py
dropfile
def dropfile(cachedir, user=None): ''' Set an AES dropfile to request the master update the publish session key ''' dfn = os.path.join(cachedir, '.dfn') # set a mask (to avoid a race condition on file creation) and store original. with salt.utils.files.set_umask(0o277): log.info('Rotatin...
python
def dropfile(cachedir, user=None): ''' Set an AES dropfile to request the master update the publish session key ''' dfn = os.path.join(cachedir, '.dfn') # set a mask (to avoid a race condition on file creation) and store original. with salt.utils.files.set_umask(0o277): log.info('Rotatin...
[ "def", "dropfile", "(", "cachedir", ",", "user", "=", "None", ")", ":", "dfn", "=", "os", ".", "path", ".", "join", "(", "cachedir", ",", "'.dfn'", ")", "# set a mask (to avoid a race condition on file creation) and store original.", "with", "salt", ".", "utils", ...
Set an AES dropfile to request the master update the publish session key
[ "Set", "an", "AES", "dropfile", "to", "request", "the", "master", "update", "the", "publish", "session", "key" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L82-L105
34,977
saltstack/salt
salt/crypt.py
gen_keys
def gen_keys(keydir, keyname, keysize, user=None, passphrase=None): ''' Generate a RSA public keypair for use with salt :param str keydir: The directory to write the keypair to :param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion') :param int ke...
python
def gen_keys(keydir, keyname, keysize, user=None, passphrase=None): ''' Generate a RSA public keypair for use with salt :param str keydir: The directory to write the keypair to :param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion') :param int ke...
[ "def", "gen_keys", "(", "keydir", ",", "keyname", ",", "keysize", ",", "user", "=", "None", ",", "passphrase", "=", "None", ")", ":", "base", "=", "os", ".", "path", ".", "join", "(", "keydir", ",", "keyname", ")", "priv", "=", "'{0}.pem'", ".", "f...
Generate a RSA public keypair for use with salt :param str keydir: The directory to write the keypair to :param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion') :param int keysize: The number of bits in the key :param str user: The user on the system...
[ "Generate", "a", "RSA", "public", "keypair", "for", "use", "with", "salt" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L108-L168
34,978
saltstack/salt
salt/crypt.py
get_rsa_pub_key
def get_rsa_pub_key(path): ''' Read a public key off the disk. ''' log.debug('salt.crypt.get_rsa_pub_key: Loading public key') if HAS_M2: with salt.utils.files.fopen(path, 'rb') as f: data = f.read().replace(b'RSA ', b'') bio = BIO.MemoryBuffer(data) key = RSA.loa...
python
def get_rsa_pub_key(path): ''' Read a public key off the disk. ''' log.debug('salt.crypt.get_rsa_pub_key: Loading public key') if HAS_M2: with salt.utils.files.fopen(path, 'rb') as f: data = f.read().replace(b'RSA ', b'') bio = BIO.MemoryBuffer(data) key = RSA.loa...
[ "def", "get_rsa_pub_key", "(", "path", ")", ":", "log", ".", "debug", "(", "'salt.crypt.get_rsa_pub_key: Loading public key'", ")", "if", "HAS_M2", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "path", ",", "'rb'", ")", "as", "f", ":"...
Read a public key off the disk.
[ "Read", "a", "public", "key", "off", "the", "disk", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L204-L217
34,979
saltstack/salt
salt/crypt.py
sign_message
def sign_message(privkey_path, message, passphrase=None): ''' Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature. ''' key = get_rsa_key(privkey_path, passphrase) log.debug('salt.crypt.sign_message: Signing message.') if HAS_M2: md = EVP.MessageDigest('sha1') ...
python
def sign_message(privkey_path, message, passphrase=None): ''' Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature. ''' key = get_rsa_key(privkey_path, passphrase) log.debug('salt.crypt.sign_message: Signing message.') if HAS_M2: md = EVP.MessageDigest('sha1') ...
[ "def", "sign_message", "(", "privkey_path", ",", "message", ",", "passphrase", "=", "None", ")", ":", "key", "=", "get_rsa_key", "(", "privkey_path", ",", "passphrase", ")", "log", ".", "debug", "(", "'salt.crypt.sign_message: Signing message.'", ")", "if", "HAS...
Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature.
[ "Use", "Crypto", ".", "Signature", ".", "PKCS1_v1_5", "to", "sign", "a", "message", ".", "Returns", "the", "signature", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L220-L233
34,980
saltstack/salt
salt/crypt.py
verify_signature
def verify_signature(pubkey_path, message, signature): ''' Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message. Returns True for valid signature. ''' log.debug('salt.crypt.verify_signature: Loading public key') pubkey = get_rsa_pub_key(pubkey_path) log.debug('salt.crypt.veri...
python
def verify_signature(pubkey_path, message, signature): ''' Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message. Returns True for valid signature. ''' log.debug('salt.crypt.verify_signature: Loading public key') pubkey = get_rsa_pub_key(pubkey_path) log.debug('salt.crypt.veri...
[ "def", "verify_signature", "(", "pubkey_path", ",", "message", ",", "signature", ")", ":", "log", ".", "debug", "(", "'salt.crypt.verify_signature: Loading public key'", ")", "pubkey", "=", "get_rsa_pub_key", "(", "pubkey_path", ")", "log", ".", "debug", "(", "'sa...
Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message. Returns True for valid signature.
[ "Use", "Crypto", ".", "Signature", ".", "PKCS1_v1_5", "to", "verify", "the", "signature", "on", "a", "message", ".", "Returns", "True", "for", "valid", "signature", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L236-L251
34,981
saltstack/salt
salt/crypt.py
gen_signature
def gen_signature(priv_path, pub_path, sign_path, passphrase=None): ''' creates a signature for the given public-key with the given private key and writes it to sign_path ''' with salt.utils.files.fopen(pub_path) as fp_: mpub_64 = fp_.read() mpub_sig = sign_message(priv_path, mpub_64, ...
python
def gen_signature(priv_path, pub_path, sign_path, passphrase=None): ''' creates a signature for the given public-key with the given private key and writes it to sign_path ''' with salt.utils.files.fopen(pub_path) as fp_: mpub_64 = fp_.read() mpub_sig = sign_message(priv_path, mpub_64, ...
[ "def", "gen_signature", "(", "priv_path", ",", "pub_path", ",", "sign_path", ",", "passphrase", "=", "None", ")", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "pub_path", ")", "as", "fp_", ":", "mpub_64", "=", "fp_", ".", "read",...
creates a signature for the given public-key with the given private key and writes it to sign_path
[ "creates", "a", "signature", "for", "the", "given", "public", "-", "key", "with", "the", "given", "private", "key", "and", "writes", "it", "to", "sign_path" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L254-L281
34,982
saltstack/salt
salt/crypt.py
private_encrypt
def private_encrypt(key, message): ''' Generate an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA key object :param str message: The message to sign :rtype: str :return: The signature, or an empty string if the signature operation failed ''' if HAS_M2: ...
python
def private_encrypt(key, message): ''' Generate an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA key object :param str message: The message to sign :rtype: str :return: The signature, or an empty string if the signature operation failed ''' if HAS_M2: ...
[ "def", "private_encrypt", "(", "key", ",", "message", ")", ":", "if", "HAS_M2", ":", "return", "key", ".", "private_encrypt", "(", "message", ",", "salt", ".", "utils", ".", "rsax931", ".", "RSA_X931_PADDING", ")", "else", ":", "signer", "=", "salt", "."...
Generate an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA key object :param str message: The message to sign :rtype: str :return: The signature, or an empty string if the signature operation failed
[ "Generate", "an", "M2Crypto", "-", "compatible", "signature" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L284-L297
34,983
saltstack/salt
salt/crypt.py
public_decrypt
def public_decrypt(pub, message): ''' Verify an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object :param str message: The signed message to verify :rtype: str :return: The message (or digest) recovered from the signature, or an empty string...
python
def public_decrypt(pub, message): ''' Verify an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object :param str message: The signed message to verify :rtype: str :return: The message (or digest) recovered from the signature, or an empty string...
[ "def", "public_decrypt", "(", "pub", ",", "message", ")", ":", "if", "HAS_M2", ":", "return", "pub", ".", "public_decrypt", "(", "message", ",", "salt", ".", "utils", ".", "rsax931", ".", "RSA_X931_PADDING", ")", "else", ":", "verifier", "=", "salt", "."...
Verify an M2Crypto-compatible signature :param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object :param str message: The signed message to verify :rtype: str :return: The message (or digest) recovered from the signature, or an empty string if the verification failed
[ "Verify", "an", "M2Crypto", "-", "compatible", "signature" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L300-L314
34,984
saltstack/salt
salt/crypt.py
MasterKeys.__get_keys
def __get_keys(self, name='master', passphrase=None): ''' Returns a key object for a key in the pki-dir ''' path = os.path.join(self.opts['pki_dir'], name + '.pem') if not os.path.exists(path): log.info('Generating %s keys: %s', name, self....
python
def __get_keys(self, name='master', passphrase=None): ''' Returns a key object for a key in the pki-dir ''' path = os.path.join(self.opts['pki_dir'], name + '.pem') if not os.path.exists(path): log.info('Generating %s keys: %s', name, self....
[ "def", "__get_keys", "(", "self", ",", "name", "=", "'master'", ",", "passphrase", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "opts", "[", "'pki_dir'", "]", ",", "name", "+", "'.pem'", ")", "if", "not", ...
Returns a key object for a key in the pki-dir
[ "Returns", "a", "key", "object", "for", "a", "key", "in", "the", "pki", "-", "dir" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L383-L407
34,985
saltstack/salt
salt/crypt.py
MasterKeys.get_pub_str
def get_pub_str(self, name='master'): ''' Return the string representation of a public key in the pki-directory ''' path = os.path.join(self.opts['pki_dir'], name + '.pub') if not os.path.isfile(path): key = self.__get_keys() ...
python
def get_pub_str(self, name='master'): ''' Return the string representation of a public key in the pki-directory ''' path = os.path.join(self.opts['pki_dir'], name + '.pub') if not os.path.isfile(path): key = self.__get_keys() ...
[ "def", "get_pub_str", "(", "self", ",", "name", "=", "'master'", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "opts", "[", "'pki_dir'", "]", ",", "name", "+", "'.pub'", ")", "if", "not", "os", ".", "path", ".", "isfile...
Return the string representation of a public key in the pki-directory
[ "Return", "the", "string", "representation", "of", "a", "public", "key", "in", "the", "pki", "-", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L409-L424
34,986
saltstack/salt
salt/crypt.py
AsyncAuth.authenticate
def authenticate(self, callback=None): ''' Ask for this client to reconnect to the origin This function will de-dupe all calls here and return a *single* future for the sign-in-- whis way callers can all assume there aren't others ''' # if an auth is in flight-- and not ...
python
def authenticate(self, callback=None): ''' Ask for this client to reconnect to the origin This function will de-dupe all calls here and return a *single* future for the sign-in-- whis way callers can all assume there aren't others ''' # if an auth is in flight-- and not ...
[ "def", "authenticate", "(", "self", ",", "callback", "=", "None", ")", ":", "# if an auth is in flight-- and not done-- just pass that back as the future to wait on", "if", "hasattr", "(", "self", ",", "'_authenticate_future'", ")", "and", "not", "self", ".", "_authentica...
Ask for this client to reconnect to the origin This function will de-dupe all calls here and return a *single* future for the sign-in-- whis way callers can all assume there aren't others
[ "Ask", "for", "this", "client", "to", "reconnect", "to", "the", "origin" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L558-L579
34,987
saltstack/salt
salt/crypt.py
AsyncAuth.get_keys
def get_keys(self): ''' Return keypair object for the minion. :rtype: Crypto.PublicKey.RSA._RSAobj :return: The RSA keypair ''' # Make sure all key parent directories are accessible user = self.opts.get('user', 'root') salt.utils.verify.check_path_travers...
python
def get_keys(self): ''' Return keypair object for the minion. :rtype: Crypto.PublicKey.RSA._RSAobj :return: The RSA keypair ''' # Make sure all key parent directories are accessible user = self.opts.get('user', 'root') salt.utils.verify.check_path_travers...
[ "def", "get_keys", "(", "self", ")", ":", "# Make sure all key parent directories are accessible", "user", "=", "self", ".", "opts", ".", "get", "(", "'user'", ",", "'root'", ")", "salt", ".", "utils", ".", "verify", ".", "check_path_traversal", "(", "self", "...
Return keypair object for the minion. :rtype: Crypto.PublicKey.RSA._RSAobj :return: The RSA keypair
[ "Return", "keypair", "object", "for", "the", "minion", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L784-L803
34,988
saltstack/salt
salt/crypt.py
AsyncAuth.minion_sign_in_payload
def minion_sign_in_payload(self): ''' Generates the payload used to authenticate with the master server. This payload consists of the passed in id_ and the ssh public key to encrypt the AES key sent back from the master. :return: Payload dictionary :rtype: dict '...
python
def minion_sign_in_payload(self): ''' Generates the payload used to authenticate with the master server. This payload consists of the passed in id_ and the ssh public key to encrypt the AES key sent back from the master. :return: Payload dictionary :rtype: dict '...
[ "def", "minion_sign_in_payload", "(", "self", ")", ":", "payload", "=", "{", "}", "payload", "[", "'cmd'", "]", "=", "'_auth'", "payload", "[", "'id'", "]", "=", "self", ".", "opts", "[", "'id'", "]", "if", "'autosign_grains'", "in", "self", ".", "opts...
Generates the payload used to authenticate with the master server. This payload consists of the passed in id_ and the ssh public key to encrypt the AES key sent back from the master. :return: Payload dictionary :rtype: dict
[ "Generates", "the", "payload", "used", "to", "authenticate", "with", "the", "master", "server", ".", "This", "payload", "consists", "of", "the", "passed", "in", "id_", "and", "the", "ssh", "public", "key", "to", "encrypt", "the", "AES", "key", "sent", "bac...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L816-L845
34,989
saltstack/salt
salt/crypt.py
AsyncAuth.decrypt_aes
def decrypt_aes(self, payload, master_pub=True): ''' This function is used to decrypt the AES seed phrase returned from the master server. The seed phrase is decrypted with the SSH RSA host key. Pass in the encrypted AES key. Returns the decrypted AES seed key, a string ...
python
def decrypt_aes(self, payload, master_pub=True): ''' This function is used to decrypt the AES seed phrase returned from the master server. The seed phrase is decrypted with the SSH RSA host key. Pass in the encrypted AES key. Returns the decrypted AES seed key, a string ...
[ "def", "decrypt_aes", "(", "self", ",", "payload", ",", "master_pub", "=", "True", ")", ":", "if", "self", ".", "opts", ".", "get", "(", "'auth_trb'", ",", "False", ")", ":", "log", ".", "warning", "(", "'Auth Called: %s'", ",", "''", ".", "join", "(...
This function is used to decrypt the AES seed phrase returned from the master server. The seed phrase is decrypted with the SSH RSA host key. Pass in the encrypted AES key. Returns the decrypted AES seed key, a string :param dict payload: The incoming payload. This is a diction...
[ "This", "function", "is", "used", "to", "decrypt", "the", "AES", "seed", "phrase", "returned", "from", "the", "master", "server", ".", "The", "seed", "phrase", "is", "decrypted", "with", "the", "SSH", "RSA", "host", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L847-L915
34,990
saltstack/salt
salt/crypt.py
AsyncAuth.verify_pubkey_sig
def verify_pubkey_sig(self, message, sig): ''' Wraps the verify_signature method so we have additional checks. :rtype: bool :return: Success or failure of public key verification ''' if self.opts['master_sign_key_name']: path = os.path.join(self.opts[...
python
def verify_pubkey_sig(self, message, sig): ''' Wraps the verify_signature method so we have additional checks. :rtype: bool :return: Success or failure of public key verification ''' if self.opts['master_sign_key_name']: path = os.path.join(self.opts[...
[ "def", "verify_pubkey_sig", "(", "self", ",", "message", ",", "sig", ")", ":", "if", "self", ".", "opts", "[", "'master_sign_key_name'", "]", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "opts", "[", "'pki_dir'", "]", ",", "sel...
Wraps the verify_signature method so we have additional checks. :rtype: bool :return: Success or failure of public key verification
[ "Wraps", "the", "verify_signature", "method", "so", "we", "have", "additional", "checks", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L917-L956
34,991
saltstack/salt
salt/crypt.py
AsyncAuth.extract_aes
def extract_aes(self, payload, master_pub=True): ''' Return the AES key received from the master after the minion has been successfully authenticated. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key...
python
def extract_aes(self, payload, master_pub=True): ''' Return the AES key received from the master after the minion has been successfully authenticated. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key...
[ "def", "extract_aes", "(", "self", ",", "payload", ",", "master_pub", "=", "True", ")", ":", "if", "master_pub", ":", "try", ":", "aes", ",", "token", "=", "self", ".", "decrypt_aes", "(", "payload", ",", "master_pub", ")", "if", "token", "!=", "self",...
Return the AES key received from the master after the minion has been successfully authenticated. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key 'enc': The format of the message. ('clear', 'pub', etc) ...
[ "Return", "the", "AES", "key", "received", "from", "the", "master", "after", "the", "minion", "has", "been", "successfully", "authenticated", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1018-L1049
34,992
saltstack/salt
salt/crypt.py
AsyncAuth.verify_master
def verify_master(self, payload, master_pub=True): ''' Verify that the master is the same one that was previously accepted. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key 'enc': The format of t...
python
def verify_master(self, payload, master_pub=True): ''' Verify that the master is the same one that was previously accepted. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key 'enc': The format of t...
[ "def", "verify_master", "(", "self", ",", "payload", ",", "master_pub", "=", "True", ")", ":", "m_pub_fn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "opts", "[", "'pki_dir'", "]", ",", "self", ".", "mpub", ")", "m_pub_exists", "=", "os",...
Verify that the master is the same one that was previously accepted. :param dict payload: The incoming payload. This is a dictionary which may have the following keys: 'aes': The shared AES key 'enc': The format of the message. ('clear', 'pub', etc) 'publish_port': The TCP p...
[ "Verify", "that", "the", "master", "is", "the", "same", "one", "that", "was", "previously", "accepted", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1051-L1127
34,993
saltstack/salt
salt/crypt.py
Crypticle.encrypt
def encrypt(self, data): ''' encrypt data with AES-CBC and sign it with HMAC-SHA256 ''' aes_key, hmac_key = self.keys pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE if six.PY2: data = data + pad * chr(pad) else: data = data + s...
python
def encrypt(self, data): ''' encrypt data with AES-CBC and sign it with HMAC-SHA256 ''' aes_key, hmac_key = self.keys pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE if six.PY2: data = data + pad * chr(pad) else: data = data + s...
[ "def", "encrypt", "(", "self", ",", "data", ")", ":", "aes_key", ",", "hmac_key", "=", "self", ".", "keys", "pad", "=", "self", ".", "AES_BLOCK_SIZE", "-", "len", "(", "data", ")", "%", "self", ".", "AES_BLOCK_SIZE", "if", "six", ".", "PY2", ":", "...
encrypt data with AES-CBC and sign it with HMAC-SHA256
[ "encrypt", "data", "with", "AES", "-", "CBC", "and", "sign", "it", "with", "HMAC", "-", "SHA256" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1406-L1426
34,994
saltstack/salt
salt/crypt.py
Crypticle.decrypt
def decrypt(self, data): ''' verify HMAC-SHA256 signature and decrypt data with AES-CBC ''' aes_key, hmac_key = self.keys sig = data[-self.SIG_SIZE:] data = data[:-self.SIG_SIZE] if six.PY3 and not isinstance(data, bytes): data = salt.utils.stringutils...
python
def decrypt(self, data): ''' verify HMAC-SHA256 signature and decrypt data with AES-CBC ''' aes_key, hmac_key = self.keys sig = data[-self.SIG_SIZE:] data = data[:-self.SIG_SIZE] if six.PY3 and not isinstance(data, bytes): data = salt.utils.stringutils...
[ "def", "decrypt", "(", "self", ",", "data", ")", ":", "aes_key", ",", "hmac_key", "=", "self", ".", "keys", "sig", "=", "data", "[", "-", "self", ".", "SIG_SIZE", ":", "]", "data", "=", "data", "[", ":", "-", "self", ".", "SIG_SIZE", "]", "if", ...
verify HMAC-SHA256 signature and decrypt data with AES-CBC
[ "verify", "HMAC", "-", "SHA256", "signature", "and", "decrypt", "data", "with", "AES", "-", "CBC" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1428-L1464
34,995
saltstack/salt
salt/crypt.py
Crypticle.dumps
def dumps(self, obj): ''' Serialize and encrypt a python object ''' return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj))
python
def dumps(self, obj): ''' Serialize and encrypt a python object ''' return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj))
[ "def", "dumps", "(", "self", ",", "obj", ")", ":", "return", "self", ".", "encrypt", "(", "self", ".", "PICKLE_PAD", "+", "self", ".", "serial", ".", "dumps", "(", "obj", ")", ")" ]
Serialize and encrypt a python object
[ "Serialize", "and", "encrypt", "a", "python", "object" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1466-L1470
34,996
saltstack/salt
salt/crypt.py
Crypticle.loads
def loads(self, data, raw=False): ''' Decrypt and un-serialize a python object ''' data = self.decrypt(data) # simple integrity check to verify that we got meaningful data if not data.startswith(self.PICKLE_PAD): return {} load = self.serial.loads(data...
python
def loads(self, data, raw=False): ''' Decrypt and un-serialize a python object ''' data = self.decrypt(data) # simple integrity check to verify that we got meaningful data if not data.startswith(self.PICKLE_PAD): return {} load = self.serial.loads(data...
[ "def", "loads", "(", "self", ",", "data", ",", "raw", "=", "False", ")", ":", "data", "=", "self", ".", "decrypt", "(", "data", ")", "# simple integrity check to verify that we got meaningful data", "if", "not", "data", ".", "startswith", "(", "self", ".", "...
Decrypt and un-serialize a python object
[ "Decrypt", "and", "un", "-", "serialize", "a", "python", "object" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1472-L1481
34,997
saltstack/salt
salt/pillar/hiera.py
ext_pillar
def ext_pillar(minion_id, # pylint: disable=W0613 pillar, # pylint: disable=W0613 conf): ''' Execute hiera and return the data ''' cmd = 'hiera -c {0}'.format(conf) for key, val in six.iteritems(__grains__): if isinstance(val, six.string_types): cm...
python
def ext_pillar(minion_id, # pylint: disable=W0613 pillar, # pylint: disable=W0613 conf): ''' Execute hiera and return the data ''' cmd = 'hiera -c {0}'.format(conf) for key, val in six.iteritems(__grains__): if isinstance(val, six.string_types): cm...
[ "def", "ext_pillar", "(", "minion_id", ",", "# pylint: disable=W0613", "pillar", ",", "# pylint: disable=W0613", "conf", ")", ":", "cmd", "=", "'hiera -c {0}'", ".", "format", "(", "conf", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "_...
Execute hiera and return the data
[ "Execute", "hiera", "and", "return", "the", "data" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/hiera.py#L29-L44
34,998
saltstack/salt
salt/modules/glusterfs.py
_gluster_output_cleanup
def _gluster_output_cleanup(result): ''' Gluster versions prior to 6 have a bug that requires tricking isatty. This adds "gluster> " to the output. Strip it off and produce clean xml for ElementTree. ''' ret = '' for line in result.splitlines(): if line.startswith('gluster>'): ...
python
def _gluster_output_cleanup(result): ''' Gluster versions prior to 6 have a bug that requires tricking isatty. This adds "gluster> " to the output. Strip it off and produce clean xml for ElementTree. ''' ret = '' for line in result.splitlines(): if line.startswith('gluster>'): ...
[ "def", "_gluster_output_cleanup", "(", "result", ")", ":", "ret", "=", "''", "for", "line", "in", "result", ".", "splitlines", "(", ")", ":", "if", "line", ".", "startswith", "(", "'gluster>'", ")", ":", "ret", "+=", "line", "[", "9", ":", "]", ".", ...
Gluster versions prior to 6 have a bug that requires tricking isatty. This adds "gluster> " to the output. Strip it off and produce clean xml for ElementTree.
[ "Gluster", "versions", "prior", "to", "6", "have", "a", "bug", "that", "requires", "tricking", "isatty", ".", "This", "adds", "gluster", ">", "to", "the", "output", ".", "Strip", "it", "off", "and", "produce", "clean", "xml", "for", "ElementTree", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L51-L66
34,999
saltstack/salt
salt/modules/glusterfs.py
_iter
def _iter(root, term): ''' Checks for python2.6 or python2.7 ''' if sys.version_info < (2, 7): return root.getiterator(term) else: return root.iter(term)
python
def _iter(root, term): ''' Checks for python2.6 or python2.7 ''' if sys.version_info < (2, 7): return root.getiterator(term) else: return root.iter(term)
[ "def", "_iter", "(", "root", ",", "term", ")", ":", "if", "sys", ".", "version_info", "<", "(", "2", ",", "7", ")", ":", "return", "root", ".", "getiterator", "(", "term", ")", "else", ":", "return", "root", ".", "iter", "(", "term", ")" ]
Checks for python2.6 or python2.7
[ "Checks", "for", "python2", ".", "6", "or", "python2", ".", "7" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L120-L127