partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
is_dictlist
Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False
salt/utils/data.py
def is_dictlist(data): ''' Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False ''' if isinstance(data, list): for element in data: if isinstance(element, dict): if len(element) != 1: retur...
def is_dictlist(data): ''' Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False ''' if isinstance(data, list): for element in data: if isinstance(element, dict): if len(element) != 1: retur...
[ "Returns", "True", "if", "data", "is", "a", "list", "of", "one", "-", "element", "dicts", "(", "as", "found", "in", "many", "SLS", "schemas", ")", "otherwise", "returns", "False" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L745-L758
[ "def", "is_dictlist", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "list", ")", ":", "for", "element", "in", "data", ":", "if", "isinstance", "(", "element", ",", "dict", ")", ":", "if", "len", "(", "element", ")", "!=", "1", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
repack_dictlist
Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary.
salt/utils/data.py
def repack_dictlist(data, strict=False, recurse=False, key_cb=None, val_cb=None): ''' Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary. ''' if isinstance(data, six.str...
def repack_dictlist(data, strict=False, recurse=False, key_cb=None, val_cb=None): ''' Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary. ''' if isinstance(data, six.str...
[ "Takes", "a", "list", "of", "one", "-", "element", "dicts", "(", "as", "found", "in", "many", "SLS", "schemas", ")", "and", "repacks", "into", "a", "single", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L761-L828
[ "def", "repack_dictlist", "(", "data", ",", "strict", "=", "False", ",", "recurse", "=", "False", ",", "key_cb", "=", "None", ",", "val_cb", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "six", ".", "string_types", ")", ":", "try", ":"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_iter
Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered iterable. This can be used to also exclude things like...
salt/utils/data.py
def is_iter(y, ignore=six.string_types): ''' Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered i...
def is_iter(y, ignore=six.string_types): ''' Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered i...
[ "Test", "if", "an", "object", "is", "iterable", "but", "not", "a", "string", "type", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L840-L860
[ "def", "is_iter", "(", "y", ",", "ignore", "=", "six", ".", "string_types", ")", ":", "if", "ignore", "and", "isinstance", "(", "y", ",", "ignore", ")", ":", "return", "False", "try", ":", "iter", "(", "y", ")", "return", "True", "except", "TypeError...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_true
Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True
salt/utils/data.py
def is_true(value=None): ''' Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True ''' # Fir...
def is_true(value=None): ''' Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True ''' # Fir...
[ "Returns", "a", "boolean", "value", "representing", "the", "truth", "of", "the", "value", "passed", ".", "The", "rules", "for", "what", "is", "a", "True", "value", "are", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L878-L903
[ "def", "is_true", "(", "value", "=", "None", ")", ":", "# First, try int/float conversion", "try", ":", "value", "=", "int", "(", "value", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "pass", "try", ":", "value", "=", "float", "(", "valu...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mysql_to_dict
Convert MySQL-style output to a python dictionary
salt/utils/data.py
def mysql_to_dict(data, key): ''' Convert MySQL-style output to a python dictionary ''' ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)):...
def mysql_to_dict(data, key): ''' Convert MySQL-style output to a python dictionary ''' ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)):...
[ "Convert", "MySQL", "-", "style", "output", "to", "a", "python", "dictionary" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L907-L932
[ "def", "mysql_to_dict", "(", "data", ",", "key", ")", ":", "ret", "=", "{", "}", "headers", "=", "[", "''", "]", "for", "line", "in", "data", ":", "if", "not", "line", ":", "continue", "if", "line", ".", "startswith", "(", "'+'", ")", ":", "conti...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
simple_types_filter
Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc.
salt/utils/data.py
def simple_types_filter(data): ''' Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc. ''' if data is None: return data simpletypes_keys = (six.string_types, six.text_type, six.integer_types, float, bool) simpletypes_values = tuple(list(simplety...
def simple_types_filter(data): ''' Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc. ''' if data is None: return data simpletypes_keys = (six.string_types, six.text_type, six.integer_types, float, bool) simpletypes_values = tuple(list(simplety...
[ "Convert", "the", "data", "list", "dictionary", "into", "simple", "types", "i", ".", "e", ".", "int", "float", "string", "bool", "etc", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L935-L969
[ "def", "simple_types_filter", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "data", "simpletypes_keys", "=", "(", "six", ".", "string_types", ",", "six", ".", "text_type", ",", "six", ".", "integer_types", ",", "float", ",", "bool", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
stringify
Given an iterable, returns its items as a list, with any non-string items converted to unicode strings.
salt/utils/data.py
def stringify(data): ''' Given an iterable, returns its items as a list, with any non-string items converted to unicode strings. ''' ret = [] for item in data: if six.PY2 and isinstance(item, str): item = salt.utils.stringutils.to_unicode(item) elif not isinstance(ite...
def stringify(data): ''' Given an iterable, returns its items as a list, with any non-string items converted to unicode strings. ''' ret = [] for item in data: if six.PY2 and isinstance(item, str): item = salt.utils.stringutils.to_unicode(item) elif not isinstance(ite...
[ "Given", "an", "iterable", "returns", "its", "items", "as", "a", "list", "with", "any", "non", "-", "string", "items", "converted", "to", "unicode", "strings", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L972-L984
[ "def", "stringify", "(", "data", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "data", ":", "if", "six", ".", "PY2", "and", "isinstance", "(", "item", ",", "str", ")", ":", "item", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_un...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
json_query
Query data using JMESPath language (http://jmespath.org).
salt/utils/data.py
def json_query(data, expr): ''' Query data using JMESPath language (http://jmespath.org). ''' if jmespath is None: err = 'json_query requires jmespath module installed' log.error(err) raise RuntimeError(err) return jmespath.search(expr, data)
def json_query(data, expr): ''' Query data using JMESPath language (http://jmespath.org). ''' if jmespath is None: err = 'json_query requires jmespath module installed' log.error(err) raise RuntimeError(err) return jmespath.search(expr, data)
[ "Query", "data", "using", "JMESPath", "language", "(", "http", ":", "//", "jmespath", ".", "org", ")", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L988-L996
[ "def", "json_query", "(", "data", ",", "expr", ")", ":", "if", "jmespath", "is", "None", ":", "err", "=", "'json_query requires jmespath module installed'", "log", ".", "error", "(", "err", ")", "raise", "RuntimeError", "(", "err", ")", "return", "jmespath", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_is_not_considered_falsey
Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool
salt/utils/data.py
def _is_not_considered_falsey(value, ignore_types=()): ''' Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool ''' retu...
def _is_not_considered_falsey(value, ignore_types=()): ''' Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool ''' retu...
[ "Helper", "function", "for", "filter_falsey", "to", "determine", "if", "something", "is", "not", "to", "be", "considered", "falsey", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L999-L1009
[ "def", "_is_not_considered_falsey", "(", "value", ",", "ignore_types", "=", "(", ")", ")", ":", "return", "isinstance", "(", "value", ",", "bool", ")", "or", "type", "(", "value", ")", "in", "ignore_types", "or", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
filter_falsey
Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Source iterable (dict, OrderedDict, list, set, ...) to process. :param in...
salt/utils/data.py
def filter_falsey(data, recurse_depth=None, ignore_types=()): ''' Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Sou...
def filter_falsey(data, recurse_depth=None, ignore_types=()): ''' Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Sou...
[ "Helper", "function", "to", "remove", "items", "from", "an", "iterable", "with", "falsey", "value", ".", "Removes", "None", "{}", "and", "[]", "0", "(", "but", "does", "not", "remove", "False", ")", ".", "Recurses", "into", "sub", "-", "iterables", "if",...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L1012-L1048
[ "def", "filter_falsey", "(", "data", ",", "recurse_depth", "=", "None", ",", "ignore_types", "=", "(", ")", ")", ":", "filter_element", "=", "(", "functools", ".", "partial", "(", "filter_falsey", ",", "recurse_depth", "=", "recurse_depth", "-", "1", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
CaseInsensitiveDict.items_lower
Returns a generator iterating over keys and values, with the keys all being lowercase.
salt/utils/data.py
def items_lower(self): ''' Returns a generator iterating over keys and values, with the keys all being lowercase. ''' return ((key, val[1]) for key, val in six.iteritems(self._data))
def items_lower(self): ''' Returns a generator iterating over keys and values, with the keys all being lowercase. ''' return ((key, val[1]) for key, val in six.iteritems(self._data))
[ "Returns", "a", "generator", "iterating", "over", "keys", "and", "values", "with", "the", "keys", "all", "being", "lowercase", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L80-L85
[ "def", "items_lower", "(", "self", ")", ":", "return", "(", "(", "key", ",", "val", "[", "1", "]", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "self", ".", "_data", ")", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
write
Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written, valid types are string, data, int[eger], float, bool[ean], dat...
salt/states/macdefaults.py
def write(name, domain, value, vtype='string', user=None): ''' Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written,...
def write(name, domain, value, vtype='string', user=None): ''' Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written,...
[ "Write", "a", "default", "to", "the", "system" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/macdefaults.py#L28-L78
[ "def", "write", "(", "name", ",", "domain", ",", "value", ",", "vtype", "=", "'string'", ",", "user", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
absent
Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to
salt/states/macdefaults.py
def absent(name, domain, user=None): ''' Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to ''' ret = {'name': name, 'result': True, ...
def absent(name, domain, user=None): ''' Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to ''' ret = {'name': name, 'result': True, ...
[ "Make", "sure", "the", "defaults", "value", "is", "absent" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/macdefaults.py#L81-L108
[ "def", "absent", "(", "name", ",", "domain", ",", "user", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "out", "=", "__salt__", "[",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
info
Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root
salt/modules/win_shadow.py
def info(name): ''' Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root ''' info = __salt__['user.info'](name...
def info(name): ''' Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root ''' info = __salt__['user.info'](name...
[ "Return", "information", "for", "the", "specified", "user", "This", "is", "just", "returns", "dummy", "data", "so", "that", "salt", "states", "can", "work", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_shadow.py#L30-L64
[ "def", "info", "(", "name", ")", ":", "info", "=", "__salt__", "[", "'user.info'", "]", "(", "name", "=", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'passwd'", ":", "''", ",", "'lstchg'", ":", "''", ",", "'min'", ":", "''", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_class_paths
Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple(str)
salt/utils/saltclass.py
def get_class_paths(_class, saltclass_path): ''' Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple...
def get_class_paths(_class, saltclass_path): ''' Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple...
[ "Converts", "the", "dotted", "notation", "of", "a", "saltclass", "class", "to", "its", "possible", "file", "counterparts", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L64-L83
[ "def", "get_class_paths", "(", "_class", ",", "saltclass_path", ")", ":", "straight", "=", "os", ".", "path", ".", "join", "(", "saltclass_path", ",", "'classes'", ",", "'{0}.yml'", ".", "format", "(", "_class", ")", ")", "sub_straight", "=", "os", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_class_from_file
Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolute path to file :param str saltclass_path: Root to saltc...
salt/utils/saltclass.py
def get_class_from_file(_file, saltclass_path): ''' Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolu...
def get_class_from_file(_file, saltclass_path): ''' Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolu...
[ "Converts", "the", "absolute", "path", "to", "a", "saltclass", "file", "back", "to", "the", "dotted", "notation", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L86-L109
[ "def", "get_class_from_file", "(", "_file", ",", "saltclass_path", ")", ":", "# remove classes path prefix", "_file", "=", "_file", "[", "len", "(", "os", ".", "path", ".", "join", "(", "saltclass_path", ",", "'classes'", ")", ")", "+", "len", "(", "os", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
match_class_glob
Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/saltclass') print(classes) # services.mariadb ...
salt/utils/saltclass.py
def match_class_glob(_class, saltclass_path): ''' Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/salt...
def match_class_glob(_class, saltclass_path): ''' Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/salt...
[ "Takes", "a", "class", "name", "possibly", "including", "*", "or", "?", "wildcards", "(", "or", "any", "other", "wildcards", "supportet", "by", "glob", ".", "glob", ")", "and", "returns", "a", "list", "of", "expanded", "class", "names", "without", "wildcar...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L231-L260
[ "def", "match_class_glob", "(", "_class", ",", "saltclass_path", ")", ":", "straight", ",", "sub_init", ",", "sub_straight", "=", "get_class_paths", "(", "_class", ",", "saltclass_path", ")", "classes", "=", "[", "]", "matches", "=", "[", "]", "matches", "."...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
expand_classes_glob
Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str)
salt/utils/saltclass.py
def expand_classes_glob(classes, salt_data): ''' Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str) ''' all...
def expand_classes_glob(classes, salt_data): ''' Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str) ''' all...
[ "Expand", "the", "list", "of", "classes", "to", "no", "longer", "include", "any", "globbing", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L263-L283
[ "def", "expand_classes_glob", "(", "classes", ",", "salt_data", ")", ":", "all_classes", "=", "[", "]", "expanded_classes", "=", "[", "]", "saltclass_path", "=", "salt_data", "[", "'path'", "]", "for", "_class", "in", "classes", ":", "all_classes", ".", "ext...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_is_simple_type
Returns True, if the given parameter value is an instance of either int, str, float or bool.
salt/modules/syslog_ng.py
def _is_simple_type(value): ''' Returns True, if the given parameter value is an instance of either int, str, float or bool. ''' return isinstance(value, six.string_types) or isinstance(value, int) or isinstance(value, float) or isinstance(value, bool)
def _is_simple_type(value): ''' Returns True, if the given parameter value is an instance of either int, str, float or bool. ''' return isinstance(value, six.string_types) or isinstance(value, int) or isinstance(value, float) or isinstance(value, bool)
[ "Returns", "True", "if", "the", "given", "parameter", "value", "is", "an", "instance", "of", "either", "int", "str", "float", "or", "bool", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L425-L430
[ "def", "_is_simple_type", "(", "value", ")", ":", "return", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", "or", "isinstance", "(", "value", ",", "int", ")", "or", "isinstance", "(", "value", ",", "float", ")", "or", "isinstance", "(",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_type_id_options
Returns the type, id and option of a configuration object.
salt/modules/syslog_ng.py
def _get_type_id_options(name, configuration): ''' Returns the type, id and option of a configuration object. ''' # it's in a form of source.name if '.' in name: type_, sep, id_ = name.partition('.') options = configuration else: type_ = next(six.iterkeys(configuration)) ...
def _get_type_id_options(name, configuration): ''' Returns the type, id and option of a configuration object. ''' # it's in a form of source.name if '.' in name: type_, sep, id_ = name.partition('.') options = configuration else: type_ = next(six.iterkeys(configuration)) ...
[ "Returns", "the", "type", "id", "and", "option", "of", "a", "configuration", "object", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L433-L446
[ "def", "_get_type_id_options", "(", "name", ",", "configuration", ")", ":", "# it's in a form of source.name", "if", "'.'", "in", "name", ":", "type_", ",", "sep", ",", "id_", "=", "name", ".", "partition", "(", "'.'", ")", "options", "=", "configuration", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_expand_one_key_dictionary
Returns the only one key and it's value from a dictionary.
salt/modules/syslog_ng.py
def _expand_one_key_dictionary(_dict): ''' Returns the only one key and it's value from a dictionary. ''' key = next(six.iterkeys(_dict)) value = _dict[key] return key, value
def _expand_one_key_dictionary(_dict): ''' Returns the only one key and it's value from a dictionary. ''' key = next(six.iterkeys(_dict)) value = _dict[key] return key, value
[ "Returns", "the", "only", "one", "key", "and", "it", "s", "value", "from", "a", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L449-L455
[ "def", "_expand_one_key_dictionary", "(", "_dict", ")", ":", "key", "=", "next", "(", "six", ".", "iterkeys", "(", "_dict", ")", ")", "value", "=", "_dict", "[", "key", "]", "return", "key", ",", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_typed_parameter_typed_value
Creates Arguments in a TypedParametervalue.
salt/modules/syslog_ng.py
def _parse_typed_parameter_typed_value(values): ''' Creates Arguments in a TypedParametervalue. ''' type_, value = _expand_one_key_dictionary(values) _current_parameter_value.type = type_ if _is_simple_type(value): arg = Argument(value) _current_parameter_value.add_argument(arg)...
def _parse_typed_parameter_typed_value(values): ''' Creates Arguments in a TypedParametervalue. ''' type_, value = _expand_one_key_dictionary(values) _current_parameter_value.type = type_ if _is_simple_type(value): arg = Argument(value) _current_parameter_value.add_argument(arg)...
[ "Creates", "Arguments", "in", "a", "TypedParametervalue", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L458-L471
[ "def", "_parse_typed_parameter_typed_value", "(", "values", ")", ":", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "values", ")", "_current_parameter_value", ".", "type", "=", "type_", "if", "_is_simple_type", "(", "value", ")", ":", "arg", "=", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_typed_parameter
Parses a TypedParameter and fills it with values.
salt/modules/syslog_ng.py
def _parse_typed_parameter(param): ''' Parses a TypedParameter and fills it with values. ''' global _current_parameter_value type_, value = _expand_one_key_dictionary(param) _current_parameter.type = type_ if _is_simple_type(value) and value != '': _current_parameter_value = SimpleP...
def _parse_typed_parameter(param): ''' Parses a TypedParameter and fills it with values. ''' global _current_parameter_value type_, value = _expand_one_key_dictionary(param) _current_parameter.type = type_ if _is_simple_type(value) and value != '': _current_parameter_value = SimpleP...
[ "Parses", "a", "TypedParameter", "and", "fills", "it", "with", "values", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L474-L493
[ "def", "_parse_typed_parameter", "(", "param", ")", ":", "global", "_current_parameter_value", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "param", ")", "_current_parameter", ".", "type", "=", "type_", "if", "_is_simple_type", "(", "value", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_create_and_add_parameters
Parses the configuration and creates Parameter instances.
salt/modules/syslog_ng.py
def _create_and_add_parameters(params): ''' Parses the configuration and creates Parameter instances. ''' global _current_parameter if _is_simple_type(params): _current_parameter = SimpleParameter(params) _current_option.add_parameter(_current_parameter) else: # must be a...
def _create_and_add_parameters(params): ''' Parses the configuration and creates Parameter instances. ''' global _current_parameter if _is_simple_type(params): _current_parameter = SimpleParameter(params) _current_option.add_parameter(_current_parameter) else: # must be a...
[ "Parses", "the", "configuration", "and", "creates", "Parameter", "instances", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L496-L512
[ "def", "_create_and_add_parameters", "(", "params", ")", ":", "global", "_current_parameter", "if", "_is_simple_type", "(", "params", ")", ":", "_current_parameter", "=", "SimpleParameter", "(", "params", ")", "_current_option", ".", "add_parameter", "(", "_current_pa...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_create_and_add_option
Parses the configuration and creates an Option instance.
salt/modules/syslog_ng.py
def _create_and_add_option(option): ''' Parses the configuration and creates an Option instance. ''' global _current_option _current_option = Option() type_, params = _expand_one_key_dictionary(option) _current_option.type = type_ _create_and_add_parameters(params) _current_statemen...
def _create_and_add_option(option): ''' Parses the configuration and creates an Option instance. ''' global _current_option _current_option = Option() type_, params = _expand_one_key_dictionary(option) _current_option.type = type_ _create_and_add_parameters(params) _current_statemen...
[ "Parses", "the", "configuration", "and", "creates", "an", "Option", "instance", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L515-L525
[ "def", "_create_and_add_option", "(", "option", ")", ":", "global", "_current_option", "_current_option", "=", "Option", "(", ")", "type_", ",", "params", "=", "_expand_one_key_dictionary", "(", "option", ")", "_current_option", ".", "type", "=", "type_", "_create...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_is_reference
Return True, if arg is a reference to a previously defined statement.
salt/modules/syslog_ng.py
def _is_reference(arg): ''' Return True, if arg is a reference to a previously defined statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), six.string_types)
def _is_reference(arg): ''' Return True, if arg is a reference to a previously defined statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), six.string_types)
[ "Return", "True", "if", "arg", "is", "a", "reference", "to", "a", "previously", "defined", "statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L536-L540
[ "def", "_is_reference", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "isinstance", "(", "next", "(", "six", ".", "itervalues", "(", "arg", ")", ")", ",", "six", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_is_junction
Return True, if arg is a junction statement.
salt/modules/syslog_ng.py
def _is_junction(arg): ''' Return True, if arg is a junction statement. ''' return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) == 'junction'
def _is_junction(arg): ''' Return True, if arg is a junction statement. ''' return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) == 'junction'
[ "Return", "True", "if", "arg", "is", "a", "junction", "statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L543-L547
[ "def", "_is_junction", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "next", "(", "six", ".", "iterkeys", "(", "arg", ")", ")", "==", "'junction'" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add_reference
Adds a reference to statement.
salt/modules/syslog_ng.py
def _add_reference(reference, statement): ''' Adds a reference to statement. ''' type_, value = _expand_one_key_dictionary(reference) opt = Option(type_) param = SimpleParameter(value) opt.add_parameter(param) statement.add_child(opt)
def _add_reference(reference, statement): ''' Adds a reference to statement. ''' type_, value = _expand_one_key_dictionary(reference) opt = Option(type_) param = SimpleParameter(value) opt.add_parameter(param) statement.add_child(opt)
[ "Adds", "a", "reference", "to", "statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L550-L558
[ "def", "_add_reference", "(", "reference", ",", "statement", ")", ":", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "reference", ")", "opt", "=", "Option", "(", "type_", ")", "param", "=", "SimpleParameter", "(", "value", ")", "opt", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_is_inline_definition
Returns True, if arg is an inline definition of a statement.
salt/modules/syslog_ng.py
def _is_inline_definition(arg): ''' Returns True, if arg is an inline definition of a statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), list)
def _is_inline_definition(arg): ''' Returns True, if arg is an inline definition of a statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), list)
[ "Returns", "True", "if", "arg", "is", "an", "inline", "definition", "of", "a", "statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L561-L565
[ "def", "_is_inline_definition", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "isinstance", "(", "next", "(", "six", ".", "itervalues", "(", "arg", ")", ")", ",", "list", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add_inline_definition
Adds an inline definition to statement.
salt/modules/syslog_ng.py
def _add_inline_definition(item, statement): ''' Adds an inline definition to statement. ''' global _current_statement backup = _current_statement type_, options = _expand_one_key_dictionary(item) _current_statement = UnnamedStatement(type=type_) _parse_statement(options) statement....
def _add_inline_definition(item, statement): ''' Adds an inline definition to statement. ''' global _current_statement backup = _current_statement type_, options = _expand_one_key_dictionary(item) _current_statement = UnnamedStatement(type=type_) _parse_statement(options) statement....
[ "Adds", "an", "inline", "definition", "to", "statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L568-L580
[ "def", "_add_inline_definition", "(", "item", ",", "statement", ")", ":", "global", "_current_statement", "backup", "=", "_current_statement", "type_", ",", "options", "=", "_expand_one_key_dictionary", "(", "item", ")", "_current_statement", "=", "UnnamedStatement", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add_junction
Adds a junction to the _current_statement.
salt/modules/syslog_ng.py
def _add_junction(item): ''' Adds a junction to the _current_statement. ''' type_, channels = _expand_one_key_dictionary(item) junction = UnnamedStatement(type='junction') for item in channels: type_, value = _expand_one_key_dictionary(item) channel = UnnamedStatement(type='chann...
def _add_junction(item): ''' Adds a junction to the _current_statement. ''' type_, channels = _expand_one_key_dictionary(item) junction = UnnamedStatement(type='junction') for item in channels: type_, value = _expand_one_key_dictionary(item) channel = UnnamedStatement(type='chann...
[ "Adds", "a", "junction", "to", "the", "_current_statement", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L583-L598
[ "def", "_add_junction", "(", "item", ")", ":", "type_", ",", "channels", "=", "_expand_one_key_dictionary", "(", "item", ")", "junction", "=", "UnnamedStatement", "(", "type", "=", "'junction'", ")", "for", "item", "in", "channels", ":", "type_", ",", "value...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_log_statement
Parses a log path.
salt/modules/syslog_ng.py
def _parse_log_statement(options): ''' Parses a log path. ''' for i in options: if _is_reference(i): _add_reference(i, _current_statement) elif _is_junction(i): _add_junction(i) elif _is_inline_definition(i): _add_inline_definition(i, _current_...
def _parse_log_statement(options): ''' Parses a log path. ''' for i in options: if _is_reference(i): _add_reference(i, _current_statement) elif _is_junction(i): _add_junction(i) elif _is_inline_definition(i): _add_inline_definition(i, _current_...
[ "Parses", "a", "log", "path", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L601-L611
[ "def", "_parse_log_statement", "(", "options", ")", ":", "for", "i", "in", "options", ":", "if", "_is_reference", "(", "i", ")", ":", "_add_reference", "(", "i", ",", "_current_statement", ")", "elif", "_is_junction", "(", "i", ")", ":", "_add_junction", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_build_config_tree
Build the configuration tree. The root object is _current_statement.
salt/modules/syslog_ng.py
def _build_config_tree(name, configuration): ''' Build the configuration tree. The root object is _current_statement. ''' type_, id_, options = _get_type_id_options(name, configuration) global _INDENT, _current_statement _INDENT = '' if type_ == 'config': _current_statement = Gi...
def _build_config_tree(name, configuration): ''' Build the configuration tree. The root object is _current_statement. ''' type_, id_, options = _get_type_id_options(name, configuration) global _INDENT, _current_statement _INDENT = '' if type_ == 'config': _current_statement = Gi...
[ "Build", "the", "configuration", "tree", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L614-L633
[ "def", "_build_config_tree", "(", "name", ",", "configuration", ")", ":", "type_", ",", "id_", ",", "options", "=", "_get_type_id_options", "(", "name", ",", "configuration", ")", "global", "_INDENT", ",", "_current_statement", "_INDENT", "=", "''", "if", "typ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
config
Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code write : if True, it writes the config into the configuration file, ...
salt/modules/syslog_ng.py
def config(name, config, write=True): ''' Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code ...
def config(name, config, write=True): ''' Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code ...
[ "Builds", "syslog", "-", "ng", "configuration", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "users", "should", "not", "use", "it", "directly!" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L645-L680
[ "def", "config", "(", "name", ",", "config", ",", "write", "=", "True", ")", ":", "_build_config_tree", "(", "name", ",", "config", ")", "configs", "=", "_render_configuration", "(", ")", "if", "__opts__", ".", "get", "(", "'test'", ",", "False", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_binary_path
Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_binary_path name=/usr/sbin
salt/modules/syslog_ng.py
def set_binary_path(name): ''' Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.se...
def set_binary_path(name): ''' Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.se...
[ "Sets", "the", "path", "where", "the", "syslog", "-", "ng", "binary", "can", "be", "found", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L683-L702
[ "def", "set_binary_path", "(", "name", ")", ":", "global", "__SYSLOG_NG_BINARY_PATH", "old", "=", "__SYSLOG_NG_BINARY_PATH", "__SYSLOG_NG_BINARY_PATH", "=", "name", "changes", "=", "_format_changes", "(", "old", ",", "name", ")", "return", "_format_state_result", "(",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_config_file
Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng
salt/modules/syslog_ng.py
def set_config_file(name): ''' Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng ''' global __SYSLOG_NG_CONFIG_FILE old = __SYSLOG_NG_CONFIG_FILE __SYSL...
def set_config_file(name): ''' Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng ''' global __SYSLOG_NG_CONFIG_FILE old = __SYSLOG_NG_CONFIG_FILE __SYSL...
[ "Sets", "the", "configuration", "s", "name", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L705-L721
[ "def", "set_config_file", "(", "name", ")", ":", "global", "__SYSLOG_NG_CONFIG_FILE", "old", "=", "__SYSLOG_NG_CONFIG_FILE", "__SYSLOG_NG_CONFIG_FILE", "=", "name", "changes", "=", "_format_changes", "(", "old", ",", "name", ")", "return", "_format_state_result", "(",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_run_command
Runs the command cmd with options as its CLI parameters and returns the result as a dictionary.
salt/modules/syslog_ng.py
def _run_command(cmd, options=(), env=None): ''' Runs the command cmd with options as its CLI parameters and returns the result as a dictionary. ''' params = [cmd] params.extend(options) return __salt__['cmd.run_all'](params, env=env, python_shell=False)
def _run_command(cmd, options=(), env=None): ''' Runs the command cmd with options as its CLI parameters and returns the result as a dictionary. ''' params = [cmd] params.extend(options) return __salt__['cmd.run_all'](params, env=env, python_shell=False)
[ "Runs", "the", "command", "cmd", "with", "options", "as", "its", "CLI", "parameters", "and", "returns", "the", "result", "as", "a", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L738-L745
[ "def", "_run_command", "(", "cmd", ",", "options", "=", "(", ")", ",", "env", "=", "None", ")", ":", "params", "=", "[", "cmd", "]", "params", ".", "extend", "(", "options", ")", "return", "__salt__", "[", "'cmd.run_all'", "]", "(", "params", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_parameters
Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.set_parameters binary_path=/home/user/install/syslog-ng/sbin config_file=/home/user/install/syslog-ng/etc/syslog-ng.conf
salt/modules/syslog_ng.py
def set_parameters(version=None, binary_path=None, config_file=None, *args, **kwargs): ''' Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.s...
def set_parameters(version=None, binary_path=None, config_file=None, *args, **kwargs): ''' Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.s...
[ "Sets", "variables", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L761-L785
[ "def", "set_parameters", "(", "version", "=", "None", ",", "binary_path", "=", "None", ",", "config_file", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "binary_path", ":", "set_binary_path", "(", "binary_path", ")", "if", "conf...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_run_command_in_extended_path
Runs the specified command with the syslog_ng_sbin_dir in the PATH
salt/modules/syslog_ng.py
def _run_command_in_extended_path(syslog_ng_sbin_dir, command, params): ''' Runs the specified command with the syslog_ng_sbin_dir in the PATH ''' orig_path = os.environ.get('PATH', '') env = None if syslog_ng_sbin_dir: # Custom environment variables should be str types. This code ...
def _run_command_in_extended_path(syslog_ng_sbin_dir, command, params): ''' Runs the specified command with the syslog_ng_sbin_dir in the PATH ''' orig_path = os.environ.get('PATH', '') env = None if syslog_ng_sbin_dir: # Custom environment variables should be str types. This code ...
[ "Runs", "the", "specified", "command", "with", "the", "syslog_ng_sbin_dir", "in", "the", "PATH" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L788-L807
[ "def", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "command", ",", "params", ")", ":", "orig_path", "=", "os", ".", "environ", ".", "get", "(", "'PATH'", ",", "''", ")", "env", "=", "None", "if", "syslog_ng_sbin_dir", ":", "# Custom enviro...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_format_return_data
Creates a dictionary from the parameters, which can be used to return data to Salt.
salt/modules/syslog_ng.py
def _format_return_data(retcode, stdout=None, stderr=None): ''' Creates a dictionary from the parameters, which can be used to return data to Salt. ''' ret = {'retcode': retcode} if stdout is not None: ret['stdout'] = stdout if stderr is not None: ret['stderr'] = stderr r...
def _format_return_data(retcode, stdout=None, stderr=None): ''' Creates a dictionary from the parameters, which can be used to return data to Salt. ''' ret = {'retcode': retcode} if stdout is not None: ret['stdout'] = stdout if stderr is not None: ret['stderr'] = stderr r...
[ "Creates", "a", "dictionary", "from", "the", "parameters", "which", "can", "be", "used", "to", "return", "data", "to", "Salt", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L810-L820
[ "def", "_format_return_data", "(", "retcode", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "ret", "=", "{", "'retcode'", ":", "retcode", "}", "if", "stdout", "is", "not", "None", ":", "ret", "[", "'stdout'", "]", "=", "stdout", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
version
Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng.version /home/user/install/syslog-ng/sbin
salt/modules/syslog_ng.py
def version(syslog_ng_sbin_dir=None): ''' Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng....
def version(syslog_ng_sbin_dir=None): ''' Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng....
[ "Returns", "the", "version", "of", "the", "installed", "syslog", "-", "ng", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L853-L884
[ "def", "version", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng'", ",", "(", "'-V'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":", "r...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
modules
Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/install/syslog-ng/sbin
salt/modules/syslog_ng.py
def modules(syslog_ng_sbin_dir=None): ''' Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/in...
def modules(syslog_ng_sbin_dir=None): ''' Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/in...
[ "Returns", "the", "available", "modules", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L887-L917
[ "def", "modules", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng'", ",", "(", "'-V'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":", "r...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
stats
Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' syslog_ng.stats /home/user/install/syslog-ng/sbin
salt/modules/syslog_ng.py
def stats(syslog_ng_sbin_dir=None): ''' Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' sy...
def stats(syslog_ng_sbin_dir=None): ''' Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' sy...
[ "Returns", "statistics", "from", "the", "running", "syslog", "-", "ng", "instance", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "-", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L920-L942
[ "def", "stats", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng-ctl'", ",", "(", "'stats'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_format_state_result
Creates the state result dictionary.
salt/modules/syslog_ng.py
def _format_state_result(name, result, changes=None, comment=''): ''' Creates the state result dictionary. ''' if changes is None: changes = {'old': '', 'new': ''} return {'name': name, 'result': result, 'changes': changes, 'comment': comment}
def _format_state_result(name, result, changes=None, comment=''): ''' Creates the state result dictionary. ''' if changes is None: changes = {'old': '', 'new': ''} return {'name': name, 'result': result, 'changes': changes, 'comment': comment}
[ "Creates", "the", "state", "result", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L949-L956
[ "def", "_format_state_result", "(", "name", ",", "result", ",", "changes", "=", "None", ",", "comment", "=", "''", ")", ":", "if", "changes", "is", "None", ":", "changes", "=", "{", "'old'", ":", "''", ",", "'new'", ":", "''", "}", "return", "{", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add_cli_param
Adds key and value as a command line parameter to params.
salt/modules/syslog_ng.py
def _add_cli_param(params, key, value): ''' Adds key and value as a command line parameter to params. ''' if value is not None: params.append('--{0}={1}'.format(key, value))
def _add_cli_param(params, key, value): ''' Adds key and value as a command line parameter to params. ''' if value is not None: params.append('--{0}={1}'.format(key, value))
[ "Adds", "key", "and", "value", "as", "a", "command", "line", "parameter", "to", "params", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L959-L964
[ "def", "_add_cli_param", "(", "params", ",", "key", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "params", ".", "append", "(", "'--{0}={1}'", ".", "format", "(", "key", ",", "value", ")", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add_boolean_cli_param
Adds key as a command line parameter to params.
salt/modules/syslog_ng.py
def _add_boolean_cli_param(params, key, value): ''' Adds key as a command line parameter to params. ''' if value is True: params.append('--{0}'.format(key))
def _add_boolean_cli_param(params, key, value): ''' Adds key as a command line parameter to params. ''' if value is True: params.append('--{0}'.format(key))
[ "Adds", "key", "as", "a", "command", "line", "parameter", "to", "params", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L967-L972
[ "def", "_add_boolean_cli_param", "(", "params", ",", "key", ",", "value", ")", ":", "if", "value", "is", "True", ":", "params", ".", "append", "(", "'--{0}'", ".", "format", "(", "key", ")", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
stop
Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function will use the set binary path....
salt/modules/syslog_ng.py
def stop(name=None): ''' Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function ...
def stop(name=None): ''' Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function ...
[ "Kills", "syslog", "-", "ng", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L975-L1009
[ "def", "stop", "(", "name", "=", "None", ")", ":", "pids", "=", "__salt__", "[", "'ps.pgrep'", "]", "(", "pattern", "=", "'syslog-ng'", ")", "if", "not", "pids", ":", "return", "_format_state_result", "(", "name", ",", "result", "=", "False", ",", "com...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
start
Ensures, that syslog-ng is started via the given parameters. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before,...
salt/modules/syslog_ng.py
def start(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfile=None, enable_core=False, fd_limit=None, verbose=False, debug=False, trace=False, yydebug=False, per...
def start(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfile=None, enable_core=False, fd_limit=None, verbose=False, debug=False, trace=False, yydebug=False, per...
[ "Ensures", "that", "syslog", "-", "ng", "is", "started", "via", "the", "given", "parameters", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1012-L1086
[ "def", "start", "(", "name", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "chroot", "=", "None", ",", "caps", "=", "None", ",", "no_caps", "=", "False", ",", "pidfile", "=", "None", ",", "enable_core", "=", "False", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
reload_
Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslog_ng.reload
salt/modules/syslog_ng.py
def reload_(name): ''' Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslo...
def reload_(name): ''' Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslo...
[ "Reloads", "syslog", "-", "ng", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1089-L1114
[ "def", "reload_", "(", "name", ")", ":", "if", "__SYSLOG_NG_BINARY_PATH", ":", "syslog_ng_ctl_binary", "=", "os", ".", "path", ".", "join", "(", "__SYSLOG_NG_BINARY_PATH", ",", "'syslog-ng-ctl'", ")", "command", "=", "[", "syslog_ng_ctl_binary", ",", "'reload'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
write_config
Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CLI Example: .. code-block:: bash salt...
salt/modules/syslog_ng.py
def write_config(config, newlines=2): ''' Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CL...
def write_config(config, newlines=2): ''' Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CL...
[ "Writes", "the", "given", "parameter", "config", "into", "the", "config", "file", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1125-L1143
[ "def", "write_config", "(", "config", ",", "newlines", "=", "2", ")", ":", "succ", "=", "_write_config", "(", "config", ",", "newlines", ")", "changes", "=", "_format_changes", "(", "new", "=", "config", ")", "return", "_format_state_result", "(", "name", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_write_config
Writes the given parameter config into the config file.
salt/modules/syslog_ng.py
def _write_config(config, newlines=2): ''' Writes the given parameter config into the config file. ''' text = config if isinstance(config, dict) and len(list(list(config.keys()))) == 1: key = next(six.iterkeys(config)) text = config[key] try: with salt.utils.files.fopen(...
def _write_config(config, newlines=2): ''' Writes the given parameter config into the config file. ''' text = config if isinstance(config, dict) and len(list(list(config.keys()))) == 1: key = next(six.iterkeys(config)) text = config[key] try: with salt.utils.files.fopen(...
[ "Writes", "the", "given", "parameter", "config", "into", "the", "config", "file", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1146-L1164
[ "def", "_write_config", "(", "config", ",", "newlines", "=", "2", ")", ":", "text", "=", "config", "if", "isinstance", "(", "config", ",", "dict", ")", "and", "len", "(", "list", "(", "list", "(", "config", ".", "keys", "(", ")", ")", ")", ")", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
write_version
Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CLI Example: ...
salt/modules/syslog_ng.py
def write_version(name): ''' Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set...
def write_version(name): ''' Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set...
[ "Removes", "the", "previous", "configuration", "file", "then", "creates", "a", "new", "one", "and", "writes", "the", "name", "line", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1167-L1203
[ "def", "write_version", "(", "name", ")", ":", "line", "=", "'@version: {0}'", ".", "format", "(", "name", ")", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "__SYSLOG_NG_CONFIG_FILE", ")", ":", "log", ".", "debug", "(", "'Removing previous conf...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Buildable.build_body
Builds the body of a syslog-ng configuration object.
salt/modules/syslog_ng.py
def build_body(self): ''' Builds the body of a syslog-ng configuration object. ''' _increase_indent() body_array = [x.build() for x in self.iterable] nl = '\n' if self.append_extra_newline else '' if len(self.iterable) >= 1: body = self.join_body_on....
def build_body(self): ''' Builds the body of a syslog-ng configuration object. ''' _increase_indent() body_array = [x.build() for x in self.iterable] nl = '\n' if self.append_extra_newline else '' if len(self.iterable) >= 1: body = self.join_body_on....
[ "Builds", "the", "body", "of", "a", "syslog", "-", "ng", "configuration", "object", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L130-L145
[ "def", "build_body", "(", "self", ")", ":", "_increase_indent", "(", ")", "body_array", "=", "[", "x", ".", "build", "(", ")", "for", "x", "in", "self", ".", "iterable", "]", "nl", "=", "'\\n'", "if", "self", ".", "append_extra_newline", "else", "''", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Buildable.build
Builds the textual representation of the whole configuration object with it's children.
salt/modules/syslog_ng.py
def build(self): ''' Builds the textual representation of the whole configuration object with it's children. ''' header = self.build_header() body = self.build_body() tail = self.build_tail() return header + body + tail
def build(self): ''' Builds the textual representation of the whole configuration object with it's children. ''' header = self.build_header() body = self.build_body() tail = self.build_tail() return header + body + tail
[ "Builds", "the", "textual", "representation", "of", "the", "whole", "configuration", "object", "with", "it", "s", "children", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L147-L155
[ "def", "build", "(", "self", ")", ":", "header", "=", "self", ".", "build_header", "(", ")", "body", "=", "self", ".", "build_body", "(", ")", "tail", "=", "self", ".", "build_tail", "(", ")", "return", "header", "+", "body", "+", "tail" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_dbus_locale
Get the 'System Locale' parameters from dbus
salt/modules/localemod.py
def _parse_dbus_locale(): ''' Get the 'System Locale' parameters from dbus ''' bus = dbus.SystemBus() localed = bus.get_object('org.freedesktop.locale1', '/org/freedesktop/locale1') properties = dbus.Interface(localed, 'org.freedesktop.DBus.Properties') system_lo...
def _parse_dbus_locale(): ''' Get the 'System Locale' parameters from dbus ''' bus = dbus.SystemBus() localed = bus.get_object('org.freedesktop.locale1', '/org/freedesktop/locale1') properties = dbus.Interface(localed, 'org.freedesktop.DBus.Properties') system_lo...
[ "Get", "the", "System", "Locale", "parameters", "from", "dbus" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L41-L62
[ "def", "_parse_dbus_locale", "(", ")", ":", "bus", "=", "dbus", ".", "SystemBus", "(", ")", "localed", "=", "bus", ".", "get_object", "(", "'org.freedesktop.locale1'", ",", "'/org/freedesktop/locale1'", ")", "properties", "=", "dbus", ".", "Interface", "(", "l...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_localectl_status
Parse localectl status into a dict. :return: dict
salt/modules/localemod.py
def _localectl_status(): ''' Parse localectl status into a dict. :return: dict ''' if salt.utils.path.which('localectl') is None: raise CommandExecutionError('Unable to find "localectl"') ret = {} locale_ctl_out = (__salt__['cmd.run']('localectl status') or '').strip() ctl_key =...
def _localectl_status(): ''' Parse localectl status into a dict. :return: dict ''' if salt.utils.path.which('localectl') is None: raise CommandExecutionError('Unable to find "localectl"') ret = {} locale_ctl_out = (__salt__['cmd.run']('localectl status') or '').strip() ctl_key =...
[ "Parse", "localectl", "status", "into", "a", "dict", ".", ":", "return", ":", "dict" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L65-L97
[ "def", "_localectl_status", "(", ")", ":", "if", "salt", ".", "utils", ".", "path", ".", "which", "(", "'localectl'", ")", "is", "None", ":", "raise", "CommandExecutionError", "(", "'Unable to find \"localectl\"'", ")", "ret", "=", "{", "}", "locale_ctl_out", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_localectl_set
Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set.
salt/modules/localemod.py
def _localectl_set(locale=''): ''' Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set. ''' locale_params = _parse_dbus_locale() if dbus is not None else _localectl_status().get('system_locale', {}) locale_params['LANG']...
def _localectl_set(locale=''): ''' Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set. ''' locale_params = _parse_dbus_locale() if dbus is not None else _localectl_status().get('system_locale', {}) locale_params['LANG']...
[ "Use", "systemd", "s", "localectl", "command", "to", "set", "the", "LANG", "locale", "parameter", "making", "sure", "not", "to", "trample", "on", "other", "params", "that", "have", "been", "set", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L100-L108
[ "def", "_localectl_set", "(", "locale", "=", "''", ")", ":", "locale_params", "=", "_parse_dbus_locale", "(", ")", "if", "dbus", "is", "not", "None", "else", "_localectl_status", "(", ")", ".", "get", "(", "'system_locale'", ",", "{", "}", ")", "locale_par...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_locale
Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale
salt/modules/localemod.py
def get_locale(): ''' Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale ''' ret = '' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is still broken in latest SP3 due to # config...
def get_locale(): ''' Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale ''' ret = '' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is still broken in latest SP3 due to # config...
[ "Get", "the", "current", "system", "locale" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L124-L163
[ "def", "get_locale", "(", ")", ":", "ret", "=", "''", "lc_ctl", "=", "salt", ".", "utils", ".", "systemd", ".", "booted", "(", "__context__", ")", "# localectl on SLE12 is installed but the integration is still broken in latest SP3 due to", "# config is rewritten by by many...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_locale
Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8'
salt/modules/localemod.py
def set_locale(locale): ''' Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8' ''' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2...
def set_locale(locale): ''' Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8' ''' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2...
[ "Sets", "the", "current", "system", "locale" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L166-L228
[ "def", "set_locale", "(", "locale", ")", ":", "lc_ctl", "=", "salt", ".", "utils", ".", "systemd", ".", "booted", "(", "__context__", ")", "# localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2", "if", "lc_ctl", "and", "not", "(...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
avail
Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8'
salt/modules/localemod.py
def avail(locale): ''' Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8' ''' try: normalized_locale = salt.utils.locales.normalize_locale(locale) except IndexError: log.error('Unabl...
def avail(locale): ''' Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8' ''' try: normalized_locale = salt.utils.locales.normalize_locale(locale) except IndexError: log.error('Unabl...
[ "Check", "if", "a", "locale", "is", "available", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L231-L251
[ "def", "avail", "(", "locale", ")", ":", "try", ":", "normalized_locale", "=", "salt", ".", "utils", ".", "locales", ".", "normalize_locale", "(", "locale", ")", "except", "IndexError", ":", "log", ".", "error", "(", "'Unable to validate locale \"%s\"'", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
gen_locale
Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the locale when generating it. verbose ...
salt/modules/localemod.py
def gen_locale(locale, **kwargs): ''' Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the loca...
def gen_locale(locale, **kwargs): ''' Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the loca...
[ "Generate", "a", "locale", ".", "Options", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L254-L357
[ "def", "gen_locale", "(", "locale", ",", "*", "*", "kwargs", ")", ":", "on_debian", "=", "__grains__", ".", "get", "(", "'os'", ")", "==", "'Debian'", "on_ubuntu", "=", "__grains__", ".", "get", "(", "'os'", ")", "==", "'Ubuntu'", "on_gentoo", "=", "__...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_template
Parsing template
salt/states/heat.py
def _parse_template(tmpl_str): ''' Parsing template ''' tmpl_str = tmpl_str.strip() if tmpl_str.startswith('{'): tpl = salt.utils.json.loads(tmpl_str) else: try: tpl = salt.utils.yaml.safe_load(tmpl_str) except salt.utils.yaml.YAMLError as exc: rai...
def _parse_template(tmpl_str): ''' Parsing template ''' tmpl_str = tmpl_str.strip() if tmpl_str.startswith('{'): tpl = salt.utils.json.loads(tmpl_str) else: try: tpl = salt.utils.yaml.safe_load(tmpl_str) except salt.utils.yaml.YAMLError as exc: rai...
[ "Parsing", "template" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L80-L99
[ "def", "_parse_template", "(", "tmpl_str", ")", ":", "tmpl_str", "=", "tmpl_str", ".", "strip", "(", ")", "if", "tmpl_str", ".", "startswith", "(", "'{'", ")", ":", "tpl", "=", "salt", ".", "utils", ".", "json", ".", "loads", "(", "tmpl_str", ")", "e...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
deployed
Deploy stack with the specified properties name The name of the stack template File of template environment File of environment params Parameter dict used to create the stack poll Poll (in sec.) and report events until stack complete rollback ...
salt/states/heat.py
def deployed(name, template=None, environment=None, params=None, poll=5, rollback=False, timeout=60, update=False, profile=None, **connection_args): ''' Deploy stack with the specified properties name The name of the stack template File of template enviro...
def deployed(name, template=None, environment=None, params=None, poll=5, rollback=False, timeout=60, update=False, profile=None, **connection_args): ''' Deploy stack with the specified properties name The name of the stack template File of template enviro...
[ "Deploy", "stack", "with", "the", "specified", "properties" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L102-L281
[ "def", "deployed", "(", "name", ",", "template", "=", "None", ",", "environment", "=", "None", ",", "params", "=", "None", ",", "poll", "=", "5", ",", "rollback", "=", "False", ",", "timeout", "=", "60", ",", "update", "=", "False", ",", "profile", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
absent
Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use
salt/states/heat.py
def absent(name, poll=5, timeout=60, profile=None): ''' Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use '...
def absent(name, poll=5, timeout=60, profile=None): ''' Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use '...
[ "Ensure", "that", "the", "named", "stack", "is", "absent" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L284-L331
[ "def", "absent", "(", "name", ",", "poll", "=", "5", ",", "timeout", "=", "60", ",", "profile", "=", "None", ")", ":", "log", ".", "debug", "(", "'Absent with (%s, %s %s)'", ",", "name", ",", "poll", ",", "profile", ")", "ret", "=", "{", "'name'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_username
Grain for the minion username
salt/grains/minion_process.py
def _username(): ''' Grain for the minion username ''' if pwd: username = pwd.getpwuid(os.getuid()).pw_name else: username = getpass.getuser() return username
def _username(): ''' Grain for the minion username ''' if pwd: username = pwd.getpwuid(os.getuid()).pw_name else: username = getpass.getuser() return username
[ "Grain", "for", "the", "minion", "username" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L34-L43
[ "def", "_username", "(", ")", ":", "if", "pwd", ":", "username", "=", "pwd", ".", "getpwuid", "(", "os", ".", "getuid", "(", ")", ")", ".", "pw_name", "else", ":", "username", "=", "getpass", ".", "getuser", "(", ")", "return", "username" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_groupname
Grain for the minion groupname
salt/grains/minion_process.py
def _groupname(): ''' Grain for the minion groupname ''' if grp: try: groupname = grp.getgrgid(os.getgid()).gr_name except KeyError: groupname = '' else: groupname = '' return groupname
def _groupname(): ''' Grain for the minion groupname ''' if grp: try: groupname = grp.getgrgid(os.getgid()).gr_name except KeyError: groupname = '' else: groupname = '' return groupname
[ "Grain", "for", "the", "minion", "groupname" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L55-L67
[ "def", "_groupname", "(", ")", ":", "if", "grp", ":", "try", ":", "groupname", "=", "grp", ".", "getgrgid", "(", "os", ".", "getgid", "(", ")", ")", ".", "gr_name", "except", "KeyError", ":", "groupname", "=", "''", "else", ":", "groupname", "=", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
unpackage
Unpackages a payload
salt/payload.py
def unpackage(package_): ''' Unpackages a payload ''' return salt.utils.msgpack.loads(package_, use_list=True, _msgpack_module=msgpack)
def unpackage(package_): ''' Unpackages a payload ''' return salt.utils.msgpack.loads(package_, use_list=True, _msgpack_module=msgpack)
[ "Unpackages", "a", "payload" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L89-L94
[ "def", "unpackage", "(", "package_", ")", ":", "return", "salt", ".", "utils", ".", "msgpack", ".", "loads", "(", "package_", ",", "use_list", "=", "True", ",", "_msgpack_module", "=", "msgpack", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
format_payload
Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict.
salt/payload.py
def format_payload(enc, **kwargs): ''' Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict. ''' payload = {'enc': enc} load = {} for key in kwargs: load[key] = kwargs[key] payload['load'] = load...
def format_payload(enc, **kwargs): ''' Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict. ''' payload = {'enc': enc} load = {} for key in kwargs: load[key] = kwargs[key] payload['load'] = load...
[ "Pass", "in", "the", "required", "arguments", "for", "a", "payload", "the", "enc", "type", "and", "the", "cmd", "then", "a", "list", "of", "keyword", "args", "to", "generate", "the", "body", "of", "the", "load", "dict", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L97-L107
[ "def", "format_payload", "(", "enc", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'enc'", ":", "enc", "}", "load", "=", "{", "}", "for", "key", "in", "kwargs", ":", "load", "[", "key", "]", "=", "kwargs", "[", "key", "]", "payload", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Serial.loads
Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' type and the 'str' type by decoding contents...
salt/payload.py
def loads(self, msg, encoding=None, raw=False): ''' Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' t...
def loads(self, msg, encoding=None, raw=False): ''' Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' t...
[ "Run", "the", "correct", "loads", "serialization", "format" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L123-L179
[ "def", "loads", "(", "self", ",", "msg", ",", "encoding", "=", "None", ",", "raw", "=", "False", ")", ":", "try", ":", "def", "ext_type_decoder", "(", "code", ",", "data", ")", ":", "if", "code", "==", "78", ":", "data", "=", "salt", ".", "utils"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Serial.load
Run the correct serialization to load a file
salt/payload.py
def load(self, fn_): ''' Run the correct serialization to load a file ''' data = fn_.read() fn_.close() if data: if six.PY3: return self.loads(data, encoding='utf-8') else: return self.loads(data)
def load(self, fn_): ''' Run the correct serialization to load a file ''' data = fn_.read() fn_.close() if data: if six.PY3: return self.loads(data, encoding='utf-8') else: return self.loads(data)
[ "Run", "the", "correct", "serialization", "to", "load", "a", "file" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L181-L191
[ "def", "load", "(", "self", ",", "fn_", ")", ":", "data", "=", "fn_", ".", "read", "(", ")", "fn_", ".", "close", "(", ")", "if", "data", ":", "if", "six", ".", "PY3", ":", "return", "self", ".", "loads", "(", "data", ",", "encoding", "=", "'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Serial.dumps
Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. Since this changes the wire protocol, ...
salt/payload.py
def dumps(self, msg, use_bin_type=False): ''' Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. ...
def dumps(self, msg, use_bin_type=False): ''' Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. ...
[ "Run", "the", "correct", "dumps", "serialization", "format" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L193-L272
[ "def", "dumps", "(", "self", ",", "msg", ",", "use_bin_type", "=", "False", ")", ":", "def", "ext_type_encoder", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "six", ".", "integer_types", ")", ":", "# msgpack can't handle the very long Python long...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
Serial.dump
Serialize the correct data into the named file object
salt/payload.py
def dump(self, msg, fn_): ''' Serialize the correct data into the named file object ''' if six.PY2: fn_.write(self.dumps(msg)) else: # When using Python 3, write files in such a way # that the 'bytes' and 'str' types are distinguishable ...
def dump(self, msg, fn_): ''' Serialize the correct data into the named file object ''' if six.PY2: fn_.write(self.dumps(msg)) else: # When using Python 3, write files in such a way # that the 'bytes' and 'str' types are distinguishable ...
[ "Serialize", "the", "correct", "data", "into", "the", "named", "file", "object" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L274-L285
[ "def", "dump", "(", "self", ",", "msg", ",", "fn_", ")", ":", "if", "six", ".", "PY2", ":", "fn_", ".", "write", "(", "self", ".", "dumps", "(", "msg", ")", ")", "else", ":", "# When using Python 3, write files in such a way", "# that the 'bytes' and 'str' t...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
SREQ.socket
Lazily create the socket.
salt/payload.py
def socket(self): ''' Lazily create the socket. ''' if not hasattr(self, '_socket'): # create a new one self._socket = self.context.socket(zmq.REQ) if hasattr(zmq, 'RECONNECT_IVL_MAX'): self._socket.setsockopt( zmq.R...
def socket(self): ''' Lazily create the socket. ''' if not hasattr(self, '_socket'): # create a new one self._socket = self.context.socket(zmq.REQ) if hasattr(zmq, 'RECONNECT_IVL_MAX'): self._socket.setsockopt( zmq.R...
[ "Lazily", "create", "the", "socket", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L302-L325
[ "def", "socket", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_socket'", ")", ":", "# create a new one", "self", ".", "_socket", "=", "self", ".", "context", ".", "socket", "(", "zmq", ".", "REQ", ")", "if", "hasattr", "(", "zmq...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
SREQ.clear_socket
delete socket if you have it
salt/payload.py
def clear_socket(self): ''' delete socket if you have it ''' if hasattr(self, '_socket'): if isinstance(self.poller.sockets, dict): sockets = list(self.poller.sockets.keys()) for socket in sockets: log.trace('Unregistering s...
def clear_socket(self): ''' delete socket if you have it ''' if hasattr(self, '_socket'): if isinstance(self.poller.sockets, dict): sockets = list(self.poller.sockets.keys()) for socket in sockets: log.trace('Unregistering s...
[ "delete", "socket", "if", "you", "have", "it" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L346-L360
[ "def", "clear_socket", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_socket'", ")", ":", "if", "isinstance", "(", "self", ".", "poller", ".", "sockets", ",", "dict", ")", ":", "sockets", "=", "list", "(", "self", ".", "poller", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
SREQ.send
Takes two arguments, the encryption type and the base payload
salt/payload.py
def send(self, enc, load, tries=1, timeout=60): ''' Takes two arguments, the encryption type and the base payload ''' payload = {'enc': enc} payload['load'] = load pkg = self.serial.dumps(payload) self.socket.send(pkg) self.poller.register(self.socket, zmq...
def send(self, enc, load, tries=1, timeout=60): ''' Takes two arguments, the encryption type and the base payload ''' payload = {'enc': enc} payload['load'] = load pkg = self.serial.dumps(payload) self.socket.send(pkg) self.poller.register(self.socket, zmq...
[ "Takes", "two", "arguments", "the", "encryption", "type", "and", "the", "base", "payload" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L362-L388
[ "def", "send", "(", "self", ",", "enc", ",", "load", ",", "tries", "=", "1", ",", "timeout", "=", "60", ")", ":", "payload", "=", "{", "'enc'", ":", "enc", "}", "payload", "[", "'load'", "]", "=", "load", "pkg", "=", "self", ".", "serial", ".",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
SREQ.send_auto
Detect the encryption type based on the payload
salt/payload.py
def send_auto(self, payload, tries=1, timeout=60): ''' Detect the encryption type based on the payload ''' enc = payload.get('enc', 'clear') load = payload.get('load', {}) return self.send(enc, load, tries, timeout)
def send_auto(self, payload, tries=1, timeout=60): ''' Detect the encryption type based on the payload ''' enc = payload.get('enc', 'clear') load = payload.get('load', {}) return self.send(enc, load, tries, timeout)
[ "Detect", "the", "encryption", "type", "based", "on", "the", "payload" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L390-L396
[ "def", "send_auto", "(", "self", ",", "payload", ",", "tries", "=", "1", ",", "timeout", "=", "60", ")", ":", "enc", "=", "payload", ".", "get", "(", "'enc'", ",", "'clear'", ")", "load", "=", "payload", ".", "get", "(", "'load'", ",", "{", "}", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
present
Creates or updates LXD profiles name : The name of the profile to create/update description : A description string config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privile...
salt/states/lxd_profile.py
def present(name, description=None, config=None, devices=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Creates or updates LXD profiles name : The name of the profile to create/update description : A description string config : A config dic...
def present(name, description=None, config=None, devices=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Creates or updates LXD profiles name : The name of the profile to create/update description : A description string config : A config dic...
[ "Creates", "or", "updates", "LXD", "profiles" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxd_profile.py#L51-L192
[ "def", "present", "(", "name", ",", "description", "=", "None", ",", "config", "=", "None", ",", "devices", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
absent
Ensure a LXD profile is not present, removing it if present. name : The name of the profile to remove. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr! Examples: https://myserver.lan:8443 /var/lib/m...
salt/states/lxd_profile.py
def absent(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Ensure a LXD profile is not present, removing it if present. name : The name of the profile to remove. remote_addr : An URL to a remote Server, you also have to give cert and key if you pr...
def absent(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Ensure a LXD profile is not present, removing it if present. name : The name of the profile to remove. remote_addr : An URL to a remote Server, you also have to give cert and key if you pr...
[ "Ensure", "a", "LXD", "profile", "is", "not", "present", "removing", "it", "if", "present", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxd_profile.py#L195-L273
[ "def", "absent", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'remote_addr'", ":", "remote_addr", ",", "'cert...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_persistent_modules
Returns a list of modules in loader.conf that load on boot.
salt/modules/freebsdkmod.py
def _get_persistent_modules(): ''' Returns a list of modules in loader.conf that load on boot. ''' mods = set() with salt.utils.files.fopen(_LOADER_CONF, 'r') as loader_conf: for line in loader_conf: line = salt.utils.stringutils.to_unicode(line) line = line.strip() ...
def _get_persistent_modules(): ''' Returns a list of modules in loader.conf that load on boot. ''' mods = set() with salt.utils.files.fopen(_LOADER_CONF, 'r') as loader_conf: for line in loader_conf: line = salt.utils.stringutils.to_unicode(line) line = line.strip() ...
[ "Returns", "a", "list", "of", "modules", "in", "loader", ".", "conf", "that", "load", "on", "boot", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L68-L80
[ "def", "_get_persistent_modules", "(", ")", ":", "mods", "=", "set", "(", ")", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "_LOADER_CONF", ",", "'r'", ")", "as", "loader_conf", ":", "for", "line", "in", "loader_conf", ":", "line", "=...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_set_persistent_module
Add a module to loader.conf to make it persistent.
salt/modules/freebsdkmod.py
def _set_persistent_module(mod): ''' Add a module to loader.conf to make it persistent. ''' if not mod or mod in mod_list(True) or mod not in \ available(): return set() __salt__['file.append'](_LOADER_CONF, _LOAD_MODULE.format(mod)) return set([mod])
def _set_persistent_module(mod): ''' Add a module to loader.conf to make it persistent. ''' if not mod or mod in mod_list(True) or mod not in \ available(): return set() __salt__['file.append'](_LOADER_CONF, _LOAD_MODULE.format(mod)) return set([mod])
[ "Add", "a", "module", "to", "loader", ".", "conf", "to", "make", "it", "persistent", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L83-L91
[ "def", "_set_persistent_module", "(", "mod", ")", ":", "if", "not", "mod", "or", "mod", "in", "mod_list", "(", "True", ")", "or", "mod", "not", "in", "available", "(", ")", ":", "return", "set", "(", ")", "__salt__", "[", "'file.append'", "]", "(", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_remove_persistent_module
Remove module from loader.conf. If comment is true only comment line where module is.
salt/modules/freebsdkmod.py
def _remove_persistent_module(mod, comment): ''' Remove module from loader.conf. If comment is true only comment line where module is. ''' if not mod or mod not in mod_list(True): return set() if comment: __salt__['file.comment'](_LOADER_CONF, _MODULE_RE.format(mod)) else: ...
def _remove_persistent_module(mod, comment): ''' Remove module from loader.conf. If comment is true only comment line where module is. ''' if not mod or mod not in mod_list(True): return set() if comment: __salt__['file.comment'](_LOADER_CONF, _MODULE_RE.format(mod)) else: ...
[ "Remove", "module", "from", "loader", ".", "conf", ".", "If", "comment", "is", "true", "only", "comment", "line", "where", "module", "is", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L94-L107
[ "def", "_remove_persistent_module", "(", "mod", ",", "comment", ")", ":", "if", "not", "mod", "or", "mod", "not", "in", "mod_list", "(", "True", ")", ":", "return", "set", "(", ")", "if", "comment", ":", "__salt__", "[", "'file.comment'", "]", "(", "_L...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
available
Return a list of all available kernel modules CLI Example: .. code-block:: bash salt '*' kmod.available
salt/modules/freebsdkmod.py
def available(): ''' Return a list of all available kernel modules CLI Example: .. code-block:: bash salt '*' kmod.available ''' ret = [] for path in __salt__['file.find']('/boot/kernel', name='*.ko$'): bpath = os.path.basename(path) comps = bpath.split('.') ...
def available(): ''' Return a list of all available kernel modules CLI Example: .. code-block:: bash salt '*' kmod.available ''' ret = [] for path in __salt__['file.find']('/boot/kernel', name='*.ko$'): bpath = os.path.basename(path) comps = bpath.split('.') ...
[ "Return", "a", "list", "of", "all", "available", "kernel", "modules" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L110-L127
[ "def", "available", "(", ")", ":", "ret", "=", "[", "]", "for", "path", "in", "__salt__", "[", "'file.find'", "]", "(", "'/boot/kernel'", ",", "name", "=", "'*.ko$'", ")", ":", "bpath", "=", "os", ".", "path", ".", "basename", "(", "path", ")", "co...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
lsmod
Return a dict containing information about currently loaded modules CLI Example: .. code-block:: bash salt '*' kmod.lsmod
salt/modules/freebsdkmod.py
def lsmod(): ''' Return a dict containing information about currently loaded modules CLI Example: .. code-block:: bash salt '*' kmod.lsmod ''' ret = [] for line in __salt__['cmd.run']('kldstat').splitlines(): comps = line.split() if not len(comps) > 2: ...
def lsmod(): ''' Return a dict containing information about currently loaded modules CLI Example: .. code-block:: bash salt '*' kmod.lsmod ''' ret = [] for line in __salt__['cmd.run']('kldstat').splitlines(): comps = line.split() if not len(comps) > 2: ...
[ "Return", "a", "dict", "containing", "information", "about", "currently", "loaded", "modules" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L143-L167
[ "def", "lsmod", "(", ")", ":", "ret", "=", "[", "]", "for", "line", "in", "__salt__", "[", "'cmd.run'", "]", "(", "'kldstat'", ")", ".", "splitlines", "(", ")", ":", "comps", "=", "line", ".", "split", "(", ")", "if", "not", "len", "(", "comps", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mod_list
Return a list of the loaded module names CLI Example: .. code-block:: bash salt '*' kmod.mod_list
salt/modules/freebsdkmod.py
def mod_list(only_persist=False): ''' Return a list of the loaded module names CLI Example: .. code-block:: bash salt '*' kmod.mod_list ''' mods = set() if only_persist: if not _get_persistent_modules(): return mods for mod in _get_persistent_modules():...
def mod_list(only_persist=False): ''' Return a list of the loaded module names CLI Example: .. code-block:: bash salt '*' kmod.mod_list ''' mods = set() if only_persist: if not _get_persistent_modules(): return mods for mod in _get_persistent_modules():...
[ "Return", "a", "list", "of", "the", "loaded", "module", "names" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L170-L189
[ "def", "mod_list", "(", "only_persist", "=", "False", ")", ":", "mods", "=", "set", "(", ")", "if", "only_persist", ":", "if", "not", "_get_persistent_modules", "(", ")", ":", "return", "mods", "for", "mod", "in", "_get_persistent_modules", "(", ")", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
load
Load the specified kernel module mod Name of the module to add persist Write the module to sysrc kld_modules to make it load on system reboot CLI Example: .. code-block:: bash salt '*' kmod.load bhyve
salt/modules/freebsdkmod.py
def load(mod, persist=False): ''' Load the specified kernel module mod Name of the module to add persist Write the module to sysrc kld_modules to make it load on system reboot CLI Example: .. code-block:: bash salt '*' kmod.load bhyve ''' pre_mods = lsmod() ...
def load(mod, persist=False): ''' Load the specified kernel module mod Name of the module to add persist Write the module to sysrc kld_modules to make it load on system reboot CLI Example: .. code-block:: bash salt '*' kmod.load bhyve ''' pre_mods = lsmod() ...
[ "Load", "the", "specified", "kernel", "module" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L192-L226
[ "def", "load", "(", "mod", ",", "persist", "=", "False", ")", ":", "pre_mods", "=", "lsmod", "(", ")", "response", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "'kldload {0}'", ".", "format", "(", "mod", ")", ",", "python_shell", "=", "False", ")",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
remove
Remove the specified kernel module mod Name of module to remove persist Also remove module from /boot/loader.conf comment If persist is set don't remove line from /boot/loader.conf but only comment it CLI Example: .. code-block:: bash salt '*' kmod.remov...
salt/modules/freebsdkmod.py
def remove(mod, persist=False, comment=True): ''' Remove the specified kernel module mod Name of module to remove persist Also remove module from /boot/loader.conf comment If persist is set don't remove line from /boot/loader.conf but only comment it CLI Examp...
def remove(mod, persist=False, comment=True): ''' Remove the specified kernel module mod Name of module to remove persist Also remove module from /boot/loader.conf comment If persist is set don't remove line from /boot/loader.conf but only comment it CLI Examp...
[ "Remove", "the", "specified", "kernel", "module" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L242-L273
[ "def", "remove", "(", "mod", ",", "persist", "=", "False", ",", "comment", "=", "True", ")", ":", "pre_mods", "=", "lsmod", "(", ")", "res", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "'kldunload {0}'", ".", "format", "(", "mod", ")", ",", "pyt...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_sd_auth
Returns requested Server Density authentication value from pillar. CLI Example: .. code-block:: bash salt '*' serverdensity_device.get_sd_auth <val>
salt/modules/serverdensity_device.py
def get_sd_auth(val, sd_auth_pillar_name='serverdensity'): ''' Returns requested Server Density authentication value from pillar. CLI Example: .. code-block:: bash salt '*' serverdensity_device.get_sd_auth <val> ''' sd_pillar = __pillar__.get(sd_auth_pillar_name) log.debug('Server...
def get_sd_auth(val, sd_auth_pillar_name='serverdensity'): ''' Returns requested Server Density authentication value from pillar. CLI Example: .. code-block:: bash salt '*' serverdensity_device.get_sd_auth <val> ''' sd_pillar = __pillar__.get(sd_auth_pillar_name) log.debug('Server...
[ "Returns", "requested", "Server", "Density", "authentication", "value", "from", "pillar", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L43-L65
[ "def", "get_sd_auth", "(", "val", ",", "sd_auth_pillar_name", "=", "'serverdensity'", ")", ":", "sd_pillar", "=", "__pillar__", ".", "get", "(", "sd_auth_pillar_name", ")", "log", ".", "debug", "(", "'Server Density Pillar: %s'", ",", "sd_pillar", ")", "if", "no...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_clean_salt_variables
Pops out variables from params which starts with `variable_prefix`.
salt/modules/serverdensity_device.py
def _clean_salt_variables(params, variable_prefix="__"): ''' Pops out variables from params which starts with `variable_prefix`. ''' list(list(map(params.pop, [k for k in params if k.startswith(variable_prefix)]))) return params
def _clean_salt_variables(params, variable_prefix="__"): ''' Pops out variables from params which starts with `variable_prefix`. ''' list(list(map(params.pop, [k for k in params if k.startswith(variable_prefix)]))) return params
[ "Pops", "out", "variables", "from", "params", "which", "starts", "with", "variable_prefix", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L68-L73
[ "def", "_clean_salt_variables", "(", "params", ",", "variable_prefix", "=", "\"__\"", ")", ":", "list", "(", "list", "(", "map", "(", "params", ".", "pop", ",", "[", "k", "for", "k", "in", "params", "if", "k", ".", "startswith", "(", "variable_prefix", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create
Function to create device in Server Density. For more info, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating CLI Example: .. code-block:: bash salt '*' serverdensity_device.create lama salt '*' serverdensity_device.create rich_lama group=lama_...
salt/modules/serverdensity_device.py
def create(name, **params): ''' Function to create device in Server Density. For more info, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating CLI Example: .. code-block:: bash salt '*' serverdensity_device.create lama salt '*' serverden...
def create(name, **params): ''' Function to create device in Server Density. For more info, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating CLI Example: .. code-block:: bash salt '*' serverdensity_device.create lama salt '*' serverden...
[ "Function", "to", "create", "device", "in", "Server", "Density", ".", "For", "more", "info", "see", "the", "API", "docs", "__", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L76-L110
[ "def", "create", "(", "name", ",", "*", "*", "params", ")", ":", "log", ".", "debug", "(", "'Server Density params: %s'", ",", "params", ")", "params", "=", "_clean_salt_variables", "(", "params", ")", "params", "[", "'name'", "]", "=", "name", "api_respon...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
delete
Delete a device from Server Density. For more information, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Deleting CLI Example: .. code-block:: bash salt '*' serverdensity_device.delete 51f7eafcdba4bb235e000ae4
salt/modules/serverdensity_device.py
def delete(device_id): ''' Delete a device from Server Density. For more information, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Deleting CLI Example: .. code-block:: bash salt '*' serverdensity_device.delete 51f7eafcdba4bb235e000ae4 ''' ...
def delete(device_id): ''' Delete a device from Server Density. For more information, see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Deleting CLI Example: .. code-block:: bash salt '*' serverdensity_device.delete 51f7eafcdba4bb235e000ae4 ''' ...
[ "Delete", "a", "device", "from", "Server", "Density", ".", "For", "more", "information", "see", "the", "API", "docs", "__", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L113-L141
[ "def", "delete", "(", "device_id", ")", ":", "api_response", "=", "requests", ".", "delete", "(", "'https://api.serverdensity.io/inventory/devices/'", "+", "device_id", ",", "params", "=", "{", "'token'", ":", "get_sd_auth", "(", "'api_token'", ")", "}", ")", "l...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ls
List devices in Server Density Results will be filtered by any params passed to this function. For more information, see the API docs on listing_ and searching_. .. _listing: https://apidocs.serverdensity.com/Inventory/Devices/Listing .. _searching: https://apidocs.serverdensity.com/Inventory/Devices/...
salt/modules/serverdensity_device.py
def ls(**params): ''' List devices in Server Density Results will be filtered by any params passed to this function. For more information, see the API docs on listing_ and searching_. .. _listing: https://apidocs.serverdensity.com/Inventory/Devices/Listing .. _searching: https://apidocs.server...
def ls(**params): ''' List devices in Server Density Results will be filtered by any params passed to this function. For more information, see the API docs on listing_ and searching_. .. _listing: https://apidocs.serverdensity.com/Inventory/Devices/Listing .. _searching: https://apidocs.server...
[ "List", "devices", "in", "Server", "Density" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L144-L193
[ "def", "ls", "(", "*", "*", "params", ")", ":", "params", "=", "_clean_salt_variables", "(", "params", ")", "endpoint", "=", "'devices'", "# Change endpoint if there are params to filter by:", "if", "params", ":", "endpoint", "=", "'resources'", "# Convert all ints to...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
update
Updates device information in Server Density. For more information see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Updating CLI Example: .. code-block:: bash salt '*' serverdensity_device.update 51f7eafcdba4bb235e000ae4 name=lama group=lama_band salt ...
salt/modules/serverdensity_device.py
def update(device_id, **params): ''' Updates device information in Server Density. For more information see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Updating CLI Example: .. code-block:: bash salt '*' serverdensity_device.update 51f7eafcdba4bb235e0...
def update(device_id, **params): ''' Updates device information in Server Density. For more information see the `API docs`__. .. __: https://apidocs.serverdensity.com/Inventory/Devices/Updating CLI Example: .. code-block:: bash salt '*' serverdensity_device.update 51f7eafcdba4bb235e0...
[ "Updates", "device", "information", "in", "Server", "Density", ".", "For", "more", "information", "see", "the", "API", "docs", "__", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L196-L231
[ "def", "update", "(", "device_id", ",", "*", "*", "params", ")", ":", "params", "=", "_clean_salt_variables", "(", "params", ")", "api_response", "=", "requests", ".", "put", "(", "'https://api.serverdensity.io/inventory/devices/'", "+", "device_id", ",", "params"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
install_agent
Function downloads Server Density installation agent, and installs sd-agent with agent_key. Optionally the agent_version would select the series to use (defaults on the v1 one). CLI Example: .. code-block:: bash salt '*' serverdensity_device.install_agent c2bbdd6689ff46282bdaa07555641498 ...
salt/modules/serverdensity_device.py
def install_agent(agent_key, agent_version=1): ''' Function downloads Server Density installation agent, and installs sd-agent with agent_key. Optionally the agent_version would select the series to use (defaults on the v1 one). CLI Example: .. code-block:: bash salt '*' serverdensity...
def install_agent(agent_key, agent_version=1): ''' Function downloads Server Density installation agent, and installs sd-agent with agent_key. Optionally the agent_version would select the series to use (defaults on the v1 one). CLI Example: .. code-block:: bash salt '*' serverdensity...
[ "Function", "downloads", "Server", "Density", "installation", "agent", "and", "installs", "sd", "-", "agent", "with", "agent_key", ".", "Optionally", "the", "agent_version", "would", "select", "the", "series", "to", "use", "(", "defaults", "on", "the", "v1", "...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L234-L274
[ "def", "install_agent", "(", "agent_key", ",", "agent_version", "=", "1", ")", ":", "work_dir", "=", "os", ".", "path", ".", "join", "(", "__opts__", "[", "'cachedir'", "]", ",", "'tmp'", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "work_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_init_client
Setup client and init datastore.
salt/cache/etcd_cache.py
def _init_client(): '''Setup client and init datastore. ''' global client, path_prefix if client is not None: return etcd_kwargs = { 'host': __opts__.get('etcd.host', '127.0.0.1'), 'port': __opts__.get('etcd.port', 2379), 'protocol': __opts__.get('etcd.pr...
def _init_client(): '''Setup client and init datastore. ''' global client, path_prefix if client is not None: return etcd_kwargs = { 'host': __opts__.get('etcd.host', '127.0.0.1'), 'port': __opts__.get('etcd.port', 2379), 'protocol': __opts__.get('etcd.pr...
[ "Setup", "client", "and", "init", "datastore", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L90-L119
[ "def", "_init_client", "(", ")", ":", "global", "client", ",", "path_prefix", "if", "client", "is", "not", "None", ":", "return", "etcd_kwargs", "=", "{", "'host'", ":", "__opts__", ".", "get", "(", "'etcd.host'", ",", "'127.0.0.1'", ")", ",", "'port'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
store
Store a key value.
salt/cache/etcd_cache.py
def store(bank, key, data): ''' Store a key value. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: value = __context__['serial'].dumps(data) client.write(etcd_key, base64.b64encode(value)) except Exception as exc: raise SaltCacheError( ...
def store(bank, key, data): ''' Store a key value. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: value = __context__['serial'].dumps(data) client.write(etcd_key, base64.b64encode(value)) except Exception as exc: raise SaltCacheError( ...
[ "Store", "a", "key", "value", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L122-L134
[ "def", "store", "(", "bank", ",", "key", ",", "data", ")", ":", "_init_client", "(", ")", "etcd_key", "=", "'{0}/{1}/{2}'", ".", "format", "(", "path_prefix", ",", "bank", ",", "key", ")", "try", ":", "value", "=", "__context__", "[", "'serial'", "]", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
fetch
Fetch a key value.
salt/cache/etcd_cache.py
def fetch(bank, key): ''' Fetch a key value. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: value = client.read(etcd_key).value return __context__['serial'].loads(base64.b64decode(value)) except etcd.EtcdKeyNotFound: return {} exce...
def fetch(bank, key): ''' Fetch a key value. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: value = client.read(etcd_key).value return __context__['serial'].loads(base64.b64decode(value)) except etcd.EtcdKeyNotFound: return {} exce...
[ "Fetch", "a", "key", "value", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L137-L153
[ "def", "fetch", "(", "bank", ",", "key", ")", ":", "_init_client", "(", ")", "etcd_key", "=", "'{0}/{1}/{2}'", ".", "format", "(", "path_prefix", ",", "bank", ",", "key", ")", "try", ":", "value", "=", "client", ".", "read", "(", "etcd_key", ")", "."...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
flush
Remove the key from the cache bank with all the key content.
salt/cache/etcd_cache.py
def flush(bank, key=None): ''' Remove the key from the cache bank with all the key content. ''' _init_client() if key is None: etcd_key = '{0}/{1}'.format(path_prefix, bank) else: etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: client.read(etcd_key) e...
def flush(bank, key=None): ''' Remove the key from the cache bank with all the key content. ''' _init_client() if key is None: etcd_key = '{0}/{1}'.format(path_prefix, bank) else: etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: client.read(etcd_key) e...
[ "Remove", "the", "key", "from", "the", "cache", "bank", "with", "all", "the", "key", "content", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L156-L176
[ "def", "flush", "(", "bank", ",", "key", "=", "None", ")", ":", "_init_client", "(", ")", "if", "key", "is", "None", ":", "etcd_key", "=", "'{0}/{1}'", ".", "format", "(", "path_prefix", ",", "bank", ")", "else", ":", "etcd_key", "=", "'{0}/{1}/{2}'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_walk
Recursively walk dirs. Return flattened list of keys. r: etcd.EtcdResult
salt/cache/etcd_cache.py
def _walk(r): ''' Recursively walk dirs. Return flattened list of keys. r: etcd.EtcdResult ''' if not r.dir: return [r.key.split('/', 3)[3]] keys = [] for c in client.read(r.key).children: keys.extend(_walk(c)) return keys
def _walk(r): ''' Recursively walk dirs. Return flattened list of keys. r: etcd.EtcdResult ''' if not r.dir: return [r.key.split('/', 3)[3]] keys = [] for c in client.read(r.key).children: keys.extend(_walk(c)) return keys
[ "Recursively", "walk", "dirs", ".", "Return", "flattened", "list", "of", "keys", ".", "r", ":", "etcd", ".", "EtcdResult" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L179-L190
[ "def", "_walk", "(", "r", ")", ":", "if", "not", "r", ".", "dir", ":", "return", "[", "r", ".", "key", ".", "split", "(", "'/'", ",", "3", ")", "[", "3", "]", "]", "keys", "=", "[", "]", "for", "c", "in", "client", ".", "read", "(", "r", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ls
Return an iterable object containing all entries stored in the specified bank.
salt/cache/etcd_cache.py
def ls(bank): ''' Return an iterable object containing all entries stored in the specified bank. ''' _init_client() path = '{0}/{1}'.format(path_prefix, bank) try: return _walk(client.read(path)) except Exception as exc: raise SaltCacheError( 'There was an err...
def ls(bank): ''' Return an iterable object containing all entries stored in the specified bank. ''' _init_client() path = '{0}/{1}'.format(path_prefix, bank) try: return _walk(client.read(path)) except Exception as exc: raise SaltCacheError( 'There was an err...
[ "Return", "an", "iterable", "object", "containing", "all", "entries", "stored", "in", "the", "specified", "bank", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L193-L207
[ "def", "ls", "(", "bank", ")", ":", "_init_client", "(", ")", "path", "=", "'{0}/{1}'", ".", "format", "(", "path_prefix", ",", "bank", ")", "try", ":", "return", "_walk", "(", "client", ".", "read", "(", "path", ")", ")", "except", "Exception", "as"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
contains
Checks if the specified bank contains the specified key.
salt/cache/etcd_cache.py
def contains(bank, key): ''' Checks if the specified bank contains the specified key. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: r = client.read(etcd_key) # return True for keys, not dirs return r.dir is False except etcd.EtcdKeyNo...
def contains(bank, key): ''' Checks if the specified bank contains the specified key. ''' _init_client() etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key) try: r = client.read(etcd_key) # return True for keys, not dirs return r.dir is False except etcd.EtcdKeyNo...
[ "Checks", "if", "the", "specified", "bank", "contains", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L210-L227
[ "def", "contains", "(", "bank", ",", "key", ")", ":", "_init_client", "(", ")", "etcd_key", "=", "'{0}/{1}/{2}'", ".", "format", "(", "path_prefix", ",", "bank", ",", "key", ")", "try", ":", "r", "=", "client", ".", "read", "(", "etcd_key", ")", "# r...
e8541fd6e744ab0df786c0f76102e41631f45d46