File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/netconfig.cpython-310.pyc
Back
o ;j�� � @ s� d Z ddlZddlZe�e�ZdZdd� Z ddd �Z ddd�Z d dd�Z d!dd�Zdd� Z dd� ZdS )"a� Network Config ============== Manage the configuration on a network device given a specific static config or template. :codeauthor: Mircea Ulinic <ping@mirceaulinic.net> & Jerome Fleury <jf@cloudflare.com> :maturity: new :depends: napalm :platform: unix Dependencies ------------ - :mod:`NAPALM proxy minion <salt.proxy.napalm>` - :mod:`Network-related basic features execution module <salt.modules.napalm_network>` .. versionadded:: 2017.7.0 � NZ netconfigc C s t jj�ttt�S )z_ NAPALM library must be installed for this module to work and run in a (proxy) minion. )�salt�utils�napalmZvirtual�__opts__�__virtualname__�__file__� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/netconfig.py�__virtual__) s r �root�755�--------------e----�jinjaFTc K s4 t d | f||||||||| | ||| ||d�|��S )a Call the necessary functions in order to execute the state. For the moment this only calls the ``net.load_template`` function from the :mod:`Network-related basic features execution module <salt.modules.napalm_network>`, but this may change in time. znet.load_template)�template_source� template_hash�template_hash_name� template_user�template_group� template_mode�template_attrs�saltenv�template_engine�skip_verify�defaults�test�commit�debug�replace)�__salt__)� template_namer r r r r r r r r r r r r r r � template_varsr r r �_update_config5 s* ���r! � � �runningc C s� t jj�| �}|ptd }td d|�}td d|�}td d|�}td ||f||||||| | ||| ||||d��}t jj�||||�S )a( .. 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 implementation that wraps Python's :py:func:`~re.sub`. pattern A regular expression, to be matched using Python's :py:func:`~re.search`. repl The replacement text. count: ``0`` Maximum number of pattern occurrences to be replaced. If count is a positive integer ``n``, only ``n`` occurrences will be replaced, otherwise all occurrences will be replaced. flags (list or int): ``8`` A list of flags defined in the ``re`` module documentation from the Python standard library. Each list item should be a string that will correlate to the human-friendly flag name. E.g., ``['IGNORECASE', 'MULTILINE']``. Optionally, ``flags`` may be an int, with a value corresponding to the XOR (``|``) of all the desired flags. Defaults to 8 (which supports 'MULTILINE'). bufsize (int or str): ``1`` How much of the configuration to buffer into memory at once. The default value ``1`` processes one line at a time. The special value ``file`` may be specified which will read the entire file into memory before processing. append_if_not_found: ``False`` If set to ``True``, and pattern is not found, then the content will be appended to the file. prepend_if_not_found: ``False`` If set to ``True`` and pattern is not found, then the content will be prepended to the file. not_found_content Content to use for append/prepend if not found. If None (default), uses ``repl``. Useful when ``repl`` uses references to group in pattern. search_only: ``False`` If set to true, this no changes will be performed on the file, and this function will simply return ``True`` if the pattern was matched, and ``False`` if not. show_changes: ``True`` If ``True``, return a diff of changes made. Otherwise, return ``True`` if changes were made, and ``False`` if not. backslash_literal: ``False`` Interpret backslashes as literal backslashes for the repl and not escape characters. This will help when using append/prepend so that the backslashes are not interpreted for the repl on the second run of the state. source: ``running`` The configuration source. Choose from: ``running``, ``candidate``, or ``startup``. Default: ``running``. path Save the temporary configuration to a specific path, then read from there. test: ``False`` Dry run? If set as ``True``, will apply the config, discard and return the changes. Default: ``False`` and will commit the changes on the device. commit: ``True`` Commit the configuration changes? Default: ``True``. debug: ``False`` Debug mode. Will insert a new key in the output dictionary, as ``loaded_config`` containing the raw configuration loaded on the device. replace: ``True`` Load and replace the configuration. Default: ``True``. If an equal sign (``=``) appears in an argument to a Salt command it is interpreted as a keyword argument in the format ``key=val``. That processing can be bypassed in order to pass an equal sign through to the remote shell command by manually specifying the kwarg: State SLS Example: .. code-block:: yaml update_policy_name: netconfig.replace_pattern: - pattern: OLD-POLICY-NAME - repl: new-policy-name - debug: true r �config.merger r r znet.replace_pattern)�count�flags�bufsize�append_if_not_found�prepend_if_not_found�not_found_content�search_only�show_changes�backslash_literal�source�pathr r r r )r r r �default_retr r � loaded_ret)�name�pattern�replr&