partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _set_labels | Replace labels dict by a new one | salt/modules/k8s.py | def _set_labels(node, apiserver_url, labels):
'''Replace labels dict by a new one'''
# Prepare URL
url = "{0}/api/v1/nodes/{1}".format(apiserver_url, node)
# Prepare data
data = [{"op": "replace", "path": "/metadata/labels", "value": labels}]
# Make request
ret = _kpatch(url, data)
if re... | def _set_labels(node, apiserver_url, labels):
'''Replace labels dict by a new one'''
# Prepare URL
url = "{0}/api/v1/nodes/{1}".format(apiserver_url, node)
# Prepare data
data = [{"op": "replace", "path": "/metadata/labels", "value": labels}]
# Make request
ret = _kpatch(url, data)
if re... | [
"Replace",
"labels",
"dict",
"by",
"a",
"new",
"one"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L197-L207 | [
"def",
"_set_labels",
"(",
"node",
",",
"apiserver_url",
",",
"labels",
")",
":",
"# Prepare URL",
"url",
"=",
"\"{0}/api/v1/nodes/{1}\"",
".",
"format",
"(",
"apiserver_url",
",",
"node",
")",
"# Prepare data",
"data",
"=",
"[",
"{",
"\"op\"",
":",
"\"replace... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_labels | .. versionadded:: 2016.3.0
Get labels from the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.get_labels
salt '*' k8s.get_labels kube-node.cluster.local http://kube-master.cluster.local | salt/modules/k8s.py | def get_labels(node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get labels from the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.get_labels
salt '*' k8s.get_labels kube-node.cluster.local http://kube-master.cluster.local
'''
# Get salt minion... | def get_labels(node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get labels from the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.get_labels
salt '*' k8s.get_labels kube-node.cluster.local http://kube-master.cluster.local
'''
# Get salt minion... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L210-L234 | [
"def",
"get_labels",
"(",
"node",
"=",
"None",
",",
"apiserver_url",
"=",
"None",
")",
":",
"# Get salt minion ID",
"node",
"=",
"_guess_node_id",
"(",
"node",
")",
"# Try to get kubernetes master",
"apiserver_url",
"=",
"_guess_apiserver",
"(",
"apiserver_url",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | label_present | .. versionadded:: 2016.3.0
Set label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_present hw/disktype ssd
salt '*' k8s.label_present hw/disktype ssd kube-node.cluster.local http://kube-master.cluster.local | salt/modules/k8s.py | def label_present(name, value, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Set label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_present hw/disktype ssd
salt '*' k8s.label_present hw/disktype ssd kube-node.cluster.local http://kube... | def label_present(name, value, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Set label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_present hw/disktype ssd
salt '*' k8s.label_present hw/disktype ssd kube-node.cluster.local http://kube... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L237-L292 | [
"def",
"label_present",
"(",
"name",
",",
"value",
",",
"node",
"=",
"None",
",",
"apiserver_url",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | label_absent | .. versionadded:: 2016.3.0
Delete label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_absent hw/disktype
salt '*' k8s.label_absent hw/disktype kube-node.cluster.local http://kube-master.cluster.local | salt/modules/k8s.py | def label_absent(name, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Delete label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_absent hw/disktype
salt '*' k8s.label_absent hw/disktype kube-node.cluster.local http://kube-master.cluster.... | def label_absent(name, node=None, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Delete label to the current node
CLI Example:
.. code-block:: bash
salt '*' k8s.label_absent hw/disktype
salt '*' k8s.label_absent hw/disktype kube-node.cluster.local http://kube-master.cluster.... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L295-L339 | [
"def",
"label_absent",
"(",
"name",
",",
"node",
"=",
"None",
",",
"apiserver_url",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"# G... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_namespaces | Get namespace is namespace is defined otherwise return all namespaces | salt/modules/k8s.py | def _get_namespaces(apiserver_url, name=""):
'''Get namespace is namespace is defined otherwise return all namespaces'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}".format(apiserver_url, name)
# Make request
ret = http.query(url)
if ret.get("body"):
return salt.utils.json.loads(ret.g... | def _get_namespaces(apiserver_url, name=""):
'''Get namespace is namespace is defined otherwise return all namespaces'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}".format(apiserver_url, name)
# Make request
ret = http.query(url)
if ret.get("body"):
return salt.utils.json.loads(ret.g... | [
"Get",
"namespace",
"is",
"namespace",
"is",
"defined",
"otherwise",
"return",
"all",
"namespaces"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L390-L399 | [
"def",
"_get_namespaces",
"(",
"apiserver_url",
",",
"name",
"=",
"\"\"",
")",
":",
"# Prepare URL",
"url",
"=",
"\"{0}/api/v1/namespaces/{1}\"",
".",
"format",
"(",
"apiserver_url",
",",
"name",
")",
"# Make request",
"ret",
"=",
"http",
".",
"query",
"(",
"u... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _create_namespace | create namespace on the defined k8s cluster | salt/modules/k8s.py | def _create_namespace(namespace, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces".format(apiserver_url)
# Prepare data
data = {
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": namespace,... | def _create_namespace(namespace, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces".format(apiserver_url)
# Prepare data
data = {
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": namespace,... | [
"create",
"namespace",
"on",
"the",
"defined",
"k8s",
"cluster"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L402-L419 | [
"def",
"_create_namespace",
"(",
"namespace",
",",
"apiserver_url",
")",
":",
"# Prepare URL",
"url",
"=",
"\"{0}/api/v1/namespaces\"",
".",
"format",
"(",
"apiserver_url",
")",
"# Prepare data",
"data",
"=",
"{",
"\"kind\"",
":",
"\"Namespace\"",
",",
"\"apiVersion... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_namespace | .. versionadded:: 2016.3.0
Create kubernetes namespace from the name, similar to the functionality added to kubectl since v.1.2.0:
.. code-block:: bash
kubectl create namespaces namespace-name
CLI Example:
.. code-block:: bash
salt '*' k8s.create_namespace namespace_name
sa... | salt/modules/k8s.py | def create_namespace(name, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Create kubernetes namespace from the name, similar to the functionality added to kubectl since v.1.2.0:
.. code-block:: bash
kubectl create namespaces namespace-name
CLI Example:
.. code-block:: bash
... | def create_namespace(name, apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Create kubernetes namespace from the name, similar to the functionality added to kubectl since v.1.2.0:
.. code-block:: bash
kubectl create namespaces namespace-name
CLI Example:
.. code-block:: bash
... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L422-L454 | [
"def",
"create_namespace",
"(",
"name",
",",
"apiserver_url",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"# Try to get kubernetes master",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_namespaces | .. versionadded:: 2016.3.0
Get one or all kubernetes namespaces.
If namespace parameter is omitted, all namespaces will be returned back to user, similar to following kubectl example:
.. code-block:: bash
kubectl get namespaces -o json
In case namespace is set by user, the output will be si... | salt/modules/k8s.py | def get_namespaces(namespace="", apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get one or all kubernetes namespaces.
If namespace parameter is omitted, all namespaces will be returned back to user, similar to following kubectl example:
.. code-block:: bash
kubectl get namespaces -o... | def get_namespaces(namespace="", apiserver_url=None):
'''
.. versionadded:: 2016.3.0
Get one or all kubernetes namespaces.
If namespace parameter is omitted, all namespaces will be returned back to user, similar to following kubectl example:
.. code-block:: bash
kubectl get namespaces -o... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L457-L491 | [
"def",
"get_namespaces",
"(",
"namespace",
"=",
"\"\"",
",",
"apiserver_url",
"=",
"None",
")",
":",
"# Try to get kubernetes master",
"apiserver_url",
"=",
"_guess_apiserver",
"(",
"apiserver_url",
")",
"if",
"apiserver_url",
"is",
"None",
":",
"return",
"False",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _update_secret | Replace secrets data by a new one | salt/modules/k8s.py | def _update_secret(namespace, name, data, apiserver_url):
'''Replace secrets data by a new one'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets/{2}".format(apiserver_url,
namespace, name)
# Prepare data
data = [{"op": "replace", "path... | def _update_secret(namespace, name, data, apiserver_url):
'''Replace secrets data by a new one'''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets/{2}".format(apiserver_url,
namespace, name)
# Prepare data
data = [{"op": "replace", "path... | [
"Replace",
"secrets",
"data",
"by",
"a",
"new",
"one"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L508-L519 | [
"def",
"_update_secret",
"(",
"namespace",
",",
"name",
",",
"data",
",",
"apiserver_url",
")",
":",
"# Prepare URL",
"url",
"=",
"\"{0}/api/v1/namespaces/{1}/secrets/{2}\"",
".",
"format",
"(",
"apiserver_url",
",",
"namespace",
",",
"name",
")",
"# Prepare data",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _create_secret | create namespace on the defined k8s cluster | salt/modules/k8s.py | def _create_secret(namespace, name, data, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets".format(apiserver_url, namespace)
# Prepare data
request = {
"apiVersion": "v1",
"kind": "Secret",
"metadata": ... | def _create_secret(namespace, name, data, apiserver_url):
''' create namespace on the defined k8s cluster '''
# Prepare URL
url = "{0}/api/v1/namespaces/{1}/secrets".format(apiserver_url, namespace)
# Prepare data
request = {
"apiVersion": "v1",
"kind": "Secret",
"metadata": ... | [
"create",
"namespace",
"on",
"the",
"defined",
"k8s",
"cluster"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L522-L538 | [
"def",
"_create_secret",
"(",
"namespace",
",",
"name",
",",
"data",
",",
"apiserver_url",
")",
":",
"# Prepare URL",
"url",
"=",
"\"{0}/api/v1/namespaces/{1}/secrets\"",
".",
"format",
"(",
"apiserver_url",
",",
"namespace",
")",
"# Prepare data",
"request",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_secrets | Get k8s namespaces
CLI Example:
.. code-block:: bash
salt '*' k8s.get_secrets namespace_name
salt '*' k8s.get_secrets namespace_name secret_name http://kube-master.cluster.local | salt/modules/k8s.py | def get_secrets(namespace, name="", apiserver_url=None, decode=False, brief=False):
'''
Get k8s namespaces
CLI Example:
.. code-block:: bash
salt '*' k8s.get_secrets namespace_name
salt '*' k8s.get_secrets namespace_name secret_name http://kube-master.cluster.local
'''
# Try ... | def get_secrets(namespace, name="", apiserver_url=None, decode=False, brief=False):
'''
Get k8s namespaces
CLI Example:
.. code-block:: bash
salt '*' k8s.get_secrets namespace_name
salt '*' k8s.get_secrets namespace_name secret_name http://kube-master.cluster.local
'''
# Try ... | [
"Get",
"k8s",
"namespaces"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L571-L593 | [
"def",
"get_secrets",
"(",
"namespace",
",",
"name",
"=",
"\"\"",
",",
"apiserver_url",
"=",
"None",
",",
"decode",
"=",
"False",
",",
"brief",
"=",
"False",
")",
":",
"# Try to get kubernetes master",
"apiserver_url",
"=",
"_guess_apiserver",
"(",
"apiserver_ur... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | update_secret | .. versionadded:: 2016.3.0
alias to k8s.create_secret with update=true
CLI Example:
.. code-block:: bash
salt '*' k8s.update_secret namespace_name secret_name sources [apiserver_url] [force=true] [update=false] [saltenv='base']
sources are either dictionary of {name: path, name1: path} pair... | salt/modules/k8s.py | def update_secret(namespace, name, sources, apiserver_url=None, force=True, saltenv='base'):
'''
.. versionadded:: 2016.3.0
alias to k8s.create_secret with update=true
CLI Example:
.. code-block:: bash
salt '*' k8s.update_secret namespace_name secret_name sources [apiserver_url] [force=t... | def update_secret(namespace, name, sources, apiserver_url=None, force=True, saltenv='base'):
'''
.. versionadded:: 2016.3.0
alias to k8s.create_secret with update=true
CLI Example:
.. code-block:: bash
salt '*' k8s.update_secret namespace_name secret_name sources [apiserver_url] [force=t... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L623-L664 | [
"def",
"update_secret",
"(",
"namespace",
",",
"name",
",",
"sources",
",",
"apiserver_url",
"=",
"None",
",",
"force",
"=",
"True",
",",
"saltenv",
"=",
"'base'",
")",
":",
"apiserver_url",
"=",
"_guess_apiserver",
"(",
"apiserver_url",
")",
"ret",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_secret | .. versionadded:: 2016.3.0
Create k8s secrets in the defined namespace from the list of files
CLI Example:
.. code-block:: bash
salt '*' k8s.create_secret namespace_name secret_name sources
salt '*' k8s.create_secret namespace_name secret_name sources
http://kube-master.cluster.... | salt/modules/k8s.py | def create_secret(namespace, name, sources, apiserver_url=None, force=False, update=False, saltenv='base'):
'''
.. versionadded:: 2016.3.0
Create k8s secrets in the defined namespace from the list of files
CLI Example:
.. code-block:: bash
salt '*' k8s.create_secret namespace_name secret... | def create_secret(namespace, name, sources, apiserver_url=None, force=False, update=False, saltenv='base'):
'''
.. versionadded:: 2016.3.0
Create k8s secrets in the defined namespace from the list of files
CLI Example:
.. code-block:: bash
salt '*' k8s.create_secret namespace_name secret... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L667-L774 | [
"def",
"create_secret",
"(",
"namespace",
",",
"name",
",",
"sources",
",",
"apiserver_url",
"=",
"None",
",",
"force",
"=",
"False",
",",
"update",
"=",
"False",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete_secret | .. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt '*' k8s.delete_secret namespace_name secret_name
salt '*' k8s.delete_secret namespace_name secret_name http://kube-m... | salt/modules/k8s.py | def delete_secret(namespace, name, apiserver_url=None, force=True):
'''
.. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt '*' k8s.delete_secret namespace_name secret_n... | def delete_secret(namespace, name, apiserver_url=None, force=True):
'''
.. versionadded:: 2016.3.0
Delete kubernetes secret in the defined namespace. Namespace is the mandatory parameter as well as name.
CLI Example:
.. code-block:: bash
salt '*' k8s.delete_secret namespace_name secret_n... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/k8s.py#L777-L811 | [
"def",
"delete_secret",
"(",
"namespace",
",",
"name",
",",
"apiserver_url",
"=",
"None",
",",
"force",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_pillar | Return the correct pillar driver based on the file_client option | salt/pillar/__init__.py | def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None, extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
file_client = opts['file_client']
if opts.get('master_type') == 'disable'... | def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None, extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
file_client = opts['file_client']
if opts.get('master_type') == 'disable'... | [
"Return",
"the",
"correct",
"pillar",
"driver",
"based",
"on",
"the",
"file_client",
"option"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L45-L66 | [
"def",
"get_pillar",
"(",
"opts",
",",
"grains",
",",
"minion_id",
",",
"saltenv",
"=",
"None",
",",
"ext",
"=",
"None",
",",
"funcs",
"=",
"None",
",",
"pillar_override",
"=",
"None",
",",
"pillarenv",
"=",
"None",
",",
"extra_minion_data",
"=",
"None",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_async_pillar | Return the correct pillar driver based on the file_client option | salt/pillar/__init__.py | def get_async_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None,
extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
file_client = opts['file_client']
if opt... | def get_async_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar_override=None, pillarenv=None,
extra_minion_data=None):
'''
Return the correct pillar driver based on the file_client option
'''
file_client = opts['file_client']
if opt... | [
"Return",
"the",
"correct",
"pillar",
"driver",
"based",
"on",
"the",
"file_client",
"option"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L70-L85 | [
"def",
"get_async_pillar",
"(",
"opts",
",",
"grains",
",",
"minion_id",
",",
"saltenv",
"=",
"None",
",",
"ext",
"=",
"None",
",",
"funcs",
"=",
"None",
",",
"pillar_override",
"=",
"None",
",",
"pillarenv",
"=",
"None",
",",
"extra_minion_data",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | RemotePillarMixin.get_ext_pillar_extra_minion_data | Returns the extra data from the minion's opts dict (the config file).
This data will be passed to external pillar functions. | salt/pillar/__init__.py | def get_ext_pillar_extra_minion_data(self, opts):
'''
Returns the extra data from the minion's opts dict (the config file).
This data will be passed to external pillar functions.
'''
def get_subconfig(opts_key):
'''
Returns a dict containing the opts key ... | def get_ext_pillar_extra_minion_data(self, opts):
'''
Returns the extra data from the minion's opts dict (the config file).
This data will be passed to external pillar functions.
'''
def get_subconfig(opts_key):
'''
Returns a dict containing the opts key ... | [
"Returns",
"the",
"extra",
"data",
"from",
"the",
"minion",
"s",
"opts",
"dict",
"(",
"the",
"config",
"file",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L92-L131 | [
"def",
"get_ext_pillar_extra_minion_data",
"(",
"self",
",",
"opts",
")",
":",
"def",
"get_subconfig",
"(",
"opts_key",
")",
":",
"'''\n Returns a dict containing the opts key subtree, while maintaining\n the opts structure\n '''",
"ret_dict",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | AsyncRemotePillar.compile_pillar | Return a future which will contain the pillar data from the master | salt/pillar/__init__.py | def compile_pillar(self):
'''
Return a future which will contain the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillarenv': self.opts['pillarenv'],
... | def compile_pillar(self):
'''
Return a future which will contain the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillarenv': self.opts['pillarenv'],
... | [
"Return",
"a",
"future",
"which",
"will",
"contain",
"the",
"pillar",
"data",
"from",
"the",
"master"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L163-L192 | [
"def",
"compile_pillar",
"(",
"self",
")",
":",
"load",
"=",
"{",
"'id'",
":",
"self",
".",
"minion_id",
",",
"'grains'",
":",
"self",
".",
"grains",
",",
"'saltenv'",
":",
"self",
".",
"opts",
"[",
"'saltenv'",
"]",
",",
"'pillarenv'",
":",
"self",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | RemotePillar.compile_pillar | Return the pillar data from the master | salt/pillar/__init__.py | def compile_pillar(self):
'''
Return the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillarenv': self.opts['pillarenv'],
'pillar_override': self.pill... | def compile_pillar(self):
'''
Return the pillar data from the master
'''
load = {'id': self.minion_id,
'grains': self.grains,
'saltenv': self.opts['saltenv'],
'pillarenv': self.opts['pillarenv'],
'pillar_override': self.pill... | [
"Return",
"the",
"pillar",
"data",
"from",
"the",
"master"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L233-L257 | [
"def",
"compile_pillar",
"(",
"self",
")",
":",
"load",
"=",
"{",
"'id'",
":",
"self",
".",
"minion_id",
",",
"'grains'",
":",
"self",
".",
"grains",
",",
"'saltenv'",
":",
"self",
".",
"opts",
"[",
"'saltenv'",
"]",
",",
"'pillarenv'",
":",
"self",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | PillarCache.fetch_pillar | In the event of a cache miss, we need to incur the overhead of caching
a new pillar. | salt/pillar/__init__.py | def fetch_pillar(self):
'''
In the event of a cache miss, we need to incur the overhead of caching
a new pillar.
'''
log.debug('Pillar cache getting external pillar with ext: %s', self.ext)
fresh_pillar = Pillar(self.opts,
self.grains,
... | def fetch_pillar(self):
'''
In the event of a cache miss, we need to incur the overhead of caching
a new pillar.
'''
log.debug('Pillar cache getting external pillar with ext: %s', self.ext)
fresh_pillar = Pillar(self.opts,
self.grains,
... | [
"In",
"the",
"event",
"of",
"a",
"cache",
"miss",
"we",
"need",
"to",
"incur",
"the",
"overhead",
"of",
"caching",
"a",
"new",
"pillar",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L318-L331 | [
"def",
"fetch_pillar",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Pillar cache getting external pillar with ext: %s'",
",",
"self",
".",
"ext",
")",
"fresh_pillar",
"=",
"Pillar",
"(",
"self",
".",
"opts",
",",
"self",
".",
"grains",
",",
"self",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | PillarCache.compile_pillar | Compile pillar and set it to the cache, if not found.
:param args:
:param kwargs:
:return: | salt/pillar/__init__.py | def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dirs
'''
Compile pillar and set it to the cache, if not found.
:param args:
:param kwargs:
:return:
'''
log.debug('Scanning pillar cache for information about minion %s and pillarenv %s', se... | def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dirs
'''
Compile pillar and set it to the cache, if not found.
:param args:
:param kwargs:
:return:
'''
log.debug('Scanning pillar cache for information about minion %s and pillarenv %s', se... | [
"Compile",
"pillar",
"and",
"set",
"it",
"to",
"the",
"cache",
"if",
"not",
"found",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L333-L374 | [
"def",
"compile_pillar",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Will likely just be pillar_dirs",
"log",
".",
"debug",
"(",
"'Scanning pillar cache for information about minion %s and pillarenv %s'",
",",
"self",
".",
"minion_id",
",",
"s... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.__valid_on_demand_ext_pillar | Check to see if the on demand external pillar is allowed | salt/pillar/__init__.py | def __valid_on_demand_ext_pillar(self, opts):
'''
Check to see if the on demand external pillar is allowed
'''
if not isinstance(self.ext, dict):
log.error(
'On-demand pillar %s is not formatted as a dictionary',
self.ext
)
... | def __valid_on_demand_ext_pillar(self, opts):
'''
Check to see if the on demand external pillar is allowed
'''
if not isinstance(self.ext, dict):
log.error(
'On-demand pillar %s is not formatted as a dictionary',
self.ext
)
... | [
"Check",
"to",
"see",
"if",
"the",
"on",
"demand",
"external",
"pillar",
"is",
"allowed"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L429-L461 | [
"def",
"__valid_on_demand_ext_pillar",
"(",
"self",
",",
"opts",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"ext",
",",
"dict",
")",
":",
"log",
".",
"error",
"(",
"'On-demand pillar %s is not formatted as a dictionary'",
",",
"self",
".",
"ext",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.__gather_avail | Gather the lists of available sls data from the master | salt/pillar/__init__.py | def __gather_avail(self):
'''
Gather the lists of available sls data from the master
'''
avail = {}
for saltenv in self._get_envs():
avail[saltenv] = self.client.list_states(saltenv)
return avail | def __gather_avail(self):
'''
Gather the lists of available sls data from the master
'''
avail = {}
for saltenv in self._get_envs():
avail[saltenv] = self.client.list_states(saltenv)
return avail | [
"Gather",
"the",
"lists",
"of",
"available",
"sls",
"data",
"from",
"the",
"master"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L463-L470 | [
"def",
"__gather_avail",
"(",
"self",
")",
":",
"avail",
"=",
"{",
"}",
"for",
"saltenv",
"in",
"self",
".",
"_get_envs",
"(",
")",
":",
"avail",
"[",
"saltenv",
"]",
"=",
"self",
".",
"client",
".",
"list_states",
"(",
"saltenv",
")",
"return",
"ava... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.__gen_opts | The options need to be altered to conform to the file client | salt/pillar/__init__.py | def __gen_opts(self, opts_in, grains, saltenv=None, ext=None, pillarenv=None):
'''
The options need to be altered to conform to the file client
'''
opts = copy.deepcopy(opts_in)
opts['file_client'] = 'local'
if not grains:
opts['grains'] = {}
else:
... | def __gen_opts(self, opts_in, grains, saltenv=None, ext=None, pillarenv=None):
'''
The options need to be altered to conform to the file client
'''
opts = copy.deepcopy(opts_in)
opts['file_client'] = 'local'
if not grains:
opts['grains'] = {}
else:
... | [
"The",
"options",
"need",
"to",
"be",
"altered",
"to",
"conform",
"to",
"the",
"file",
"client"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L472-L510 | [
"def",
"__gen_opts",
"(",
"self",
",",
"opts_in",
",",
"grains",
",",
"saltenv",
"=",
"None",
",",
"ext",
"=",
"None",
",",
"pillarenv",
"=",
"None",
")",
":",
"opts",
"=",
"copy",
".",
"deepcopy",
"(",
"opts_in",
")",
"opts",
"[",
"'file_client'",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar._get_envs | Pull the file server environments out of the master options | salt/pillar/__init__.py | def _get_envs(self):
'''
Pull the file server environments out of the master options
'''
envs = set(['base'])
if 'pillar_roots' in self.opts:
envs.update(list(self.opts['pillar_roots']))
return envs | def _get_envs(self):
'''
Pull the file server environments out of the master options
'''
envs = set(['base'])
if 'pillar_roots' in self.opts:
envs.update(list(self.opts['pillar_roots']))
return envs | [
"Pull",
"the",
"file",
"server",
"environments",
"out",
"of",
"the",
"master",
"options"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L512-L519 | [
"def",
"_get_envs",
"(",
"self",
")",
":",
"envs",
"=",
"set",
"(",
"[",
"'base'",
"]",
")",
"if",
"'pillar_roots'",
"in",
"self",
".",
"opts",
":",
"envs",
".",
"update",
"(",
"list",
"(",
"self",
".",
"opts",
"[",
"'pillar_roots'",
"]",
")",
")",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.get_tops | Gather the top files | salt/pillar/__init__.py | def get_tops(self):
'''
Gather the top files
'''
tops = collections.defaultdict(list)
include = collections.defaultdict(list)
done = collections.defaultdict(list)
errors = []
# Gather initial top files
try:
saltenvs = set()
... | def get_tops(self):
'''
Gather the top files
'''
tops = collections.defaultdict(list)
include = collections.defaultdict(list)
done = collections.defaultdict(list)
errors = []
# Gather initial top files
try:
saltenvs = set()
... | [
"Gather",
"the",
"top",
"files"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L521-L608 | [
"def",
"get_tops",
"(",
"self",
")",
":",
"tops",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"include",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"done",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"errors",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.merge_tops | Cleanly merge the top files | salt/pillar/__init__.py | def merge_tops(self, tops):
'''
Cleanly merge the top files
'''
top = collections.defaultdict(OrderedDict)
orders = collections.defaultdict(OrderedDict)
for ctops in six.itervalues(tops):
for ctop in ctops:
for saltenv, targets in six.iteritems... | def merge_tops(self, tops):
'''
Cleanly merge the top files
'''
top = collections.defaultdict(OrderedDict)
orders = collections.defaultdict(OrderedDict)
for ctops in six.itervalues(tops):
for ctop in ctops:
for saltenv, targets in six.iteritems... | [
"Cleanly",
"merge",
"the",
"top",
"files"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L610-L651 | [
"def",
"merge_tops",
"(",
"self",
",",
"tops",
")",
":",
"top",
"=",
"collections",
".",
"defaultdict",
"(",
"OrderedDict",
")",
"orders",
"=",
"collections",
".",
"defaultdict",
"(",
"OrderedDict",
")",
"for",
"ctops",
"in",
"six",
".",
"itervalues",
"(",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.sort_top_targets | Returns the sorted high data from the merged top files | salt/pillar/__init__.py | def sort_top_targets(self, top, orders):
'''
Returns the sorted high data from the merged top files
'''
sorted_top = collections.defaultdict(OrderedDict)
# pylint: disable=cell-var-from-loop
for saltenv, targets in six.iteritems(top):
sorted_targets = sorted(t... | def sort_top_targets(self, top, orders):
'''
Returns the sorted high data from the merged top files
'''
sorted_top = collections.defaultdict(OrderedDict)
# pylint: disable=cell-var-from-loop
for saltenv, targets in six.iteritems(top):
sorted_targets = sorted(t... | [
"Returns",
"the",
"sorted",
"high",
"data",
"from",
"the",
"merged",
"top",
"files"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L653-L665 | [
"def",
"sort_top_targets",
"(",
"self",
",",
"top",
",",
"orders",
")",
":",
"sorted_top",
"=",
"collections",
".",
"defaultdict",
"(",
"OrderedDict",
")",
"# pylint: disable=cell-var-from-loop",
"for",
"saltenv",
",",
"targets",
"in",
"six",
".",
"iteritems",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.get_top | Returns the high data derived from the top file | salt/pillar/__init__.py | def get_top(self):
'''
Returns the high data derived from the top file
'''
tops, errors = self.get_tops()
try:
merged_tops = self.merge_tops(tops)
except TypeError as err:
merged_tops = OrderedDict()
errors.append('Error encountered whi... | def get_top(self):
'''
Returns the high data derived from the top file
'''
tops, errors = self.get_tops()
try:
merged_tops = self.merge_tops(tops)
except TypeError as err:
merged_tops = OrderedDict()
errors.append('Error encountered whi... | [
"Returns",
"the",
"high",
"data",
"derived",
"from",
"the",
"top",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L667-L677 | [
"def",
"get_top",
"(",
"self",
")",
":",
"tops",
",",
"errors",
"=",
"self",
".",
"get_tops",
"(",
")",
"try",
":",
"merged_tops",
"=",
"self",
".",
"merge_tops",
"(",
"tops",
")",
"except",
"TypeError",
"as",
"err",
":",
"merged_tops",
"=",
"OrderedDi... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.top_matches | Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]} | salt/pillar/__init__.py | def top_matches(self, top):
'''
Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]}
'''
matches = {}
for saltenv, body in six.iteritems(top):
if ... | def top_matches(self, top):
'''
Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]}
'''
matches = {}
for saltenv, body in six.iteritems(top):
if ... | [
"Search",
"through",
"the",
"top",
"high",
"data",
"for",
"matches",
"and",
"return",
"the",
"states",
"that",
"this",
"minion",
"needs",
"to",
"execute",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L679-L705 | [
"def",
"top_matches",
"(",
"self",
",",
"top",
")",
":",
"matches",
"=",
"{",
"}",
"for",
"saltenv",
",",
"body",
"in",
"six",
".",
"iteritems",
"(",
"top",
")",
":",
"if",
"self",
".",
"opts",
"[",
"'pillarenv'",
"]",
":",
"if",
"saltenv",
"!=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.render_pstate | Collect a single pillar sls file and render it | salt/pillar/__init__.py | def render_pstate(self, sls, saltenv, mods, defaults=None):
'''
Collect a single pillar sls file and render it
'''
if defaults is None:
defaults = {}
err = ''
errors = []
state_data = self.client.get_state(sls, saltenv)
fn_ = state_data.get('de... | def render_pstate(self, sls, saltenv, mods, defaults=None):
'''
Collect a single pillar sls file and render it
'''
if defaults is None:
defaults = {}
err = ''
errors = []
state_data = self.client.get_state(sls, saltenv)
fn_ = state_data.get('de... | [
"Collect",
"a",
"single",
"pillar",
"sls",
"file",
"and",
"render",
"it"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L707-L859 | [
"def",
"render_pstate",
"(",
"self",
",",
"sls",
",",
"saltenv",
",",
"mods",
",",
"defaults",
"=",
"None",
")",
":",
"if",
"defaults",
"is",
"None",
":",
"defaults",
"=",
"{",
"}",
"err",
"=",
"''",
"errors",
"=",
"[",
"]",
"state_data",
"=",
"sel... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.render_pillar | Extract the sls pillar files from the matches and render them into the
pillar | salt/pillar/__init__.py | def render_pillar(self, matches, errors=None):
'''
Extract the sls pillar files from the matches and render them into the
pillar
'''
pillar = copy.copy(self.pillar_override)
if errors is None:
errors = []
for saltenv, pstates in six.iteritems(matches):... | def render_pillar(self, matches, errors=None):
'''
Extract the sls pillar files from the matches and render them into the
pillar
'''
pillar = copy.copy(self.pillar_override)
if errors is None:
errors = []
for saltenv, pstates in six.iteritems(matches):... | [
"Extract",
"the",
"sls",
"pillar",
"files",
"from",
"the",
"matches",
"and",
"render",
"them",
"into",
"the",
"pillar"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L861-L910 | [
"def",
"render_pillar",
"(",
"self",
",",
"matches",
",",
"errors",
"=",
"None",
")",
":",
"pillar",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"pillar_override",
")",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"[",
"]",
"for",
"saltenv",
","... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar._external_pillar_data | Builds actual pillar data structure and updates the ``pillar`` variable | salt/pillar/__init__.py | def _external_pillar_data(self, pillar, val, key):
'''
Builds actual pillar data structure and updates the ``pillar`` variable
'''
ext = None
args = salt.utils.args.get_function_argspec(self.ext_pillars[key]).args
if isinstance(val, dict):
if ('extra_minion_d... | def _external_pillar_data(self, pillar, val, key):
'''
Builds actual pillar data structure and updates the ``pillar`` variable
'''
ext = None
args = salt.utils.args.get_function_argspec(self.ext_pillars[key]).args
if isinstance(val, dict):
if ('extra_minion_d... | [
"Builds",
"actual",
"pillar",
"data",
"structure",
"and",
"updates",
"the",
"pillar",
"variable"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L912-L946 | [
"def",
"_external_pillar_data",
"(",
"self",
",",
"pillar",
",",
"val",
",",
"key",
")",
":",
"ext",
"=",
"None",
"args",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"get_function_argspec",
"(",
"self",
".",
"ext_pillars",
"[",
"key",
"]",
")",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.ext_pillar | Render the external pillar data | salt/pillar/__init__.py | def ext_pillar(self, pillar, errors=None):
'''
Render the external pillar data
'''
if errors is None:
errors = []
try:
# Make sure that on-demand git_pillar is fetched before we try to
# compile the pillar data. git_pillar will fetch a remote w... | def ext_pillar(self, pillar, errors=None):
'''
Render the external pillar data
'''
if errors is None:
errors = []
try:
# Make sure that on-demand git_pillar is fetched before we try to
# compile the pillar data. git_pillar will fetch a remote w... | [
"Render",
"the",
"external",
"pillar",
"data"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L948-L1026 | [
"def",
"ext_pillar",
"(",
"self",
",",
"pillar",
",",
"errors",
"=",
"None",
")",
":",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"[",
"]",
"try",
":",
"# Make sure that on-demand git_pillar is fetched before we try to",
"# compile the pillar data. git_pillar w... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.compile_pillar | Render the pillar data and return | salt/pillar/__init__.py | def compile_pillar(self, ext=True):
'''
Render the pillar data and return
'''
top, top_errors = self.get_top()
if ext:
if self.opts.get('ext_pillar_first', False):
self.opts['pillar'], errors = self.ext_pillar(self.pillar_override)
self... | def compile_pillar(self, ext=True):
'''
Render the pillar data and return
'''
top, top_errors = self.get_top()
if ext:
if self.opts.get('ext_pillar_first', False):
self.opts['pillar'], errors = self.ext_pillar(self.pillar_override)
self... | [
"Render",
"the",
"pillar",
"data",
"and",
"return"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L1028-L1083 | [
"def",
"compile_pillar",
"(",
"self",
",",
"ext",
"=",
"True",
")",
":",
"top",
",",
"top_errors",
"=",
"self",
".",
"get_top",
"(",
")",
"if",
"ext",
":",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'ext_pillar_first'",
",",
"False",
")",
":",
"s... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | Pillar.decrypt_pillar | Decrypt the specified pillar dictionary items, if configured to do so | salt/pillar/__init__.py | def decrypt_pillar(self, pillar):
'''
Decrypt the specified pillar dictionary items, if configured to do so
'''
errors = []
if self.opts.get('decrypt_pillar'):
decrypt_pillar = self.opts['decrypt_pillar']
if not isinstance(decrypt_pillar, dict):
... | def decrypt_pillar(self, pillar):
'''
Decrypt the specified pillar dictionary items, if configured to do so
'''
errors = []
if self.opts.get('decrypt_pillar'):
decrypt_pillar = self.opts['decrypt_pillar']
if not isinstance(decrypt_pillar, dict):
... | [
"Decrypt",
"the",
"specified",
"pillar",
"dictionary",
"items",
"if",
"configured",
"to",
"do",
"so"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L1085-L1143 | [
"def",
"decrypt_pillar",
"(",
"self",
",",
"pillar",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'decrypt_pillar'",
")",
":",
"decrypt_pillar",
"=",
"self",
".",
"opts",
"[",
"'decrypt_pillar'",
"]",
"if",
"not",
"is... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _cmd_run | Ensure that the Pki module is loaded, and convert to and extract data from
Json as needed. | salt/modules/win_pki.py | def _cmd_run(cmd, as_json=False):
'''
Ensure that the Pki module is loaded, and convert to and extract data from
Json as needed.
'''
cmd_full = ['Import-Module -Name PKI; ']
if as_json:
cmd_full.append(r'ConvertTo-Json -Compress -Depth 4 -InputObject '
r'@({0})'.... | def _cmd_run(cmd, as_json=False):
'''
Ensure that the Pki module is loaded, and convert to and extract data from
Json as needed.
'''
cmd_full = ['Import-Module -Name PKI; ']
if as_json:
cmd_full.append(r'ConvertTo-Json -Compress -Depth 4 -InputObject '
r'@({0})'.... | [
"Ensure",
"that",
"the",
"Pki",
"module",
"is",
"loaded",
"and",
"convert",
"to",
"and",
"extract",
"data",
"from",
"Json",
"as",
"needed",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L65-L91 | [
"def",
"_cmd_run",
"(",
"cmd",
",",
"as_json",
"=",
"False",
")",
":",
"cmd_full",
"=",
"[",
"'Import-Module -Name PKI; '",
"]",
"if",
"as_json",
":",
"cmd_full",
".",
"append",
"(",
"r'ConvertTo-Json -Compress -Depth 4 -InputObject '",
"r'@({0})'",
".",
"format",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _validate_cert_path | Ensure that the certificate path, as determind from user input, is valid. | salt/modules/win_pki.py | def _validate_cert_path(name):
'''
Ensure that the certificate path, as determind from user input, is valid.
'''
cmd = r"Test-Path -Path '{0}'".format(name)
if not ast.literal_eval(_cmd_run(cmd=cmd)):
raise SaltInvocationError(r"Invalid path specified: {0}".format(name)) | def _validate_cert_path(name):
'''
Ensure that the certificate path, as determind from user input, is valid.
'''
cmd = r"Test-Path -Path '{0}'".format(name)
if not ast.literal_eval(_cmd_run(cmd=cmd)):
raise SaltInvocationError(r"Invalid path specified: {0}".format(name)) | [
"Ensure",
"that",
"the",
"certificate",
"path",
"as",
"determind",
"from",
"user",
"input",
"is",
"valid",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L94-L101 | [
"def",
"_validate_cert_path",
"(",
"name",
")",
":",
"cmd",
"=",
"r\"Test-Path -Path '{0}'\"",
".",
"format",
"(",
"name",
")",
"if",
"not",
"ast",
".",
"literal_eval",
"(",
"_cmd_run",
"(",
"cmd",
"=",
"cmd",
")",
")",
":",
"raise",
"SaltInvocationError",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _validate_cert_format | Ensure that the certificate format, as determind from user input, is valid. | salt/modules/win_pki.py | def _validate_cert_format(name):
'''
Ensure that the certificate format, as determind from user input, is valid.
'''
cert_formats = ['cer', 'pfx']
if name not in cert_formats:
message = ("Invalid certificate format '{0}' specified. Valid formats:"
' {1}').format(name, cer... | def _validate_cert_format(name):
'''
Ensure that the certificate format, as determind from user input, is valid.
'''
cert_formats = ['cer', 'pfx']
if name not in cert_formats:
message = ("Invalid certificate format '{0}' specified. Valid formats:"
' {1}').format(name, cer... | [
"Ensure",
"that",
"the",
"certificate",
"format",
"as",
"determind",
"from",
"user",
"input",
"is",
"valid",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L104-L113 | [
"def",
"_validate_cert_format",
"(",
"name",
")",
":",
"cert_formats",
"=",
"[",
"'cer'",
",",
"'pfx'",
"]",
"if",
"name",
"not",
"in",
"cert_formats",
":",
"message",
"=",
"(",
"\"Invalid certificate format '{0}' specified. Valid formats:\"",
"' {1}'",
")",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_stores | Get the certificate location contexts and their corresponding stores.
:return: A dictionary of the certificate location contexts and stores.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' win_pki.get_stores | salt/modules/win_pki.py | def get_stores():
'''
Get the certificate location contexts and their corresponding stores.
:return: A dictionary of the certificate location contexts and stores.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' win_pki.get_stores
'''
ret = dict()
cmd = r"Get-Child... | def get_stores():
'''
Get the certificate location contexts and their corresponding stores.
:return: A dictionary of the certificate location contexts and stores.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' win_pki.get_stores
'''
ret = dict()
cmd = r"Get-Child... | [
"Get",
"the",
"certificate",
"location",
"contexts",
"and",
"their",
"corresponding",
"stores",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L116-L140 | [
"def",
"get_stores",
"(",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"cmd",
"=",
"r\"Get-ChildItem -Path 'Cert:\\' | \"",
"r\"Select-Object LocationName, StoreNames\"",
"items",
"=",
"_cmd_run",
"(",
"cmd",
"=",
"cmd",
",",
"as_json",
"=",
"True",
")",
"for",
"item... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_certs | Get the available certificates in the given store.
:param str context: The name of the certificate store location context.
:param str store: The name of the certificate store.
:return: A dictionary of the certificate thumbprints and properties.
:rtype: dict
CLI Example:
.. code-block:: bash
... | salt/modules/win_pki.py | def get_certs(context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Get the available certificates in the given store.
:param str context: The name of the certificate store location context.
:param str store: The name of the certificate store.
:return: A dictionary of the certificate thumbprints an... | def get_certs(context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Get the available certificates in the given store.
:param str context: The name of the certificate store location context.
:param str store: The name of the certificate store.
:return: A dictionary of the certificate thumbprints an... | [
"Get",
"the",
"available",
"certificates",
"in",
"the",
"given",
"store",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L143-L183 | [
"def",
"get_certs",
"(",
"context",
"=",
"_DEFAULT_CONTEXT",
",",
"store",
"=",
"_DEFAULT_STORE",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"cmd",
"=",
"list",
"(",
")",
"blacklist_keys",
"=",
"[",
"'DnsNameList'",
"]",
"store_path",
"=",
"r'Cert:\\{0}\\{1}'",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_cert_file | Get the details of the certificate file.
:param str name: The filesystem path of the certificate file.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
'pfx' for PKCS #12.
:param str password: The password of the certificate. Only applicable to pfx
format. Note th... | salt/modules/win_pki.py | def get_cert_file(name, cert_format=_DEFAULT_FORMAT, password=''):
'''
Get the details of the certificate file.
:param str name: The filesystem path of the certificate file.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
'pfx' for PKCS #12.
:param str password: ... | def get_cert_file(name, cert_format=_DEFAULT_FORMAT, password=''):
'''
Get the details of the certificate file.
:param str name: The filesystem path of the certificate file.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
'pfx' for PKCS #12.
:param str password: ... | [
"Get",
"the",
"details",
"of",
"the",
"certificate",
"file",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L186-L250 | [
"def",
"get_cert_file",
"(",
"name",
",",
"cert_format",
"=",
"_DEFAULT_FORMAT",
",",
"password",
"=",
"''",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"cmd",
"=",
"list",
"(",
")",
"blacklist_keys",
"=",
"[",
"'DnsNameList'",
"]",
"cert_format",
"=",
"cert... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | import_cert | Import the certificate file into the given certificate store.
:param str name: The path of the certificate file to import.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
'pfx' for PKCS #12.
:param str context: The name of the certificate store location context.
:par... | salt/modules/win_pki.py | def import_cert(name,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
exportable=True,
password='',
saltenv='base'):
'''
Import the certificate file into the given certificate store.
... | def import_cert(name,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
exportable=True,
password='',
saltenv='base'):
'''
Import the certificate file into the given certificate store.
... | [
"Import",
"the",
"certificate",
"file",
"into",
"the",
"given",
"certificate",
"store",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L253-L344 | [
"def",
"import_cert",
"(",
"name",
",",
"cert_format",
"=",
"_DEFAULT_FORMAT",
",",
"context",
"=",
"_DEFAULT_CONTEXT",
",",
"store",
"=",
"_DEFAULT_STORE",
",",
"exportable",
"=",
"True",
",",
"password",
"=",
"''",
",",
"saltenv",
"=",
"'base'",
")",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | export_cert | Export the certificate to a file from the given certificate store.
:param str name: The destination path for the exported certificate file.
:param str thumbprint: The thumbprint value of the target certificate.
:param str cert_format: The certificate format. Specify 'cer' for X.509, or
'pfx' for PK... | salt/modules/win_pki.py | def export_cert(name,
thumbprint,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
password=''):
'''
Export the certificate to a file from the given certificate store.
:param str name: The destinatio... | def export_cert(name,
thumbprint,
cert_format=_DEFAULT_FORMAT,
context=_DEFAULT_CONTEXT,
store=_DEFAULT_STORE,
password=''):
'''
Export the certificate to a file from the given certificate store.
:param str name: The destinatio... | [
"Export",
"the",
"certificate",
"to",
"a",
"file",
"from",
"the",
"given",
"certificate",
"store",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L347-L409 | [
"def",
"export_cert",
"(",
"name",
",",
"thumbprint",
",",
"cert_format",
"=",
"_DEFAULT_FORMAT",
",",
"context",
"=",
"_DEFAULT_CONTEXT",
",",
"store",
"=",
"_DEFAULT_STORE",
",",
"password",
"=",
"''",
")",
":",
"cmd",
"=",
"list",
"(",
")",
"thumbprint",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove_cert | Remove the certificate from the given certificate store.
:param str thumbprint: The thumbprint value of the target certificate.
:param str context: The name of the certificate store location context.
:param str store: The name of the certificate store.
:return: A boolean representing whether all chang... | salt/modules/win_pki.py | def remove_cert(thumbprint, context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Remove the certificate from the given certificate store.
:param str thumbprint: The thumbprint value of the target certificate.
:param str context: The name of the certificate store location context.
:param str store: ... | def remove_cert(thumbprint, context=_DEFAULT_CONTEXT, store=_DEFAULT_STORE):
'''
Remove the certificate from the given certificate store.
:param str thumbprint: The thumbprint value of the target certificate.
:param str context: The name of the certificate store location context.
:param str store: ... | [
"Remove",
"the",
"certificate",
"from",
"the",
"given",
"certificate",
"store",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pki.py#L459-L497 | [
"def",
"remove_cert",
"(",
"thumbprint",
",",
"context",
"=",
"_DEFAULT_CONTEXT",
",",
"store",
"=",
"_DEFAULT_STORE",
")",
":",
"thumbprint",
"=",
"thumbprint",
".",
"upper",
"(",
")",
"store_path",
"=",
"r'Cert:\\{0}\\{1}'",
".",
"format",
"(",
"context",
",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensure that the named schema is present in the database.
dbname
The database's name will work on
name
The name of the schema to manage
user
system user all operations should be performed on behalf of
db_user
database username if different from config or default
d... | salt/states/postgres_schema.py | def present(dbname, name,
owner=None, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Ensure that the named schema is present in the database.
dbname
The database's name will work on
name
The name of the schema to manage
... | def present(dbname, name,
owner=None, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Ensure that the named schema is present in the database.
dbname
The database's name will work on
name
The name of the schema to manage
... | [
"Ensure",
"that",
"the",
"named",
"schema",
"is",
"present",
"in",
"the",
"database",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_schema.py#L31-L106 | [
"def",
"present",
"(",
"dbname",
",",
"name",
",",
"owner",
"=",
"None",
",",
"user",
"=",
"None",
",",
"db_user",
"=",
"None",
",",
"db_password",
"=",
"None",
",",
"db_host",
"=",
"None",
",",
"db_port",
"=",
"None",
")",
":",
"ret",
"=",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_serv | Return a memcache server object | salt/returners/memcache_return.py | def _get_serv(ret):
'''
Return a memcache server object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
log.debug('memcache server: %s:%s', host, port)
if not host or not port:
log.error('Host or port not defined in salt config')
... | def _get_serv(ret):
'''
Return a memcache server object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
log.debug('memcache server: %s:%s', host, port)
if not host or not port:
log.error('Host or port not defined in salt config')
... | [
"Return",
"a",
"memcache",
"server",
"object"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L93-L110 | [
"def",
"_get_serv",
"(",
"ret",
")",
":",
"_options",
"=",
"_get_options",
"(",
"ret",
")",
"host",
"=",
"_options",
".",
"get",
"(",
"'host'",
")",
"port",
"=",
"_options",
".",
"get",
"(",
"'port'",
")",
"log",
".",
"debug",
"(",
"'memcache server: %... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | returner | Return data to a memcache data store | salt/returners/memcache_return.py | def returner(ret):
'''
Return data to a memcache data store
'''
serv = _get_serv(ret)
minion = ret['id']
jid = ret['jid']
fun = ret['fun']
rets = salt.utils.json.dumps(ret)
serv.set('{0}:{1}'.format(jid, minion), rets) # cache for get_jid
serv.set('{0}:{1}'.format(fun, minion), ... | def returner(ret):
'''
Return data to a memcache data store
'''
serv = _get_serv(ret)
minion = ret['id']
jid = ret['jid']
fun = ret['fun']
rets = salt.utils.json.dumps(ret)
serv.set('{0}:{1}'.format(jid, minion), rets) # cache for get_jid
serv.set('{0}:{1}'.format(fun, minion), ... | [
"Return",
"data",
"to",
"a",
"memcache",
"data",
"store"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L140-L155 | [
"def",
"returner",
"(",
"ret",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
")",
"minion",
"=",
"ret",
"[",
"'id'",
"]",
"jid",
"=",
"ret",
"[",
"'jid'",
"]",
"fun",
"=",
"ret",
"[",
"'fun'",
"]",
"rets",
"=",
"salt",
".",
"utils",
".",
"jso... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | save_load | Save the load to the specified jid | salt/returners/memcache_return.py | def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
serv = _get_serv(ret=None)
serv.set(jid, salt.utils.json.dumps(load))
_append_list(serv, 'jids', jid) | def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
serv = _get_serv(ret=None)
serv.set(jid, salt.utils.json.dumps(load))
_append_list(serv, 'jids', jid) | [
"Save",
"the",
"load",
"to",
"the",
"specified",
"jid"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L158-L164 | [
"def",
"save_load",
"(",
"jid",
",",
"load",
",",
"minions",
"=",
"None",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
"=",
"None",
")",
"serv",
".",
"set",
"(",
"jid",
",",
"salt",
".",
"utils",
".",
"json",
".",
"dumps",
"(",
"load",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_fun | Return a dict of the last function called for all minions | salt/returners/memcache_return.py | def get_fun(fun):
'''
Return a dict of the last function called for all minions
'''
serv = _get_serv(ret=None)
minions = _get_list(serv, 'minions')
returns = serv.get_multi(minions, key_prefix='{0}:'.format(fun))
# returns = {minion: return, minion: return, ...}
ret = {}
for minion, ... | def get_fun(fun):
'''
Return a dict of the last function called for all minions
'''
serv = _get_serv(ret=None)
minions = _get_list(serv, 'minions')
returns = serv.get_multi(minions, key_prefix='{0}:'.format(fun))
# returns = {minion: return, minion: return, ...}
ret = {}
for minion, ... | [
"Return",
"a",
"dict",
"of",
"the",
"last",
"function",
"called",
"for",
"all",
"minions"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L199-L210 | [
"def",
"get_fun",
"(",
"fun",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
"=",
"None",
")",
"minions",
"=",
"_get_list",
"(",
"serv",
",",
"'minions'",
")",
"returns",
"=",
"serv",
".",
"get_multi",
"(",
"minions",
",",
"key_prefix",
"=",
"'{0}:'",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_jids | Return a list of all job ids | salt/returners/memcache_return.py | def get_jids():
'''
Return a list of all job ids
'''
serv = _get_serv(ret=None)
jids = _get_list(serv, 'jids')
loads = serv.get_multi(jids) # {jid: load, jid: load, ...}
ret = {}
for jid, load in six.iteritems(loads):
ret[jid] = salt.utils.jid.format_jid_instance(jid, salt.utils... | def get_jids():
'''
Return a list of all job ids
'''
serv = _get_serv(ret=None)
jids = _get_list(serv, 'jids')
loads = serv.get_multi(jids) # {jid: load, jid: load, ...}
ret = {}
for jid, load in six.iteritems(loads):
ret[jid] = salt.utils.jid.format_jid_instance(jid, salt.utils... | [
"Return",
"a",
"list",
"of",
"all",
"job",
"ids"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L213-L223 | [
"def",
"get_jids",
"(",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
"=",
"None",
")",
"jids",
"=",
"_get_list",
"(",
"serv",
",",
"'jids'",
")",
"loads",
"=",
"serv",
".",
"get_multi",
"(",
"jids",
")",
"# {jid: load, jid: load, ...}",
"ret",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensure the ELB exists.
name
Name of the ELB.
availability_zones
A list of availability zones for this ELB.
listeners
A list of listener lists; example::
[
['443', 'HTTPS', 'arn:aws:iam::1111111:server-certificate/mycert'],
['8443', '80'... | salt/states/boto_elb.py | def present(name, listeners, availability_zones=None, subnets=None,
subnet_names=None, security_groups=None, scheme='internet-facing',
health_check=None, attributes=None,
attributes_from_pillar="boto_elb_attributes", cnames=None,
alarms=None, alarms_from_pillar="boto_elb_... | def present(name, listeners, availability_zones=None, subnets=None,
subnet_names=None, security_groups=None, scheme='internet-facing',
health_check=None, attributes=None,
attributes_from_pillar="boto_elb_attributes", cnames=None,
alarms=None, alarms_from_pillar="boto_elb_... | [
"Ensure",
"the",
"ELB",
"exists",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L261-L485 | [
"def",
"present",
"(",
"name",
",",
"listeners",
",",
"availability_zones",
"=",
"None",
",",
"subnets",
"=",
"None",
",",
"subnet_names",
"=",
"None",
",",
"security_groups",
"=",
"None",
",",
"scheme",
"=",
"'internet-facing'",
",",
"health_check",
"=",
"N... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | register_instances | Add EC2 instance(s) to an Elastic Load Balancer. Removing an instance from
the ``instances`` list does not remove it from the ELB.
name
The name of the Elastic Load Balancer to add EC2 instances to.
instances
A list of EC2 instance IDs that this Elastic Load Balancer should
distrib... | salt/states/boto_elb.py | def register_instances(name, instances, region=None, key=None, keyid=None,
profile=None):
'''
Add EC2 instance(s) to an Elastic Load Balancer. Removing an instance from
the ``instances`` list does not remove it from the ELB.
name
The name of the Elastic Load Balancer to a... | def register_instances(name, instances, region=None, key=None, keyid=None,
profile=None):
'''
Add EC2 instance(s) to an Elastic Load Balancer. Removing an instance from
the ``instances`` list does not remove it from the ELB.
name
The name of the Elastic Load Balancer to a... | [
"Add",
"EC2",
"instance",
"(",
"s",
")",
"to",
"an",
"Elastic",
"Load",
"Balancer",
".",
"Removing",
"an",
"instance",
"from",
"the",
"instances",
"list",
"does",
"not",
"remove",
"it",
"from",
"the",
"ELB",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L488-L550 | [
"def",
"register_instances",
"(",
"name",
",",
"instances",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _alarms_present | helper method for present. ensure that cloudwatch_alarms are set | salt/states/boto_elb.py | def _alarms_present(name, alarms, alarms_from_pillar, region, key, keyid, profile):
'''helper method for present. ensure that cloudwatch_alarms are set'''
current = __salt__['config.option'](alarms_from_pillar, {})
if alarms:
current = salt.utils.dictupdate.update(current, alarms)
ret = {'name'... | def _alarms_present(name, alarms, alarms_from_pillar, region, key, keyid, profile):
'''helper method for present. ensure that cloudwatch_alarms are set'''
current = __salt__['config.option'](alarms_from_pillar, {})
if alarms:
current = salt.utils.dictupdate.update(current, alarms)
ret = {'name'... | [
"helper",
"method",
"for",
"present",
".",
"ensure",
"that",
"cloudwatch_alarms",
"are",
"set"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L987-L1013 | [
"def",
"_alarms_present",
"(",
"name",
",",
"alarms",
",",
"alarms_from_pillar",
",",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"current",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"alarms_from_pillar",
",",
"{",
"}",
")",
"if"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _policies_present | helper method for present. ensure that ELB policies are set | salt/states/boto_elb.py | def _policies_present(name, policies, policies_from_pillar, listeners, backends,
region, key, keyid, profile):
'''helper method for present. ensure that ELB policies are set'''
if policies is None:
policies = []
pillar_policies = __salt__['config.option'](policies_from_pillar, ... | def _policies_present(name, policies, policies_from_pillar, listeners, backends,
region, key, keyid, profile):
'''helper method for present. ensure that ELB policies are set'''
if policies is None:
policies = []
pillar_policies = __salt__['config.option'](policies_from_pillar, ... | [
"helper",
"method",
"for",
"present",
".",
"ensure",
"that",
"ELB",
"policies",
"are",
"set"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L1016-L1247 | [
"def",
"_policies_present",
"(",
"name",
",",
"policies",
",",
"policies_from_pillar",
",",
"listeners",
",",
"backends",
",",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"if",
"policies",
"is",
"None",
":",
"policies",
"=",
"[",
"]",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure an ELB does not exist
name
name of the ELB | salt/states/boto_elb.py | def absent(name, region=None, key=None, keyid=None, profile=None):
'''
Ensure an ELB does not exist
name
name of the ELB
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
exists = __salt__['boto_elb.exists'](name, region, key, keyid, profile)
if exists:
... | def absent(name, region=None, key=None, keyid=None, profile=None):
'''
Ensure an ELB does not exist
name
name of the ELB
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
exists = __salt__['boto_elb.exists'](name, region, key, keyid, profile)
if exists:
... | [
"Ensure",
"an",
"ELB",
"does",
"not",
"exist"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L1262-L1288 | [
"def",
"absent",
"(",
"name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _tags_present | helper function to validate tags on elb | salt/states/boto_elb.py | def _tags_present(name, tags, region, key, keyid, profile):
'''
helper function to validate tags on elb
'''
ret = {'result': True, 'comment': '', 'changes': {}}
if tags:
lb = __salt__['boto_elb.get_elb_config'](name, region, key, keyid, profile)
tags_to_add = tags
tags_to_up... | def _tags_present(name, tags, region, key, keyid, profile):
'''
helper function to validate tags on elb
'''
ret = {'result': True, 'comment': '', 'changes': {}}
if tags:
lb = __salt__['boto_elb.get_elb_config'](name, region, key, keyid, profile)
tags_to_add = tags
tags_to_up... | [
"helper",
"function",
"to",
"validate",
"tags",
"on",
"elb"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_elb.py#L1291-L1364 | [
"def",
"_tags_present",
"(",
"name",
",",
"tags",
",",
"region",
",",
"key",
",",
"keyid",
",",
"profile",
")",
":",
"ret",
"=",
"{",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"if",
"tags",
":",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ThreadLocalProxy.get_reference | Return the object that is referenced by the specified proxy.
If the proxy has not been bound to a reference for the current thread,
the behavior depends on th the ``fallback_to_shared`` flag that has
been specified when creating the proxy. If the flag has been set, the
last reference th... | salt/utils/thread_local_proxy.py | def get_reference(proxy):
'''
Return the object that is referenced by the specified proxy.
If the proxy has not been bound to a reference for the current thread,
the behavior depends on th the ``fallback_to_shared`` flag that has
been specified when creating the proxy. If the fl... | def get_reference(proxy):
'''
Return the object that is referenced by the specified proxy.
If the proxy has not been bound to a reference for the current thread,
the behavior depends on th the ``fallback_to_shared`` flag that has
been specified when creating the proxy. If the fl... | [
"Return",
"the",
"object",
"that",
"is",
"referenced",
"by",
"the",
"specified",
"proxy",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/thread_local_proxy.py#L47-L92 | [
"def",
"get_reference",
"(",
"proxy",
")",
":",
"thread_local",
"=",
"object",
".",
"__getattribute__",
"(",
"proxy",
",",
"'_thread_local'",
")",
"try",
":",
"return",
"thread_local",
".",
"reference",
"except",
"AttributeError",
":",
"fallback_to_shared",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ThreadLocalProxy.set_reference | Set the reference to be used the current thread of execution.
After calling this function, the specified proxy will act like it was
the referenced object.
proxy:
proxy object for which the reference shall be set. If the specified
object is not an instance of `ThreadLoca... | salt/utils/thread_local_proxy.py | def set_reference(proxy, new_reference):
'''
Set the reference to be used the current thread of execution.
After calling this function, the specified proxy will act like it was
the referenced object.
proxy:
proxy object for which the reference shall be set. If the s... | def set_reference(proxy, new_reference):
'''
Set the reference to be used the current thread of execution.
After calling this function, the specified proxy will act like it was
the referenced object.
proxy:
proxy object for which the reference shall be set. If the s... | [
"Set",
"the",
"reference",
"to",
"be",
"used",
"the",
"current",
"thread",
"of",
"execution",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/thread_local_proxy.py#L95-L123 | [
"def",
"set_reference",
"(",
"proxy",
",",
"new_reference",
")",
":",
"# If the new reference is itself a proxy, we have to ensure that it does",
"# not refer to this proxy. If it does, we simply return because updating",
"# the reference would result in an inifite loop when trying to use the",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ThreadLocalProxy.unproxy | Unwrap and return the object referenced by a proxy.
This function is very similar to :func:`get_reference`, but works for
both proxies and regular objects. If the specified object is a proxy,
its reference is extracted with ``get_reference`` and returned. If it
is not a proxy, it is ret... | salt/utils/thread_local_proxy.py | def unproxy(possible_proxy):
'''
Unwrap and return the object referenced by a proxy.
This function is very similar to :func:`get_reference`, but works for
both proxies and regular objects. If the specified object is a proxy,
its reference is extracted with ``get_reference`` and ... | def unproxy(possible_proxy):
'''
Unwrap and return the object referenced by a proxy.
This function is very similar to :func:`get_reference`, but works for
both proxies and regular objects. If the specified object is a proxy,
its reference is extracted with ``get_reference`` and ... | [
"Unwrap",
"and",
"return",
"the",
"object",
"referenced",
"by",
"a",
"proxy",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/thread_local_proxy.py#L143-L160 | [
"def",
"unproxy",
"(",
"possible_proxy",
")",
":",
"while",
"isinstance",
"(",
"possible_proxy",
",",
"ThreadLocalProxy",
")",
":",
"possible_proxy",
"=",
"ThreadLocalProxy",
".",
"get_reference",
"(",
"possible_proxy",
")",
"return",
"possible_proxy"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _new_mods | Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run | salt/modules/kmod.py | def _new_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in post_mods:
post.add(mod['module'])
r... | def _new_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in post_mods:
post.add(mod['module'])
r... | [
"Return",
"a",
"list",
"of",
"the",
"new",
"modules",
"pass",
"an",
"lsmod",
"dict",
"before",
"running",
"modprobe",
"and",
"one",
"after",
"modprobe",
"has",
"run"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L26-L37 | [
"def",
"_new_mods",
"(",
"pre_mods",
",",
"post_mods",
")",
":",
"pre",
"=",
"set",
"(",
")",
"post",
"=",
"set",
"(",
")",
"for",
"mod",
"in",
"pre_mods",
":",
"pre",
".",
"add",
"(",
"mod",
"[",
"'module'",
"]",
")",
"for",
"mod",
"in",
"post_m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _rm_mods | Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run | salt/modules/kmod.py | def _rm_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in post_mods:
post.add(mod['module'])
re... | def _rm_mods(pre_mods, post_mods):
'''
Return a list of the new modules, pass an lsmod dict before running
modprobe and one after modprobe has run
'''
pre = set()
post = set()
for mod in pre_mods:
pre.add(mod['module'])
for mod in post_mods:
post.add(mod['module'])
re... | [
"Return",
"a",
"list",
"of",
"the",
"new",
"modules",
"pass",
"an",
"lsmod",
"dict",
"before",
"running",
"modprobe",
"and",
"one",
"after",
"modprobe",
"has",
"run"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L40-L51 | [
"def",
"_rm_mods",
"(",
"pre_mods",
",",
"post_mods",
")",
":",
"pre",
"=",
"set",
"(",
")",
"post",
"=",
"set",
"(",
")",
"for",
"mod",
"in",
"pre_mods",
":",
"pre",
".",
"add",
"(",
"mod",
"[",
"'module'",
"]",
")",
"for",
"mod",
"in",
"post_mo... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _set_persistent_module | Add module to configuration file to make it persistent. If module is
commented uncomment it. | salt/modules/kmod.py | def _set_persistent_module(mod):
'''
Add module to configuration file to make it persistent. If module is
commented uncomment it.
'''
conf = _get_modules_conf()
if not os.path.exists(conf):
__salt__['file.touch'](conf)
mod_name = _strip_module_name(mod)
if not mod_name or mod_nam... | def _set_persistent_module(mod):
'''
Add module to configuration file to make it persistent. If module is
commented uncomment it.
'''
conf = _get_modules_conf()
if not os.path.exists(conf):
__salt__['file.touch'](conf)
mod_name = _strip_module_name(mod)
if not mod_name or mod_nam... | [
"Add",
"module",
"to",
"configuration",
"file",
"to",
"make",
"it",
"persistent",
".",
"If",
"module",
"is",
"commented",
"uncomment",
"it",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L76-L96 | [
"def",
"_set_persistent_module",
"(",
"mod",
")",
":",
"conf",
"=",
"_get_modules_conf",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"conf",
")",
":",
"__salt__",
"[",
"'file.touch'",
"]",
"(",
"conf",
")",
"mod_name",
"=",
"_strip_modu... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _remove_persistent_module | Remove module from configuration file. If comment is true only comment line
where module is. | salt/modules/kmod.py | def _remove_persistent_module(mod, comment):
'''
Remove module from configuration file. If comment is true only comment line
where module is.
'''
conf = _get_modules_conf()
mod_name = _strip_module_name(mod)
if not mod_name or mod_name not in mod_list(True):
return set()
escape_m... | def _remove_persistent_module(mod, comment):
'''
Remove module from configuration file. If comment is true only comment line
where module is.
'''
conf = _get_modules_conf()
mod_name = _strip_module_name(mod)
if not mod_name or mod_name not in mod_list(True):
return set()
escape_m... | [
"Remove",
"module",
"from",
"configuration",
"file",
".",
"If",
"comment",
"is",
"true",
"only",
"comment",
"line",
"where",
"module",
"is",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L99-L113 | [
"def",
"_remove_persistent_module",
"(",
"mod",
",",
"comment",
")",
":",
"conf",
"=",
"_get_modules_conf",
"(",
")",
"mod_name",
"=",
"_strip_module_name",
"(",
"mod",
")",
"if",
"not",
"mod_name",
"or",
"mod_name",
"not",
"in",
"mod_list",
"(",
"True",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | available | Return a list of all available kernel modules
CLI Example:
.. code-block:: bash
salt '*' kmod.available | salt/modules/kmod.py | def available():
'''
Return a list of all available kernel modules
CLI Example:
.. code-block:: bash
salt '*' kmod.available
'''
ret = []
mod_dir = os.path.join('/lib/modules/', os.uname()[2])
built_in_file = os.path.join(mod_dir, 'modules.builtin')
if os.path.exists(bui... | def available():
'''
Return a list of all available kernel modules
CLI Example:
.. code-block:: bash
salt '*' kmod.available
'''
ret = []
mod_dir = os.path.join('/lib/modules/', os.uname()[2])
built_in_file = os.path.join(mod_dir, 'modules.builtin')
if os.path.exists(bui... | [
"Return",
"a",
"list",
"of",
"all",
"available",
"kernel",
"modules"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L116-L150 | [
"def",
"available",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"mod_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'/lib/modules/'",
",",
"os",
".",
"uname",
"(",
")",
"[",
"2",
"]",
")",
"built_in_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mod_list | Return a list of the loaded module names
only_persist
Only return the list of loaded persistent modules
CLI Example:
.. code-block:: bash
salt '*' kmod.mod_list | salt/modules/kmod.py | def mod_list(only_persist=False):
'''
Return a list of the loaded module names
only_persist
Only return the list of loaded persistent modules
CLI Example:
.. code-block:: bash
salt '*' kmod.mod_list
'''
mods = set()
if only_persist:
conf = _get_modules_conf()
... | def mod_list(only_persist=False):
'''
Return a list of the loaded module names
only_persist
Only return the list of loaded persistent modules
CLI Example:
.. code-block:: bash
salt '*' kmod.mod_list
'''
mods = set()
if only_persist:
conf = _get_modules_conf()
... | [
"Return",
"a",
"list",
"of",
"the",
"loaded",
"module",
"names"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L196-L225 | [
"def",
"mod_list",
"(",
"only_persist",
"=",
"False",
")",
":",
"mods",
"=",
"set",
"(",
")",
"if",
"only_persist",
":",
"conf",
"=",
"_get_modules_conf",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"conf",
")",
":",
"try",
":",
"with",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | load | Load the specified kernel module
mod
Name of module to add
persist
Write module to /etc/modules to make it load on system reboot
CLI Example:
.. code-block:: bash
salt '*' kmod.load kvm | salt/modules/kmod.py | def load(mod, persist=False):
'''
Load the specified kernel module
mod
Name of module to add
persist
Write module to /etc/modules to make it load on system reboot
CLI Example:
.. code-block:: bash
salt '*' kmod.load kvm
'''
pre_mods = lsmod()
res = __salt... | def load(mod, persist=False):
'''
Load the specified kernel module
mod
Name of module to add
persist
Write module to /etc/modules to make it load on system reboot
CLI Example:
.. code-block:: bash
salt '*' kmod.load kvm
'''
pre_mods = lsmod()
res = __salt... | [
"Load",
"the",
"specified",
"kernel",
"module"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L228-L254 | [
"def",
"load",
"(",
"mod",
",",
"persist",
"=",
"False",
")",
":",
"pre_mods",
"=",
"lsmod",
"(",
")",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'modprobe {0}'",
".",
"format",
"(",
"mod",
")",
",",
"python_shell",
"=",
"False",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | init | Required.
Can be used to initialize the server connection. | salt/proxy/onyx.py | def init(opts=None):
'''
Required.
Can be used to initialize the server connection.
'''
if opts is None:
opts = __opts__
try:
DETAILS[_worker_name()] = SSHConnection(
host=opts['proxy']['host'],
username=opts['proxy']['username'],
password=opts... | def init(opts=None):
'''
Required.
Can be used to initialize the server connection.
'''
if opts is None:
opts = __opts__
try:
DETAILS[_worker_name()] = SSHConnection(
host=opts['proxy']['host'],
username=opts['proxy']['username'],
password=opts... | [
"Required",
".",
"Can",
"be",
"used",
"to",
"initialize",
"the",
"server",
"connection",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L87-L107 | [
"def",
"init",
"(",
"opts",
"=",
"None",
")",
":",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"__opts__",
"try",
":",
"DETAILS",
"[",
"_worker_name",
"(",
")",
"]",
"=",
"SSHConnection",
"(",
"host",
"=",
"opts",
"[",
"'proxy'",
"]",
"[",
"'host... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ping | Ping the device on the other end of the connection
.. code-block: bash
salt '*' onyx.cmd ping | salt/proxy/onyx.py | def ping():
'''
Ping the device on the other end of the connection
.. code-block: bash
salt '*' onyx.cmd ping
'''
if _worker_name() not in DETAILS:
init()
try:
return DETAILS[_worker_name()].conn.isalive()
except TerminalException as e:
log.error(e)
... | def ping():
'''
Ping the device on the other end of the connection
.. code-block: bash
salt '*' onyx.cmd ping
'''
if _worker_name() not in DETAILS:
init()
try:
return DETAILS[_worker_name()].conn.isalive()
except TerminalException as e:
log.error(e)
... | [
"Ping",
"the",
"device",
"on",
"the",
"other",
"end",
"of",
"the",
"connection"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L117-L131 | [
"def",
"ping",
"(",
")",
":",
"if",
"_worker_name",
"(",
")",
"not",
"in",
"DETAILS",
":",
"init",
"(",
")",
"try",
":",
"return",
"DETAILS",
"[",
"_worker_name",
"(",
")",
"]",
".",
"conn",
".",
"isalive",
"(",
")",
"except",
"TerminalException",
"a... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | sendline | Run command through switch's cli
.. code-block: bash
salt '*' onyx.cmd sendline 'show run | include
"username admin password 7"' | salt/proxy/onyx.py | def sendline(command):
'''
Run command through switch's cli
.. code-block: bash
salt '*' onyx.cmd sendline 'show run | include
"username admin password 7"'
'''
if ping() is False:
init()
out, _ = DETAILS[_worker_name()].sendline(command)
return out | def sendline(command):
'''
Run command through switch's cli
.. code-block: bash
salt '*' onyx.cmd sendline 'show run | include
"username admin password 7"'
'''
if ping() is False:
init()
out, _ = DETAILS[_worker_name()].sendline(command)
return out | [
"Run",
"command",
"through",
"switch",
"s",
"cli"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L141-L153 | [
"def",
"sendline",
"(",
"command",
")",
":",
"if",
"ping",
"(",
")",
"is",
"False",
":",
"init",
"(",
")",
"out",
",",
"_",
"=",
"DETAILS",
"[",
"_worker_name",
"(",
")",
"]",
".",
"sendline",
"(",
"command",
")",
"return",
"out"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | grains | Get grains for proxy minion
.. code-block: bash
salt '*' onyx.cmd grains | salt/proxy/onyx.py | def grains():
'''
Get grains for proxy minion
.. code-block: bash
salt '*' onyx.cmd grains
'''
if not DETAILS['grains_cache']:
ret = system_info()
log.debug(ret)
DETAILS['grains_cache'].update(ret)
return {'onyx': DETAILS['grains_cache']} | def grains():
'''
Get grains for proxy minion
.. code-block: bash
salt '*' onyx.cmd grains
'''
if not DETAILS['grains_cache']:
ret = system_info()
log.debug(ret)
DETAILS['grains_cache'].update(ret)
return {'onyx': DETAILS['grains_cache']} | [
"Get",
"grains",
"for",
"proxy",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L221-L233 | [
"def",
"grains",
"(",
")",
":",
"if",
"not",
"DETAILS",
"[",
"'grains_cache'",
"]",
":",
"ret",
"=",
"system_info",
"(",
")",
"log",
".",
"debug",
"(",
"ret",
")",
"DETAILS",
"[",
"'grains_cache'",
"]",
".",
"update",
"(",
"ret",
")",
"return",
"{",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_user | Get username line from switch
.. code-block: bash
salt '*' onyx.cmd get_user username=admin | salt/proxy/onyx.py | def get_user(username):
'''
Get username line from switch
.. code-block: bash
salt '*' onyx.cmd get_user username=admin
'''
try:
enable()
configure_terminal()
cmd_out = sendline('show running-config | include "username {0} password 7"'.format(username))
cmd_... | def get_user(username):
'''
Get username line from switch
.. code-block: bash
salt '*' onyx.cmd get_user username=admin
'''
try:
enable()
configure_terminal()
cmd_out = sendline('show running-config | include "username {0} password 7"'.format(username))
cmd_... | [
"Get",
"username",
"line",
"from",
"switch"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L248-L267 | [
"def",
"get_user",
"(",
"username",
")",
":",
"try",
":",
"enable",
"(",
")",
"configure_terminal",
"(",
")",
"cmd_out",
"=",
"sendline",
"(",
"'show running-config | include \"username {0} password 7\"'",
".",
"format",
"(",
"username",
")",
")",
"cmd_out",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_roles | Get roles that the username is assigned from switch
.. code-block: bash
salt '*' onyx.cmd get_roles username=admin | salt/proxy/onyx.py | def get_roles(username):
'''
Get roles that the username is assigned from switch
.. code-block: bash
salt '*' onyx.cmd get_roles username=admin
'''
info = sendline('show user-account {0}'.format(username))
roles = re.search(r'^\s*roles:(.*)$', info, re.MULTILINE)
if roles:
... | def get_roles(username):
'''
Get roles that the username is assigned from switch
.. code-block: bash
salt '*' onyx.cmd get_roles username=admin
'''
info = sendline('show user-account {0}'.format(username))
roles = re.search(r'^\s*roles:(.*)$', info, re.MULTILINE)
if roles:
... | [
"Get",
"roles",
"that",
"the",
"username",
"is",
"assigned",
"from",
"switch"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L270-L284 | [
"def",
"get_roles",
"(",
"username",
")",
":",
"info",
"=",
"sendline",
"(",
"'show user-account {0}'",
".",
"format",
"(",
"username",
")",
")",
"roles",
"=",
"re",
".",
"search",
"(",
"r'^\\s*roles:(.*)$'",
",",
"info",
",",
"re",
".",
"MULTILINE",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | remove_user | Remove user from switch
.. code-block:: bash
salt '*' onyx.cmd remove_user username=daniel | salt/proxy/onyx.py | def remove_user(username):
'''
Remove user from switch
.. code-block:: bash
salt '*' onyx.cmd remove_user username=daniel
'''
try:
sendline('config terminal')
user_line = 'no username {0}'.format(username)
ret = sendline(user_line)
sendline('end')
se... | def remove_user(username):
'''
Remove user from switch
.. code-block:: bash
salt '*' onyx.cmd remove_user username=daniel
'''
try:
sendline('config terminal')
user_line = 'no username {0}'.format(username)
ret = sendline(user_line)
sendline('end')
se... | [
"Remove",
"user",
"from",
"switch"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L298-L315 | [
"def",
"remove_user",
"(",
"username",
")",
":",
"try",
":",
"sendline",
"(",
"'config terminal'",
")",
"user_line",
"=",
"'no username {0}'",
".",
"format",
"(",
"username",
")",
"ret",
"=",
"sendline",
"(",
"user_line",
")",
"sendline",
"(",
"'end'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | set_role | Assign role to username
.. code-block:: bash
salt '*' onyx.cmd set_role username=daniel role=vdc-admin | salt/proxy/onyx.py | def set_role(username, role):
'''
Assign role to username
.. code-block:: bash
salt '*' onyx.cmd set_role username=daniel role=vdc-admin
'''
try:
sendline('config terminal')
role_line = 'username {0} role {1}'.format(username, role)
ret = sendline(role_line)
... | def set_role(username, role):
'''
Assign role to username
.. code-block:: bash
salt '*' onyx.cmd set_role username=daniel role=vdc-admin
'''
try:
sendline('config terminal')
role_line = 'username {0} role {1}'.format(username, role)
ret = sendline(role_line)
... | [
"Assign",
"role",
"to",
"username"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L318-L335 | [
"def",
"set_role",
"(",
"username",
",",
"role",
")",
":",
"try",
":",
"sendline",
"(",
"'config terminal'",
")",
"role_line",
"=",
"'username {0} role {1}'",
".",
"format",
"(",
"username",
",",
"role",
")",
"ret",
"=",
"sendline",
"(",
"role_line",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show_run | Shortcut to run `show run` on switch
.. code-block:: bash
salt '*' onyx.cmd show_run | salt/proxy/onyx.py | def show_run():
'''
Shortcut to run `show run` on switch
.. code-block:: bash
salt '*' onyx.cmd show_run
'''
try:
enable()
configure_terminal()
ret = sendline('show running-config')
configure_terminal_exit()
disable()
except TerminalException as ... | def show_run():
'''
Shortcut to run `show run` on switch
.. code-block:: bash
salt '*' onyx.cmd show_run
'''
try:
enable()
configure_terminal()
ret = sendline('show running-config')
configure_terminal_exit()
disable()
except TerminalException as ... | [
"Shortcut",
"to",
"run",
"show",
"run",
"on",
"switch"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L358-L375 | [
"def",
"show_run",
"(",
")",
":",
"try",
":",
"enable",
"(",
")",
"configure_terminal",
"(",
")",
"ret",
"=",
"sendline",
"(",
"'show running-config'",
")",
"configure_terminal_exit",
"(",
")",
"disable",
"(",
")",
"except",
"TerminalException",
"as",
"e",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_config | Add one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw'
.. note::
For more than one config added per command, lines should be a list. | salt/proxy/onyx.py | def add_config(lines):
'''
Add one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw'
.. note::
For more than one config added per command, lines should be a list.
'''
if not isinstance(... | def add_config(lines):
'''
Add one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw'
.. note::
For more than one config added per command, lines should be a list.
'''
if not isinstance(... | [
"Add",
"one",
"or",
"more",
"config",
"lines",
"to",
"the",
"switch",
"running",
"config"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L394-L418 | [
"def",
"add_config",
"(",
"lines",
")",
":",
"if",
"not",
"isinstance",
"(",
"lines",
",",
"list",
")",
":",
"lines",
"=",
"[",
"lines",
"]",
"try",
":",
"enable",
"(",
")",
"configure_terminal",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"sendline... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete_config | Delete one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator'
.. note::
For more than one config deleted per command, lines should be a list. | salt/proxy/onyx.py | def delete_config(lines):
'''
Delete one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator'
.. note::
For more than one config deleted per command, lines should be a list.... | def delete_config(lines):
'''
Delete one or more config lines to the switch running config
.. code-block:: bash
salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator'
.. note::
For more than one config deleted per command, lines should be a list.... | [
"Delete",
"one",
"or",
"more",
"config",
"lines",
"to",
"the",
"switch",
"running",
"config"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L421-L444 | [
"def",
"delete_config",
"(",
"lines",
")",
":",
"if",
"not",
"isinstance",
"(",
"lines",
",",
"list",
")",
":",
"lines",
"=",
"[",
"lines",
"]",
"try",
":",
"sendline",
"(",
"'config terminal'",
")",
"for",
"line",
"in",
"lines",
":",
"sendline",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | find | Find all instances where the pattern is in the running command
.. code-block:: bash
salt '*' onyx.cmd find '^snmp-server.*$'
.. note::
This uses the `re.MULTILINE` regex format for python, and runs the
regex against the whole show_run output. | salt/proxy/onyx.py | def find(pattern):
'''
Find all instances where the pattern is in the running command
.. code-block:: bash
salt '*' onyx.cmd find '^snmp-server.*$'
.. note::
This uses the `re.MULTILINE` regex format for python, and runs the
regex against the whole show_run output.
'''
... | def find(pattern):
'''
Find all instances where the pattern is in the running command
.. code-block:: bash
salt '*' onyx.cmd find '^snmp-server.*$'
.. note::
This uses the `re.MULTILINE` regex format for python, and runs the
regex against the whole show_run output.
'''
... | [
"Find",
"all",
"instances",
"where",
"the",
"pattern",
"is",
"in",
"the",
"running",
"command"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L447-L460 | [
"def",
"find",
"(",
"pattern",
")",
":",
"matcher",
"=",
"re",
".",
"compile",
"(",
"pattern",
",",
"re",
".",
"MULTILINE",
")",
"return",
"matcher",
".",
"findall",
"(",
"show_run",
"(",
")",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | replace | Replace string or full line matches in switch's running config
If full_match is set to True, then the whole line will need to be matched
as part of the old value.
.. code-block:: bash
salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWTESTSTRINGHERE' | salt/proxy/onyx.py | def replace(old_value, new_value, full_match=False):
'''
Replace string or full line matches in switch's running config
If full_match is set to True, then the whole line will need to be matched
as part of the old value.
.. code-block:: bash
salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWT... | def replace(old_value, new_value, full_match=False):
'''
Replace string or full line matches in switch's running config
If full_match is set to True, then the whole line will need to be matched
as part of the old value.
.. code-block:: bash
salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWT... | [
"Replace",
"string",
"or",
"full",
"line",
"matches",
"in",
"switch",
"s",
"running",
"config"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/onyx.py#L463-L489 | [
"def",
"replace",
"(",
"old_value",
",",
"new_value",
",",
"full_match",
"=",
"False",
")",
":",
"if",
"full_match",
"is",
"False",
":",
"matcher",
"=",
"re",
".",
"compile",
"(",
"'^.*{0}.*$'",
".",
"format",
"(",
"re",
".",
"escape",
"(",
"old_value",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | Ensure that the named group is present with the specified privileges
Please note that the user/group notion in postgresql is just abstract, we
have roles, where users can be seen as roles with the ``LOGIN`` privilege
and groups the others.
name
The name of the group to manage
createdb
... | salt/states/postgres_group.py | def present(name,
createdb=None,
createroles=None,
encrypted=None,
superuser=None,
inherit=None,
login=None,
replication=None,
password=None,
refresh_password=None,
groups=None,
user=None,... | def present(name,
createdb=None,
createroles=None,
encrypted=None,
superuser=None,
inherit=None,
login=None,
replication=None,
password=None,
refresh_password=None,
groups=None,
user=None,... | [
"Ensure",
"that",
"the",
"named",
"group",
"is",
"present",
"with",
"the",
"specified",
"privileges",
"Please",
"note",
"that",
"the",
"user",
"/",
"group",
"notion",
"in",
"postgresql",
"is",
"just",
"abstract",
"we",
"have",
"roles",
"where",
"users",
"can... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_group.py#L36-L213 | [
"def",
"present",
"(",
"name",
",",
"createdb",
"=",
"None",
",",
"createroles",
"=",
"None",
",",
"encrypted",
"=",
"None",
",",
"superuser",
"=",
"None",
",",
"inherit",
"=",
"None",
",",
"login",
"=",
"None",
",",
"replication",
"=",
"None",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure that the named group is absent
name
The groupname of the group to remove
user
System user all operations should be performed on behalf of
.. versionadded:: 0.17.0
db_user
database username if different from config or defaul
db_password
user password if... | salt/states/postgres_group.py | def absent(name,
user=None,
maintenance_db=None,
db_password=None,
db_host=None,
db_port=None,
db_user=None):
'''
Ensure that the named group is absent
name
The groupname of the group to remove
user
System user all opera... | def absent(name,
user=None,
maintenance_db=None,
db_password=None,
db_host=None,
db_port=None,
db_user=None):
'''
Ensure that the named group is absent
name
The groupname of the group to remove
user
System user all opera... | [
"Ensure",
"that",
"the",
"named",
"group",
"is",
"absent"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_group.py#L216-L273 | [
"def",
"absent",
"(",
"name",
",",
"user",
"=",
"None",
",",
"maintenance_db",
"=",
"None",
",",
"db_password",
"=",
"None",
",",
"db_host",
"=",
"None",
",",
"db_port",
"=",
"None",
",",
"db_user",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_port_def | Given a port number and protocol, returns the port definition expected by
docker-py. For TCP ports this is simply an integer, for UDP ports this is
(port_num, 'udp').
port_num can also be a string in the format 'port_num/udp'. If so, the
"proto" argument will be ignored. The reason we need to be able t... | salt/utils/docker/translate/helpers.py | def get_port_def(port_num, proto='tcp'):
'''
Given a port number and protocol, returns the port definition expected by
docker-py. For TCP ports this is simply an integer, for UDP ports this is
(port_num, 'udp').
port_num can also be a string in the format 'port_num/udp'. If so, the
"proto" argu... | def get_port_def(port_num, proto='tcp'):
'''
Given a port number and protocol, returns the port definition expected by
docker-py. For TCP ports this is simply an integer, for UDP ports this is
(port_num, 'udp').
port_num can also be a string in the format 'port_num/udp'. If so, the
"proto" argu... | [
"Given",
"a",
"port",
"number",
"and",
"protocol",
"returns",
"the",
"port",
"definition",
"expected",
"by",
"docker",
"-",
"py",
".",
"For",
"TCP",
"ports",
"this",
"is",
"simply",
"an",
"integer",
"for",
"UDP",
"ports",
"this",
"is",
"(",
"port_num",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L26-L59 | [
"def",
"get_port_def",
"(",
"port_num",
",",
"proto",
"=",
"'tcp'",
")",
":",
"try",
":",
"port_num",
",",
"_",
",",
"port_num_proto",
"=",
"port_num",
".",
"partition",
"(",
"'/'",
")",
"except",
"AttributeError",
":",
"pass",
"else",
":",
"if",
"port_n... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_port_range | Given a port number or range, return a start and end to that range. Port
ranges are defined as a string containing two numbers separated by a dash
(e.g. '4505-4506').
A ValueError will be raised if bad input is provided. | salt/utils/docker/translate/helpers.py | def get_port_range(port_def):
'''
Given a port number or range, return a start and end to that range. Port
ranges are defined as a string containing two numbers separated by a dash
(e.g. '4505-4506').
A ValueError will be raised if bad input is provided.
'''
if isinstance(port_def, six.inte... | def get_port_range(port_def):
'''
Given a port number or range, return a start and end to that range. Port
ranges are defined as a string containing two numbers separated by a dash
(e.g. '4505-4506').
A ValueError will be raised if bad input is provided.
'''
if isinstance(port_def, six.inte... | [
"Given",
"a",
"port",
"number",
"or",
"range",
"return",
"a",
"start",
"and",
"end",
"to",
"that",
"range",
".",
"Port",
"ranges",
"are",
"defined",
"as",
"a",
"string",
"containing",
"two",
"numbers",
"separated",
"by",
"a",
"dash",
"(",
"e",
".",
"g"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L62-L93 | [
"def",
"get_port_range",
"(",
"port_def",
")",
":",
"if",
"isinstance",
"(",
"port_def",
",",
"six",
".",
"integer_types",
")",
":",
"# Single integer, start/end of range is the same",
"return",
"port_def",
",",
"port_def",
"try",
":",
"comps",
"=",
"[",
"int",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | map_vals | Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list
of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function
provides common code to handle these instances. | salt/utils/docker/translate/helpers.py | def map_vals(val, *names, **extra_opts):
'''
Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list
of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function
provides common code to handle these instances.
'''
fill = extra_opts.pop('fill', NOTSET)
expected_num_elements... | def map_vals(val, *names, **extra_opts):
'''
Many arguments come in as a list of VAL1:VAL2 pairs, but map to a list
of dicts in the format {NAME1: VAL1, NAME2: VAL2}. This function
provides common code to handle these instances.
'''
fill = extra_opts.pop('fill', NOTSET)
expected_num_elements... | [
"Many",
"arguments",
"come",
"in",
"as",
"a",
"list",
"of",
"VAL1",
":",
"VAL2",
"pairs",
"but",
"map",
"to",
"a",
"list",
"of",
"dicts",
"in",
"the",
"format",
"{",
"NAME1",
":",
"VAL1",
"NAME2",
":",
"VAL2",
"}",
".",
"This",
"function",
"provides"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L96-L127 | [
"def",
"map_vals",
"(",
"val",
",",
"*",
"names",
",",
"*",
"*",
"extra_opts",
")",
":",
"fill",
"=",
"extra_opts",
".",
"pop",
"(",
"'fill'",
",",
"NOTSET",
")",
"expected_num_elements",
"=",
"len",
"(",
"names",
")",
"val",
"=",
"translate_stringlist",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_command | Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint"). | salt/utils/docker/translate/helpers.py | def translate_command(val):
'''
Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint").
'''
if isinstance(val, six.string_types):
return val
elif isinstance(val, list):
for idx in range(len(... | def translate_command(val):
'''
Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint").
'''
if isinstance(val, six.string_types):
return val
elif isinstance(val, list):
for idx in range(len(... | [
"Input",
"should",
"either",
"be",
"a",
"single",
"string",
"or",
"a",
"list",
"of",
"strings",
".",
"This",
"is",
"used",
"for",
"the",
"two",
"args",
"that",
"deal",
"with",
"commands",
"(",
"command",
"and",
"entrypoint",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L176-L190 | [
"def",
"translate_command",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"six",
".",
"string_types",
")",
":",
"return",
"val",
"elif",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"for",
"idx",
"in",
"range",
"(",
"len",
"(",
"val"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_bytes | These values can be expressed as an integer number of bytes, or a string
expression (i.e. 100mb, 1gb, etc.). | salt/utils/docker/translate/helpers.py | def translate_bytes(val):
'''
These values can be expressed as an integer number of bytes, or a string
expression (i.e. 100mb, 1gb, etc.).
'''
try:
val = int(val)
except (TypeError, ValueError):
if not isinstance(val, six.string_types):
val = six.text_type(val)
re... | def translate_bytes(val):
'''
These values can be expressed as an integer number of bytes, or a string
expression (i.e. 100mb, 1gb, etc.).
'''
try:
val = int(val)
except (TypeError, ValueError):
if not isinstance(val, six.string_types):
val = six.text_type(val)
re... | [
"These",
"values",
"can",
"be",
"expressed",
"as",
"an",
"integer",
"number",
"of",
"bytes",
"or",
"a",
"string",
"expression",
"(",
"i",
".",
"e",
".",
"100mb",
"1gb",
"etc",
".",
")",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L193-L203 | [
"def",
"translate_bytes",
"(",
"val",
")",
":",
"try",
":",
"val",
"=",
"int",
"(",
"val",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"six",
".",
"string_types",
")",
":",
"val",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_stringlist | On the CLI, these are passed as multiple instances of a given CLI option.
In Salt, we accept these as a comma-delimited list but the API expects a
Python list. This function accepts input and returns it back as a Python
list of strings. If the input is a string which is a comma-separated list
of items, ... | salt/utils/docker/translate/helpers.py | def translate_stringlist(val):
'''
On the CLI, these are passed as multiple instances of a given CLI option.
In Salt, we accept these as a comma-delimited list but the API expects a
Python list. This function accepts input and returns it back as a Python
list of strings. If the input is a string whi... | def translate_stringlist(val):
'''
On the CLI, these are passed as multiple instances of a given CLI option.
In Salt, we accept these as a comma-delimited list but the API expects a
Python list. This function accepts input and returns it back as a Python
list of strings. If the input is a string whi... | [
"On",
"the",
"CLI",
"these",
"are",
"passed",
"as",
"multiple",
"instances",
"of",
"a",
"given",
"CLI",
"option",
".",
"In",
"Salt",
"we",
"accept",
"these",
"as",
"a",
"comma",
"-",
"delimited",
"list",
"but",
"the",
"API",
"expects",
"a",
"Python",
"... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L206-L222 | [
"def",
"translate_stringlist",
"(",
"val",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"try",
":",
"val",
"=",
"split",
"(",
"val",
")",
"except",
"AttributeError",
":",
"val",
"=",
"split",
"(",
"six",
".",
"text_type",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_device_rates | CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{'Path': path, 'Rate': rate}] | salt/utils/docker/translate/helpers.py | def translate_device_rates(val, numeric_rate=True):
'''
CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{'Path': path, 'Rate': rate}]
'''
val = map_vals(val, 'Path', 'Rate')
for idx in range(len(val)):
try:
is_abs = os.path.is... | def translate_device_rates(val, numeric_rate=True):
'''
CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{'Path': path, 'Rate': rate}]
'''
val = map_vals(val, 'Path', 'Rate')
for idx in range(len(val)):
try:
is_abs = os.path.is... | [
"CLI",
"input",
"is",
"a",
"list",
"of",
"PATH",
":",
"RATE",
"pairs",
"but",
"the",
"API",
"expects",
"a",
"list",
"of",
"dictionaries",
"in",
"the",
"format",
"[",
"{",
"Path",
":",
"path",
"Rate",
":",
"rate",
"}",
"]"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L225-L257 | [
"def",
"translate_device_rates",
"(",
"val",
",",
"numeric_rate",
"=",
"True",
")",
":",
"val",
"=",
"map_vals",
"(",
"val",
",",
"'Path'",
",",
"'Rate'",
")",
"for",
"idx",
"in",
"range",
"(",
"len",
"(",
"val",
")",
")",
":",
"try",
":",
"is_abs",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_key_val | CLI input is a list of key/val pairs, but the API expects a dictionary in
the format {key: val} | salt/utils/docker/translate/helpers.py | def translate_key_val(val, delimiter='='):
'''
CLI input is a list of key/val pairs, but the API expects a dictionary in
the format {key: val}
'''
if isinstance(val, dict):
return val
val = translate_stringlist(val)
new_val = {}
for item in val:
try:
lvalue, r... | def translate_key_val(val, delimiter='='):
'''
CLI input is a list of key/val pairs, but the API expects a dictionary in
the format {key: val}
'''
if isinstance(val, dict):
return val
val = translate_stringlist(val)
new_val = {}
for item in val:
try:
lvalue, r... | [
"CLI",
"input",
"is",
"a",
"list",
"of",
"key",
"/",
"val",
"pairs",
"but",
"the",
"API",
"expects",
"a",
"dictionary",
"in",
"the",
"format",
"{",
"key",
":",
"val",
"}"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L260-L277 | [
"def",
"translate_key_val",
"(",
"val",
",",
"delimiter",
"=",
"'='",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"return",
"val",
"val",
"=",
"translate_stringlist",
"(",
"val",
")",
"new_val",
"=",
"{",
"}",
"for",
"item",
"in",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | translate_labels | Can either be a list of label names, or a list of name=value pairs. The API
can accept either a list of label names or a dictionary mapping names to
values, so the value we translate will be different depending on the input. | salt/utils/docker/translate/helpers.py | def translate_labels(val):
'''
Can either be a list of label names, or a list of name=value pairs. The API
can accept either a list of label names or a dictionary mapping names to
values, so the value we translate will be different depending on the input.
'''
if not isinstance(val, dict):
... | def translate_labels(val):
'''
Can either be a list of label names, or a list of name=value pairs. The API
can accept either a list of label names or a dictionary mapping names to
values, so the value we translate will be different depending on the input.
'''
if not isinstance(val, dict):
... | [
"Can",
"either",
"be",
"a",
"list",
"of",
"label",
"names",
"or",
"a",
"list",
"of",
"name",
"=",
"value",
"pairs",
".",
"The",
"API",
"can",
"accept",
"either",
"a",
"list",
"of",
"label",
"names",
"or",
"a",
"dictionary",
"mapping",
"names",
"to",
... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L280-L308 | [
"def",
"translate_labels",
"(",
"val",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"val",
"=",
"split",
"(",
"val",
")",
"new_val",
"=",
"{",
"}",
"for",
"i... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | check | Checks if there is an open connection from the minion to the defined
host on a specific port.
name
host name or ip address to test connection to
port
The port to test the connection on
kwargs
Additional parameters, parameters allowed are:
proto (tcp or udp)
family (i... | salt/states/firewall.py | def check(name, port=None, **kwargs):
'''
Checks if there is an open connection from the minion to the defined
host on a specific port.
name
host name or ip address to test connection to
port
The port to test the connection on
kwargs
Additional parameters, parameters allowe... | def check(name, port=None, **kwargs):
'''
Checks if there is an open connection from the minion to the defined
host on a specific port.
name
host name or ip address to test connection to
port
The port to test the connection on
kwargs
Additional parameters, parameters allowe... | [
"Checks",
"if",
"there",
"is",
"an",
"open",
"connection",
"from",
"the",
"minion",
"to",
"the",
"defined",
"host",
"on",
"a",
"specific",
"port",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/firewall.py#L19-L67 | [
"def",
"check",
"(",
"name",
",",
"port",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# set name to host as required by the module",
"host",
"=",
"name",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _refine_mode | Return a mode value that is predictable | salt/states/selinux.py | def _refine_mode(mode):
'''
Return a mode value that is predictable
'''
mode = six.text_type(mode).lower()
if any([mode.startswith('e'),
mode == '1',
mode == 'on']):
return 'Enforcing'
if any([mode.startswith('p'),
mode == '0',
mode == 'off... | def _refine_mode(mode):
'''
Return a mode value that is predictable
'''
mode = six.text_type(mode).lower()
if any([mode.startswith('e'),
mode == '1',
mode == 'on']):
return 'Enforcing'
if any([mode.startswith('p'),
mode == '0',
mode == 'off... | [
"Return",
"a",
"mode",
"value",
"that",
"is",
"predictable"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L41-L56 | [
"def",
"_refine_mode",
"(",
"mode",
")",
":",
"mode",
"=",
"six",
".",
"text_type",
"(",
"mode",
")",
".",
"lower",
"(",
")",
"if",
"any",
"(",
"[",
"mode",
".",
"startswith",
"(",
"'e'",
")",
",",
"mode",
"==",
"'1'",
",",
"mode",
"==",
"'on'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | mode | Verifies the mode SELinux is running in, can be set to enforcing,
permissive, or disabled
.. note::
A change to or from disabled mode requires a system reboot. You will
need to perform this yourself.
name
The mode to run SELinux in, permissive, enforcing, or disabled. | salt/states/selinux.py | def mode(name):
'''
Verifies the mode SELinux is running in, can be set to enforcing,
permissive, or disabled
.. note::
A change to or from disabled mode requires a system reboot. You will
need to perform this yourself.
name
The mode to run SELinux in, permissive, enforcing... | def mode(name):
'''
Verifies the mode SELinux is running in, can be set to enforcing,
permissive, or disabled
.. note::
A change to or from disabled mode requires a system reboot. You will
need to perform this yourself.
name
The mode to run SELinux in, permissive, enforcing... | [
"Verifies",
"the",
"mode",
"SELinux",
"is",
"running",
"in",
"can",
"be",
"set",
"to",
"enforcing",
"permissive",
"or",
"disabled"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L84-L133 | [
"def",
"mode",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"tmode",
"=",
"_refine_mode",
"(",
"name",
")",
"if",
"tmode",
"==",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | boolean | Set up an SELinux boolean
name
The name of the boolean to set
value
The value to set on the boolean
persist
Defaults to False, set persist to true to make the boolean apply on a
reboot | salt/states/selinux.py | def boolean(name, value, persist=False):
'''
Set up an SELinux boolean
name
The name of the boolean to set
value
The value to set on the boolean
persist
Defaults to False, set persist to true to make the boolean apply on a
reboot
'''
ret = {'name': name,
... | def boolean(name, value, persist=False):
'''
Set up an SELinux boolean
name
The name of the boolean to set
value
The value to set on the boolean
persist
Defaults to False, set persist to true to make the boolean apply on a
reboot
'''
ret = {'name': name,
... | [
"Set",
"up",
"an",
"SELinux",
"boolean"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L136-L191 | [
"def",
"boolean",
"(",
"name",
",",
"value",
",",
"persist",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"bools",
"=",
"__salt__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | module | Enable/Disable and optionally force a specific version for an SELinux module
name
The name of the module to control
module_state
Should the module be enabled or disabled?
version
Defaults to no preference, set to a specified value if required.
Currently can only alert if t... | salt/states/selinux.py | def module(name, module_state='Enabled', version='any', **opts):
'''
Enable/Disable and optionally force a specific version for an SELinux module
name
The name of the module to control
module_state
Should the module be enabled or disabled?
version
Defaults to no preference... | def module(name, module_state='Enabled', version='any', **opts):
'''
Enable/Disable and optionally force a specific version for an SELinux module
name
The name of the module to control
module_state
Should the module be enabled or disabled?
version
Defaults to no preference... | [
"Enable",
"/",
"Disable",
"and",
"optionally",
"force",
"a",
"specific",
"version",
"for",
"an",
"SELinux",
"module"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L194-L268 | [
"def",
"module",
"(",
"name",
",",
"module_state",
"=",
"'Enabled'",
",",
"version",
"=",
"'any'",
",",
"*",
"*",
"opts",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | module_install | Installs custom SELinux module from given file
name
Path to file with module to install
.. versionadded:: 2016.11.6 | salt/states/selinux.py | def module_install(name):
'''
Installs custom SELinux module from given file
name
Path to file with module to install
.. versionadded:: 2016.11.6
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
if __salt__['selinux.install_sem... | def module_install(name):
'''
Installs custom SELinux module from given file
name
Path to file with module to install
.. versionadded:: 2016.11.6
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
if __salt__['selinux.install_sem... | [
"Installs",
"custom",
"SELinux",
"module",
"from",
"given",
"file"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L271-L289 | [
"def",
"module_install",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"if",
"__salt__",
"[",
"'selinux.install_semod'",
"]",
"(",
"name",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | module_remove | Removes SELinux module
name
The name of the module to remove
.. versionadded:: 2016.11.6 | salt/states/selinux.py | def module_remove(name):
'''
Removes SELinux module
name
The name of the module to remove
.. versionadded:: 2016.11.6
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
modules = __salt__['selinux.list_semod']()
if name not i... | def module_remove(name):
'''
Removes SELinux module
name
The name of the module to remove
.. versionadded:: 2016.11.6
'''
ret = {'name': name,
'result': True,
'comment': '',
'changes': {}}
modules = __salt__['selinux.list_semod']()
if name not i... | [
"Removes",
"SELinux",
"module"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L292-L315 | [
"def",
"module_remove",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"modules",
"=",
"__salt__",
"[",
"'selinux.list_semod'",
"]",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | fcontext_policy_present | .. versionadded:: 2017.7.0
Makes sure a SELinux policy for a given filespec (name), filetype
and SELinux context type is present.
name
filespec of the file or directory. Regex syntax is allowed.
sel_type
SELinux context type. There are many.
filetype
The SELinux filetype ... | salt/states/selinux.py | def fcontext_policy_present(name, sel_type, filetype='a', sel_user=None, sel_level=None):
'''
.. versionadded:: 2017.7.0
Makes sure a SELinux policy for a given filespec (name), filetype
and SELinux context type is present.
name
filespec of the file or directory. Regex syntax is allowed.
... | def fcontext_policy_present(name, sel_type, filetype='a', sel_user=None, sel_level=None):
'''
.. versionadded:: 2017.7.0
Makes sure a SELinux policy for a given filespec (name), filetype
and SELinux context type is present.
name
filespec of the file or directory. Regex syntax is allowed.
... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L318-L396 | [
"def",
"fcontext_policy_present",
"(",
"name",
",",
"sel_type",
",",
"filetype",
"=",
"'a'",
",",
"sel_user",
"=",
"None",
",",
"sel_level",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | fcontext_policy_absent | .. versionadded:: 2017.7.0
Makes sure an SELinux file context policy for a given filespec
(name), filetype and SELinux context type is absent.
name
filespec of the file or directory. Regex syntax is allowed.
filetype
The SELinux filetype specification. Use one of [a, f, d, c, b,
... | salt/states/selinux.py | def fcontext_policy_absent(name, filetype='a', sel_type=None, sel_user=None, sel_level=None):
'''
.. versionadded:: 2017.7.0
Makes sure an SELinux file context policy for a given filespec
(name), filetype and SELinux context type is absent.
name
filespec of the file or directory. Regex syn... | def fcontext_policy_absent(name, filetype='a', sel_type=None, sel_user=None, sel_level=None):
'''
.. versionadded:: 2017.7.0
Makes sure an SELinux file context policy for a given filespec
(name), filetype and SELinux context type is absent.
name
filespec of the file or directory. Regex syn... | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/selinux.py#L399-L455 | [
"def",
"fcontext_policy_absent",
"(",
"name",
",",
"filetype",
"=",
"'a'",
",",
"sel_type",
"=",
"None",
",",
"sel_user",
"=",
"None",
",",
"sel_level",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.