%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyc

�
���^c@@sddZddlmZmZmZddlZddlmZddlZ	ddl
Z	ddlmZddl
mZdZdgZd	�Zed
�Zeded�Zd�Zdd
�Zddedd�Zdddd�Zdddddd�Zdddddd�Zdddddd�Zdddddd�Zdddddd�ZdS(u
Cisco IOS configuration manipulation helpers

.. versionadded:: 2019.2.0

This module provides a collection of helper functions for Cisco IOS style
configuration manipulation. This module does not have external dependencies
and can be used from any Proxy or regular Minion.
i(tabsolute_importtunicode_literalstprint_functionN(tsix(tOrderedDict(t
SaltExceptionu	iosconfigu*cC@s;||kr&t�||<|||<n||j|�dS(N(Rtupdate(tobjteletdata((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt_attach_data_to_path$s

cC@s�d|krg|d<n|g}|}t}x�tr�dj|�|d<|jd�}|scPq1||krt�||<n||}|r1|r1|dji||6�t}q1q1W||kr�||j|�n
|||<t||d<dS(Nu#listu u#textiu#standalone(tTruetjointpopRtappendtFalseR(RtpathR	tlist_tobj_tmptfirstt	path_item((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt_attach_data_to_path_tags,s(
		


c		C@sPt�}x@|rK|jd�}|j�s|j�jd�rIqn|j�}t|�t|�}||kr�t|d|d|dt�}|r�t||||�qHt	|||�q||kr�|j
d|�Pq|s7t|d|d|dt�}|r$t||||�qHt	|||�q|j
d|�PqW|S(Niu!tcurrent_indentt	with_tagstnested(RR
tstriptlstript
startswithtlent_parse_text_configRRR
tinsert(	tconfig_linesRRRt
struct_cfgtlinetcurrent_linetleading_spacest
current_block((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyRFsF		"		
		
cC@sPtj|jd�|jd��}djg|D]}|jdd�^q1�S(u-
    Returns the diff of two text blobs.
    iuu
(tdifflibtunified_difft
splitlinesRtreplace(toldtnewtdifftx((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt_get_diff_texttscC@smd}x`tj|�D]O\}}|djdd|d|�7}|r|t|d|d�7}qqW|S(u7
    Return the config as text from a config tree.
    uu{indent}{line}
tindentu R!tindentationi(Rt	iteritemstformatt_print_config_text(ttreeR/tconfigtkeytvalue((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyR2}s !ubasecC@s_|rCtd|d|�}|tkrCtdj|���qCn|j�}t|d|�S(u�
    Transform Cisco IOS style configuration to structured Python dictionary.
    Depending on the value of the ``with_tags`` argument, this function may
    provide different views, valuable in different situations.

    config
        The configuration sent as text. This argument is ignored when ``path``
        is configured.

    path
        Absolute or remote path from where to load the configuration text. This
        argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    with_tags: ``False``
        Whether this function should return a detailed view, with tags.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``path`` is not a ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.tree path=salt://path/to/my/config.txt
        salt '*' iosconfig.tree path=https://bit.ly/2mAdq7z
    ucp.get_file_strtsaltenvu{} is not availableR(t__salt__RRR1R'R(R4RRR7R((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyR3�s!cC@s%td|d|d|�}t|�S(u�
    Return a clean version of the config, without any special signs (such as
    ``!`` as an individual line) or empty lines, but just lines with significant
    value in the configuration of the network device.

    config
        The configuration sent as text. This argument is ignored when ``path``
        is configured.

    path
        Absolute or remote path from where to load the configuration text. This
        argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``path`` is not a ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.clean path=salt://path/to/my/config.txt
        salt '*' iosconfig.clean path=https://bit.ly/2mAdq7z
    R4RR7(R3R2(R4RR7tconfig_tree((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pytclean�scC@sLtd|d|d|�}td|d|d|�}tjjj||�S(u�
    Return the merge tree of the ``initial_config`` with the ``merge_config``,
    as a Python dictionary.

    initial_config
        The initial configuration sent as text. This argument is ignored when
        ``initial_path`` is set.

    initial_path
        Absolute or remote path from where to load the initial configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    merge_config
        The config to be merged into the initial config, sent as text. This
        argument is ignored when ``merge_path`` is set.

    merge_path
        Absolute or remote path from where to load the merge configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``initial_path`` or ``merge_path`` is not a ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.merge_tree initial_path=salt://path/to/running.cfg merge_path=salt://path/to/merge.cfg
    R4RR7(R3tsalttutilst
dictupdatetmerge(tinitial_configtinitial_pathtmerge_configt
merge_pathR7t
merge_treetinitial_tree((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyRC�s'		cC@s1td|d|d|d|d|�}t|�S(u�
    Return the merge result of the ``initial_config`` with the ``merge_config``,
    as plain text.

    initial_config
        The initial configuration sent as text. This argument is ignored when
        ``initial_path`` is set.

    initial_path
        Absolute or remote path from where to load the initial configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    merge_config
        The config to be merged into the initial config, sent as text. This
        argument is ignored when ``merge_path`` is set.

    merge_path
        Absolute or remote path from where to load the merge configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``initial_path`` or ``merge_path`` is not a ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.merge_text initial_path=salt://path/to/running.cfg merge_path=salt://path/to/merge.cfg
    R?R@RARBR7(RCR2(R?R@RARBR7tcandidate_tree((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt
merge_texts'	c	C@sh|rtd|d|�}ntd|d|d|d|�}td|�}t|�}t||�S(u�
    Return the merge diff, as text, after merging the merge config into the
    initial config.

    initial_config
        The initial configuration sent as text. This argument is ignored when
        ``initial_path`` is set.

    initial_path
        Absolute or remote path from where to load the initial configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    merge_config
        The config to be merged into the initial config, sent as text. This
        argument is ignored when ``merge_path`` is set.

    merge_path
        Absolute or remote path from where to load the merge configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``initial_path`` or ``merge_path`` is not a ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.merge_diff initial_path=salt://path/to/running.cfg merge_path=salt://path/to/merge.cfg
    ucp.get_file_strR7R?RARBR4(R8RFR3R2R-(R?R@RARBR7tcandidate_configtclean_running_dictt
clean_running((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt
merge_diff4s'	cC@sLtd|d|d|�}td|d|d|�}tjjj||�S(u
    Return the diff, as Python dictionary, between the candidate and the running
    configuration.

    candidate_config
        The candidate configuration sent as text. This argument is ignored when
        ``candidate_path`` is set.

    candidate_path
        Absolute or remote path from where to load the candidate configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    running_config
        The running configuration sent as text. This argument is ignored when
        ``running_path`` is set.

    running_path
        Absolute or remote path from where to load the runing configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``candidate_path`` or ``running_path`` is not a
        ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.diff_tree candidate_path=salt://path/to/candidate.cfg running_path=salt://path/to/running.cfg
    R4RR7(R3R;R<t
dictdiffert	deep_diff(RGtcandidate_pathtrunning_configtrunning_pathR7REtrunning_tree((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt	diff_treefs(		cC@sCtd|d|d|�}td|d|d|�}t||�S(u�
    Return the diff, as text, between the candidate and the running config.

    candidate_config
        The candidate configuration sent as text. This argument is ignored when
        ``candidate_path`` is set.

    candidate_path
        Absolute or remote path from where to load the candidate configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    running_config
        The running configuration sent as text. This argument is ignored when
        ``running_path`` is set.

    running_path
        Absolute or remote path from where to load the runing configuration
        text. This argument allows any URI supported by
        :py:func:`cp.get_url <salt.modules.cp.get_url>`), e.g., ``salt://``,
        ``https://``, ``s3://``, ``ftp:/``, etc.

    saltenv: ``base``
        Salt fileserver environment from which to retrieve the file.
        Ignored if ``candidate_path`` or ``running_path`` is not a
        ``salt://`` URL.

    CLI Example:

    .. code-block:: bash

        salt '*' iosconfig.diff_text candidate_path=salt://path/to/candidate.cfg running_path=salt://path/to/running.cfg
    R4RR7(R:R-(RGRMRNROR7tcandidate_texttrunning_text((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt	diff_text�s'		(t__doc__t
__future__RRRR%tsalt.extRtsalt.utils.dictupdateR;tsalt.utils.dictdiffertsalt.utils.odictRtsalt.exceptionsRt__virtualname__t__proxyenabled__R
RRRR-R2tNoneR3R:RCRFRJRQRT(((s:/usr/lib/python2.7/site-packages/salt/modules/iosconfig.pyt<module>
s\		+		&,+.-

Zerion Mini Shell 1.0