id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,000 | saltstack/salt | salt/utils/virtualbox.py | vb_create_machine | def vb_create_machine(name=None):
'''
Creates a machine on the virtualbox hypervisor
TODO pass more params to customize machine creation
@param name:
@type name: str
@return: Representation of the created machine
@rtype: dict
'''
vbox = vb_get_box()
log.info('Create virtualbox m... | python | def vb_create_machine(name=None):
'''
Creates a machine on the virtualbox hypervisor
TODO pass more params to customize machine creation
@param name:
@type name: str
@return: Representation of the created machine
@rtype: dict
'''
vbox = vb_get_box()
log.info('Create virtualbox m... | [
"def",
"vb_create_machine",
"(",
"name",
"=",
"None",
")",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"log",
".",
"info",
"(",
"'Create virtualbox machine %s '",
",",
"name",
")",
"groups",
"=",
"None",
"os_type_id",
"=",
"'Other'",
"new_machine",
"=",
"vbox"... | Creates a machine on the virtualbox hypervisor
TODO pass more params to customize machine creation
@param name:
@type name: str
@return: Representation of the created machine
@rtype: dict | [
"Creates",
"a",
"machine",
"on",
"the",
"virtualbox",
"hypervisor"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L345-L368 |
37,001 | saltstack/salt | salt/utils/virtualbox.py | vb_clone_vm | def vb_clone_vm(
name=None,
clone_from=None,
clone_mode=0,
timeout=10000,
**kwargs
):
'''
Tells virtualbox to create a VM by cloning from an existing one
@param name: Name for the new VM
@type name: str
@param clone_from:
@type clone_from: str
@param timeout: maximum tim... | python | def vb_clone_vm(
name=None,
clone_from=None,
clone_mode=0,
timeout=10000,
**kwargs
):
'''
Tells virtualbox to create a VM by cloning from an existing one
@param name: Name for the new VM
@type name: str
@param clone_from:
@type clone_from: str
@param timeout: maximum tim... | [
"def",
"vb_clone_vm",
"(",
"name",
"=",
"None",
",",
"clone_from",
"=",
"None",
",",
"clone_mode",
"=",
"0",
",",
"timeout",
"=",
"10000",
",",
"*",
"*",
"kwargs",
")",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"log",
".",
"info",
"(",
"'Clone virtua... | Tells virtualbox to create a VM by cloning from an existing one
@param name: Name for the new VM
@type name: str
@param clone_from:
@type clone_from: str
@param timeout: maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return dict of resulting VM | [
"Tells",
"virtualbox",
"to",
"create",
"a",
"VM",
"by",
"cloning",
"from",
"an",
"existing",
"one"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L371-L415 |
37,002 | saltstack/salt | salt/utils/virtualbox.py | _start_machine | def _start_machine(machine, session):
'''
Helper to try and start machines
@param machine:
@type machine: IMachine
@param session:
@type session: ISession
@return:
@rtype: IProgress or None
'''
try:
return machine.launchVMProcess(session, '', '')
except Exception as ... | python | def _start_machine(machine, session):
'''
Helper to try and start machines
@param machine:
@type machine: IMachine
@param session:
@type session: ISession
@return:
@rtype: IProgress or None
'''
try:
return machine.launchVMProcess(session, '', '')
except Exception as ... | [
"def",
"_start_machine",
"(",
"machine",
",",
"session",
")",
":",
"try",
":",
"return",
"machine",
".",
"launchVMProcess",
"(",
"session",
",",
"''",
",",
"''",
")",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"debug",
"(",
"e",
".",
"message",... | Helper to try and start machines
@param machine:
@type machine: IMachine
@param session:
@type session: ISession
@return:
@rtype: IProgress or None | [
"Helper",
"to",
"try",
"and",
"start",
"machines"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L418-L433 |
37,003 | saltstack/salt | salt/utils/virtualbox.py | vb_start_vm | def vb_start_vm(name=None, timeout=10000, **kwargs):
'''
Tells Virtualbox to start up a VM.
Blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of started VM
'''
... | python | def vb_start_vm(name=None, timeout=10000, **kwargs):
'''
Tells Virtualbox to start up a VM.
Blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of started VM
'''
... | [
"def",
"vb_start_vm",
"(",
"name",
"=",
"None",
",",
"timeout",
"=",
"10000",
",",
"*",
"*",
"kwargs",
")",
":",
"# Time tracking",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"timeout_in_seconds",
"=",
"timeout",
"/",
"1000",
"max_time",
"=",
"sta... | Tells Virtualbox to start up a VM.
Blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of started VM | [
"Tells",
"Virtualbox",
"to",
"start",
"up",
"a",
"VM",
".",
"Blocking",
"function!"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L436-L475 |
37,004 | saltstack/salt | salt/utils/virtualbox.py | vb_stop_vm | def vb_stop_vm(name=None, timeout=10000, **kwargs):
'''
Tells Virtualbox to stop a VM.
This is a blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of stopped VM
''... | python | def vb_stop_vm(name=None, timeout=10000, **kwargs):
'''
Tells Virtualbox to stop a VM.
This is a blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of stopped VM
''... | [
"def",
"vb_stop_vm",
"(",
"name",
"=",
"None",
",",
"timeout",
"=",
"10000",
",",
"*",
"*",
"kwargs",
")",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"machine",
"=",
"vbox",
".",
"findMachine",
"(",
"name",
")",
"log",
".",
"info",
"(",
"'Stopping mac... | Tells Virtualbox to stop a VM.
This is a blocking function!
@param name:
@type name: str
@param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely
@type timeout: int
@return untreated dict of stopped VM | [
"Tells",
"Virtualbox",
"to",
"stop",
"a",
"VM",
".",
"This",
"is",
"a",
"blocking",
"function!"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L478-L501 |
37,005 | saltstack/salt | salt/utils/virtualbox.py | vb_destroy_machine | def vb_destroy_machine(name=None, timeout=10000):
'''
Attempts to get rid of a machine and all its files from the hypervisor
@param name:
@type name: str
@param timeout int timeout in milliseconds
'''
vbox = vb_get_box()
log.info('Destroying machine %s', name)
machine = vbox.findMach... | python | def vb_destroy_machine(name=None, timeout=10000):
'''
Attempts to get rid of a machine and all its files from the hypervisor
@param name:
@type name: str
@param timeout int timeout in milliseconds
'''
vbox = vb_get_box()
log.info('Destroying machine %s', name)
machine = vbox.findMach... | [
"def",
"vb_destroy_machine",
"(",
"name",
"=",
"None",
",",
"timeout",
"=",
"10000",
")",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"log",
".",
"info",
"(",
"'Destroying machine %s'",
",",
"name",
")",
"machine",
"=",
"vbox",
".",
"findMachine",
"(",
"na... | Attempts to get rid of a machine and all its files from the hypervisor
@param name:
@type name: str
@param timeout int timeout in milliseconds | [
"Attempts",
"to",
"get",
"rid",
"of",
"a",
"machine",
"and",
"all",
"its",
"files",
"from",
"the",
"hypervisor"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L504-L517 |
37,006 | saltstack/salt | salt/utils/virtualbox.py | vb_xpcom_to_attribute_dict | def vb_xpcom_to_attribute_dict(xpcom,
interface_name=None,
attributes=None,
excluded_attributes=None,
extra_attributes=None
):
'''
Attempts to build a dict f... | python | def vb_xpcom_to_attribute_dict(xpcom,
interface_name=None,
attributes=None,
excluded_attributes=None,
extra_attributes=None
):
'''
Attempts to build a dict f... | [
"def",
"vb_xpcom_to_attribute_dict",
"(",
"xpcom",
",",
"interface_name",
"=",
"None",
",",
"attributes",
"=",
"None",
",",
"excluded_attributes",
"=",
"None",
",",
"extra_attributes",
"=",
"None",
")",
":",
"# Check the interface",
"if",
"interface_name",
":",
"m... | Attempts to build a dict from an XPCOM object.
Attributes that don't exist in the object return an empty string.
attribute_list = list of str or tuple(str,<a class>)
e.g attributes=[('bad_attribute', list)] --> { 'bad_attribute': [] }
@param xpcom:
@type xpcom:
@param interface_name: Which in... | [
"Attempts",
"to",
"build",
"a",
"dict",
"from",
"an",
"XPCOM",
"object",
".",
"Attributes",
"that",
"don",
"t",
"exist",
"in",
"the",
"object",
"return",
"an",
"empty",
"string",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L520-L573 |
37,007 | saltstack/salt | salt/utils/virtualbox.py | treat_machine_dict | def treat_machine_dict(machine):
'''
Make machine presentable for outside world.
!!!Modifies the input machine!!!
@param machine:
@type machine: dict
@return: the modified input machine
@rtype: dict
'''
machine.update({
'id': machine.get('id', ''),
'image': machine.... | python | def treat_machine_dict(machine):
'''
Make machine presentable for outside world.
!!!Modifies the input machine!!!
@param machine:
@type machine: dict
@return: the modified input machine
@rtype: dict
'''
machine.update({
'id': machine.get('id', ''),
'image': machine.... | [
"def",
"treat_machine_dict",
"(",
"machine",
")",
":",
"machine",
".",
"update",
"(",
"{",
"'id'",
":",
"machine",
".",
"get",
"(",
"'id'",
",",
"''",
")",
",",
"'image'",
":",
"machine",
".",
"get",
"(",
"'image'",
",",
"''",
")",
",",
"'size'",
"... | Make machine presentable for outside world.
!!!Modifies the input machine!!!
@param machine:
@type machine: dict
@return: the modified input machine
@rtype: dict | [
"Make",
"machine",
"presentable",
"for",
"outside",
"world",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L576-L599 |
37,008 | saltstack/salt | salt/utils/virtualbox.py | vb_machine_exists | def vb_machine_exists(name):
'''
Checks in with the hypervisor to see if the machine with the given name is known
@param name:
@type name:
@return:
@rtype:
'''
try:
vbox = vb_get_box()
vbox.findMachine(name)
return True
except Exception as e:
if isinst... | python | def vb_machine_exists(name):
'''
Checks in with the hypervisor to see if the machine with the given name is known
@param name:
@type name:
@return:
@rtype:
'''
try:
vbox = vb_get_box()
vbox.findMachine(name)
return True
except Exception as e:
if isinst... | [
"def",
"vb_machine_exists",
"(",
"name",
")",
":",
"try",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"vbox",
".",
"findMachine",
"(",
"name",
")",
"return",
"True",
"except",
"Exception",
"as",
"e",
":",
"if",
"isinstance",
"(",
"e",
".",
"message",
","... | Checks in with the hypervisor to see if the machine with the given name is known
@param name:
@type name:
@return:
@rtype: | [
"Checks",
"in",
"with",
"the",
"hypervisor",
"to",
"see",
"if",
"the",
"machine",
"with",
"the",
"given",
"name",
"is",
"known"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L652-L674 |
37,009 | saltstack/salt | salt/utils/virtualbox.py | vb_get_machine | def vb_get_machine(name, **kwargs):
'''
Attempts to fetch a machine from Virtualbox and convert it to a dict
@param name: The unique name of the machine
@type name:
@param kwargs: To be passed to vb_xpcom_to_attribute_dict
@type kwargs:
@return:
@rtype: dict
'''
vbox = vb_get_bo... | python | def vb_get_machine(name, **kwargs):
'''
Attempts to fetch a machine from Virtualbox and convert it to a dict
@param name: The unique name of the machine
@type name:
@param kwargs: To be passed to vb_xpcom_to_attribute_dict
@type kwargs:
@return:
@rtype: dict
'''
vbox = vb_get_bo... | [
"def",
"vb_get_machine",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"vbox",
"=",
"vb_get_box",
"(",
")",
"machine",
"=",
"vbox",
".",
"findMachine",
"(",
"name",
")",
"return",
"vb_xpcom_to_attribute_dict",
"(",
"machine",
",",
"'IMachine'",
",",
"*",... | Attempts to fetch a machine from Virtualbox and convert it to a dict
@param name: The unique name of the machine
@type name:
@param kwargs: To be passed to vb_xpcom_to_attribute_dict
@type kwargs:
@return:
@rtype: dict | [
"Attempts",
"to",
"fetch",
"a",
"machine",
"from",
"Virtualbox",
"and",
"convert",
"it",
"to",
"a",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L677-L690 |
37,010 | saltstack/salt | salt/utils/data.py | compare_dicts | def compare_dicts(old=None, new=None):
'''
Compare before and after results from various salt functions, returning a
dict describing the changes that were made.
'''
ret = {}
for key in set((new or {})).union((old or {})):
if key not in old:
# New key
ret[key] = {'... | python | def compare_dicts(old=None, new=None):
'''
Compare before and after results from various salt functions, returning a
dict describing the changes that were made.
'''
ret = {}
for key in set((new or {})).union((old or {})):
if key not in old:
# New key
ret[key] = {'... | [
"def",
"compare_dicts",
"(",
"old",
"=",
"None",
",",
"new",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"key",
"in",
"set",
"(",
"(",
"new",
"or",
"{",
"}",
")",
")",
".",
"union",
"(",
"(",
"old",
"or",
"{",
"}",
")",
")",
":",
... | Compare before and after results from various salt functions, returning a
dict describing the changes that were made. | [
"Compare",
"before",
"and",
"after",
"results",
"from",
"various",
"salt",
"functions",
"returning",
"a",
"dict",
"describing",
"the",
"changes",
"that",
"were",
"made",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L124-L143 |
37,011 | saltstack/salt | salt/utils/data.py | compare_lists | def compare_lists(old=None, new=None):
'''
Compare before and after results from various salt functions, returning a
dict describing the changes that were made
'''
ret = dict()
for item in new:
if item not in old:
ret['new'] = item
for item in old:
if item not in ... | python | def compare_lists(old=None, new=None):
'''
Compare before and after results from various salt functions, returning a
dict describing the changes that were made
'''
ret = dict()
for item in new:
if item not in old:
ret['new'] = item
for item in old:
if item not in ... | [
"def",
"compare_lists",
"(",
"old",
"=",
"None",
",",
"new",
"=",
"None",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"for",
"item",
"in",
"new",
":",
"if",
"item",
"not",
"in",
"old",
":",
"ret",
"[",
"'new'",
"]",
"=",
"item",
"for",
"item",
"in"... | Compare before and after results from various salt functions, returning a
dict describing the changes that were made | [
"Compare",
"before",
"and",
"after",
"results",
"from",
"various",
"salt",
"functions",
"returning",
"a",
"dict",
"describing",
"the",
"changes",
"that",
"were",
"made"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L147-L159 |
37,012 | saltstack/salt | salt/utils/data.py | decode | def decode(data, encoding=None, errors='strict', keep=False,
normalize=False, preserve_dict_class=False, preserve_tuples=False,
to_str=False):
'''
Generic function which will decode whichever type is passed, if necessary.
Optionally use to_str=True to ensure strings are str types and n... | python | def decode(data, encoding=None, errors='strict', keep=False,
normalize=False, preserve_dict_class=False, preserve_tuples=False,
to_str=False):
'''
Generic function which will decode whichever type is passed, if necessary.
Optionally use to_str=True to ensure strings are str types and n... | [
"def",
"decode",
"(",
"data",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"keep",
"=",
"False",
",",
"normalize",
"=",
"False",
",",
"preserve_dict_class",
"=",
"False",
",",
"preserve_tuples",
"=",
"False",
",",
"to_str",
"=",
"Fa... | Generic function which will decode whichever type is passed, if necessary.
Optionally use to_str=True to ensure strings are str types and not unicode
on Python 2.
If `strict` is True, and `keep` is False, and we fail to decode, a
UnicodeDecodeError will be raised. Passing `keep` as True allows for the
... | [
"Generic",
"function",
"which",
"will",
"decode",
"whichever",
"type",
"is",
"passed",
"if",
"necessary",
".",
"Optionally",
"use",
"to_str",
"=",
"True",
"to",
"ensure",
"strings",
"are",
"str",
"types",
"and",
"not",
"unicode",
"on",
"Python",
"2",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L162-L218 |
37,013 | saltstack/salt | salt/utils/data.py | encode | def encode(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False, preserve_tuples=False):
'''
Generic function which will encode whichever type is passed, if necessary
If `strict` is True, and `keep` is False, and we fail to encode, a
UnicodeEncodeError will be raised. ... | python | def encode(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False, preserve_tuples=False):
'''
Generic function which will encode whichever type is passed, if necessary
If `strict` is True, and `keep` is False, and we fail to encode, a
UnicodeEncodeError will be raised. ... | [
"def",
"encode",
"(",
"data",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"keep",
"=",
"False",
",",
"preserve_dict_class",
"=",
"False",
",",
"preserve_tuples",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Mappin... | Generic function which will encode whichever type is passed, if necessary
If `strict` is True, and `keep` is False, and we fail to encode, a
UnicodeEncodeError will be raised. Passing `keep` as True allows for the
original value to silently be returned in cases where encoding fails. This
can be useful ... | [
"Generic",
"function",
"which",
"will",
"encode",
"whichever",
"type",
"is",
"passed",
"if",
"necessary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L332-L365 |
37,014 | saltstack/salt | salt/utils/data.py | encode_tuple | def encode_tuple(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False):
'''
Encode all string values to Unicode
'''
return tuple(
encode_list(data, encoding, errors, keep, preserve_dict_class, True)) | python | def encode_tuple(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False):
'''
Encode all string values to Unicode
'''
return tuple(
encode_list(data, encoding, errors, keep, preserve_dict_class, True)) | [
"def",
"encode_tuple",
"(",
"data",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"keep",
"=",
"False",
",",
"preserve_dict_class",
"=",
"False",
")",
":",
"return",
"tuple",
"(",
"encode_list",
"(",
"data",
",",
"encoding",
",",
"er... | Encode all string values to Unicode | [
"Encode",
"all",
"string",
"values",
"to",
"Unicode"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L457-L463 |
37,015 | saltstack/salt | salt/utils/data.py | filter_by | def filter_by(lookup_dict,
lookup,
traverse,
merge=None,
default='default',
base=None):
'''
Common code to filter data structures like grains and pillar
'''
ret = None
# Default value would be an empty list if lookup not found
... | python | def filter_by(lookup_dict,
lookup,
traverse,
merge=None,
default='default',
base=None):
'''
Common code to filter data structures like grains and pillar
'''
ret = None
# Default value would be an empty list if lookup not found
... | [
"def",
"filter_by",
"(",
"lookup_dict",
",",
"lookup",
",",
"traverse",
",",
"merge",
"=",
"None",
",",
"default",
"=",
"'default'",
",",
"base",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"# Default value would be an empty list if lookup not found",
"val",
"=",... | Common code to filter data structures like grains and pillar | [
"Common",
"code",
"to",
"filter",
"data",
"structures",
"like",
"grains",
"and",
"pillar"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L484-L536 |
37,016 | saltstack/salt | salt/utils/data.py | is_iter | 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... | python | 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",
")",
":",
"if",
"ignore",
"and",
"isinstance",
"(",
"y",
",",
"ignore",
")",
":",
"return",
"False",
"try",
":",
"iter",
"(",
"y",
")",
"return",
"True",
"except",
"TypeError... | 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... | [
"Test",
"if",
"an",
"object",
"is",
"iterable",
"but",
"not",
"a",
"string",
"type",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L840-L860 |
37,017 | saltstack/salt | salt/utils/data.py | mysql_to_dict | 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)):... | python | 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",
")",
":",
"ret",
"=",
"{",
"}",
"headers",
"=",
"[",
"''",
"]",
"for",
"line",
"in",
"data",
":",
"if",
"not",
"line",
":",
"continue",
"if",
"line",
".",
"startswith",
"(",
"'+'",
")",
":",
"conti... | Convert MySQL-style output to a python dictionary | [
"Convert",
"MySQL",
"-",
"style",
"output",
"to",
"a",
"python",
"dictionary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L907-L932 |
37,018 | saltstack/salt | salt/utils/data.py | simple_types_filter | 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... | python | 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",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"data",
"simpletypes_keys",
"=",
"(",
"six",
".",
"string_types",
",",
"six",
".",
"text_type",
",",
"six",
".",
"integer_types",
",",
"float",
",",
"bool",
"... | Convert the data list, dictionary into simple types, i.e., int, float, string,
bool, etc. | [
"Convert",
"the",
"data",
"list",
"dictionary",
"into",
"simple",
"types",
"i",
".",
"e",
".",
"int",
"float",
"string",
"bool",
"etc",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L935-L969 |
37,019 | saltstack/salt | salt/utils/data.py | stringify | 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... | python | 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",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
":",
"if",
"six",
".",
"PY2",
"and",
"isinstance",
"(",
"item",
",",
"str",
")",
":",
"item",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_un... | Given an iterable, returns its items as a list, with any non-string items
converted to unicode strings. | [
"Given",
"an",
"iterable",
"returns",
"its",
"items",
"as",
"a",
"list",
"with",
"any",
"non",
"-",
"string",
"items",
"converted",
"to",
"unicode",
"strings",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L972-L984 |
37,020 | saltstack/salt | salt/utils/data.py | _is_not_considered_falsey | 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... | python | 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",
"=",
"(",
")",
")",
":",
"return",
"isinstance",
"(",
"value",
",",
"bool",
")",
"or",
"type",
"(",
"value",
")",
"in",
"ignore_types",
"or",
"value"
] | 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 | [
"Helper",
"function",
"for",
"filter_falsey",
"to",
"determine",
"if",
"something",
"is",
"not",
"to",
"be",
"considered",
"falsey",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L999-L1009 |
37,021 | saltstack/salt | salt/utils/data.py | CaseInsensitiveDict.items_lower | 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)) | python | 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",
")",
":",
"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. | [
"Returns",
"a",
"generator",
"iterating",
"over",
"keys",
"and",
"values",
"with",
"the",
"keys",
"all",
"being",
"lowercase",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L80-L85 |
37,022 | saltstack/salt | salt/states/macdefaults.py | absent | 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,
... | python | 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",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"out",
"=",
"__salt__",
"[",... | 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 | [
"Make",
"sure",
"the",
"defaults",
"value",
"is",
"absent"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/macdefaults.py#L81-L108 |
37,023 | saltstack/salt | salt/modules/win_shadow.py | info | 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... | python | 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",
")",
":",
"info",
"=",
"__salt__",
"[",
"'user.info'",
"]",
"(",
"name",
"=",
"name",
")",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'passwd'",
":",
"''",
",",
"'lstchg'",
":",
"''",
",",
"'min'",
":",
"''",
",",
... | 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 | [
"Return",
"information",
"for",
"the",
"specified",
"user",
"This",
"is",
"just",
"returns",
"dummy",
"data",
"so",
"that",
"salt",
"states",
"can",
"work",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_shadow.py#L30-L64 |
37,024 | saltstack/salt | salt/utils/saltclass.py | get_class_paths | 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... | python | 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",
")",
":",
"straight",
"=",
"os",
".",
"path",
".",
"join",
"(",
"saltclass_path",
",",
"'classes'",
",",
"'{0}.yml'",
".",
"format",
"(",
"_class",
")",
")",
"sub_straight",
"=",
"os",
".",
... | 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) | [
"Converts",
"the",
"dotted",
"notation",
"of",
"a",
"saltclass",
"class",
"to",
"its",
"possible",
"file",
"counterparts",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L64-L83 |
37,025 | saltstack/salt | salt/utils/saltclass.py | get_class_from_file | 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... | python | 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",
")",
":",
"# remove classes path prefix",
"_file",
"=",
"_file",
"[",
"len",
"(",
"os",
".",
"path",
".",
"join",
"(",
"saltclass_path",
",",
"'classes'",
")",
")",
"+",
"len",
"(",
"os",
"... | 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... | [
"Converts",
"the",
"absolute",
"path",
"to",
"a",
"saltclass",
"file",
"back",
"to",
"the",
"dotted",
"notation",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L86-L109 |
37,026 | saltstack/salt | salt/utils/saltclass.py | expand_classes_glob | 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... | python | 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",
")",
":",
"all_classes",
"=",
"[",
"]",
"expanded_classes",
"=",
"[",
"]",
"saltclass_path",
"=",
"salt_data",
"[",
"'path'",
"]",
"for",
"_class",
"in",
"classes",
":",
"all_classes",
".",
"ext... | 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) | [
"Expand",
"the",
"list",
"of",
"classes",
"to",
"no",
"longer",
"include",
"any",
"globbing",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L263-L283 |
37,027 | saltstack/salt | salt/modules/syslog_ng.py | _is_simple_type | 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) | python | 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",
")",
":",
"return",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
"or",
"isinstance",
"(",
"value",
",",
"int",
")",
"or",
"isinstance",
"(",
"value",
",",
"float",
")",
"or",
"isinstance",
"(",... | Returns True, if the given parameter value is an instance of either
int, str, float or bool. | [
"Returns",
"True",
"if",
"the",
"given",
"parameter",
"value",
"is",
"an",
"instance",
"of",
"either",
"int",
"str",
"float",
"or",
"bool",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L425-L430 |
37,028 | saltstack/salt | salt/modules/syslog_ng.py | _get_type_id_options | 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))
... | python | 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",
")",
":",
"# it's in a form of source.name",
"if",
"'.'",
"in",
"name",
":",
"type_",
",",
"sep",
",",
"id_",
"=",
"name",
".",
"partition",
"(",
"'.'",
")",
"options",
"=",
"configuration",
"... | Returns the type, id and option of a configuration object. | [
"Returns",
"the",
"type",
"id",
"and",
"option",
"of",
"a",
"configuration",
"object",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L433-L446 |
37,029 | saltstack/salt | salt/modules/syslog_ng.py | _expand_one_key_dictionary | 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 | python | 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",
")",
":",
"key",
"=",
"next",
"(",
"six",
".",
"iterkeys",
"(",
"_dict",
")",
")",
"value",
"=",
"_dict",
"[",
"key",
"]",
"return",
"key",
",",
"value"
] | Returns the only one key and it's value from a dictionary. | [
"Returns",
"the",
"only",
"one",
"key",
"and",
"it",
"s",
"value",
"from",
"a",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L449-L455 |
37,030 | saltstack/salt | salt/modules/syslog_ng.py | _parse_typed_parameter_typed_value | 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)... | python | 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",
")",
":",
"type_",
",",
"value",
"=",
"_expand_one_key_dictionary",
"(",
"values",
")",
"_current_parameter_value",
".",
"type",
"=",
"type_",
"if",
"_is_simple_type",
"(",
"value",
")",
":",
"arg",
"=",
... | Creates Arguments in a TypedParametervalue. | [
"Creates",
"Arguments",
"in",
"a",
"TypedParametervalue",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L458-L471 |
37,031 | saltstack/salt | salt/modules/syslog_ng.py | _parse_typed_parameter | 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... | python | 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",
")",
":",
"global",
"_current_parameter_value",
"type_",
",",
"value",
"=",
"_expand_one_key_dictionary",
"(",
"param",
")",
"_current_parameter",
".",
"type",
"=",
"type_",
"if",
"_is_simple_type",
"(",
"value",
")",
... | Parses a TypedParameter and fills it with values. | [
"Parses",
"a",
"TypedParameter",
"and",
"fills",
"it",
"with",
"values",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L474-L493 |
37,032 | saltstack/salt | salt/modules/syslog_ng.py | _create_and_add_parameters | 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... | python | 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",
")",
":",
"global",
"_current_parameter",
"if",
"_is_simple_type",
"(",
"params",
")",
":",
"_current_parameter",
"=",
"SimpleParameter",
"(",
"params",
")",
"_current_option",
".",
"add_parameter",
"(",
"_current_pa... | Parses the configuration and creates Parameter instances. | [
"Parses",
"the",
"configuration",
"and",
"creates",
"Parameter",
"instances",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L496-L512 |
37,033 | saltstack/salt | salt/modules/syslog_ng.py | _create_and_add_option | 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... | python | 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",
")",
":",
"global",
"_current_option",
"_current_option",
"=",
"Option",
"(",
")",
"type_",
",",
"params",
"=",
"_expand_one_key_dictionary",
"(",
"option",
")",
"_current_option",
".",
"type",
"=",
"type_",
"_create... | Parses the configuration and creates an Option instance. | [
"Parses",
"the",
"configuration",
"and",
"creates",
"an",
"Option",
"instance",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L515-L525 |
37,034 | saltstack/salt | salt/modules/syslog_ng.py | _is_reference | 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) | python | 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",
"isinstance",
"(",
"arg",
",",
"dict",
")",
"and",
"len",
"(",
"arg",
")",
"==",
"1",
"and",
"isinstance",
"(",
"next",
"(",
"six",
".",
"itervalues",
"(",
"arg",
")",
")",
",",
"six",
".",
... | Return True, if arg is a reference to a previously defined statement. | [
"Return",
"True",
"if",
"arg",
"is",
"a",
"reference",
"to",
"a",
"previously",
"defined",
"statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L536-L540 |
37,035 | saltstack/salt | salt/modules/syslog_ng.py | _is_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' | python | 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",
"isinstance",
"(",
"arg",
",",
"dict",
")",
"and",
"len",
"(",
"arg",
")",
"==",
"1",
"and",
"next",
"(",
"six",
".",
"iterkeys",
"(",
"arg",
")",
")",
"==",
"'junction'"
] | Return True, if arg is a junction statement. | [
"Return",
"True",
"if",
"arg",
"is",
"a",
"junction",
"statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L543-L547 |
37,036 | saltstack/salt | salt/modules/syslog_ng.py | _add_reference | 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) | python | 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",
")",
":",
"type_",
",",
"value",
"=",
"_expand_one_key_dictionary",
"(",
"reference",
")",
"opt",
"=",
"Option",
"(",
"type_",
")",
"param",
"=",
"SimpleParameter",
"(",
"value",
")",
"opt",
".",
... | Adds a reference to statement. | [
"Adds",
"a",
"reference",
"to",
"statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L550-L558 |
37,037 | saltstack/salt | salt/modules/syslog_ng.py | _is_inline_definition | 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) | python | 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",
")",
":",
"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. | [
"Returns",
"True",
"if",
"arg",
"is",
"an",
"inline",
"definition",
"of",
"a",
"statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L561-L565 |
37,038 | saltstack/salt | salt/modules/syslog_ng.py | _add_inline_definition | 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.... | python | 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",
")",
":",
"global",
"_current_statement",
"backup",
"=",
"_current_statement",
"type_",
",",
"options",
"=",
"_expand_one_key_dictionary",
"(",
"item",
")",
"_current_statement",
"=",
"UnnamedStatement",
... | Adds an inline definition to statement. | [
"Adds",
"an",
"inline",
"definition",
"to",
"statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L568-L580 |
37,039 | saltstack/salt | salt/modules/syslog_ng.py | _add_junction | 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... | python | 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",
")",
":",
"type_",
",",
"channels",
"=",
"_expand_one_key_dictionary",
"(",
"item",
")",
"junction",
"=",
"UnnamedStatement",
"(",
"type",
"=",
"'junction'",
")",
"for",
"item",
"in",
"channels",
":",
"type_",
",",
"value... | Adds a junction to the _current_statement. | [
"Adds",
"a",
"junction",
"to",
"the",
"_current_statement",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L583-L598 |
37,040 | saltstack/salt | salt/modules/syslog_ng.py | _parse_log_statement | 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_... | python | 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",
")",
":",
"for",
"i",
"in",
"options",
":",
"if",
"_is_reference",
"(",
"i",
")",
":",
"_add_reference",
"(",
"i",
",",
"_current_statement",
")",
"elif",
"_is_junction",
"(",
"i",
")",
":",
"_add_junction",
"... | Parses a log path. | [
"Parses",
"a",
"log",
"path",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L601-L611 |
37,041 | saltstack/salt | salt/modules/syslog_ng.py | _build_config_tree | 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... | python | 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",
")",
":",
"type_",
",",
"id_",
",",
"options",
"=",
"_get_type_id_options",
"(",
"name",
",",
"configuration",
")",
"global",
"_INDENT",
",",
"_current_statement",
"_INDENT",
"=",
"''",
"if",
"typ... | Build the configuration tree.
The root object is _current_statement. | [
"Build",
"the",
"configuration",
"tree",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L614-L633 |
37,042 | saltstack/salt | salt/modules/syslog_ng.py | config | 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
... | python | 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",
")",
":",
"_build_config_tree",
"(",
"name",
",",
"config",
")",
"configs",
"=",
"_render_configuration",
"(",
")",
"if",
"__opts__",
".",
"get",
"(",
"'test'",
",",
"False",
")",
... | 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,
... | [
"Builds",
"syslog",
"-",
"ng",
"configuration",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"the",
"state",
"module",
"users",
"should",
"not",
"use",
"it",
"directly!"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L645-L680 |
37,043 | saltstack/salt | salt/modules/syslog_ng.py | set_binary_path | 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... | python | 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",
")",
":",
"global",
"__SYSLOG_NG_BINARY_PATH",
"old",
"=",
"__SYSLOG_NG_BINARY_PATH",
"__SYSLOG_NG_BINARY_PATH",
"=",
"name",
"changes",
"=",
"_format_changes",
"(",
"old",
",",
"name",
")",
"return",
"_format_state_result",
"(",... | 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 | [
"Sets",
"the",
"path",
"where",
"the",
"syslog",
"-",
"ng",
"binary",
"can",
"be",
"found",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L683-L702 |
37,044 | saltstack/salt | salt/modules/syslog_ng.py | set_config_file | 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... | python | 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",
")",
":",
"global",
"__SYSLOG_NG_CONFIG_FILE",
"old",
"=",
"__SYSLOG_NG_CONFIG_FILE",
"__SYSLOG_NG_CONFIG_FILE",
"=",
"name",
"changes",
"=",
"_format_changes",
"(",
"old",
",",
"name",
")",
"return",
"_format_state_result",
"(",... | 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 | [
"Sets",
"the",
"configuration",
"s",
"name",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L705-L721 |
37,045 | saltstack/salt | salt/modules/syslog_ng.py | _run_command | 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) | python | 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",
")",
":",
"params",
"=",
"[",
"cmd",
"]",
"params",
".",
"extend",
"(",
"options",
")",
"return",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"params",
",",
... | Runs the command cmd with options as its CLI parameters and returns the
result as a dictionary. | [
"Runs",
"the",
"command",
"cmd",
"with",
"options",
"as",
"its",
"CLI",
"parameters",
"and",
"returns",
"the",
"result",
"as",
"a",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L738-L745 |
37,046 | saltstack/salt | salt/modules/syslog_ng.py | set_parameters | 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... | python | 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",
")",
":",
"if",
"binary_path",
":",
"set_binary_path",
"(",
"binary_path",
")",
"if",
"conf... | 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 | [
"Sets",
"variables",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L761-L785 |
37,047 | saltstack/salt | salt/modules/syslog_ng.py | _run_command_in_extended_path | 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
... | python | 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",
")",
":",
"orig_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"''",
")",
"env",
"=",
"None",
"if",
"syslog_ng_sbin_dir",
":",
"# Custom enviro... | Runs the specified command with the syslog_ng_sbin_dir in the PATH | [
"Runs",
"the",
"specified",
"command",
"with",
"the",
"syslog_ng_sbin_dir",
"in",
"the",
"PATH"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L788-L807 |
37,048 | saltstack/salt | salt/modules/syslog_ng.py | _format_return_data | 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... | python | 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",
")",
":",
"ret",
"=",
"{",
"'retcode'",
":",
"retcode",
"}",
"if",
"stdout",
"is",
"not",
"None",
":",
"ret",
"[",
"'stdout'",
"]",
"=",
"stdout",
"... | Creates a dictionary from the parameters, which can be used to return data
to Salt. | [
"Creates",
"a",
"dictionary",
"from",
"the",
"parameters",
"which",
"can",
"be",
"used",
"to",
"return",
"data",
"to",
"Salt",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L810-L820 |
37,049 | saltstack/salt | salt/modules/syslog_ng.py | version | 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.... | python | 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",
")",
":",
"try",
":",
"ret",
"=",
"_run_command_in_extended_path",
"(",
"syslog_ng_sbin_dir",
",",
"'syslog-ng'",
",",
"(",
"'-V'",
",",
")",
")",
"except",
"CommandExecutionError",
"as",
"err",
":",
"r... | 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 | [
"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",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L853-L884 |
37,050 | saltstack/salt | salt/modules/syslog_ng.py | modules | 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... | python | 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",
")",
":",
"try",
":",
"ret",
"=",
"_run_command_in_extended_path",
"(",
"syslog_ng_sbin_dir",
",",
"'syslog-ng'",
",",
"(",
"'-V'",
",",
")",
")",
"except",
"CommandExecutionError",
"as",
"err",
":",
"r... | 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 | [
"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",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L887-L917 |
37,051 | saltstack/salt | salt/modules/syslog_ng.py | stats | 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... | python | 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",
")",
":",
"try",
":",
"ret",
"=",
"_run_command_in_extended_path",
"(",
"syslog_ng_sbin_dir",
",",
"'syslog-ng-ctl'",
",",
"(",
"'stats'",
",",
")",
")",
"except",
"CommandExecutionError",
"as",
"err",
":",... | 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 | [
"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",
"-",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L920-L942 |
37,052 | saltstack/salt | salt/modules/syslog_ng.py | _format_state_result | 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} | python | 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",
"=",
"''",
")",
":",
"if",
"changes",
"is",
"None",
":",
"changes",
"=",
"{",
"'old'",
":",
"''",
",",
"'new'",
":",
"''",
"}",
"return",
"{",
"... | Creates the state result dictionary. | [
"Creates",
"the",
"state",
"result",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L949-L956 |
37,053 | saltstack/salt | salt/modules/syslog_ng.py | _add_cli_param | 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)) | python | 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",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"params",
".",
"append",
"(",
"'--{0}={1}'",
".",
"format",
"(",
"key",
",",
"value",
")",
")"
] | Adds key and value as a command line parameter to params. | [
"Adds",
"key",
"and",
"value",
"as",
"a",
"command",
"line",
"parameter",
"to",
"params",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L959-L964 |
37,054 | saltstack/salt | salt/modules/syslog_ng.py | _add_boolean_cli_param | 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)) | python | 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",
")",
":",
"if",
"value",
"is",
"True",
":",
"params",
".",
"append",
"(",
"'--{0}'",
".",
"format",
"(",
"key",
")",
")"
] | Adds key as a command line parameter to params. | [
"Adds",
"key",
"as",
"a",
"command",
"line",
"parameter",
"to",
"params",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L967-L972 |
37,055 | saltstack/salt | salt/modules/syslog_ng.py | stop | 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
... | python | 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",
")",
":",
"pids",
"=",
"__salt__",
"[",
"'ps.pgrep'",
"]",
"(",
"pattern",
"=",
"'syslog-ng'",
")",
"if",
"not",
"pids",
":",
"return",
"_format_state_result",
"(",
"name",
",",
"result",
"=",
"False",
",",
"com... | 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.... | [
"Kills",
"syslog",
"-",
"ng",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"the",
"state",
"module",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L975-L1009 |
37,056 | saltstack/salt | salt/modules/syslog_ng.py | start | 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... | python | 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",
",",
... | 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,... | [
"Ensures",
"that",
"syslog",
"-",
"ng",
"is",
"started",
"via",
"the",
"given",
"parameters",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"the",
"state",
"module",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1012-L1086 |
37,057 | saltstack/salt | salt/modules/syslog_ng.py | reload_ | 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... | python | 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",
")",
":",
"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'",
... | 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 | [
"Reloads",
"syslog",
"-",
"ng",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1089-L1114 |
37,058 | saltstack/salt | salt/modules/syslog_ng.py | write_config | 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... | python | 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",
")",
":",
"succ",
"=",
"_write_config",
"(",
"config",
",",
"newlines",
")",
"changes",
"=",
"_format_changes",
"(",
"new",
"=",
"config",
")",
"return",
"_format_state_result",
"(",
"name",
... | 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... | [
"Writes",
"the",
"given",
"parameter",
"config",
"into",
"the",
"config",
"file",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1125-L1143 |
37,059 | saltstack/salt | salt/modules/syslog_ng.py | _write_config | 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(... | python | 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",
")",
":",
"text",
"=",
"config",
"if",
"isinstance",
"(",
"config",
",",
"dict",
")",
"and",
"len",
"(",
"list",
"(",
"list",
"(",
"config",
".",
"keys",
"(",
")",
")",
")",
")",
"... | Writes the given parameter config into the config file. | [
"Writes",
"the",
"given",
"parameter",
"config",
"into",
"the",
"config",
"file",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1146-L1164 |
37,060 | saltstack/salt | salt/modules/syslog_ng.py | write_version | 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... | python | 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",
")",
":",
"line",
"=",
"'@version: {0}'",
".",
"format",
"(",
"name",
")",
"try",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"__SYSLOG_NG_CONFIG_FILE",
")",
":",
"log",
".",
"debug",
"(",
"'Removing previous conf... | 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:
... | [
"Removes",
"the",
"previous",
"configuration",
"file",
"then",
"creates",
"a",
"new",
"one",
"and",
"writes",
"the",
"name",
"line",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"from",
"states",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1167-L1203 |
37,061 | saltstack/salt | salt/modules/syslog_ng.py | Buildable.build_body | 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.... | python | 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",
")",
":",
"_increase_indent",
"(",
")",
"body_array",
"=",
"[",
"x",
".",
"build",
"(",
")",
"for",
"x",
"in",
"self",
".",
"iterable",
"]",
"nl",
"=",
"'\\n'",
"if",
"self",
".",
"append_extra_newline",
"else",
"''",
... | Builds the body of a syslog-ng configuration object. | [
"Builds",
"the",
"body",
"of",
"a",
"syslog",
"-",
"ng",
"configuration",
"object",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L130-L145 |
37,062 | saltstack/salt | salt/modules/syslog_ng.py | Buildable.build | 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 | python | 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",
")",
":",
"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. | [
"Builds",
"the",
"textual",
"representation",
"of",
"the",
"whole",
"configuration",
"object",
"with",
"it",
"s",
"children",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L147-L155 |
37,063 | saltstack/salt | salt/modules/localemod.py | _parse_dbus_locale | 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... | python | 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",
"(",
")",
":",
"bus",
"=",
"dbus",
".",
"SystemBus",
"(",
")",
"localed",
"=",
"bus",
".",
"get_object",
"(",
"'org.freedesktop.locale1'",
",",
"'/org/freedesktop/locale1'",
")",
"properties",
"=",
"dbus",
".",
"Interface",
"(",
"l... | Get the 'System Locale' parameters from dbus | [
"Get",
"the",
"System",
"Locale",
"parameters",
"from",
"dbus"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L41-L62 |
37,064 | saltstack/salt | salt/modules/localemod.py | _localectl_set | 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']... | python | 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",
"=",
"''",
")",
":",
"locale_params",
"=",
"_parse_dbus_locale",
"(",
")",
"if",
"dbus",
"is",
"not",
"None",
"else",
"_localectl_status",
"(",
")",
".",
"get",
"(",
"'system_locale'",
",",
"{",
"}",
")",
"locale_par... | Use systemd's localectl command to set the LANG locale parameter, making
sure not to trample on other params that have been set. | [
"Use",
"systemd",
"s",
"localectl",
"command",
"to",
"set",
"the",
"LANG",
"locale",
"parameter",
"making",
"sure",
"not",
"to",
"trample",
"on",
"other",
"params",
"that",
"have",
"been",
"set",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L100-L108 |
37,065 | saltstack/salt | salt/modules/localemod.py | get_locale | 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... | python | 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",
"(",
")",
":",
"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... | Get the current system locale
CLI Example:
.. code-block:: bash
salt '*' locale.get_locale | [
"Get",
"the",
"current",
"system",
"locale"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L124-L163 |
37,066 | saltstack/salt | salt/modules/localemod.py | set_locale | 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... | python | 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",
")",
":",
"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",
"(... | Sets the current system locale
CLI Example:
.. code-block:: bash
salt '*' locale.set_locale 'en_US.UTF-8' | [
"Sets",
"the",
"current",
"system",
"locale"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L166-L228 |
37,067 | saltstack/salt | salt/modules/localemod.py | avail | 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... | python | 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",
")",
":",
"try",
":",
"normalized_locale",
"=",
"salt",
".",
"utils",
".",
"locales",
".",
"normalize_locale",
"(",
"locale",
")",
"except",
"IndexError",
":",
"log",
".",
"error",
"(",
"'Unable to validate locale \"%s\"'",
",",
... | Check if a locale is available.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' locale.avail 'en_US.UTF-8' | [
"Check",
"if",
"a",
"locale",
"is",
"available",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L231-L251 |
37,068 | saltstack/salt | salt/states/heat.py | absent | 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
'... | python | 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",
")",
":",
"log",
".",
"debug",
"(",
"'Absent with (%s, %s %s)'",
",",
"name",
",",
"poll",
",",
"profile",
")",
"ret",
"=",
"{",
"'name'",
... | 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"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L284-L331 |
37,069 | saltstack/salt | salt/grains/minion_process.py | _username | def _username():
'''
Grain for the minion username
'''
if pwd:
username = pwd.getpwuid(os.getuid()).pw_name
else:
username = getpass.getuser()
return username | python | def _username():
'''
Grain for the minion username
'''
if pwd:
username = pwd.getpwuid(os.getuid()).pw_name
else:
username = getpass.getuser()
return username | [
"def",
"_username",
"(",
")",
":",
"if",
"pwd",
":",
"username",
"=",
"pwd",
".",
"getpwuid",
"(",
"os",
".",
"getuid",
"(",
")",
")",
".",
"pw_name",
"else",
":",
"username",
"=",
"getpass",
".",
"getuser",
"(",
")",
"return",
"username"
] | Grain for the minion username | [
"Grain",
"for",
"the",
"minion",
"username"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L34-L43 |
37,070 | saltstack/salt | salt/grains/minion_process.py | _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 | python | 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",
"(",
")",
":",
"if",
"grp",
":",
"try",
":",
"groupname",
"=",
"grp",
".",
"getgrgid",
"(",
"os",
".",
"getgid",
"(",
")",
")",
".",
"gr_name",
"except",
"KeyError",
":",
"groupname",
"=",
"''",
"else",
":",
"groupname",
"=",
"... | Grain for the minion groupname | [
"Grain",
"for",
"the",
"minion",
"groupname"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L55-L67 |
37,071 | saltstack/salt | salt/payload.py | unpackage | def unpackage(package_):
'''
Unpackages a payload
'''
return salt.utils.msgpack.loads(package_, use_list=True,
_msgpack_module=msgpack) | python | def unpackage(package_):
'''
Unpackages a payload
'''
return salt.utils.msgpack.loads(package_, use_list=True,
_msgpack_module=msgpack) | [
"def",
"unpackage",
"(",
"package_",
")",
":",
"return",
"salt",
".",
"utils",
".",
"msgpack",
".",
"loads",
"(",
"package_",
",",
"use_list",
"=",
"True",
",",
"_msgpack_module",
"=",
"msgpack",
")"
] | Unpackages a payload | [
"Unpackages",
"a",
"payload"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L89-L94 |
37,072 | saltstack/salt | salt/payload.py | format_payload | 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... | python | 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",
")",
":",
"payload",
"=",
"{",
"'enc'",
":",
"enc",
"}",
"load",
"=",
"{",
"}",
"for",
"key",
"in",
"kwargs",
":",
"load",
"[",
"key",
"]",
"=",
"kwargs",
"[",
"key",
"]",
"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. | [
"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",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L97-L107 |
37,073 | saltstack/salt | salt/payload.py | Serial.loads | 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... | python | 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",
")",
":",
"try",
":",
"def",
"ext_type_decoder",
"(",
"code",
",",
"data",
")",
":",
"if",
"code",
"==",
"78",
":",
"data",
"=",
"salt",
".",
"utils"... | 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... | [
"Run",
"the",
"correct",
"loads",
"serialization",
"format"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L123-L179 |
37,074 | saltstack/salt | salt/payload.py | Serial.load | 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) | python | 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_",
")",
":",
"data",
"=",
"fn_",
".",
"read",
"(",
")",
"fn_",
".",
"close",
"(",
")",
"if",
"data",
":",
"if",
"six",
".",
"PY3",
":",
"return",
"self",
".",
"loads",
"(",
"data",
",",
"encoding",
"=",
"'... | Run the correct serialization to load a file | [
"Run",
"the",
"correct",
"serialization",
"to",
"load",
"a",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L181-L191 |
37,075 | saltstack/salt | salt/payload.py | Serial.dumps | 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.
... | python | 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",
")",
":",
"def",
"ext_type_encoder",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"six",
".",
"integer_types",
")",
":",
"# msgpack can't handle the very long Python long... | 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, ... | [
"Run",
"the",
"correct",
"dumps",
"serialization",
"format"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L193-L272 |
37,076 | saltstack/salt | salt/payload.py | Serial.dump | 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
... | python | 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_",
")",
":",
"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... | Serialize the correct data into the named file object | [
"Serialize",
"the",
"correct",
"data",
"into",
"the",
"named",
"file",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L274-L285 |
37,077 | saltstack/salt | salt/payload.py | SREQ.socket | 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... | python | 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",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_socket'",
")",
":",
"# create a new one",
"self",
".",
"_socket",
"=",
"self",
".",
"context",
".",
"socket",
"(",
"zmq",
".",
"REQ",
")",
"if",
"hasattr",
"(",
"zmq... | Lazily create the socket. | [
"Lazily",
"create",
"the",
"socket",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L302-L325 |
37,078 | saltstack/salt | salt/payload.py | SREQ.clear_socket | 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... | python | 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",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_socket'",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"poller",
".",
"sockets",
",",
"dict",
")",
":",
"sockets",
"=",
"list",
"(",
"self",
".",
"poller",
".",
... | delete socket if you have it | [
"delete",
"socket",
"if",
"you",
"have",
"it"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L346-L360 |
37,079 | saltstack/salt | salt/payload.py | SREQ.send | 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... | python | 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",
")",
":",
"payload",
"=",
"{",
"'enc'",
":",
"enc",
"}",
"payload",
"[",
"'load'",
"]",
"=",
"load",
"pkg",
"=",
"self",
".",
"serial",
".",... | Takes two arguments, the encryption type and the base payload | [
"Takes",
"two",
"arguments",
"the",
"encryption",
"type",
"and",
"the",
"base",
"payload"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L362-L388 |
37,080 | saltstack/salt | salt/payload.py | SREQ.send_auto | 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) | python | 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",
")",
":",
"enc",
"=",
"payload",
".",
"get",
"(",
"'enc'",
",",
"'clear'",
")",
"load",
"=",
"payload",
".",
"get",
"(",
"'load'",
",",
"{",
"}",
... | Detect the encryption type based on the payload | [
"Detect",
"the",
"encryption",
"type",
"based",
"on",
"the",
"payload"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L390-L396 |
37,081 | saltstack/salt | salt/states/lxd_profile.py | present | 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... | python | 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 dict or None (None = unset).
Can also be a list:
[{'key': 'boot.autostart', 'value': 1},
{'key': 'security.privile... | [
"Creates",
"or",
"updates",
"LXD",
"profiles"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxd_profile.py#L51-L192 |
37,082 | saltstack/salt | salt/states/lxd_profile.py | absent | 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... | python | 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",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'remote_addr'",
":",
"remote_addr",
",",
"'cert... | 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... | [
"Ensure",
"a",
"LXD",
"profile",
"is",
"not",
"present",
"removing",
"it",
"if",
"present",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxd_profile.py#L195-L273 |
37,083 | saltstack/salt | salt/modules/freebsdkmod.py | _get_persistent_modules | 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()
... | python | 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",
"(",
")",
":",
"mods",
"=",
"set",
"(",
")",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"_LOADER_CONF",
",",
"'r'",
")",
"as",
"loader_conf",
":",
"for",
"line",
"in",
"loader_conf",
":",
"line",
"=... | Returns a list of modules in loader.conf that load on boot. | [
"Returns",
"a",
"list",
"of",
"modules",
"in",
"loader",
".",
"conf",
"that",
"load",
"on",
"boot",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L68-L80 |
37,084 | saltstack/salt | salt/modules/freebsdkmod.py | _set_persistent_module | 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]) | python | 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",
")",
":",
"if",
"not",
"mod",
"or",
"mod",
"in",
"mod_list",
"(",
"True",
")",
"or",
"mod",
"not",
"in",
"available",
"(",
")",
":",
"return",
"set",
"(",
")",
"__salt__",
"[",
"'file.append'",
"]",
"(",
"... | Add a module to loader.conf to make it persistent. | [
"Add",
"a",
"module",
"to",
"loader",
".",
"conf",
"to",
"make",
"it",
"persistent",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L83-L91 |
37,085 | saltstack/salt | salt/modules/freebsdkmod.py | _remove_persistent_module | 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:
... | python | 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",
")",
":",
"if",
"not",
"mod",
"or",
"mod",
"not",
"in",
"mod_list",
"(",
"True",
")",
":",
"return",
"set",
"(",
")",
"if",
"comment",
":",
"__salt__",
"[",
"'file.comment'",
"]",
"(",
"_L... | Remove module from loader.conf. If comment is true only comment line where
module is. | [
"Remove",
"module",
"from",
"loader",
".",
"conf",
".",
"If",
"comment",
"is",
"true",
"only",
"comment",
"line",
"where",
"module",
"is",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L94-L107 |
37,086 | saltstack/salt | salt/modules/freebsdkmod.py | lsmod | 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:
... | python | 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",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'kldstat'",
")",
".",
"splitlines",
"(",
")",
":",
"comps",
"=",
"line",
".",
"split",
"(",
")",
"if",
"not",
"len",
"(",
"comps",
... | Return a dict containing information about currently loaded modules
CLI Example:
.. code-block:: bash
salt '*' kmod.lsmod | [
"Return",
"a",
"dict",
"containing",
"information",
"about",
"currently",
"loaded",
"modules"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L143-L167 |
37,087 | saltstack/salt | salt/modules/freebsdkmod.py | remove | 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... | python | 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",
")",
":",
"pre_mods",
"=",
"lsmod",
"(",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'kldunload {0}'",
".",
"format",
"(",
"mod",
")",
",",
"pyt... | 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... | [
"Remove",
"the",
"specified",
"kernel",
"module"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/freebsdkmod.py#L242-L273 |
37,088 | saltstack/salt | salt/modules/serverdensity_device.py | get_sd_auth | 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... | python | 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'",
")",
":",
"sd_pillar",
"=",
"__pillar__",
".",
"get",
"(",
"sd_auth_pillar_name",
")",
"log",
".",
"debug",
"(",
"'Server Density Pillar: %s'",
",",
"sd_pillar",
")",
"if",
"no... | Returns requested Server Density authentication value from pillar.
CLI Example:
.. code-block:: bash
salt '*' serverdensity_device.get_sd_auth <val> | [
"Returns",
"requested",
"Server",
"Density",
"authentication",
"value",
"from",
"pillar",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L43-L65 |
37,089 | saltstack/salt | salt/modules/serverdensity_device.py | _clean_salt_variables | 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 | python | 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",
"=",
"\"__\"",
")",
":",
"list",
"(",
"list",
"(",
"map",
"(",
"params",
".",
"pop",
",",
"[",
"k",
"for",
"k",
"in",
"params",
"if",
"k",
".",
"startswith",
"(",
"variable_prefix",
... | Pops out variables from params which starts with `variable_prefix`. | [
"Pops",
"out",
"variables",
"from",
"params",
"which",
"starts",
"with",
"variable_prefix",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L68-L73 |
37,090 | saltstack/salt | salt/modules/serverdensity_device.py | ls | 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... | python | 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",
")",
":",
"params",
"=",
"_clean_salt_variables",
"(",
"params",
")",
"endpoint",
"=",
"'devices'",
"# Change endpoint if there are params to filter by:",
"if",
"params",
":",
"endpoint",
"=",
"'resources'",
"# Convert all ints to... | 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/... | [
"List",
"devices",
"in",
"Server",
"Density"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/serverdensity_device.py#L144-L193 |
37,091 | saltstack/salt | salt/cache/etcd_cache.py | _init_client | 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... | python | 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",
"(",
")",
":",
"global",
"client",
",",
"path_prefix",
"if",
"client",
"is",
"not",
"None",
":",
"return",
"etcd_kwargs",
"=",
"{",
"'host'",
":",
"__opts__",
".",
"get",
"(",
"'etcd.host'",
",",
"'127.0.0.1'",
")",
",",
"'port'",
... | Setup client and init datastore. | [
"Setup",
"client",
"and",
"init",
"datastore",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/etcd_cache.py#L90-L119 |
37,092 | saltstack/salt | salt/modules/udev.py | _parse_udevadm_info | def _parse_udevadm_info(udev_info):
'''
Parse the info returned by udevadm command.
'''
devices = []
dev = {}
for line in (line.strip() for line in udev_info.splitlines()):
if line:
line = line.split(':', 1)
if len(line) != 2:
continue
... | python | def _parse_udevadm_info(udev_info):
'''
Parse the info returned by udevadm command.
'''
devices = []
dev = {}
for line in (line.strip() for line in udev_info.splitlines()):
if line:
line = line.split(':', 1)
if len(line) != 2:
continue
... | [
"def",
"_parse_udevadm_info",
"(",
"udev_info",
")",
":",
"devices",
"=",
"[",
"]",
"dev",
"=",
"{",
"}",
"for",
"line",
"in",
"(",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"udev_info",
".",
"splitlines",
"(",
")",
")",
":",
"if",
"line... | Parse the info returned by udevadm command. | [
"Parse",
"the",
"info",
"returned",
"by",
"udevadm",
"command",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/udev.py#L31-L70 |
37,093 | saltstack/salt | salt/modules/udev.py | _normalize_info | def _normalize_info(dev):
'''
Replace list with only one element to the value of the element.
:param dev:
:return:
'''
for sect, val in dev.items():
if len(val) == 1:
dev[sect] = val[0]
return dev | python | def _normalize_info(dev):
'''
Replace list with only one element to the value of the element.
:param dev:
:return:
'''
for sect, val in dev.items():
if len(val) == 1:
dev[sect] = val[0]
return dev | [
"def",
"_normalize_info",
"(",
"dev",
")",
":",
"for",
"sect",
",",
"val",
"in",
"dev",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"val",
")",
"==",
"1",
":",
"dev",
"[",
"sect",
"]",
"=",
"val",
"[",
"0",
"]",
"return",
"dev"
] | Replace list with only one element to the value of the element.
:param dev:
:return: | [
"Replace",
"list",
"with",
"only",
"one",
"element",
"to",
"the",
"value",
"of",
"the",
"element",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/udev.py#L73-L84 |
37,094 | saltstack/salt | salt/modules/udev.py | info | def info(dev):
'''
Extract all info delivered by udevadm
CLI Example:
.. code-block:: bash
salt '*' udev.info /dev/sda
salt '*' udev.info /sys/class/net/eth0
'''
if 'sys' in dev:
qtype = 'path'
else:
qtype = 'name'
cmd = 'udevadm info --export --query=... | python | def info(dev):
'''
Extract all info delivered by udevadm
CLI Example:
.. code-block:: bash
salt '*' udev.info /dev/sda
salt '*' udev.info /sys/class/net/eth0
'''
if 'sys' in dev:
qtype = 'path'
else:
qtype = 'name'
cmd = 'udevadm info --export --query=... | [
"def",
"info",
"(",
"dev",
")",
":",
"if",
"'sys'",
"in",
"dev",
":",
"qtype",
"=",
"'path'",
"else",
":",
"qtype",
"=",
"'name'",
"cmd",
"=",
"'udevadm info --export --query=all --{0}={1}'",
".",
"format",
"(",
"qtype",
",",
"dev",
")",
"udev_result",
"="... | Extract all info delivered by udevadm
CLI Example:
.. code-block:: bash
salt '*' udev.info /dev/sda
salt '*' udev.info /sys/class/net/eth0 | [
"Extract",
"all",
"info",
"delivered",
"by",
"udevadm"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/udev.py#L87-L109 |
37,095 | saltstack/salt | salt/modules/udev.py | exportdb | def exportdb():
'''
Return all the udev database
CLI Example:
.. code-block:: bash
salt '*' udev.exportdb
'''
cmd = 'udevadm info --export-db'
udev_result = __salt__['cmd.run_all'](cmd, output_loglevel='quiet')
if udev_result['retcode']:
raise CommandExecutionError(u... | python | def exportdb():
'''
Return all the udev database
CLI Example:
.. code-block:: bash
salt '*' udev.exportdb
'''
cmd = 'udevadm info --export-db'
udev_result = __salt__['cmd.run_all'](cmd, output_loglevel='quiet')
if udev_result['retcode']:
raise CommandExecutionError(u... | [
"def",
"exportdb",
"(",
")",
":",
"cmd",
"=",
"'udevadm info --export-db'",
"udev_result",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'quiet'",
")",
"if",
"udev_result",
"[",
"'retcode'",
"]",
":",
"raise",
"CommandEx... | Return all the udev database
CLI Example:
.. code-block:: bash
salt '*' udev.exportdb | [
"Return",
"all",
"the",
"udev",
"database"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/udev.py#L168-L185 |
37,096 | saltstack/salt | salt/modules/mac_timezone.py | get_date | def get_date():
'''
Displays the current date
:return: the system date
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_date
'''
ret = salt.utils.mac_utils.execute_return_result('systemsetup -getdate')
return salt.utils.mac_utils.parse_return(ret) | python | def get_date():
'''
Displays the current date
:return: the system date
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_date
'''
ret = salt.utils.mac_utils.execute_return_result('systemsetup -getdate')
return salt.utils.mac_utils.parse_return(ret) | [
"def",
"get_date",
"(",
")",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"execute_return_result",
"(",
"'systemsetup -getdate'",
")",
"return",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"parse_return",
"(",
"ret",
")"
] | Displays the current date
:return: the system date
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_date | [
"Displays",
"the",
"current",
"date"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_timezone.py#L61-L75 |
37,097 | saltstack/salt | salt/modules/mac_timezone.py | set_date | def set_date(date):
'''
Set the current month, day, and year
:param str date: The date to set. Valid date formats are:
- %m:%d:%y
- %m:%d:%Y
- %m/%d/%y
- %m/%d/%Y
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Da... | python | def set_date(date):
'''
Set the current month, day, and year
:param str date: The date to set. Valid date formats are:
- %m:%d:%y
- %m:%d:%Y
- %m/%d/%y
- %m/%d/%Y
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Da... | [
"def",
"set_date",
"(",
"date",
")",
":",
"date_format",
"=",
"_get_date_time_format",
"(",
"date",
")",
"dt_obj",
"=",
"datetime",
".",
"strptime",
"(",
"date",
",",
"date_format",
")",
"cmd",
"=",
"'systemsetup -setdate {0}'",
".",
"format",
"(",
"dt_obj",
... | Set the current month, day, and year
:param str date: The date to set. Valid date formats are:
- %m:%d:%y
- %m:%d:%Y
- %m/%d/%y
- %m/%d/%Y
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Date format
:raises: CommandEx... | [
"Set",
"the",
"current",
"month",
"day",
"and",
"year"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_timezone.py#L78-L105 |
37,098 | saltstack/salt | salt/modules/mac_timezone.py | get_time | def get_time():
'''
Get the current system time.
:return: The current time in 24 hour format
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_time
'''
ret = salt.utils.mac_utils.execute_return_result('systemsetup -gettime')
return salt.utils.mac_utils.p... | python | def get_time():
'''
Get the current system time.
:return: The current time in 24 hour format
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_time
'''
ret = salt.utils.mac_utils.execute_return_result('systemsetup -gettime')
return salt.utils.mac_utils.p... | [
"def",
"get_time",
"(",
")",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"execute_return_result",
"(",
"'systemsetup -gettime'",
")",
"return",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"parse_return",
"(",
"ret",
")"
] | Get the current system time.
:return: The current time in 24 hour format
:rtype: str
CLI Example:
.. code-block:: bash
salt '*' timezone.get_time | [
"Get",
"the",
"current",
"system",
"time",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_timezone.py#L108-L122 |
37,099 | saltstack/salt | salt/modules/mac_timezone.py | set_time | def set_time(time):
'''
Sets the current time. Must be in 24 hour format.
:param str time: The time to set in 24 hour format. The value must be
double quoted. ie: '"17:46"'
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Time format
... | python | def set_time(time):
'''
Sets the current time. Must be in 24 hour format.
:param str time: The time to set in 24 hour format. The value must be
double quoted. ie: '"17:46"'
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Time format
... | [
"def",
"set_time",
"(",
"time",
")",
":",
"# time must be double quoted '\"17:46\"'",
"time_format",
"=",
"_get_date_time_format",
"(",
"time",
")",
"dt_obj",
"=",
"datetime",
".",
"strptime",
"(",
"time",
",",
"time_format",
")",
"cmd",
"=",
"'systemsetup -settime ... | Sets the current time. Must be in 24 hour format.
:param str time: The time to set in 24 hour format. The value must be
double quoted. ie: '"17:46"'
:return: True if successful, False if not
:rtype: bool
:raises: SaltInvocationError on Invalid Time format
:raises: CommandExecutionError o... | [
"Sets",
"the",
"current",
"time",
".",
"Must",
"be",
"in",
"24",
"hour",
"format",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_timezone.py#L125-L149 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.