%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZeje	�Z
ddlmZddl
ZddlZddlZddlZyddlZeZWnek
r�eZnXdZdgZdfZd�Zd	�Zd
�Zd�Zd�Zd
�Zeeeee e e e e e d�
Z!ej"j#j$d��Z%ej"j#j$d��Z&ej"j#j$d��Z'ej"j#j$d��Z(ej"j#j$e e e e d��Z)ej"j#j$e e e e e e d��Z*ej"j#j$dddd��Z+ej"j#j$d��Z,ej"j#j$d��Z-ej"j#j$dd��Z.ej"j#j$dddd��Z/ej"j#j$e d��Z0ej"j#j$d��Z1ej"j#j$e e eeeee e e e e e dd�
�Z2ej"j#j$e e e e dde e eeeeee e e e e d ��Z3ej"j#j$e d!��Z4ej"j#j$e d"��Z5ej"j#j$e d#��Z6ej"j#j$e d$��Z7ej"j#j$e d%��Z8ej"j#j$e d&��Z9d'�Z:d(�Z;e e d)�Z<dd*d+eee eeee e eeeed,�Z=deeeed-e eeeed.�Z>dde ed-e eeeed/�
Z?dS(0u�
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
------------

- :mod:`napalm proxy minion <salt.proxy.napalm>`

.. versionadded:: 2016.11.0
.. versionchanged:: 2017.7.0
i(tabsolute_importtunicode_literalstprint_functionN(tsixunetu*u
napalm_netcC@stjjjttt�S(u_
    NAPALM library must be installed for this module to work and run in a (proxy) minion.
    (tsalttutilstnapalmtvirtualt__opts__t__virtualname__t__file__(((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt__virtual__;scC@sCt�}x3|D]+}|j|�|kr|j|�qqW|S(u<
    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
    (tlisttgettappend(t
input_listt
search_keytsearch_valuetoutput_listt
dictionary((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt_filter_listFs
	
cC@sRt�}xBtj|�D]1\}}t|||�}|r|||<qqW|S(uA
    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
    (tdictRt	iteritemsR(t
input_dictRRtoutput_dicttkeytkey_listtkey_list_filtered((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt_filter_dictZs	cC@sxtd|�}|jdt�st|dc|jd�rD|dnd7<t|d<t||�}|dst|Sn|S(Ntinherit_napalm_deviceuresultucommentuUnable to commit.(tcommitR
tFalset_safe_dicard_config(t
loaded_resultt
napalm_devicet_committ	discarded((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt_safe_commit_configos)

cC@s�tjd�tj|�td|�}|jdt�s�|dc|jd�r^|dnd7<t|d<t|�dtd<|S|S(u
    uDiscarding the configRuresultucommentuUnable to discard config.iuretcode(tlogtdebugtdiscard_configR
Rt_explicit_closet__context__(R!R"t
_discarded((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR |s

#


cC@sktjjjt�rgy|dj�Wqgtk
rc}tjd�tj|�tjd�qgXndS(u
    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.
    uDRIVERu4Unable to close the temp connection with the device:uPlease report.N(	RRRtnot_always_aliveRtcloset	ExceptionR&terror(R"terr((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR)�s

cK@s�|jd�}
|
s0djtjj��}
nt|d<d|d<|rW||d<ntd|�}|jdt�r�|jd�|d	<|jdd�n5d|d	<t|d<|jd
�|d
<dtd<|S|jdt�}|s�|r�|d
r|d
cd
7<nt	|jd	d��dks:t
|d<nt||�}|dsW|S|d
cd7<t|�|ds�dtd<n|S|r�|r�|r�t
jdt|��t|�}t
jd�t
j|d
�nt	|jd	d��dkr}|s|r?tdd|d|�}dj|
�}tjjj�}tjjj|d��}|j|�WdQXtd|dddi|d6|
d6|d6d|�}t
jd �t
j|�td!�}t||�}|ds|d
cd"jd#|�7<|Sd$jd#|d%td&d'|
�|d
<|
|d(<|St
jd)�t
j|d	�|	si|
r]tdd|	d|
�}td*d+krDts�d,|d
<t|d<|Std-d|	d|
�}t|tj�d.�}td/d0|�}|ds)d1j|d2�|d
<t|d<t||�}|dsA|Sq)n�tjjj�}td3d4d5�dd5}tjjj|d��}|j|�WdQXt||�}|ds�|Sdj|
�}td|dddi|d6|
d6t
d6d|�}t
jd6�t
j|�td!�}d7jd#|d%td&d'|
�|d
<|
|d(<|St||�}|ds�|Sq�t||�}|ds�|St
|d<d8|d
<nt|�|ds�dtd<n|S(9uR
    Builds the config logic for `load_config` and `load_template` functions.
    u	__pub_jidu{0:%Y%m%d%H%M%S%f}ualready_configureduu
loaded_configRuresultuoutudiffucommentiuretcodeu
iuConfiguration discarded.uCommitting the JID: %su'Cleaned up the commit from the scheduleutimeutil.get_time_atttime_inttime_atu__napalm_commit_{}uwNuschedule.addtfunctionunet.load_configt
job_kwargsufilenameu
commit_jidureplacetonceuScheduling jobu
schedule.saveuZScheduled the job to be executed at {schedule_ts}, but was unable to discard the config: 
tschedule_tsu�Changes discarded for now, and scheduled commit at: {schedule_ts}.
The commit ID is: {current_jid}.
To discard this commit, you can execute: 

salt {min_id} net.cancel_commit {current_jid}tmin_iduidtcurrent_jidu	commit_iduAbout to commit:uosujunosuqThis feature requires the library jxmlease to be installed.
To install, please execute: ``pip install jxmlease``.utimeutil.get_timestamp_ati<unapalm.junos_committconfirmuUnable to commit confirm: {}umessageu
net.configtsourceurunninguScheduling commit confirmedu�The commit ID is: {current_jid}.
This commit will be reverted at: {schedule_ts}, unless confirmed.
To confirm the commit and avoid reverting, you can execute:

salt {min_id} net.confirm_commit {current_jid}uAlready configured.( R
tformattdatetimetnowRtcompare_configtpoptNoneR*tlentTrueR R)R&tinfotstrt
cancel_commitR't	__utils__RRtfilestmkstemptfopentwritet__salt__Rt
__grains__tHAS_JXMLEASEtintttimeR%(R"R!ttestR'treplacet
commit_configt
loaded_configt	commit_int	commit_att	revert_int	revert_att
commit_jidtkwargsR8t_comparet_loaded_resR$tremovedtcommit_timetscheduled_job_namet	temp_filetfp_t	scheduledtsavedtrevert_timettimestamp_attminutest_commtrunning_configt	committed((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt
_config_logic�s�














	

	



		



	

	






	


	









cK@sitjdt�d6S(u�
    Specifies if the connection to the device succeeded.

    CLI Example:

    .. code-block:: bash

        salt '*' net.connected
    uUPuout(R"R
R(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt	connected`scK@stjjjtdi�S(u�
    Returns characteristics of the network device.
    :return: a dictionary with the following keys:

        * uptime - Uptime of the device in seconds.
        * vendor - Manufacturer of the device.
        * model - Device model.
        * hostname - Hostname of the device
        * fqdn - Fqdn of the device
        * os_version - String with the OS version running on the device.
        * serial_number - Serial number of the device
        * interface_list - List of the interfaces of the device

    CLI Example:

    .. code-block:: bash

        salt '*' net.facts

    Example output:

    .. code-block:: python

        {
            'os_version': '13.3R6.5',
            'uptime': 10117140,
            'interface_list': [
                'lc-0/0/0',
                'pfe-0/0/0',
                'pfh-0/0/0',
                'xe-0/0/0',
                'xe-0/0/1',
                'xe-0/0/2',
                'xe-0/0/3',
                'gr-0/0/10',
                'ip-0/0/10'
            ],
            'vendor': 'Juniper',
            'serial_number': 'JN131356FBFA',
            'model': 'MX480',
            'hostname': 're0.edge05.syd01',
            'fqdn': 're0.edge05.syd01'
        }
    u	get_facts(RRRtcallR"(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytfactsqs/cK@stjjjtdi�S(u
    Returns the environment of the device.

    CLI Example:

    .. code-block:: bash

        salt '*' net.environment


    Example output:

    .. code-block:: python

        {
            'fans': {
                'Bottom Rear Fan': {
                    'status': True
                },
                'Bottom Middle Fan': {
                    'status': True
                },
                'Top Middle Fan': {
                    'status': True
                },
                'Bottom Front Fan': {
                    'status': True
                },
                'Top Front Fan': {
                    'status': True
                },
                'Top Rear Fan': {
                    'status': True
                }
            },
            'memory': {
                'available_ram': 16349,
                'used_ram': 4934
            },
            'temperature': {
               'FPC 0 Exhaust A': {
                    'is_alert': False,
                    'temperature': 35.0,
                    'is_critical': False
                }
            },
            'cpu': {
                '1': {
                    '%usage': 19.0
                },
                '0': {
                    '%usage': 35.0
                }
            }
        }
    uget_environment(RRRRkR"(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytenvironment�s;c O@sOtjjjtdit|�d6�}|ds6|S|jd�pctjd�pctjdt	�}|s}t
jd�|Sdtks�dtkr�|d	cd
7<t
j
|d	�|S|jd�}t
jd|�|jd
�ptjd
�ptjd
�}t
jd|�|jd�pCtjd�pCtjdi�}t
jd|�|jd�p�tjd�p�tjd�}t
jd|�|jd�p�tjd�p�tjdd�}t
jd|�|jd�ptjd�ptjdd�}	t
jd|	�|jdd�}
|jdt	�}|jd �}|jd!�}
i|jd	d"�d	6|dd6id#6}t
jd$�x�t|�D]�}|d#|}t
jd%|�t
j|�d;}|r�t
jd&|�td|d'|d(|	d)|j�d*|d+|
d,|d-|d.|
�}t
jd/�t
j|�|ds�t
jd0�|}|d	cd1j||d	�7<t
j
|d	�q%|d#r�t
jd2|�|d#}q%d3j|�}|d	c|7<t
j
|�|}n1|s||kr�||kr||}nt
jd4||�td|d5|d+|
�}t
jd/�t
j|�|ds�t
jd6�|}|d	cd7j||d	�7<t
j
|d	�q%|d#r�t
jd2|�|d#}q%t
jd8|�|}n,t
j
d9�|}|d	cd:j|�7<||d#|<q�W|d	j�|d	<|S(<u�
    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 be also specified in the minion configuration
            file or pillar as ``napalm_cli_textfsm_parse``.

    textfsm_path
        The path where the TextFSM templates can be found. This option implies
        the usage of the TextFSM index file.
        ``textfsm_path`` can be either absolute path on the server,
        either specified using the following URL mschemes: ``file://``,
        ``salt://``, ``http://``, ``https://``, ``ftp://``,
        ``s3://``, ``swift://``.

        .. versionadded:: 2018.3.0

        .. note::
            This needs to be a directory with a flat structure, having an
            index file (whose name can be specified using the ``index_file`` option)
            and a number of TextFSM templates.

        .. note::
            This option can be also specified in the minion configuration
            file or pillar as ``textfsm_path``.

    textfsm_template
        The path to a certain the TextFSM template.
        This can be specified using the absolute path
        to the file, or using one of the following URL schemes:

        - ``salt://``, to fetch the template from the Salt fileserver.
        - ``http://`` or ``https://``
        - ``ftp://``
        - ``s3://``
        - ``swift://``

        .. versionadded:: 2018.3.0

    textfsm_template_dict
        A dictionary with the mapping between a command
        and the corresponding TextFSM path to use to extract the data.
        The TextFSM paths can be specified as in ``textfsm_template``.

        .. versionadded:: 2018.3.0

        .. note::
            This option can be also specified in the minion configuration
            file or pillar as ``napalm_cli_textfsm_template_dict``.

    platform_grain_name: ``os``
        The name of the grain used to identify the platform name
        in the TextFSM index file. Default: ``os``.

        .. versionadded:: 2018.3.0

        .. note::
            This option can be also specified in the minion configuration
            file or pillar as ``textfsm_platform_grain``.

    platform_column_name: ``Platform``
        The column name used to identify the platform,
        exactly as specified in the TextFSM index file.
        Default: ``Platform``.

        .. versionadded:: 2018.3.0

        .. note::
            This is field is case sensitive, make sure
            to assign the correct value to this option,
            exactly as defined in the index file.

        .. note::
            This option can be also specified in the minion configuration
            file or pillar as ``textfsm_platform_column_name``.

    index_file: ``index``
        The name of the TextFSM index file, under the ``textfsm_path``. Default: ``index``.

        .. versionadded:: 2018.3.0

        .. note::
            This option can be also specified in the minion configuration
            file or pillar as ``textfsm_index_file``.

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

        .. versionadded:: 2018.3.0

    include_empty: ``False``
        Include empty files under the ``textfsm_path``.

        .. versionadded:: 2018.3.0

    include_pat
        Glob or regex to narrow down the files cached from the given path.
        If matching with a regex, the regex must be prefixed with ``E@``,
        otherwise the expression will be interpreted as a glob.

        .. versionadded:: 2018.3.0

    exclude_pat
        Glob or regex to exclude certain files from being cached from the given path.
        If matching with a regex, the regex must be prefixed with ``E@``,
        otherwise the expression will be interpreted as a glob.

        .. versionadded:: 2018.3.0

        .. note::
            If used with ``include_pat``, files matching this pattern will be
            excluded from the subset of files defined by ``include_pat``.

    CLI Example:

    .. code-block:: bash

        salt '*' net.cli "show version" "show chassis fan"

    CLI Example with TextFSM template:

    .. code-block:: bash

        salt '*' net.cli textfsm_parse=True textfsm_path=salt://textfsm/

    Example output:

    .. code-block:: python

        {
            'show version and haiku':  'Hostname: re0.edge01.arn01
                                          Model: mx480
                                          Junos: 13.3R6.5
                                            Help me, Obi-Wan
                                            I just saw Episode Two
                                            You're my only hope
                                         ',
            'show chassis fan' :   'Item                      Status   RPM     Measurement
                                      Top Rear Fan              OK       3840    Spinning at intermediate-speed
                                      Bottom Rear Fan           OK       3840    Spinning at intermediate-speed
                                      Top Middle Fan            OK       3900    Spinning at intermediate-speed
                                      Bottom Middle Fan         OK       3840    Spinning at intermediate-speed
                                      Top Front Fan             OK       3810    Spinning at intermediate-speed
                                      Bottom Front Fan          OK       3840    Spinning at intermediate-speed
                                     '
        }

    Example output with TextFSM parsing:

    .. code-block:: json

        {
          "comment": "",
          "result": true,
          "out": {
            "sh ver": [
              {
                "kernel": "9.1S3.5",
                "documentation": "9.1S3.5",
                "boot": "9.1S3.5",
                "crypto": "9.1S3.5",
                "chassis": "",
                "routing": "9.1S3.5",
                "base": "9.1S3.5",
                "model": "mx960"
              }
            ]
          }
        }
    ucliucommandsuresultu
textfsm_parseunapalm_cli_textfsm_parseuNo TextFSM parsing requested.utextfsm.extractu
textfsm.indexucommentu(Unable to process: is TextFSM installed?utextfsm_templateutextfsm_template: %sutextfsm_pathutextfsm_path: %sutextfsm_template_dictu napalm_cli_textfsm_template_dictu$TextFSM command-template mapping: %su
index_fileutextfsm_index_fileuindex_file: %suplatform_grain_nameutextfsm_platform_grainuosuplatform_grain_name: %suplatform_column_nameutextfsm_platform_column_nameuPlatformuplatform_column_name: %susaltenvubaseu
include_emptyuinclude_patuexclude_patuuoutu#Starting to analyse the raw outputsuOutput from command: %suUsing the templates under %stplatform_grain_nametplatform_column_nametoutputttextfsm_pathtsaltenvt
include_emptytinclude_pattexclude_patuProcessed CLI output:u3Apparently this didnt work, returnin the raw outputu,
Unable to process the output from {0}: {1}.uAll good, %s has a nice output!uM
Processing "{}" didn't fail, but didn't return anything either. Dumping raw.u#Using %s to process the command: %straw_textu4Apparently this didnt work, returning the raw outputu+
Unable to process the output from {0}: {1}uHProcessing %s didnt fail, but didnt return anything either. Dumping raw.u9No TextFSM template specified, or no TextFSM path definedu&
Unable to process the output from {}.N(RRRRkR"RR
Rt
__pillar__RR&R'RKR/R@tstripR;(tcommandsRYtraw_cli_outputst
textfsm_parsettextfsm_templateRqttextfsm_template_dictt
index_fileRnRoRrRsRtRutprocessed_cli_outputstcommandtcommand_outputtprocessed_command_outputtprocessed_cli_outputtcomment((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytcli�s��





	






	
	

	






		
cK@s<tjjjtdi|d6|d6|d6|d6|d6�S(u�
    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-to-live value (or IPv6 maximum hop-limit value)

    timeout
        Number of seconds to wait for response (seconds)

    vrf
        VRF (routing instance) for traceroute attempt

        .. versionadded:: 2016.11.4

    CLI Example:

    .. code-block:: bash

        salt '*' net.traceroute 8.8.8.8
        salt '*' net.traceroute 8.8.8.8 source=127.0.0.1 ttl=5 timeout=1
    u
tracerouteudestinationusourceuttlutimeoutuvrf(RRRRkR"(tdestinationR:tttlttimeouttvrfRY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt
traceroutes cK@sJtjjjtdi|d6|d6|d6|d6|d6|d6|d6�S(	u
    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 final packet (seconds)

    size
        Size of request packets (0..65468 bytes)

    count
        Number of ping requests to send (1..2000000000 packets)

    vrf
        VRF (routing instance) for ping attempt

        .. versionadded:: 2016.11.4

    CLI Example:

    .. code-block:: bash

        salt '*' net.ping 8.8.8.8
        salt '*' net.ping 8.8.8.8 ttl=3 size=65468
        salt '*' net.ping 8.8.8.8 source=127.0.0.1 timeout=1 count=100
    upingudestinationusourceuttlutimeoutusizeucountuvrf(RRRRkR"(R�R:R�R�tsizetcountR�RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytping?s&ucK@s�tjjjtdi�}|jd�s.|S|jd�}|rXt|d|�}n|rst|d|�}n|r�t|d|�}n|ji|d6�|S(u�
    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 '*' net.arp
        salt '*' net.arp macaddr='5c:5e:ab:da:3c:f0'

    Example output:

    .. code-block:: python

        [
            {
                'interface' : 'MgmtEth0/RSP0/CPU0/0',
                'mac'       : '5c:5e:ab:da:3c:f0',
                'ip'        : '172.17.17.1',
                'age'       : 1454496274.84
            },
            {
                'interface': 'MgmtEth0/RSP0/CPU0/0',
                'mac'       : '66:0e:94:96:e0:ff',
                'ip'        : '172.17.17.2',
                'age'       : 1435641582.49
            }
        ]
    u
get_arp_tableuresultuoutu	interfaceuipumac(RRRRkR"R
Rtupdate(t	interfacetipaddrtmacaddrRYtproxy_outputt	arp_table((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytarpts &		cK@stjjjtdi�S(uu
    Returns IP addresses configured on the device.

    :return:   A dictionary with the IPv4 and IPv6 addresses of the interfaces.
        Returns all configured IP addresses on all interfaces as a dictionary
        of dictionaries.  Keys of the main dictionary represent the name of the
        interface.  Values of the main dictionary represent are dictionaries
        that may consist of two keys 'ipv4' and 'ipv6' (one, both or none)
        which are themselvs dictionaries with the IP addresses as keys.

    CLI Example:

    .. code-block:: bash

        salt '*' net.ipaddrs

    Example output:

    .. code-block:: python

        {
            'FastEthernet8': {
                'ipv4': {
                    '10.66.43.169': {
                        'prefix_length': 22
                    }
                }
            },
            'Loopback555': {
                'ipv4': {
                    '192.168.1.1': {
                        'prefix_length': 24
                    }
                },
                'ipv6': {
                    '1::1': {
                        'prefix_length': 64
                    },
                    '2001:DB8:1::1': {
                        'prefix_length': 64
                    },
                    'FE80::3': {
                        'prefix_length': 'N/A'
                    }
                }
            }
        }
    uget_interfaces_ip(RRRRkR"(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytipaddrs�s4cK@stjjjtdi�S(uo
    Returns details of the interfaces on the device.

    :return: Returns a dictionary of dictionaries. The keys for the first
        dictionary will be the interfaces in the devices.

    CLI Example:

    .. code-block:: bash

        salt '*' net.interfaces

    Example output:

    .. code-block:: python

        {
            'Management1': {
                'is_up': False,
                'is_enabled': False,
                'description': '',
                'last_flapped': -1,
                'speed': 1000,
                'mac_address': 'dead:beef:dead',
            },
            'Ethernet1':{
                'is_up': True,
                'is_enabled': True,
                'description': 'foo',
                'last_flapped': 1429978575.1554043,
                'speed': 1000,
                'mac_address': 'beef:dead:beef',
            }
        }
    uget_interfaces(RRRRkR"(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt
interfaces�s'cK@sttjjjtdi�}|jd�s.|S|jd�}|r\i|j|�|6}n|ji|d6�|S(u�
    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 interface='TenGigE0/0/0/8'

    Example output:

    .. code-block:: python

        {
            'TenGigE0/0/0/8': [
                {
                    'parent_interface': 'Bundle-Ether8',
                    'interface_description': 'TenGigE0/0/0/8',
                    'remote_chassis_id': '8c60.4f69.e96c',
                    'remote_system_name': 'switch',
                    'remote_port': 'Eth2/2/1',
                    'remote_port_description': 'Ethernet2/2/1',
                    'remote_system_description': 'Cisco Nexus Operating System (NX-OS) Software 7.1(0)N1(1a)
                          TAC support: http://www.cisco.com/tac
                          Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.',
                    'remote_system_capab': 'B, R',
                    'remote_system_enable_capab': 'B'
                }
            ]
        }
    uget_lldp_neighbors_detailuresultuout(RRRRkR"R
R�(R�RYR�tlldp_neighbors((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytlldp!s)		cK@s�tjjjtdi�}|jd�s.|S|jd�}|rgt|t�rgt|d|�}n|r�t|d|�}n|r�t|d|�}n|j	i|d6�|S(u-
    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

        salt '*' net.mac
        salt '*' net.mac vlan=10

    Example output:

    .. code-block:: python

        [
            {
                'mac'       : '00:1c:58:29:4a:71',
                'interface' : 'xe-3/0/2',
                'static'    : False,
                'active'    : True,
                'moves'     : 1,
                'vlan'      : 10,
                'last_move' : 1454417742.58
            },
            {
                'mac'       : '8c:60:4f:58:e1:c1',
                'interface' : 'xe-1/0/1',
                'static'    : False,
                'active'    : True,
                'moves'     : 2,
                'vlan'      : 42,
                'last_move' : 1453191948.11
            }
        ]
    uget_mac_address_tableuresultuoutuvlanumacu	interface(
RRRRkR"R
t
isinstanceRNRR�(taddressR�tvlanRYR�tmac_address_table((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytmac`s ,		cK@s tjjjtdi|d6�S(u�
    .. versionadded:: 2017.7.0

    Return the whole configuration of the network device. By default, it will
    return all possible configuration sources supported by the network device.
    At most, there will be:

    - running config
    - startup config
    - candidate config

    To return only one of the configurations, you can use the ``source``
    argument.

    source
        Which configuration type you want to display, default is all of them.

        Options:

        - running
        - candidate
        - startup

    :return:
        The object returned is a dictionary with the following keys:

        - running (string): Representation of the native running configuration.
        - candidate (string): Representation of the native candidate configuration.
            If the device doesn't differentiate between running and startup
            configuration this will an empty string.
        - startup (string): Representation of the native startup configuration.
            If the device doesn't differentiate between running and startup
            configuration this will an empty string.

    CLI Example:

    .. code-block:: bash

        salt '*' net.config
        salt '*' net.config source=candidate
    u
get_configuretrieve(RRRRkR"(R:RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytconfig�s
+cK@stjjjtdi�S(u�
    .. versionadded:: 2017.7.0

    Fetches the power usage on the various transceivers installed
    on the network device (in dBm), and returns a view that conforms with the
    OpenConfig model openconfig-platform-transceiver.yang.

    :return:
        Returns a dictionary where the keys are as listed below:
            * intf_name (unicode)
                * physical_channels
                    * channels (list of dicts)
                        * index (int)
                        * state
                            * input_power
                                * instant (float)
                                * avg (float)
                                * min (float)
                                * max (float)
                            * output_power
                                * instant (float)
                                * avg (float)
                                * min (float)
                                * max (float)
                            * laser_bias_current
                                * instant (float)
                                * avg (float)
                                * min (float)
                                * max (float)

    CLI Example:

    .. code-block:: bash

        salt '*' net.optics
    u
get_optics(RRRRkR"(RY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytoptics�s&ubasec
K@s(d}|rd}ntjjjt�r7ttd<n|r�td|d|�}|tkr�itd6dd6}dj	|�|d	<t
j|d	�|S|
r�tjjj
|�q�ntjjjt|i|d
6�}tt|d|d|d
|d|d|d|d|d|d|	d|
|
�
S(u�!
    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 ``already_configured`` will be set as ``True`` to point this out.

    To avoid committing the configuration, set the argument ``test`` to ``True`` and will discard (dry run).

    To keep the changes but not commit, set ``commit`` to ``False``.

    To replace the config, set ``replace`` to ``True``.

    filename
        Path to the file containing the desired configuration.
        This can be specified using the absolute path to the file,
        or using one of the following URL schemes:

        - ``salt://``, to fetch the template from the Salt fileserver.
        - ``http://`` or ``https://``
        - ``ftp://``
        - ``s3://``
        - ``swift://``

        .. versionchanged:: 2018.3.0

    text
        String containing the desired configuration.
        This argument is ignored when ``filename`` is specified.

    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.

        .. versionadded:: 2016.11.2

    replace: False
        Load and replace the configuration. Default: ``False``.

        .. versionadded:: 2016.11.2

    commit_in: ``None``
        Commit the changes in a specific number of minutes / hours. Example of
        accepted formats: ``5`` (commit in 5 minutes), ``2m`` (commit in 2
        minutes), ``1h`` (commit the changes in 1 hour)`, ``5h30m`` (commit
        the changes in 5 hours and 30 minutes).

        .. note::
            This feature works on any platforms, as it does not rely on the
            native features of the network operating system.

        .. note::
            After the command is executed and the ``diff`` is not satisfactory,
            or for any other reasons you have to discard the commit, you are
            able to do so using the
            :py:func:`net.cancel_commit <salt.modules.napalm_network.cancel_commit>`
            execution function, using the commit ID returned by this function.

        .. warning::
            Using this feature, Salt will load the exact configuration you
            expect, however the diff may change in time (i.e., if an user
            applies a manual configuration change, or a different process or
            command changes the configuration in the meanwhile).

        .. versionadded:: 2019.2.0

    commit_at: ``None``
        Commit the changes at a specific time. Example of accepted formats:
        ``1am`` (will commit the changes at the next 1AM), ``13:20`` (will
        commit at 13:20), ``1:20am``, etc.

        .. note::
            This feature works on any platforms, as it does not rely on the
            native features of the network operating system.

        .. note::
            After the command is executed and the ``diff`` is not satisfactory,
            or for any other reasons you have to discard the commit, you are
            able to do so using the
            :py:func:`net.cancel_commit <salt.modules.napalm_network.cancel_commit>`
            execution function, using the commit ID returned by this function.

        .. warning::
            Using this feature, Salt will load the exact configuration you
            expect, however the diff may change in time (i.e., if an user
            applies a manual configuration change, or a different process or
            command changes the configuration in the meanwhile).

        .. versionadded:: 2019.2.0

    revert_in: ``None``
        Commit and revert the changes in a specific number of minutes / hours.
        Example of accepted formats: ``5`` (revert in 5 minutes), ``2m`` (revert
        in 2 minutes), ``1h`` (revert the changes in 1 hour)`, ``5h30m`` (revert
        the changes in 5 hours and 30 minutes).

        .. note::
            To confirm the commit, and prevent reverting the changes, you will
            have to execute the
            :mod:`net.confirm_commit <salt.modules.napalm_network.confirm_commit>`
            function, using the commit ID returned by this function.

        .. warning::
            This works on any platform, regardless if they have or don't have
            native capabilities to confirming a commit. However, please be
            *very* cautious when using this feature: on Junos (as it is the only
            NAPALM core platform supporting this natively) it executes a commit
            confirmed as you would do from the command line.
            All the other platforms don't have this capability natively,
            therefore the revert is done via Salt. That means, your device needs
            to be reachable at the moment when Salt will attempt to revert your
            changes. Be cautious when pushing configuration changes that would
            prevent you reach the device.

            Similarly, if an user or a different process apply other
            configuration changes in the meanwhile (between the moment you
            commit and till the changes are reverted), these changes would be
            equally reverted, as Salt cannot be aware of them.

        .. versionadded:: 2019.2.0

    revert_at: ``None``
        Commit and revert the changes at a specific time. Example of accepted
        formats: ``1am`` (will commit and revert the changes at the next 1AM),
        ``13:20`` (will commit and revert at 13:20), ``1:20am``, etc.

        .. note::
            To confirm the commit, and prevent reverting the changes, you will
            have to execute the
            :mod:`net.confirm_commit <salt.modules.napalm_network.confirm_commit>`
            function, using the commit ID returned by this function.

        .. warning::
            This works on any platform, regardless if they have or don't have
            native capabilities to confirming a commit. However, please be
            *very* cautious when using this feature: on Junos (as it is the only
            NAPALM core platform supporting this natively) it executes a commit
            confirmed as you would do from the command line.
            All the other platforms don't have this capability natively,
            therefore the revert is done via Salt. That means, your device needs
            to be reachable at the moment when Salt will attempt to revert your
            changes. Be cautious when pushing configuration changes that would
            prevent you reach the device.

            Similarly, if an user or a different process apply other
            configuration changes in the meanwhile (between the moment you
            commit and till the changes are reverted), these changes would be
            equally reverted, as Salt cannot be aware of them.

        .. versionadded:: 2019.2.0

    saltenv: ``base``
        Specifies the Salt environment name.

        .. versionadded:: 2018.3.0

    :return: a dictionary having the following keys:

    * result (bool): if the config was applied successfully. It is ``False`` only in case of failure. In case     there are no changes to be applied and successfully performs all operations it is still ``True`` and so will be     the ``already_configured`` flag (example below)
    * comment (str): a message for the user
    * already_configured (bool): flag to check if there were no changes applied
    * loaded_config (str): the configuration loaded on the device. Requires ``debug`` to be set as ``True``
    * diff (str): returns the config changes applied

    CLI Example:

    .. code-block:: bash

        salt '*' net.load_config text='ntp peer 192.168.0.1'
        salt '*' net.load_config filename='/absolute/path/to/your/file'
        salt '*' net.load_config filename='/absolute/path/to/your/file' test=True
        salt '*' net.load_config filename='/absolute/path/to/your/file' commit=False

    Example output:

    .. code-block:: python

        {
            'comment': 'Configuration discarded.',
            'already_configured': False,
            'result': True,
            'diff': '[edit interfaces xe-0/0/5]+   description "Adding a description";'
        }
    uload_merge_candidateuload_replace_candidateuCLOSEucp.get_file_strRruresultuoutu<Unable to read from {}. Please specify a valid file or text.ucommentuconfigRPR'RQRRRSRURTRVRWRXN(RRRR,RRR"RKR@R;R&R/RGtsafe_rmRkRi(tfilenamettextRPRR'RQRTRURVRWRXRRrRYtfuntrett_loaded((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytload_configsD�	


ujinjac'&K@s�d}itd6dd6td6}t}ddddf}xI|D]A}|j|�r�||=tjjjd	d
jd|��nq@W|tjjj	kr�|j
itd6djd
djt
tjjj	j����d6�|Snddddf}t}t}t|tt
f�r]x-|D]%}|rF|p@|j|�}nq!Wtd|�}n|p�|p�|p�t|tt
f�r�|tkr�i}n|j
|�|rBtdd|d|d|d|d|�}t|tj�r?d|kr|d|d<n
t|d<d|kr.|d|d<n
d|d<|Snnt|t
tf�rd|g}n|o}t|t
tf�r�|g}n|r�tgt|�}n|o�t|tj�o�|jd�p�|jd�r�|g}ni|ot|tj�o|jd�p|jd�r8|gt|�}n|rUtgt|�}nx�t|�D]�\}}||}||}td|d�} tdd| �}!td d!|!d"|d#|d$|d%td&td'td(td|d|d|d|d)|�
}"t|"t
tf�o(t|"tj�rH|dc|"7<t|d<n�t|"t
tf�omt|"�d*kr�t|d<|dcd7<nMt|"t
tf�o�t|"d*�d*kr�t|d<|dc|"d+7<n|drK|"d*}#td|#�}$|$r&t|d<|dcd7<|Sn|td,|#�7}td-|#�n|SqbW|}|dr�d.}%|rxd/}%ntjjjt�r�ttd0<ntjjjt|%i|d16�}nn�tjjjd	d2�|r�|ni}&|&j
|�|&j
i|d36|d46td56td66td76�tjjjt�rIttd0<ntjjjtd8|&�}tt|d9|	d:|d;|d<|
d=|d>|d?|
d@|dA||�	S(Bu�3
    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 configuration, set the argument ``test`` to ``True``
    and will discard (dry run).

    To preserve the changes, set ``commit`` to ``False``.
    However, this is recommended to be used only in exceptional cases
    when there are applied few consecutive states
    and/or configuration changes.
    Otherwise the user might forget that the config DB is locked
    and the candidate config buffer is not cleared/merged in the running config.

    To replace the config, set ``replace`` to ``True``.

    template_name
        Identifies path to the template source.
        The template can be either stored on the local machine, either remotely.
        The recommended location is under the ``file_roots``
        as specified in the master config file.
        For example, let's suppose the ``file_roots`` is configured as:

        .. code-block:: yaml

            file_roots:
              base:
                - /etc/salt/states

        Placing the template under ``/etc/salt/states/templates/example.jinja``,
        it can be used as ``salt://templates/example.jinja``.
        Alternatively, for local files, the user can specify the absolute path.
        If remotely, the source can be retrieved via ``http``, ``https`` or ``ftp``.

        Examples:

        - ``salt://my_template.jinja``
        - ``/absolute/path/to/my_template.jinja``
        - ``http://example.com/template.cheetah``
        - ``https:/example.com/template.mako``
        - ``ftp://example.com/template.py``

        .. versionchanged:: 2019.2.0
            This argument can now support a list of templates to be rendered.
            The resulting configuration text is loaded at once, as a single
            configuration chunk.

    template_source: None
        Inline config template to be rendered and loaded on the device.

    template_hash: None
        Hash of the template file. Format: ``{hash_type: 'md5', 'hsum': <md5sum>}``

        .. versionadded:: 2016.11.2

    context: None
        Overrides default context variables passed to the template.

        .. versionadded:: 2019.2.0

    template_hash_name: None
        When ``template_hash`` refers to a remote file,
        this specifies the filename to look for in that file.

        .. versionadded:: 2016.11.2

    saltenv: ``base``
        Specifies the template environment.
        This will influence the relative imports inside the templates.

        .. versionadded:: 2016.11.2

    template_engine: jinja
        The following templates engines are supported:

        - :mod:`cheetah<salt.renderers.cheetah>`
        - :mod:`genshi<salt.renderers.genshi>`
        - :mod:`jinja<salt.renderers.jinja>`
        - :mod:`mako<salt.renderers.mako>`
        - :mod:`py<salt.renderers.py>`
        - :mod:`wempy<salt.renderers.wempy>`

        .. versionadded:: 2016.11.2

    skip_verify: True
        If ``True``, hash verification of remote file sources
        (``http://``, ``https://``, ``ftp://``) will be skipped,
        and the ``source_hash`` argument will be ignored.

        .. versionadded:: 2016.11.2

    test: False
        Dry run? If set to ``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 result after the template was rendered.

        .. versionadded:: 2016.11.2

    replace: False
        Load and replace the configuration.

        .. versionadded:: 2016.11.2

    commit_in: ``None``
        Commit the changes in a specific number of minutes / hours. Example of
        accepted formats: ``5`` (commit in 5 minutes), ``2m`` (commit in 2
        minutes), ``1h`` (commit the changes in 1 hour)`, ``5h30m`` (commit
        the changes in 5 hours and 30 minutes).

        .. note::
            This feature works on any platforms, as it does not rely on the
            native features of the network operating system.

        .. note::
            After the command is executed and the ``diff`` is not satisfactory,
            or for any other reasons you have to discard the commit, you are
            able to do so using the
            :py:func:`net.cancel_commit <salt.modules.napalm_network.cancel_commit>`
            execution function, using the commit ID returned by this function.

        .. warning::
            Using this feature, Salt will load the exact configuration you
            expect, however the diff may change in time (i.e., if an user
            applies a manual configuration change, or a different process or
            command changes the configuration in the meanwhile).

        .. versionadded:: 2019.2.0

    commit_at: ``None``
        Commit the changes at a specific time. Example of accepted formats:
        ``1am`` (will commit the changes at the next 1AM), ``13:20`` (will
        commit at 13:20), ``1:20am``, etc.

        .. note::
            This feature works on any platforms, as it does not rely on the
            native features of the network operating system.

        .. note::
            After the command is executed and the ``diff`` is not satisfactory,
            or for any other reasons you have to discard the commit, you are
            able to do so using the
            :py:func:`net.cancel_commit <salt.modules.napalm_network.cancel_commit>`
            execution function, using the commit ID returned by this function.

        .. warning::
            Using this feature, Salt will load the exact configuration you
            expect, however the diff may change in time (i.e., if an user
            applies a manual configuration change, or a different process or
            command changes the configuration in the meanwhile).

        .. versionadded:: 2019.2.0

    revert_in: ``None``
        Commit and revert the changes in a specific number of minutes / hours.
        Example of accepted formats: ``5`` (revert in 5 minutes), ``2m`` (revert
        in 2 minutes), ``1h`` (revert the changes in 1 hour)`, ``5h30m`` (revert
        the changes in 5 hours and 30 minutes).

        .. note::
            To confirm the commit, and prevent reverting the changes, you will
            have to execute the
            :mod:`net.confirm_commit <salt.modules.napalm_network.confirm_commit>`
            function, using the commit ID returned by this function.

        .. warning::
            This works on any platform, regardless if they have or don't have
            native capabilities to confirming a commit. However, please be
            *very* cautious when using this feature: on Junos (as it is the only
            NAPALM core platform supporting this natively) it executes a commit
            confirmed as you would do from the command line.
            All the other platforms don't have this capability natively,
            therefore the revert is done via Salt. That means, your device needs
            to be reachable at the moment when Salt will attempt to revert your
            changes. Be cautious when pushing configuration changes that would
            prevent you reach the device.

            Similarly, if an user or a different process apply other
            configuration changes in the meanwhile (between the moment you
            commit and till the changes are reverted), these changes would be
            equally reverted, as Salt cannot be aware of them.

        .. versionadded:: 2019.2.0

    revert_at: ``None``
        Commit and revert the changes at a specific time. Example of accepted
        formats: ``1am`` (will commit and revert the changes at the next 1AM),
        ``13:20`` (will commit and revert at 13:20), ``1:20am``, etc.

        .. note::
            To confirm the commit, and prevent reverting the changes, you will
            have to execute the
            :mod:`net.confirm_commit <salt.modules.napalm_network.confirm_commit>`
            function, using the commit ID returned by this function.

        .. warning::
            This works on any platform, regardless if they have or don't have
            native capabilities to confirming a commit. However, please be
            *very* cautious when using this feature: on Junos (as it is the only
            NAPALM core platform supporting this natively) it executes a commit
            confirmed as you would do from the command line.
            All the other platforms don't have this capability natively,
            therefore the revert is done via Salt. That means, your device needs
            to be reachable at the moment when Salt will attempt to revert your
            changes. Be cautious when pushing configuration changes that would
            prevent you reach the device.

            Similarly, if an user or a different process apply other
            configuration changes in the meanwhile (between the moment you
            commit and till the changes are reverted), these changes would be
            equally reverted, as Salt cannot be aware of them.

        .. versionadded:: 2019.2.0

    defaults: None
        Default variables/context passed to the template.

        .. versionadded:: 2016.11.2

    template_vars
        Dictionary with the arguments/context to be used when the template is rendered.

        .. note::
            Do not explicitly specify this argument. This represents any other
            variable that will be sent to the template rendering system.
            Please see the examples below!

        .. note::
            It is more recommended to use the ``context`` argument to avoid
            conflicts between CLI arguments and template variables.

    :return: a dictionary having the following keys:

    - result (bool): if the config was applied successfully. It is ``False``
      only in case of failure. In case there are no changes to be applied and
      successfully performs all operations it is still ``True`` and so will be
      the ``already_configured`` flag (example below)
    - comment (str): a message for the user
    - already_configured (bool): flag to check if there were no changes applied
    - loaded_config (str): the configuration loaded on the device, after
      rendering the template. Requires ``debug`` to be set as ``True``
    - diff (str): returns the config changes applied

    The template can use variables from the ``grains``, ``pillar`` or ``opts``, for example:

    .. code-block:: jinja

        {% set router_model = grains.get('model') -%}
        {% set router_vendor = grains.get('vendor') -%}
        {% set os_version = grains.get('version') -%}
        {% set hostname = pillar.get('proxy', {}).get('host') -%}
        {% if router_vendor|lower == 'juniper' %}
        system {
            host-name {{hostname}};
        }
        {% elif router_vendor|lower == 'cisco' %}
        hostname {{hostname}}
        {% endif %}

    CLI Examples:

    .. code-block:: bash

        salt '*' net.load_template set_ntp_peers peers=[192.168.0.1]  # uses NAPALM default templates

        # inline template:
        salt -G 'os:junos' net.load_template template_source='system { host-name {{host_name}}; }'         host_name='MX480.lab'

        # inline template using grains info:
        salt -G 'os:junos' net.load_template         template_source='system { host-name {{grains.model}}.lab; }'
        # if the device is a MX480, the command above will set the hostname as: MX480.lab

        # inline template using pillar data:
        salt -G 'os:junos' net.load_template template_source='system { host-name {{pillar.proxy.host}}; }'

        salt '*' net.load_template https://bit.ly/2OhSgqP hostname=example  # will commit
        salt '*' net.load_template https://bit.ly/2OhSgqP hostname=example test=True  # dry run

        salt '*' net.load_template salt://templates/example.jinja debug=True  # Using the salt:// URI

        # render a mako template:
        salt '*' net.load_template salt://templates/example.mako template_engine=mako debug=True

        # render remote template
        salt -G 'os:junos' net.load_template http://bit.ly/2fReJg7 test=True debug=True peers=['192.168.0.1']
        salt -G 'os:ios' net.load_template http://bit.ly/2gKOj20 test=True debug=True peers=['192.168.0.1']

        # render multiple templates at once
        salt '*' net.load_template "['https://bit.ly/2OhSgqP', 'salt://templates/example.jinja']" context="{'hostname': 'example'}"

    Example output:

    .. code-block:: python

        {
            'comment': '',
            'already_configured': False,
            'result': True,
            'diff': '[edit system]+  host-name edge01.bjm01',
            'loaded_config': 'system { host-name edge01.bjm01; }''
        }
    uuresultucommentuoutu
template_userutemplate_attrsutemplate_groupu
template_modeuSodiumuNThe '{arg}' argument to 'net.load_template' is deprecated and has been ignoredtargu9Invalid templating engine! Choose between: {tpl_eng_opts}ttpl_eng_optsu, usalt://uhttp://uhttps://uftp://ufile.file_existsufile.apply_template_on_contentstcontentsttemplatetcontexttdefaultsRru#Error while rendering the template.ufile://urandom.hashumd5u	file.joinu/tmpufile.get_managedtnameR:tsource_hashtsource_hash_nametusertgrouptmodetattrstskip_verifyii����u	file.readufile.removeuload_merge_candidateuload_replace_candidateuCLOSEuconfigu�Native NAPALM templates support will be removed in the Sodium release. Please consider using the Salt rendering pipeline instead.If you are using the 'netntp', 'netsnmp', or 'netusers' Salt State modules, you can ignore this messageu
template_nameutemplate_sourceupillarugrainsuoptsu
load_templateRPR'RQRRRSRURTRVRW(RBR@R
RRtversionst
warn_untilR;t	templatestTEMPLATE_REGISTRYR�RtjoinRtkeysR�ttuplet
startswithRKRtstring_typesRAt	enumerateRR,RR"RkRwRLRi('t
template_namettemplate_sourceR�R�ttemplate_engineRrt
template_hashttemplate_hash_nameR�RPRR'RQRTRURVRWRt
template_varst	_renderedR�RStdeprecated_argstdeprecated_argtsalt_render_prefixestsalt_rendertfile_existstsalt_render_prefixt	tpl_indexttpl_namettpl_hasht
tpl_hash_namet_rand_filenamet
_temp_filet_managedt_temp_tpl_filet_temp_tpl_file_existsR�tload_templates_params((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt
load_templates�N

			,
'	

	




	(
(
,




	

	
	cK@stjjjtdi�S(u�
    Commits the configuration changes made on the network device.

    CLI Example:

    .. code-block:: bash

        salt '*' net.commit
    u
commit_config(RRRRkR"(RRY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR%s
cK@stjjjtdi�S(ux
    Discards the changes applied.

    CLI Example:

    .. code-block:: bash

        salt '*' net.discard_config
    udiscard_config(RRRRkR"(RRY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR(9s
cK@stjjjtdi�S(u�
    Returns the difference between the running config and the candidate config.

    CLI Example:

    .. code-block:: bash

        salt '*' net.compare_config
    ucompare_config(RRRRkR"(RRY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR>Ms
cK@stjjjtdi�S(uq
    Rollbacks the configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' net.rollback
    urollback(RRRRkR"(RRY((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytrollbackas
cK@sdt}d}tdt�}|jd�rK|jd�rBt}qZd}n|jd�}||fS(uJ
    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_changed
    uRuresultuoutu,Configuration was not changed on the device.ucomment(RR>R"R
RB(RRYtis_config_changedtreasonttry_compare((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytconfig_changedus		cK@s�t}d}tdt�\}}|s1||fSt�}|jd�s�t}djd|jd��}t�}|jd�s�|djd|jd��7}q�n||fS(u�
    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 why the configuration was not committed properly.

    CLI Example:

    .. code-block:: bash

        salt '*' net.config_control
    uRuresultuIUnable to commit the changes: {reason}.
        Will try to rollback now!R�ucommentu
Cannot rollback! {reason}(RBR�R"RR
RR;R�(RRYtresultR�tchangedtnot_changed_rsnt
try_committtry_rollback((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytconfig_control�s
			cC@sidj|�}td|�}|drOtd�}djd|�|d<ndjd|�|d<|S(	u
    .. 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 commit ID is displayed when the commit is scheduled
    via the functions named above.

    CLI Example:

    .. code-block:: bash

        salt '*' net.cancel_commit 20180726083540640360
    u__napalm_commit_{}uschedule.deleteuresultu
schedule.saveuCommit #{jid} cancelled.tjiducommentuUnable to find commit #{jid}.(R;RK(R�tjob_nameR\Rb((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyRE�s

cC@sytddkrFtd�}|jd�|d<|jd�|d<nt|�}|drudjd	|�|d<n|S(
u
    .. 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 ID is displayed when the commit confirmed
    is scheduled via the functions named above.

    CLI Example:

    .. code-block:: bash

        salt '*' net.confirm_commit 20180726083540640360
    uosujunosunapalm.junos_commituouturesultumessageucommentuCommit #{jid} confirmed.R�(RLRKR?RER;(R�t	confirmed((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytconfirm_commit�s

cC@s�|sd}n|s*tjjj�}ntdd|�}|sO|dr`tjd�|Stjjj|d��}|j|d|�WdQXit	d6|d6d	j
d|d
|�d6S(u
    .. 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 push the files to the Master, use
        :mod:`cp.push <salt.modules.cp.push>` Execution function.

    CLI Example:

    .. code-block:: bash

        salt '*' net.save_config source=running
    urunningu
net.configR:uresultuUnable to retrieve the configuwuoutNu{source} config saved to {path}tpathucomment(RRRGRHRKR&R/RIRJRBR;(R:R�Rgtfh_((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytsave_config�s	
iicC@s�td|d|�}|s'|dr+|S|d}td|||d|d|d|d	|d
|d|d|d
|	d|
�	}tjjj|d��}|j�}WdQXtdd|d|
d|d|d|�S(uy
    .. 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:

    .. code-block:: bash

        salt '*' net.replace_pattern "bind-address\s*=" "bind-address:"

    CLI Example:

    .. code-block:: bash

        salt '*' net.replace_pattern PREFIX-LIST_NAME new-prefix-list-name
        salt '*' net.replace_pattern bgp-group-name new-bgp-group-name count=1
    R:R�uresultuoutufile.replaceR�tflagstbufsizetappend_if_not_foundtprepend_if_not_foundtnot_found_contenttsearch_onlytshow_changestbackslash_literalurNunet.load_configR�RPR'RQR(R�RKRRRGRItread(tpatterntreplR�R�R�R�R�R�R�R�R�R:R�RPRQR'Rtconfig_savedtreplace_patternR�tupdated_config((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyR�	s.v

	urunningc
C@s�td|d|�}
|
s'|
dr+|
S|
d}td|d|d|d|d	|d
|d|d|�}tjjj|d
��}|j�}WdQXtdd|d|	d|d|d|
�S(uZ
    .. 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 content block.
        Note that the whole line containing this marker will be considered,
        so whitespace or extra content before or after the marker is included
        in final output.

    marker_end
        The line content identifying a line as the end of the content block.
        Note that the whole line containing this marker will be considered,
        so whitespace or extra content before or after the marker is included
        in final output.

    content
        The content to be used between the two lines identified by
        ``marker_start`` and ``marker_stop``.

    append_if_not_found: ``False``
        If markers are not found and set to True then, the markers and content
        will be appended to the file.

    prepend_if_not_found: ``False``
        If markers are not found and set to True then, the markers and content
        will be prepended to the file.

    append_newline: ``False``
        Controls whether or not a newline is appended to the content block.
        If the value of this argument is ``True`` then a newline will be added
        to the content block. If it is ``False``, then a newline will not be
        added to the content block. If it is ``None`` then a newline will only
        be added to the content block if it does not already end in a newline.

    show_changes: ``True``
        Controls how changes are presented. If ``True``, this function will
        return the of the changes made.
        If ``False``, then it will return a boolean (``True`` if any changes
        were made, otherwise False).

    source: ``running``
        The configuration source. Choose from: ``running``, ``candidate``, or
        ``startup``. Default: ``running``.

    path: ``None``
        Save the temporary configuration to a specific path, then read from
        there. This argument is optional, can be used when you prefers a
        particular location of the temporary file.

    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``.

    CLI Example:

    .. code-block:: bash

        salt '*' net.blockreplace 'ntp' 'interface' ''
    R:R�uresultuoutufile.blockreplacetmarker_startt
marker_endtcontentR�R�R�tappend_newlineurNunet.load_configR�RPR'RQR(R�RKRRRGRIR�(R�R�R�R�R�R�R�R:R�RPRR'RQR�R�R�R�((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytblockreplace�	s&X

	c
C@s�td|d|�}|s'|dr+|S|d}td|�}|tkrsidd6td6dj|�d6Std||d	|�}
tjjj|d
��}|j	�}WdQXtdd
|d|d|	d|
d|�S(u,
    .. 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 ``patchfile`` argument)  is an
        HTTP(S) or FTP URL and the file exists in the minion's file cache, this
        option can be passed to keep the minion from re-downloading the file if
        the cached copy matches the specified hash.

    show_changes: ``True``
        Controls how changes are presented. If ``True``, this function will
        return the of the changes made.
        If ``False``, then it will return a boolean (``True`` if any changes
        were made, otherwise False).

    source: ``running``
        The configuration source. Choose from: ``running``, ``candidate``, or
        ``startup``. Default: ``running``.

    path: ``None``
        Save the temporary configuration to a specific path, then read from
        there. This argument is optional, can the user prefers a particular
        location of the temporary file.

    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``.

    CLI Example:

    .. code-block:: bash

        salt '*' net.patch https://example.com/running_config.patch
    R:R�uresultuoutu
cp.cache_fileuThe file "{}" does not exist.ucommentu
file.patchtoptionsurNunet.load_configR�RPR'RQR(
R�RKRR@R;RRRGRIR�(t	patchfileR�RrR�R�R:R�RPRR'RQR�tpatchfile_cacheR�R�R�((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pytpatch
s(A

	(@t__doc__t
__future__RRRROtloggingR<t	getLoggert__name__R&tsalt.extRtsalt.utils.filesRtsalt.utils.napalmtsalt.utils.versionstsalt.utils.templatestjxmleaseRBRMtImportErrorRR	t__proxyenabled__t__virtual_aliases__RRRR%R R)R@RiRRtproxy_napalm_wrapRjRlRmR�R�R�R�R�R�R�R�R�R�R�R�RR(R>R�R�R�RER�R�R�R�R�(((s?/usr/lib/python2.7/site-packages/salt/modules/napalm_network.pyt<module>s


						
		�7C�(,4A</>H32���)		(�b

Zerion Mini Shell 1.0