Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def get_filter_pillar(filter_name, pillar_key='acl', pillarenv=None, saltenv=None): ''' Helper that can be used inside a state SLS, in order to get the filter configuration given its name. fil...
[]
Please provide a description of the function:def get_term_pillar(filter_name, term_name, pillar_key='acl', pillarenv=None, saltenv=None): ''' Helper that can be used inside a state SLS, in order to get the term configuration giv...
[]
Please provide a description of the function:def _get_blade(): ''' Get Pure Storage FlasBlade configuration 1) From the minion config pure_tags: fb: san_ip: management vip or hostname for the FlashBlade api_token: A valid api token for the FlashBlade being managed ...
[]
Please provide a description of the function:def _get_fs(name, blade): ''' Private function to check for existance of a filesystem ''' _fs = [] _fs.append(name) try: res = blade.file_systems.list_file_systems(names=_fs) return res.items[0] except rest.ApiException: ...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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 No...
[]
Please provide a description of the function: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=F...
[]
Please provide a description of the function:def _prep_ssh( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', kwarg=None, **kwargs): ''' Prepare the arguments ''' opts = copy.deepcopy(sel...
[]
Please provide a description of the function:def cmd_iter( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, **kwargs): ''' Execute a single command via the salt-ssh subsy...
[]
Please provide a description of the function: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 a...
[]
Please provide a description of the function: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', ...
[]
Please provide a description of the function:def cmd_subset( self, tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, sub=3, **kwargs): ''' Execute a command on a ran...
[]
Please provide a description of the function: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 additiona...
[]
Please provide a description of the function: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 a...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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 pres...
[]
Please provide a description of the function:def _config_logic(napalm_device, loaded_result, test=False, debug=False, replace=False, commit_config=True, loaded_config=None, commit_in=None, ...
[]
Please provide a description of the function: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 t...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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 :p...
[]
Please provide a description of the function: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 interface...
[]
Please provide a description of the function: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 iden...
[]
Please provide a description of the function:def load_config(filename=None, text=None, test=False, commit=True, debug=False, replace=False, commit_in=None, commit_at=None, revert_in=None, ...
[]
Please provide a description of the function:def load_template(template_name=None, template_source=None, context=None, defaults=None, template_engine='jinja', saltenv='base', template_hash=None, ...
[]
Please provide a description of the function: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 pr...
[]
Please provide a description of the function: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 w...
[]
Please provide a description of the function: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_...
[]
Please provide a description of the function: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_confi...
[]
Please provide a description of the function: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``, ``start...
[]
Please provide a description of the function:def replace_pattern(pattern, repl, count=0, flags=8, bufsize=1, append_if_not_found=False, prepend_if_not_found=False, not_found_conten...
[]
Please provide a description of the function:def blockreplace(marker_start, marker_end, content='', append_if_not_found=False, prepend_if_not_found=False, show_changes=True, append_newline=False, sourc...
[]
Please provide a description of the function:def patch(patchfile, options='', saltenv='base', source_hash=None, show_changes=True, source='running', path=None, test=False, commit=True, debug=False, replace=True): '''...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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_passwor...
[]
Please provide a description of the function: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. dat...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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'][...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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) ...
[]
Please provide a description of the function: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 execu...
[]
Please provide a description of the function: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. ...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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 = multiproce...
[]
Please provide a description of the function: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_handle...
[]
Please provide a description of the function:def handle_message(self, stream, header, payload): ''' Handle incoming messages from underylying tcp streams ''' try: try: payload = self._decode_payload(payload) except Exception: stream...
[]
Please provide a description of the function: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()...
[]
Please provide a description of the function:def shutdown(self): ''' Shutdown the whole server ''' for item in self.clients: client, address = item client.close() self.clients.remove(item)
[]
Please provide a description of the function: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 the...
[]
Please provide a description of the function: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: ...
[]
Please provide a description of the function: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(...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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: ...
[]
Please provide a description of the function: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 ''' ...
[]
Please provide a description of the function: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) ...
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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, '|'.jo...
[]
Please provide a description of the function: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,...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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, IOErr...
[]
Please provide a description of the function: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(_...
[]
Please provide a description of the function:def __int(value): '''validate an integer''' valid, _value = False, value try: _value = int(value) valid = True except ValueError: pass return (valid, _value, 'integer')
[]
Please provide a description of the function:def __float(value): '''validate a float''' valid, _value = False, value try: _value = float(value) valid = True except ValueError: pass return (valid, _value, 'float')
[]
Please provide a description of the function: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.netm...
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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, '...
[]
Please provide a description of the function: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, ''' ...
[]
Please provide a description of the function: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): ...
[]
Please provide a description of the function: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 = ...
[]
Please provide a description of the function: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. ''' ...
[]
Please provide a description of the function: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. ''' ...
[]
Please provide a description of the function: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. ''' bo...
[]
Please provide a description of the function: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 'po...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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[if...
[]
Please provide a description of the function: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)...
[]
Please provide a description of the function: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: _...
[]
Please provide a description of the function: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,...
[]
Please provide a description of the function: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 exis...
[]
Please provide a description of the function: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
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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') ...
[]
Please provide a description of the function: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 = ...
[]
Please provide a description of the function: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() ...
[]
Please provide a description of the function: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: tem...
[]
Please provide a description of the function: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)
[]
Please provide a description of the function: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 == 'so...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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) ...
[]
Please provide a description of the function: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...
[]
Please provide a description of the function: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 cur...
[]
Please provide a description of the function: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. Re...
[]
Please provide a description of the function: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 ...
[]
Please provide a description of the function: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: ...
[]
Please provide a description of the function: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 ...
[]