repository_name
stringclasses
316 values
func_path_in_repository
stringlengths
6
223
func_name
stringlengths
1
134
language
stringclasses
1 value
func_code_string
stringlengths
57
65.5k
func_documentation_string
stringlengths
1
46.3k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
called_functions
listlengths
1
156
enclosing_scope
stringlengths
2
1.48M
saltstack/salt
salt/modules/purefb.py
_get_snapshot
python
def _get_snapshot(name, suffix, blade): ''' Return name of Snapshot or None ''' try: filt = 'source=\'{}\' and suffix=\'{}\''.format(name, suffix) res = blade.file_system_snapshots.list_file_system_snapshots(filter=filt) return res.items[0] except rest.ApiException: ...
Return name of Snapshot or None
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefb.py#L140-L150
null
# -*- coding: utf-8 -*- ## # Copyright 2018 Pure Storage Inc # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
saltstack/salt
salt/modules/purefb.py
_get_deleted_fs
python
def _get_deleted_fs(name, blade): ''' Private function to check if a file systeem has already been deleted ''' try: _fs = _get_fs(name, blade) if _fs and _fs.destroyed: return _fs except rest.ApiException: return None
Private function to check if a file systeem has already been deleted
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefb.py#L153-L163
[ "def _get_fs(name, blade):\n '''\n Private function to\n check for existance of a filesystem\n '''\n _fs = []\n _fs.append(name)\n try:\n res = blade.file_systems.list_file_systems(names=_fs)\n return res.items[0]\n except rest.ApiException:\n return None\n" ]
# -*- coding: utf-8 -*- ## # Copyright 2018 Pure Storage Inc # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
saltstack/salt
salt/states/syslog_ng.py
started
python
def started(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfile=None, enable_core=False, fd_limit=None, verbose=False, debug=False, trace=False, yy...
Ensures, that syslog-ng is started via the given parameters. Users shouldn't use this function, if the service module is available on their system.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/syslog_ng.py#L76-L115
null
# -*- coding: utf-8 -*- ''' State module for syslog_ng ========================== :maintainer: Tibor Benke <btibi@sch.bme.hu> :maturity: new :depends: cmd, ps, syslog_ng :platform: all Users can generate syslog-ng configuration files from YAML format or use plain ones and reload, start, or stop th...
saltstack/salt
salt/client/ssh/client.py
SSHClient._prep_ssh
python
def _prep_ssh( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', kwarg=None, **kwargs): ''' Prepare the arguments ''' opts = copy.deepcopy(self.opts) opts.update(kwargs) i...
Prepare the arguments
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/client.py#L43-L64
[ "def condition_input(args, kwargs):\n '''\n Return a single arg structure for the publisher to safely use\n '''\n ret = []\n for arg in args:\n if (six.PY3 and isinstance(arg, six.integer_types) and salt.utils.jid.is_jid(six.text_type(arg))) or \\\n (six.PY2 and isinstance(arg, long)): ...
class SSHClient(object): ''' Create a client object for executing routines via the salt-ssh backend .. versionadded:: 2015.5.0 ''' def __init__(self, c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, disable_custom_roster=False): ...
saltstack/salt
salt/client/ssh/client.py
SSHClient.cmd_iter
python
def cmd_iter( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, **kwargs): ''' Execute a single command via the salt-ssh subsystem and return a generator ...
Execute a single command via the salt-ssh subsystem and return a generator .. versionadded:: 2015.5.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/client.py#L66-L91
[ "def run_iter(self, mine=False, jid=None):\n '''\n Execute and yield returns as they come in, do not print to the display\n\n mine\n The Single objects will use mine_functions defined in the roster,\n pillar, or master config (they will be checked in that order) and\n will modify the a...
class SSHClient(object): ''' Create a client object for executing routines via the salt-ssh backend .. versionadded:: 2015.5.0 ''' def __init__(self, c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, disable_custom_roster=False): ...
saltstack/salt
salt/client/ssh/client.py
SSHClient.cmd
python
def cmd(self, tgt, fun, arg=(), timeout=None, tgt_type='glob', kwarg=None, **kwargs): ''' Execute a single command via the salt-ssh subsystem and return all routines at once .. versionadded:: 2015.5.0 ...
Execute a single command via the salt-ssh subsystem and return all routines at once .. versionadded:: 2015.5.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/client.py#L93-L118
[ "def run_iter(self, mine=False, jid=None):\n '''\n Execute and yield returns as they come in, do not print to the display\n\n mine\n The Single objects will use mine_functions defined in the roster,\n pillar, or master config (they will be checked in that order) and\n will modify the a...
class SSHClient(object): ''' Create a client object for executing routines via the salt-ssh backend .. versionadded:: 2015.5.0 ''' def __init__(self, c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, disable_custom_roster=False): ...
saltstack/salt
salt/client/ssh/client.py
SSHClient.cmd_sync
python
def cmd_sync(self, low): ''' Execute a salt-ssh call synchronously. .. versionadded:: 2015.5.0 WARNING: Eauth is **NOT** respected .. code-block:: python client.cmd_sync({ 'tgt': 'silver', 'fun': 'test.ping', 'arg': ...
Execute a salt-ssh call synchronously. .. versionadded:: 2015.5.0 WARNING: Eauth is **NOT** respected .. code-block:: python client.cmd_sync({ 'tgt': 'silver', 'fun': 'test.ping', 'arg': (), 'tgt_type'='glob', ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/client.py#L120-L152
[ "def cmd(self,\n tgt,\n fun,\n arg=(),\n timeout=None,\n tgt_type='glob',\n kwarg=None,\n **kwargs):\n '''\n Execute a single command via the salt-ssh subsystem and return all\n routines at once\n\n .. versionadded:: 2015.5.0\n '''\n ssh = self._pre...
class SSHClient(object): ''' Create a client object for executing routines via the salt-ssh backend .. versionadded:: 2015.5.0 ''' def __init__(self, c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, disable_custom_roster=False): ...
saltstack/salt
salt/client/ssh/client.py
SSHClient.cmd_subset
python
def cmd_subset( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, sub=3, **kwargs): ''' Execute a command on a random subset of the targeted systems T...
Execute a command on a random subset of the targeted systems The function signature is the same as :py:meth:`cmd` with the following exceptions. :param sub: The number of systems to execute on .. code-block:: python >>> import salt.client.ssh.client >>> sshcli...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/client.py#L174-L214
[ "def cmd_iter(\n self,\n tgt,\n fun,\n arg=(),\n timeout=None,\n tgt_type='glob',\n ret='',\n kwarg=None,\n **kwargs):\n '''\n Execute a single command via the salt-ssh subsystem and return a\n generator\n\n .. versionadded:: 2015.5.0\n '...
class SSHClient(object): ''' Create a client object for executing routines via the salt-ssh backend .. versionadded:: 2015.5.0 ''' def __init__(self, c_path=os.path.join(syspaths.CONFIG_DIR, 'master'), mopts=None, disable_custom_roster=False): ...
saltstack/salt
salt/states/eselect.py
set_
python
def set_(name, target, module_parameter=None, action_parameter=None): ''' Verify that the given module is set to the given target name The name of the module target The target to be set for this module module_parameter additional params passed to the defined module ac...
Verify that the given module is set to the given target name The name of the module target The target to be set for this module module_parameter additional params passed to the defined module action_parameter additional params passed to the defined action .. code...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/eselect.py#L26-L85
null
# -*- coding: utf-8 -*- ''' Management of Gentoo configuration using eselect ================================================ A state module to manage Gentoo configuration via eselect ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Define a function alias in order...
saltstack/salt
salt/modules/napalm_network.py
_filter_list
python
def _filter_list(input_list, search_key, search_value): ''' Filters a list of dictionary by a set of key-value pair. :param input_list: is a list of dictionaries :param search_key: is the key we are looking for :param search_value: is the value we are looking for the key specified in search_ke...
Filters a list of dictionary by a set of key-value pair. :param input_list: is a list of dictionaries :param search_key: is the key we are looking for :param search_value: is the value we are looking for the key specified in search_key :return: filered list of dictionaries
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L70-L87
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
_filter_dict
python
def _filter_dict(input_dict, search_key, search_value): ''' Filters a dictionary of dictionaries by a key-value pair. :param input_dict: is a dictionary whose values are lists of dictionaries :param search_key: is the key in the leaf dictionaries :param search_values: is the value in the lea...
Filters a dictionary of dictionaries by a key-value pair. :param input_dict: is a dictionary whose values are lists of dictionaries :param search_key: is the key in the leaf dictionaries :param search_values: is the value in the leaf dictionaries :return: filtered dictionary
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L90-L108
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
_explicit_close
python
def _explicit_close(napalm_device): ''' Will explicily close the config session with the network device, when running in a now-always-alive proxy minion or regular minion. This helper must be used in configuration-related functions, as the session is preserved and not closed before making any change...
Will explicily close the config session with the network device, when running in a now-always-alive proxy minion or regular minion. This helper must be used in configuration-related functions, as the session is preserved and not closed before making any changes.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L142-L158
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
_config_logic
python
def _config_logic(napalm_device, loaded_result, test=False, debug=False, replace=False, commit_config=True, loaded_config=None, commit_in=None, commit_at=None, ...
Builds the config logic for `load_config` and `load_template` functions.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L161-L345
[ "def mkstemp(*args, **kwargs):\n '''\n Helper function which does exactly what ``tempfile.mkstemp()`` does but\n accepts another argument, ``close_fd``, which, by default, is true and closes\n the fd before returning the file path. Something commonly done throughout\n Salt's code.\n '''\n if 'p...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
cli
python
def cli(*commands, **kwargs): # pylint: disable=unused-argument ''' Returns a dictionary with the raw output of all commands passed as arguments. commands List of commands to be executed on the device. textfsm_parse: ``False`` Try parsing the outputs using the TextFSM templates. ...
Returns a dictionary with the raw output of all commands passed as arguments. commands List of commands to be executed on the device. textfsm_parse: ``False`` Try parsing the outputs using the TextFSM templates. .. versionadded:: 2018.3.0 .. note:: This option can...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L492-L783
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
traceroute
python
def traceroute(destination, source=None, ttl=None, timeout=None, vrf=None, **kwargs): # pylint: disable=unused-argument ''' Calls the method traceroute from the NAPALM driver object and returns a dictionary with the result of the traceroute command executed on the device. destination Hostname...
Calls the method traceroute from the NAPALM driver object and returns a dictionary with the result of the traceroute command executed on the device. destination Hostname or address of remote host source Source address to use in outgoing traceroute packets ttl IP maximum time-t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L787-L828
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
ping
python
def ping(destination, source=None, ttl=None, timeout=None, size=None, count=None, vrf=None, **kwargs): # pylint: disable=unused-argument ''' Executes a ping on the network device and returns a dictionary as a result. destination Hostname or IP address of remote host source Source add...
Executes a ping on the network device and returns a dictionary as a result. destination Hostname or IP address of remote host source Source address of echo request ttl IP time-to-live value (IPv6 hop-limit value) (1..255 hops) timeout Maximum wait time after sending f...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L832-L881
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
arp
python
def arp(interface='', ipaddr='', macaddr='', **kwargs): # pylint: disable=unused-argument ''' NAPALM returns a list of dictionaries with details of the ARP entries. :param interface: interface name to filter on :param ipaddr: IP address to filter on :param macaddr: MAC address to filter on :r...
NAPALM returns a list of dictionaries with details of the ARP entries. :param interface: interface name to filter on :param ipaddr: IP address to filter on :param macaddr: MAC address to filter on :return: List of the entries in the ARP table CLI Example: .. code-block:: bash salt '*...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L885-L947
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
lldp
python
def lldp(interface='', **kwargs): # pylint: disable=unused-argument ''' Returns a detailed view of the LLDP neighbors. :param interface: interface name to filter on :return: A dictionary with the LLDL neighbors. The keys are the interfaces with LLDP activated on. CLI Example: ...
Returns a detailed view of the LLDP neighbors. :param interface: interface name to filter on :return: A dictionary with the LLDL neighbors. The keys are the interfaces with LLDP activated on. CLI Example: .. code-block:: bash salt '*' net.lldp salt '*' net.lldp inte...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L1058-L1117
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
mac
python
def mac(address='', interface='', vlan=0, **kwargs): # pylint: disable=unused-argument ''' Returns the MAC Address Table on the device. :param address: MAC address to filter on :param interface: Interface name to filter on :param vlan: VLAN identifier :return: A list of dictio...
Returns the MAC Address Table on the device. :param address: MAC address to filter on :param interface: Interface name to filter on :param vlan: VLAN identifier :return: A list of dictionaries representing the entries in the MAC Address Table CLI Example: .. code-block:: bash ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L1121-L1190
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
load_config
python
def load_config(filename=None, text=None, test=False, commit=True, debug=False, replace=False, commit_in=None, commit_at=None, revert_in=None, revert_at=None, c...
Applies configuration changes on the device. It can be loaded from a file or from inline string. If you send both a filename and a string containing the configuration, the file has higher precedence. By default this function will commit the changes. If there are no changes, it does not commit and the flag ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L1296-L1551
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
load_template
python
def load_template(template_name=None, template_source=None, context=None, defaults=None, template_engine='jinja', saltenv='base', template_hash=None, template_hash_name=None, s...
Renders a configuration template (default: Jinja) and loads the result on the device. By default this function will commit the changes. If there are no changes, it does not commit, discards he config and the flag ``already_configured`` will be set as ``True`` to point this out. To avoid committing the...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L1555-L2082
[ "def call(napalm_device, method, *args, **kwargs):\n '''\n Calls arbitrary methods from the network driver instance.\n Please check the readthedocs_ page for the updated list of getters.\n\n .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix\n\n method\...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
config_changed
python
def config_changed(inherit_napalm_device=None, **kwargs): # pylint: disable=unused-argument ''' Will prompt if the configuration has been changed. :return: A tuple with a boolean that specifies if the config was changed on the device.\ And a string that provides more details of the reason why the con...
Will prompt if the configuration has been changed. :return: A tuple with a boolean that specifies if the config was changed on the device.\ And a string that provides more details of the reason why the configuration was not changed. CLI Example: .. code-block:: bash salt '*' net.config_chang...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2166-L2193
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
config_control
python
def config_control(inherit_napalm_device=None, **kwargs): # pylint: disable=unused-argument ''' Will check if the configuration was changed. If differences found, will try to commit. In case commit unsuccessful, will try to rollback. :return: A tuple with a boolean that specifies if the config wa...
Will check if the configuration was changed. If differences found, will try to commit. In case commit unsuccessful, will try to rollback. :return: A tuple with a boolean that specifies if the config was changed/committed/rollbacked on the device.\ And a string that provides more details of the reason w...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2197-L2235
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
cancel_commit
python
def cancel_commit(jid): ''' .. versionadded:: 2019.2.0 Cancel a commit scheduled to be executed via the ``commit_in`` and ``commit_at`` arguments from the :py:func:`net.load_template <salt.modules.napalm_network.load_template>` or :py:func:`net.load_config <salt.modules.napalm_network.load_conf...
.. versionadded:: 2019.2.0 Cancel a commit scheduled to be executed via the ``commit_in`` and ``commit_at`` arguments from the :py:func:`net.load_template <salt.modules.napalm_network.load_template>` or :py:func:`net.load_config <salt.modules.napalm_network.load_config>` execution functions. The co...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2238-L2262
null
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
confirm_commit
python
def confirm_commit(jid): ''' .. versionadded:: 2019.2.0 Confirm a commit scheduled to be reverted via the ``revert_in`` and ``revert_at`` arguments from the :mod:`net.load_template <salt.modules.napalm_network.load_template>` or :mod:`net.load_config <salt.modules.napalm_network.load_config>` ...
.. versionadded:: 2019.2.0 Confirm a commit scheduled to be reverted via the ``revert_in`` and ``revert_at`` arguments from the :mod:`net.load_template <salt.modules.napalm_network.load_template>` or :mod:`net.load_config <salt.modules.napalm_network.load_config>` execution functions. The commit I...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2265-L2291
[ "def cancel_commit(jid):\n '''\n .. versionadded:: 2019.2.0\n\n Cancel a commit scheduled to be executed via the ``commit_in`` and\n ``commit_at`` arguments from the\n :py:func:`net.load_template <salt.modules.napalm_network.load_template>` or\n :py:func:`net.load_config <salt.modules.napalm_netwo...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
save_config
python
def save_config(source=None, path=None): ''' .. versionadded:: 2019.2.0 Save the configuration to a file on the local file system. source: ``running`` The configuration source. Choose from: ``running``, ``candidate``, ``startup``. Default: ``running``. path ...
.. versionadded:: 2019.2.0 Save the configuration to a file on the local file system. source: ``running`` The configuration source. Choose from: ``running``, ``candidate``, ``startup``. Default: ``running``. path Absolute path to file where to save the configuration. To pu...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2294-L2330
[ "def mkstemp(*args, **kwargs):\n '''\n Helper function which does exactly what ``tempfile.mkstemp()`` does but\n accepts another argument, ``close_fd``, which, by default, is true and closes\n the fd before returning the file path. Something commonly done throughout\n Salt's code.\n '''\n if 'p...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
replace_pattern
python
def replace_pattern(pattern, repl, count=0, flags=8, bufsize=1, append_if_not_found=False, prepend_if_not_found=False, not_found_content=None, search_only=False...
.. versionadded:: 2019.2.0 Replace occurrences of a pattern in the configuration source. If ``show_changes`` is ``True``, then a diff of what changed will be returned, otherwise a ``True`` will be returned when changes are made, and ``False`` when no changes are made. This is a pure Python implemen...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2333-L2473
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
blockreplace
python
def blockreplace(marker_start, marker_end, content='', append_if_not_found=False, prepend_if_not_found=False, show_changes=True, append_newline=False, source='running', path=None, ...
.. versionadded:: 2019.2.0 Replace content of the configuration source, delimited by the line markers. A block of content delimited by comments can help you manage several lines without worrying about old entries removal. marker_start The line content identifying a line as the start of the co...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2476-L2582
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/modules/napalm_network.py
patch
python
def patch(patchfile, options='', saltenv='base', source_hash=None, show_changes=True, source='running', path=None, test=False, commit=True, debug=False, replace=True): ''' .. versionadded:: 2019.2.0 Apply a ...
.. versionadded:: 2019.2.0 Apply a patch to the configuration source, and load the result into the running config of the device. patchfile A patch file to apply to the configuration source. options Options to pass to patch. source_hash If the patch file (specified via the...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2585-L2670
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' NAPALM Network ============== Basic methods for interaction with the network device through the virtual proxy 'napalm'. :codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ ...
saltstack/salt
salt/cli/run.py
SaltRun.run
python
def run(self): ''' Execute salt-run ''' import salt.runner self.parse_args() # Setup file logging! self.setup_logfile_logger() verify_log(self.config) profiling_enabled = self.options.profiling_enabled runner = salt.runner.Runner(self.con...
Execute salt-run
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/run.py#L17-L58
[ "def check_user(user):\n '''\n Check user and assign process uid/gid.\n '''\n if salt.utils.platform.is_windows():\n return True\n if user == salt.utils.user.get_user():\n return True\n import pwd # after confirming not running Windows\n try:\n pwuser = pwd.getpwnam(user)\...
class SaltRun(salt.utils.parsers.SaltRunOptionParser): ''' Used to execute Salt runners '''
saltstack/salt
salt/states/dellchassis.py
blade_idrac
python
def blade_idrac(name, idrac_password=None, idrac_ipmi=None, idrac_ip=None, idrac_netmask=None, idrac_gateway=None, idrac_dnsname=None, idrac_dhcp=None): ''' Set parameters for iDRAC in a blade. :param idrac_password: Password to use to connect to the iDRACs d...
Set parameters for iDRAC in a blade. :param idrac_password: Password to use to connect to the iDRACs directly (idrac_ipmi and idrac_dnsname must be set directly on the iDRAC. They can't be set through the CMC. If this password is present, use it instead of the CMC password) :param idr...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dellchassis.py#L174-L317
null
# -*- coding: utf-8 -*- ''' Manage chassis via Salt Proxies. .. versionadded:: 2015.8.2 Below is an example state that sets basic parameters: .. code-block:: yaml my-dell-chassis: dellchassis.chassis: - chassis_name: my-dell-chassis - datacenter: dc-1-us - location: my-location ...
saltstack/salt
salt/states/dellchassis.py
chassis
python
def chassis(name, chassis_name=None, password=None, datacenter=None, location=None, mode=None, idrac_launch=None, slot_names=None, blade_power_states=None): ''' Manage a Dell Chassis. chassis_name The name of the chassis. datacenter The datacenter in which the c...
Manage a Dell Chassis. chassis_name The name of the chassis. datacenter The datacenter in which the chassis is located location The location of the chassis. password Password for the chassis. Note: If this password is set for the chassis, the current implement...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dellchassis.py#L320-L546
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Manage chassis via Salt Proxies. .. versionadded:: 2015.8.2 Below is an example state that sets basic parameters: .. code-block:: yaml my-dell-chassis: dellchassis.chassis: - chassis_name: my-dell-chassis - datacenter: dc-1-us - location: my-location ...
saltstack/salt
salt/states/dellchassis.py
switch
python
def switch(name, ip=None, netmask=None, gateway=None, dhcp=None, password=None, snmp=None): ''' Manage switches in a Dell Chassis. name The switch designation (e.g. switch-1, switch-2) ip The Static IP Address of the switch netmask The netmask for the stati...
Manage switches in a Dell Chassis. name The switch designation (e.g. switch-1, switch-2) ip The Static IP Address of the switch netmask The netmask for the static IP gateway The gateway for the static IP dhcp True: Enable DHCP False: Do not change...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dellchassis.py#L549-L664
null
# -*- coding: utf-8 -*- ''' Manage chassis via Salt Proxies. .. versionadded:: 2015.8.2 Below is an example state that sets basic parameters: .. code-block:: yaml my-dell-chassis: dellchassis.chassis: - chassis_name: my-dell-chassis - datacenter: dc-1-us - location: my-location ...
saltstack/salt
salt/states/dellchassis.py
_firmware_update
python
def _firmware_update(firmwarefile='', host='', directory=''): ''' Update firmware for a single host ''' dest = os.path.join(directory, firmwarefile[7:]) __salt__['cp.get_file'](firmwarefile, dest) username = __pillar__['proxy']['admin_user'] password = __pillar__['prox...
Update firmware for a single host
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dellchassis.py#L667-L681
null
# -*- coding: utf-8 -*- ''' Manage chassis via Salt Proxies. .. versionadded:: 2015.8.2 Below is an example state that sets basic parameters: .. code-block:: yaml my-dell-chassis: dellchassis.chassis: - chassis_name: my-dell-chassis - datacenter: dc-1-us - location: my-location ...
saltstack/salt
salt/states/dellchassis.py
firmware_update
python
def firmware_update(hosts=None, directory=''): ''' State to update the firmware on host using the ``racadm`` command firmwarefile filename (string) starting with ``salt://`` host string representing the hostname supplied to the ``racadm`` command ...
State to update the firmware on host using the ``racadm`` command firmwarefile filename (string) starting with ``salt://`` host string representing the hostname supplied to the ``racadm`` command directory Directory name where firmwarefile...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dellchassis.py#L684-L731
[ "def _firmware_update(firmwarefile='', host='',\n directory=''):\n '''\n Update firmware for a single host\n '''\n dest = os.path.join(directory, firmwarefile[7:])\n\n __salt__['cp.get_file'](firmwarefile, dest)\n\n username = __pillar__['proxy']['admin_user']\n password = _...
# -*- coding: utf-8 -*- ''' Manage chassis via Salt Proxies. .. versionadded:: 2015.8.2 Below is an example state that sets basic parameters: .. code-block:: yaml my-dell-chassis: dellchassis.chassis: - chassis_name: my-dell-chassis - datacenter: dc-1-us - location: my-location ...
saltstack/salt
salt/transport/tcp.py
_set_tcp_keepalive
python
def _set_tcp_keepalive(sock, opts): ''' Ensure that TCP keepalives are set for the socket. ''' if hasattr(socket, 'SO_KEEPALIVE'): if opts.get('tcp_keepalive', False): sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) if hasattr(socket, 'SOL_TCP'): ...
Ensure that TCP keepalives are set for the socket.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L83-L135
null
# -*- coding: utf-8 -*- ''' TCP transport classes Wire protocol: "len(payload) msgpack({'head': SOMEHEADER, 'body': SOMEBODY})" ''' # Import Python Libs from __future__ import absolute_import, print_function, unicode_literals import errno import logging import socket import os import weakref import time import threa...
saltstack/salt
salt/transport/tcp.py
AsyncTCPReqChannel._crypted_transfer
python
def _crypted_transfer(self, load, tries=3, timeout=60): ''' In case of authentication errors, try to renegotiate authentication and retry the method. Indeed, we can fail too early in case of a master restart during a minion state execution call ''' @tornado.gen.co...
In case of authentication errors, try to renegotiate authentication and retry the method. Indeed, we can fail too early in case of a master restart during a minion state execution call
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L361-L391
null
class AsyncTCPReqChannel(salt.transport.client.ReqChannel): ''' Encapsulate sending routines to tcp. Note: this class returns a singleton ''' # This class is only a singleton per minion/master pair # mapping of io_loop -> {key -> channel} instance_map = weakref.WeakKeyDictionary() def ...
saltstack/salt
salt/transport/tcp.py
AsyncTCPPubChannel.send_id
python
def send_id(self, tok, force_auth): ''' Send the minion id to the master so that the master may better track the connection state of the minion. In case of authentication errors, try to renegotiate authentication and retry the method. ''' load = {'id': self.opts['...
Send the minion id to the master so that the master may better track the connection state of the minion. In case of authentication errors, try to renegotiate authentication and retry the method.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L451-L482
null
class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.transport.client.AsyncPubChannel): def __init__(self, opts, **kwargs): self.opts = opts self.serial = salt.payload.Serial(self.opts) self.crypt = kwargs.get('crypt', 'aes') ...
saltstack/salt
salt/transport/tcp.py
AsyncTCPPubChannel.on_recv
python
def on_recv(self, callback): ''' Register an on_recv callback ''' if callback is None: return self.message_client.on_recv(callback) @tornado.gen.coroutine def wrap_callback(body): if not isinstance(body, dict): # TODO: For some rea...
Register an on_recv callback
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L579-L596
null
class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.transport.client.AsyncPubChannel): def __init__(self, opts, **kwargs): self.opts = opts self.serial = salt.payload.Serial(self.opts) self.crypt = kwargs.get('crypt', 'aes') ...
saltstack/salt
salt/transport/tcp.py
TCPReqServerChannel.pre_fork
python
def pre_fork(self, process_manager): ''' Pre-fork we need to create the zmq router device ''' salt.transport.mixins.auth.AESReqServerMixin.pre_fork(self, process_manager) if USE_LOAD_BALANCER: self.socket_queue = multiprocessing.Queue() process_manager.add...
Pre-fork we need to create the zmq router device
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L633-L648
[ "def _set_tcp_keepalive(sock, opts):\n '''\n Ensure that TCP keepalives are set for the socket.\n '''\n if hasattr(socket, 'SO_KEEPALIVE'):\n if opts.get('tcp_keepalive', False):\n sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)\n if hasattr(socket, 'SOL_TCP'):\n ...
class TCPReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.transport.server.ReqServerChannel): # TODO: opts! backlog = 5 def __init__(self, opts): salt.transport.server.ReqServerChannel.__init__(self, opts) self._socket = None @property def socket(self): r...
saltstack/salt
salt/transport/tcp.py
TCPReqServerChannel.post_fork
python
def post_fork(self, payload_handler, io_loop): ''' After forking we need to create all of the local sockets to listen to the router payload_handler: function to call with your payloads ''' self.payload_handler = payload_handler self.io_loop = io_loop self...
After forking we need to create all of the local sockets to listen to the router payload_handler: function to call with your payloads
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L650-L676
[ "def _set_tcp_keepalive(sock, opts):\n '''\n Ensure that TCP keepalives are set for the socket.\n '''\n if hasattr(socket, 'SO_KEEPALIVE'):\n if opts.get('tcp_keepalive', False):\n sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)\n if hasattr(socket, 'SOL_TCP'):\n ...
class TCPReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.transport.server.ReqServerChannel): # TODO: opts! backlog = 5 def __init__(self, opts): salt.transport.server.ReqServerChannel.__init__(self, opts) self._socket = None @property def socket(self): r...
saltstack/salt
salt/transport/tcp.py
TCPReqServerChannel.handle_message
python
def handle_message(self, stream, header, payload): ''' Handle incoming messages from underylying tcp streams ''' try: try: payload = self._decode_payload(payload) except Exception: stream.write(salt.transport.frame.frame_msg('bad lo...
Handle incoming messages from underylying tcp streams
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L679-L750
[ "def frame_msg(body, header=None, raw_body=False): # pylint: disable=unused-argument\n '''\n Frame the given message with our wire protocol\n '''\n framed_msg = {}\n if header is None:\n header = {}\n\n framed_msg['head'] = header\n framed_msg['body'] = body\n return salt.utils.msgpa...
class TCPReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.transport.server.ReqServerChannel): # TODO: opts! backlog = 5 def __init__(self, opts): salt.transport.server.ReqServerChannel.__init__(self, opts) self._socket = None @property def socket(self): r...
saltstack/salt
salt/transport/tcp.py
SaltMessageServer.handle_stream
python
def handle_stream(self, stream, address): ''' Handle incoming streams and add messages to the incoming queue ''' log.trace('Req client %s connected', address) self.clients.append((stream, address)) unpacker = msgpack.Unpacker() try: while True: ...
Handle incoming streams and add messages to the incoming queue
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L766-L791
null
class SaltMessageServer(tornado.tcpserver.TCPServer, object): ''' Raw TCP server which will receive all of the TCP streams and re-assemble messages that are sent through to us ''' def __init__(self, message_handler, *args, **kwargs): super(SaltMessageServer, self).__init__(*args, **kwargs) ...
saltstack/salt
salt/transport/tcp.py
SaltMessageServer.shutdown
python
def shutdown(self): ''' Shutdown the whole server ''' for item in self.clients: client, address = item client.close() self.clients.remove(item)
Shutdown the whole server
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L793-L800
null
class SaltMessageServer(tornado.tcpserver.TCPServer, object): ''' Raw TCP server which will receive all of the TCP streams and re-assemble messages that are sent through to us ''' def __init__(self, message_handler, *args, **kwargs): super(SaltMessageServer, self).__init__(*args, **kwargs) ...
saltstack/salt
salt/transport/tcp.py
TCPClientKeepAlive._create_stream
python
def _create_stream(self, max_buffer_size, af, addr, **kwargs): # pylint: disable=unused-argument ''' Override _create_stream() in TCPClient. Tornado 4.5 added the kwargs 'source_ip' and 'source_port'. Due to this, use **kwargs to swallow these and any future kwargs to maintain ...
Override _create_stream() in TCPClient. Tornado 4.5 added the kwargs 'source_ip' and 'source_port'. Due to this, use **kwargs to swallow these and any future kwargs to maintain compatibility.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L849-L866
null
class TCPClientKeepAlive(tornado.tcpclient.TCPClient): ''' Override _create_stream() in TCPClient to enable keep alive support. ''' def __init__(self, opts, resolver=None): self.opts = opts super(TCPClientKeepAlive, self).__init__(resolver=resolver)
saltstack/salt
salt/transport/tcp.py
SaltMessageClient._connect
python
def _connect(self): ''' Try to connect for the rest of time! ''' while True: if self._closing: break try: kwargs = {} if self.source_ip or self.source_port: if tornado.version_info >= (4, 5): ...
Try to connect for the rest of time!
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1007-L1033
null
class SaltMessageClient(object): ''' Low-level message sending client ''' def __init__(self, opts, host, port, io_loop=None, resolver=None, connect_callback=None, disconnect_callback=None, source_ip=None, source_port=None): self.opts = opts self.host = h...
saltstack/salt
salt/transport/tcp.py
SaltMessageClient.on_recv
python
def on_recv(self, callback): ''' Register a callback for received messages (that we didn't initiate) ''' if callback is None: self._on_recv = callback else: def wrap_recv(header, body): callback(body) self._on_recv = wrap_recv
Register a callback for received messages (that we didn't initiate)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1142-L1151
null
class SaltMessageClient(object): ''' Low-level message sending client ''' def __init__(self, opts, host, port, io_loop=None, resolver=None, connect_callback=None, disconnect_callback=None, source_ip=None, source_port=None): self.opts = opts self.host = h...
saltstack/salt
salt/transport/tcp.py
SaltMessageClient.send
python
def send(self, msg, timeout=None, callback=None, raw=False): ''' Send given message, and return a future ''' message_id = self._message_id() header = {'mid': message_id} future = tornado.concurrent.Future() if callback is not None: def handle_future(f...
Send given message, and return a future
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1167-L1194
[ "def frame_msg(body, header=None, raw_body=False): # pylint: disable=unused-argument\n '''\n Frame the given message with our wire protocol\n '''\n framed_msg = {}\n if header is None:\n header = {}\n\n framed_msg['head'] = header\n framed_msg['body'] = body\n return salt.utils.msgpa...
class SaltMessageClient(object): ''' Low-level message sending client ''' def __init__(self, opts, host, port, io_loop=None, resolver=None, connect_callback=None, disconnect_callback=None, source_ip=None, source_port=None): self.opts = opts self.host = h...
saltstack/salt
salt/transport/tcp.py
TCPPubServerChannel._publish_daemon
python
def _publish_daemon(self, **kwargs): ''' Bind to the interface specified in the configuration file ''' salt.utils.process.appendproctitle(self.__class__.__name__) log_queue = kwargs.get('log_queue') if log_queue is not None: salt.log.setup.set_multiprocessing...
Bind to the interface specified in the configuration file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1418-L1469
null
class TCPPubServerChannel(salt.transport.server.PubServerChannel): # TODO: opts! # Based on default used in tornado.netutil.bind_sockets() backlog = 128 def __init__(self, opts): self.opts = opts self.serial = salt.payload.Serial(self.opts) # TODO: in init? self.ckminions = sal...
saltstack/salt
salt/transport/tcp.py
TCPPubServerChannel.pre_fork
python
def pre_fork(self, process_manager, kwargs=None): ''' Do anything necessary pre-fork. Since this is on the master side this will primarily be used to create IPC channels and create our daemon process to do the actual publishing ''' process_manager.add_process(self._publis...
Do anything necessary pre-fork. Since this is on the master side this will primarily be used to create IPC channels and create our daemon process to do the actual publishing
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1471-L1477
null
class TCPPubServerChannel(salt.transport.server.PubServerChannel): # TODO: opts! # Based on default used in tornado.netutil.bind_sockets() backlog = 128 def __init__(self, opts): self.opts = opts self.serial = salt.payload.Serial(self.opts) # TODO: in init? self.ckminions = sal...
saltstack/salt
salt/transport/tcp.py
TCPPubServerChannel.publish
python
def publish(self, load): ''' Publish "load" to minions ''' payload = {'enc': 'aes'} crypticle = salt.crypt.Crypticle(self.opts, salt.master.SMaster.secrets['aes']['secret'].value) payload['load'] = crypticle.dumps(load) if self.opts['sign_pub_messages']: ...
Publish "load" to minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L1479-L1520
[ "def sign_message(privkey_path, message, passphrase=None):\n '''\n Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature.\n '''\n key = get_rsa_key(privkey_path, passphrase)\n log.debug('salt.crypt.sign_message: Signing message.')\n if HAS_M2:\n md = EVP.MessageDigest('sh...
class TCPPubServerChannel(salt.transport.server.PubServerChannel): # TODO: opts! # Based on default used in tornado.netutil.bind_sockets() backlog = 128 def __init__(self, opts): self.opts = opts self.serial = salt.payload.Serial(self.opts) # TODO: in init? self.ckminions = sal...
saltstack/salt
salt/fileserver/gitfs.py
find_file
python
def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613 ''' Find the first file to match the path and ref, read the file out of git and send the path to the newly cached file ''' return _gitfs().find_file(path, tgt_env=tgt_env, **kwargs)
Find the first file to match the path and ref, read the file out of git and send the path to the newly cached file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/gitfs.py#L150-L155
[ "def _gitfs(init_remotes=True):\n return salt.utils.gitfs.GitFS(\n __opts__,\n __opts__['gitfs_remotes'],\n per_remote_overrides=PER_REMOTE_OVERRIDES,\n per_remote_only=PER_REMOTE_ONLY,\n init_remotes=init_remotes)\n" ]
# -*- coding: utf-8 -*- ''' Git Fileserver Backend With this backend, branches and tags in a remote git repository are exposed to salt as different environments. To enable, add ``gitfs`` to the :conf_master:`fileserver_backend` option in the Master config file. .. code-block:: yaml fileserver_backend: - g...
saltstack/salt
salt/modules/debian_ip.py
_error_msg_iface
python
def _error_msg_iface(iface, option, expected): ''' Build an appropriate error message from a given option and a list of expected values. ''' msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]' return msg.format(iface, option, '|'.join(str(e) for e in expected))
Build an appropriate error message from a given option and a list of expected values.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L155-L161
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_error_msg_routes
python
def _error_msg_routes(iface, option, expected): ''' Build an appropriate error message from a given option and a list of expected values. ''' msg = 'Invalid option -- Route interface: {0}, Option: {1}, Expected: [{2}]' return msg.format(iface, option, expected)
Build an appropriate error message from a given option and a list of expected values.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L164-L170
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_error_msg_network
python
def _error_msg_network(option, expected): ''' Build an appropriate error message from a given option and a list of expected values. ''' msg = 'Invalid network setting -- Setting: {0}, Expected: [{1}]' return msg.format(option, '|'.join(str(e) for e in expected))
Build an appropriate error message from a given option and a list of expected values.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L180-L186
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_raise_error_iface
python
def _raise_error_iface(iface, option, expected): ''' Log and raise an error with a logical formatted message. ''' msg = _error_msg_iface(iface, option, expected) log.error(msg) raise AttributeError(msg)
Log and raise an error with a logical formatted message.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L193-L199
[ "def _error_msg_iface(iface, option, expected):\n '''\n Build an appropriate error message from a given option and\n a list of expected values.\n '''\n msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]'\n return msg.format(iface, option, '|'.join(str(e) for e in expected))\n" ]
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_raise_error_network
python
def _raise_error_network(option, expected): ''' Log and raise an error with a logical formatted message. ''' msg = _error_msg_network(option, expected) log.error(msg) raise AttributeError(msg)
Log and raise an error with a logical formatted message.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L202-L208
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_raise_error_routes
python
def _raise_error_routes(iface, option, expected): ''' Log and raise an error with a logical formatted message. ''' msg = _error_msg_routes(iface, option, expected) log.error(msg) raise AttributeError(msg)
Log and raise an error with a logical formatted message.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L211-L217
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_read_file
python
def _read_file(path): ''' Reads and returns the contents of a text file ''' try: with salt.utils.files.flopen(path, 'rb') as contents: return [salt.utils.stringutils.to_str(line) for line in contents.readlines()] except (OSError, IOError): return ''
Reads and returns the contents of a text file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L220-L228
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_current_network_settings
python
def _parse_current_network_settings(): ''' Parse /etc/default/networking and return current configuration ''' opts = salt.utils.odict.OrderedDict() opts['networking'] = '' if os.path.isfile(_DEB_NETWORKING_FILE): with salt.utils.files.fopen(_DEB_NETWORKING_FILE) as contents: ...
Parse /etc/default/networking and return current configuration
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L263-L286
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__int
python
def __int(value): '''validate an integer''' valid, _value = False, value try: _value = int(value) valid = True except ValueError: pass return (valid, _value, 'integer')
validate an integer
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L315-L323
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__float
python
def __float(value): '''validate a float''' valid, _value = False, value try: _value = float(value) valid = True except ValueError: pass return (valid, _value, 'float')
validate a float
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L326-L334
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__ipv4_netmask
python
def __ipv4_netmask(value): '''validate an IPv4 dotted quad or integer CIDR netmask''' valid, errmsg = False, 'dotted quad or integer CIDR (0->32)' valid, value, _ = __int(value) if not (valid and 0 <= value <= 32): valid = salt.utils.validate.net.netmask(value) return (valid, value, errmsg)
validate an IPv4 dotted quad or integer CIDR netmask
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L337-L343
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__ipv6_netmask
python
def __ipv6_netmask(value): '''validate an IPv6 integer netmask''' valid, errmsg = False, 'IPv6 netmask (0->128)' valid, value, _ = __int(value) valid = (valid and 0 <= value <= 128) return (valid, value, errmsg)
validate an IPv6 integer netmask
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L346-L351
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__within2
python
def __within2(value, within=None, errmsg=None, dtype=None): '''validate that a value is in ``within`` and optionally a ``dtype``''' valid, _value = False, value if dtype: try: _value = dtype(value) # TODO: this is a bit loose when dtype is a class valid = _value in within ...
validate that a value is in ``within`` and optionally a ``dtype``
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L354-L373
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
__space_delimited_list
python
def __space_delimited_list(value): '''validate that a value contains one or more space-delimited values''' if isinstance(value, six.string_types): value = value.strip().split() if hasattr(value, '__iter__') and value != []: return (True, value, 'space-delimited string') else: re...
validate that a value contains one or more space-delimited values
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L381-L389
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_validate_interface_option
python
def _validate_interface_option(attr, value, addrfam='inet'): '''lookup the validation function for a [addrfam][attr] and return the results :param attr: attribute name :param value: raw setting value :param addrfam: address family (inet, inet6, ''' valid, _value, errmsg = False, value, 'Unk...
lookup the validation function for a [addrfam][attr] and return the results :param attr: attribute name :param value: raw setting value :param addrfam: address family (inet, inet6,
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L523-L538
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_interfaces
python
def _parse_interfaces(interface_files=None): ''' Parse /etc/network/interfaces and return current configured interfaces ''' if interface_files is None: interface_files = [] # Add this later. if os.path.exists(_DEB_NETWORK_DIR): interface_files += ['{0}/{1}'.format(_DE...
Parse /etc/network/interfaces and return current configured interfaces
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L548-L692
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_ethtool_opts
python
def _parse_ethtool_opts(opts, iface): ''' Filters given options and outputs valid settings for ETHTOOLS_OPTS If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting. ''' config = {} if 'autoneg' in opts: if opts...
Filters given options and outputs valid settings for ETHTOOLS_OPTS If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L695-L736
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_ethtool_pppoe_opts
python
def _parse_ethtool_pppoe_opts(opts, iface): ''' Filters given options and outputs valid settings for ETHTOOLS_PPPOE_OPTS If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting. ''' config = {} for opt in _DEB_CONFIG_PP...
Filters given options and outputs valid settings for ETHTOOLS_PPPOE_OPTS If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L739-L765
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_settings_bond
python
def _parse_settings_bond(opts, iface): ''' Filters given options and outputs valid settings for requested operation. If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting. ''' bond_def = { # 803.ad aggregation sel...
Filters given options and outputs valid settings for requested operation. If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L768-L835
[ "def _raise_error_iface(iface, option, expected):\n '''\n Log and raise an error with a logical formatted message.\n '''\n msg = _error_msg_iface(iface, option, expected)\n log.error(msg)\n raise AttributeError(msg)\n", "def _parse_settings_bond_0(opts, iface, bond_def):\n '''\n Filters gi...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_settings_bond_2
python
def _parse_settings_bond_2(opts, iface, bond_def): ''' Filters given options and outputs valid settings for bond2. If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting. ''' bond = {'mode': '2'} valid = ['list of ips...
Filters given options and outputs valid settings for bond2. If an option has a value that is not expected, this function will log what the Interface, Setting and what it was expecting.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L918-L962
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_bridge_opts
python
def _parse_bridge_opts(opts, iface): ''' Filters given options and outputs valid settings for BRIDGING_OPTS If an option has a value that is not expected, this function will log the Interface, Setting and what was expected. ''' config = {} if 'ports' in opts: if isinstance(opts['por...
Filters given options and outputs valid settings for BRIDGING_OPTS If an option has a value that is not expected, this function will log the Interface, Setting and what was expected.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1130-L1198
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_settings_eth
python
def _parse_settings_eth(opts, iface_type, enabled, iface): ''' Filters given options and outputs valid settings for a network interface. ''' adapters = salt.utils.odict.OrderedDict() adapters[iface] = salt.utils.odict.OrderedDict() adapters[iface]['type'] = iface_type adapters[iface]['...
Filters given options and outputs valid settings for a network interface.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1201-L1312
[ "def _validate_interface_option(attr, value, addrfam='inet'):\n '''lookup the validation function for a [addrfam][attr] and\n return the results\n\n :param attr: attribute name\n :param value: raw setting value\n :param addrfam: address family (inet, inet6,\n '''\n valid, _value, errmsg = False...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_settings_source
python
def _parse_settings_source(opts, iface_type, enabled, iface): ''' Filters given options and outputs valid settings for a network interface. ''' adapters = salt.utils.odict.OrderedDict() adapters[iface] = salt.utils.odict.OrderedDict() adapters[iface]['type'] = iface_type adapters[iface...
Filters given options and outputs valid settings for a network interface.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1315-L1329
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_network_settings
python
def _parse_network_settings(opts, current): ''' Filters given options and outputs valid settings for the global network settings file. ''' # Normalize keys opts = dict((k.lower(), v) for (k, v) in six.iteritems(opts)) current = dict((k.lower(), v) for (k, v) in six.iteritems(current)) re...
Filters given options and outputs valid settings for the global network settings file.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1332-L1375
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_parse_routes
python
def _parse_routes(iface, opts): ''' Filters given options and outputs valid settings for the route settings file. ''' # Normalize keys opts = dict((k.lower(), v) for (k, v) in six.iteritems(opts)) result = {} if 'routes' not in opts: _raise_error_routes(iface, 'routes', 'List of ...
Filters given options and outputs valid settings for the route settings file.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1378-L1392
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _raise_error_routes(iface, option, expected):\n '''\n Log and raise an error with a logical formatted message.\n '''\n msg = _error_msg_routes(iface, option, expected)\n log.error(msg)\n raise AttributeError(msg)\n" ]
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_write_file
python
def _write_file(iface, data, folder, pattern): ''' Writes a file to disk ''' filename = os.path.join(folder, pattern.format(iface)) if not os.path.exists(folder): msg = '{0} cannot be written. {1} does not exist' msg = msg.format(filename, folder) log.error(msg) raise...
Writes a file to disk
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1395-L1407
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_write_file_network
python
def _write_file_network(data, filename, create=False): ''' Writes a file to disk If file does not exist, only create if create argument is True ''' if not os.path.exists(filename) and not create: msg = '{0} cannot be written. {0} does not exist\ and create is set to False...
Writes a file to disk If file does not exist, only create if create argument is True
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1437-L1450
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_read_temp
python
def _read_temp(data): ''' Return what would be written to disk ''' tout = StringIO() tout.write(data) tout.seek(0) output = tout.readlines() tout.close() return output
Return what would be written to disk
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1453-L1463
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_read_temp_ifaces
python
def _read_temp_ifaces(iface, data): ''' Return what would be written to disk for interfaces ''' try: template = JINJA.get_template('debian_eth.jinja') except jinja2.exceptions.TemplateNotFound: log.error('Could not load template debian_eth.jinja') return '' ifcfg = templ...
Return what would be written to disk for interfaces
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1466-L1478
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_write_file_ifaces
python
def _write_file_ifaces(iface, data, **settings): ''' Writes a file to disk ''' try: eth_template = JINJA.get_template('debian_eth.jinja') source_template = JINJA.get_template('debian_source.jinja') except jinja2.exceptions.TemplateNotFound: log.error('Could not load template ...
Writes a file to disk
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1481-L1532
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
_write_file_ppp_ifaces
python
def _write_file_ppp_ifaces(iface, data): ''' Writes a file to disk ''' try: template = JINJA.get_template('debian_ppp_eth.jinja') except jinja2.exceptions.TemplateNotFound: log.error('Could not load template debian_ppp_eth.jinja') return '' adapters = _parse_interfaces()...
Writes a file to disk
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1535-L1562
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
build_bond
python
def build_bond(iface, **settings): ''' Create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. CLI Example: .. code-block:: bash salt '*' ip.build_bond bond0 mode=balance-alb ''' deb_major = __grains__['osrelease'][:1] opts = _pars...
Create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. CLI Example: .. code-block:: bash salt '*' ip.build_bond bond0 mode=balance-alb
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1565-L1604
[ "def _read_file(path):\n '''\n Reads and returns the contents of a text file\n '''\n try:\n with salt.utils.files.flopen(path, 'rb') as contents:\n return [salt.utils.stringutils.to_str(line) for line in contents.readlines()]\n except (OSError, IOError):\n return ''\n", "de...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
build_interface
python
def build_interface(iface, iface_type, enabled, **settings): ''' Build an interface script for a network interface. CLI Example: .. code-block:: bash salt '*' ip.build_interface eth0 eth <settings> ''' iface_type = iface_type.lower() if iface_type not in _IFACE_TYPES: _r...
Build an interface script for a network interface. CLI Example: .. code-block:: bash salt '*' ip.build_interface eth0 eth <settings>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1607-L1670
[ "def _raise_error_iface(iface, option, expected):\n '''\n Log and raise an error with a logical formatted message.\n '''\n msg = _error_msg_iface(iface, option, expected)\n log.error(msg)\n raise AttributeError(msg)\n", "def _parse_settings_eth(opts, iface_type, enabled, iface):\n '''\n Fi...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
build_routes
python
def build_routes(iface, **settings): ''' Add route scripts for a network interface using up commands. CLI Example: .. code-block:: bash salt '*' ip.build_routes eth0 <settings> ''' opts = _parse_routes(iface, settings) try: template = JINJA.get_template('route_eth.jinja')...
Add route scripts for a network interface using up commands. CLI Example: .. code-block:: bash salt '*' ip.build_routes eth0 <settings>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1673-L1714
[ "def _read_file(path):\n '''\n Reads and returns the contents of a text file\n '''\n try:\n with salt.utils.files.flopen(path, 'rb') as contents:\n return [salt.utils.stringutils.to_str(line) for line in contents.readlines()]\n except (OSError, IOError):\n return ''\n", "de...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
get_bond
python
def get_bond(iface): ''' Return the content of a bond script CLI Example: .. code-block:: bash salt '*' ip.get_bond bond0 ''' path = os.path.join(_DEB_NETWORK_CONF_FILES, '{0}.conf'.format(iface)) return _read_file(path)
Return the content of a bond script CLI Example: .. code-block:: bash salt '*' ip.get_bond bond0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1734-L1745
[ "def _read_file(path):\n '''\n Reads and returns the contents of a text file\n '''\n try:\n with salt.utils.files.flopen(path, 'rb') as contents:\n return [salt.utils.stringutils.to_str(line) for line in contents.readlines()]\n except (OSError, IOError):\n return ''\n" ]
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
get_interface
python
def get_interface(iface): ''' Return the contents of an interface script CLI Example: .. code-block:: bash salt '*' ip.get_interface eth0 ''' adapters = _parse_interfaces() if iface in adapters: try: if iface == 'source': template = JINJA.get_t...
Return the contents of an interface script CLI Example: .. code-block:: bash salt '*' ip.get_interface eth0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1748-L1775
[ "def _parse_interfaces(interface_files=None):\n '''\n Parse /etc/network/interfaces and return current configured interfaces\n '''\n if interface_files is None:\n interface_files = []\n # Add this later.\n if os.path.exists(_DEB_NETWORK_DIR):\n interface_files += ['{0}/{1...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
get_network_settings
python
def get_network_settings(): ''' Return the contents of the global network script. CLI Example: .. code-block:: bash salt '*' ip.get_network_settings ''' skip_etc_default_networking = ( __grains__['osfullname'] == 'Ubuntu' and int(__grains__['osrelease'].split('.')[0]) ...
Return the contents of the global network script. CLI Example: .. code-block:: bash salt '*' ip.get_network_settings
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1795-L1837
[ "def _read_temp(data):\n '''\n Return what would be written to disk\n '''\n tout = StringIO()\n tout.write(data)\n tout.seek(0)\n output = tout.readlines()\n tout.close()\n\n return output\n" ]
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
get_routes
python
def get_routes(iface): ''' Return the routes for the interface CLI Example: .. code-block:: bash salt '*' ip.get_routes eth0 ''' filename = os.path.join(_DEB_NETWORK_UP_DIR, 'route-{0}'.format(iface)) results = _read_file(filename) filename = os.path.join(_DEB_NETWORK_DOWN_D...
Return the routes for the interface CLI Example: .. code-block:: bash salt '*' ip.get_routes eth0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1840-L1857
[ "def _read_file(path):\n '''\n Reads and returns the contents of a text file\n '''\n try:\n with salt.utils.files.flopen(path, 'rb') as contents:\n return [salt.utils.stringutils.to_str(line) for line in contents.readlines()]\n except (OSError, IOError):\n return ''\n" ]
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
apply_network_settings
python
def apply_network_settings(**settings): ''' Apply global network configuration. CLI Example: .. code-block:: bash salt '*' ip.apply_network_settings ''' if 'require_reboot' not in settings: settings['require_reboot'] = False if 'apply_hostname' not in settings: se...
Apply global network configuration. CLI Example: .. code-block:: bash salt '*' ip.apply_network_settings
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1860-L1899
null
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/debian_ip.py
build_network_settings
python
def build_network_settings(**settings): ''' Build the global network script. CLI Example: .. code-block:: bash salt '*' ip.build_network_settings <settings> ''' changes = [] # Read current configuration and store default values current_network_settings = _parse_current_networ...
Build the global network script. CLI Example: .. code-block:: bash salt '*' ip.build_network_settings <settings>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debian_ip.py#L1902-L2024
[ "def _parse_current_network_settings():\n '''\n Parse /etc/default/networking and return current configuration\n '''\n opts = salt.utils.odict.OrderedDict()\n opts['networking'] = ''\n\n if os.path.isfile(_DEB_NETWORKING_FILE):\n with salt.utils.files.fopen(_DEB_NETWORKING_FILE) as contents...
# -*- coding: utf-8 -*- ''' The networking module for Debian-based distros References: * http://www.debian.org/doc/manuals/debian-reference/ch05.en.html ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import functools import logging import os.path import os import re...
saltstack/salt
salt/modules/environ.py
setval
python
def setval(key, val, false_unsets=False, permanent=False): ''' Set a single salt process environment variable. Returns True on success. key The environment key to set. Must be a string. val The value to set. Must be a string or False. Refer to the 'false_unsets' parameter f...
Set a single salt process environment variable. Returns True on success. key The environment key to set. Must be a string. val The value to set. Must be a string or False. Refer to the 'false_unsets' parameter for behavior when set to False. false_unsets If val is Fals...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/environ.py#L27-L105
null
# -*- coding: utf-8 -*- ''' Support for getting and setting the environment variables of the current salt process. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import os import logging # Import Salt libs import salt.utils.platform # Import 3rd-party libs from salt....
saltstack/salt
salt/modules/environ.py
setenv
python
def setenv(environ, false_unsets=False, clear_all=False, update_minion=False, permanent=False): ''' Set multiple salt process environment variables from a dict. Returns a dict. environ Must be a dict. The top-level keys of the dict are the names of the environment variables to set. Each...
Set multiple salt process environment variables from a dict. Returns a dict. environ Must be a dict. The top-level keys of the dict are the names of the environment variables to set. Each key's value must be a string or False. Refer to the 'false_unsets' parameter for behavior w...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/environ.py#L108-L186
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def setval(key, val, false_unsets=False, permanent=False):\n '''\n Set a single salt process environment variable. Returns True\n on success.\n\n key\n The environment key to set. Must be a string.\n\n val\n The value to set....
# -*- coding: utf-8 -*- ''' Support for getting and setting the environment variables of the current salt process. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import os import logging # Import Salt libs import salt.utils.platform # Import 3rd-party libs from salt....
saltstack/salt
salt/modules/environ.py
get
python
def get(key, default=''): ''' Get a single salt process environment variable. key String used as the key for environment lookup. default If the key is not found in the environment, return this value. Default: '' CLI Example: .. code-block:: bash salt '*' env...
Get a single salt process environment variable. key String used as the key for environment lookup. default If the key is not found in the environment, return this value. Default: '' CLI Example: .. code-block:: bash salt '*' environ.get foo salt '*' environ....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/environ.py#L189-L211
null
# -*- coding: utf-8 -*- ''' Support for getting and setting the environment variables of the current salt process. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import os import logging # Import Salt libs import salt.utils.platform # Import 3rd-party libs from salt....
saltstack/salt
salt/modules/environ.py
has_value
python
def has_value(key, value=None): ''' Determine whether the key exists in the current salt process environment dictionary. Optionally compare the current value of the environment against the supplied value string. key Must be a string. Used as key for environment lookup. value: O...
Determine whether the key exists in the current salt process environment dictionary. Optionally compare the current value of the environment against the supplied value string. key Must be a string. Used as key for environment lookup. value: Optional. If key exists in the environment, c...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/environ.py#L214-L245
null
# -*- coding: utf-8 -*- ''' Support for getting and setting the environment variables of the current salt process. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import os import logging # Import Salt libs import salt.utils.platform # Import 3rd-party libs from salt....
saltstack/salt
salt/modules/environ.py
item
python
def item(keys, default=''): ''' Get one or more salt process environment variables. Returns a dict. keys Either a string or a list of strings that will be used as the keys for environment lookup. default If the key is not found in the environment, return this value. ...
Get one or more salt process environment variables. Returns a dict. keys Either a string or a list of strings that will be used as the keys for environment lookup. default If the key is not found in the environment, return this value. Default: '' CLI Example: .. c...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/environ.py#L248-L281
null
# -*- coding: utf-8 -*- ''' Support for getting and setting the environment variables of the current salt process. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import os import logging # Import Salt libs import salt.utils.platform # Import 3rd-party libs from salt....
saltstack/salt
salt/pillar/svn_pillar.py
_extract_key_val
python
def _extract_key_val(kv, delimiter='='): '''Extract key and value from key=val string. Example: >>> _extract_key_val('foo=bar') ('foo', 'bar') ''' pieces = kv.split(delimiter) key = pieces[0] val = delimiter.join(pieces[1:]) return key, val
Extract key and value from key=val string. Example: >>> _extract_key_val('foo=bar') ('foo', 'bar')
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/svn_pillar.py#L148-L158
null
# -*- coding: utf-8 -*- ''' Clone a remote SVN repository and use the filesystem as a Pillar source This external Pillar source can be configured in the master config file like so: .. code-block:: yaml ext_pillar: - svn: trunk svn://svnserver/repo root=subdirectory The `root=` parameter is optional and us...
saltstack/salt
salt/pillar/svn_pillar.py
ext_pillar
python
def ext_pillar(minion_id, pillar, # pylint: disable=W0613 repo_string): ''' Execute a command and read the output as YAML ''' # split the branch, repo name and optional extra (key=val) parameters. options = repo_string.strip().split() branch = options[0] repo_l...
Execute a command and read the output as YAML
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/svn_pillar.py#L161-L201
[ "def _extract_key_val(kv, delimiter='='):\n '''Extract key and value from key=val string.\n\n Example:\n >>> _extract_key_val('foo=bar')\n ('foo', 'bar')\n '''\n pieces = kv.split(delimiter)\n key = pieces[0]\n val = delimiter.join(pieces[1:])\n return key, val\n", "def compile_pillar(s...
# -*- coding: utf-8 -*- ''' Clone a remote SVN repository and use the filesystem as a Pillar source This external Pillar source can be configured in the master config file like so: .. code-block:: yaml ext_pillar: - svn: trunk svn://svnserver/repo root=subdirectory The `root=` parameter is optional and us...
saltstack/salt
salt/pillar/svn_pillar.py
SvnPillar.pillar_dir
python
def pillar_dir(self): ''' Returns the directory of the pillars (repo cache + branch + root) ''' repo_dir = self.repo_dir root = self.root branch = self.branch if branch == 'trunk' or branch == 'base': working_dir = os.path.join(repo_dir, 'trunk', root)...
Returns the directory of the pillars (repo cache + branch + root)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/svn_pillar.py#L125-L145
null
class SvnPillar(object): ''' Deal with the remote SVN repository for Pillar ''' def __init__(self, branch, repo_location, root, opts): ''' Try to initialize the SVN repo object ''' repo_hash = hashlib.md5(repo_location).hexdigest() repo_dir = os.path.join(opts['c...