%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/net_napalm_yang.pyc

�
���^c@@s�dZddlmZmZmZddlZeje�Zyddl	Z	e
ZWnek
rle
ZnXddlZddlZddlZddlZddlZdZd�Zd�Zd�ZdS(u
NAPALM YANG state
=================

Manage the configuration of network devices according to
the YANG models (OpenConfig/IETF).

.. versionadded:: 2017.7.0

Dependencies
------------

- napalm-yang
- pyangbing > 0.5.11

To be able to load configuration on network devices,
it requires NAPALM_ library to be installed:  ``pip install napalm``.
Please check Installation_ for complete details.

.. _NAPALM: https://napalm.readthedocs.io
.. _Installation: https://napalm.readthedocs.io/en/latest/installation.html
i(tabsolute_importtprint_functiontunicode_literalsNunapalm_yangcC@s)tstdfStjjjttt�S(u�
    NAPALM library must be installed for this module to work and run in a (proxy) minion.
    This module in particular requires also napalm-yang.
    uHUnable to load napalm_yang execution module: please install napalm-yang!(	tHAS_NAPALM_YANGtFalsetsalttutilstnapalmtvirtualt__opts__t__virtualname__t__file__(((s?/usr/lib/python2.7/site-packages/salt/states/net_napalm_yang.pyt__virtual__<s
cK@s(|jdd�}t|t�rAt|dt�rA|d}ntjjj|�}|jdt	�pwt
jdt	�}|jdt	�p�t
jdt	�}|jdt�p�t
jdt�}|jdt	�p�t
jdt	�}|jdt	�pt
jdt	�}	|jdg�}
td	�}t
jd
|�d|krUi|d6}n|g}tjjj|d��A}tjjjtjjjtjjj|��|d
d�WdQXtddtd|
|�}
t
jd�t
j|
�td|
d||�}t
jd�t
j|�|jdt	�}|rf|jitd6dd6�t
jd�|St
jd�|dd}d|kr�|jd�ntd|d|
d|d |d!|d"||�}t
jd#�t
j|�td$|�||d<tjjj||||d%t
d&|	�S('u�
    Manage the device configuration given the input data structured
    according to the YANG models.

    data
        YANG structured data.

    models
         A list of models to be used when generating the config.

    profiles: ``None``
        Use certain profiles to generate the config.
        If not specified, will use the platform default profile(s).

    compliance_report: ``False``
        Return the compliance report in the comment.

        .. versionadded:: 2017.7.3

    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? Default: ``True``.

    debug: ``False``
        Debug mode. Will insert a new key under the output dictionary,
        as ``loaded_config`` containing the raw configuration loaded on the device.

    replace: ``False``
        Should replace the config with the new generate one?

    State SLS example:

    .. code-block:: jinja

        {%- set expected_config =  pillar.get('openconfig_interfaces_cfg') -%}
        interfaces_config:
          napalm_yang.managed:
            - data: {{ expected_config | json }}
            - models:
              - models.openconfig_interfaces
            - debug: true

    Pillar example:

    .. code-block:: yaml

        openconfig_interfaces_cfg:
          _kwargs:
            filter: true
          interfaces:
            interface:
              Et1:
                config:
                  mtu: 9000
              Et2:
                config:
                  description: "description example"
    umodelsiutestudebugucommitureplaceucompliance_reportuprofilesu	temp.fileuCreating temp file: %suto_dictuwtencodinguutf-8Nunapalm_yang.parsetconfigtprofilesu"Parsed the config from the device:unapalm_yang.compliance_reporttfilepathuCompliance report:ucompliesuresultuAlready configured as required.ucommentuAll good here.u3Does not comply, trying to generate and load configu_kwargsunapalm_yang.load_configttesttdebugtcommittreplaceuLoaded config result:ufile.removetoptstcompliance_report(tgettNonet
isinstancettupletlistRRRtdefault_retRR	tTruet__salt__tlogRtfilestfopentyamlt	safe_dumptjsontloadstdumpstupdatetpopt
loaded_ret(tnametdatatkwargstmodelstretRRRRtreturn_compliance_reportRt	temp_filetfile_handlet
device_configRtcompliestloaded_changes((s?/usr/lib/python2.7/site-packages/salt/states/net_napalm_yang.pytmanagedNspA"
$$$$$
	!






	





cK@sa|jdd�}t|t�rAt|dt�rA|d}ntjjj|�}|jdt	�pwt
jdt	�}|jdt	�p�t
jdt	�}|jdt�p�t
jdt�}|jdt	�p�t
jdt	�}|jdg�}	d|kr|jd�nt
d	|d
|	d|d|d
|d||�}
tjjj||
||�S(uC
    Configure the network device, given the input data strucuted
    according to the YANG models.

    .. note::
        The main difference between this function and ``managed``
        is that the later generates and loads the configuration
        only when there are differences between the existing
        configuration on the device and the expected
        configuration. Depending on the platform and hardware
        capabilities, one could be more optimal than the other.
        Additionally, the output of the ``managed`` is different,
        in such a way that the ``pchange`` field in the output
        contains structured data, rather than text.

    data
        YANG structured data.

    models
         A list of models to be used when generating the config.

    profiles: ``None``
        Use certain profiles to generate the config.
        If not specified, will use the platform default profile(s).

    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? Default: ``True``.

    debug: ``False``
        Debug mode. Will insert a new key under the output dictionary,
        as ``loaded_config`` containing the raw configuration loaded on the device.

    replace: ``False``
        Should replace the config with the new generate one?

    State SLS example:

    .. code-block:: jinja

        {%- set expected_config =  pillar.get('openconfig_interfaces_cfg') -%}
        interfaces_config:
          napalm_yang.configured:
            - data: {{ expected_config | json }}
            - models:
              - models.openconfig_interfaces
            - debug: true

    Pillar example:

    .. code-block:: yaml

        openconfig_interfaces_cfg:
          _kwargs:
            filter: true
          interfaces:
            interface:
              Et1:
                config:
                  mtu: 9000
              Et2:
                config:
                  description: "description example"
    umodelsiutestudebugucommitureplaceuprofilesu_kwargsunapalm_yang.load_configRRRRRN(RRRRRRRRRRR	RR(RR)(R*R+R,R-R.RRRRRR4((s?/usr/lib/python2.7/site-packages/salt/states/net_napalm_yang.pyt
configured�s$G"
$$$$
(t__doc__t
__future__RRRtloggingt	getLoggerRRtnapalm_yangRRtImportErrorRtsalt.utils.filesRtsalt.utils.jsontsalt.utils.napalmtsalt.utils.stringutilstsalt.utils.yamlR
RR5R6(((s?/usr/lib/python2.7/site-packages/salt/states/net_napalm_yang.pyt<module>s"


		

Zerion Mini Shell 1.0