%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/junos.pyc

�
���^c@@sndZddlmZmZmZddlZddlZddlmZyddl	m
Z
Wn!ek
r�ddlm
Z
nXddlZddlZddlZddlZddlmZynddlmZdd	lmZdd
lmZddlmZddlZddlZddl Z e!Z"Wnek
rIe#Z"nXej$e%�Z&dZ'dgZ(d
�Z)d�Z*d�Z+d�Z,e*ddd��Z.e*dd��Z/e*d��Z0e*d��Z1d�Z2e*dd��Z3e*dd��Z4d�Z5e*dd��Z6d�Z7e*dd��Z8ddd�Z9d�Z:d�Z;dd�Z<d �Z=dS(!uE
Module to interact with Junos devices.

:maturity: new
:dependencies: junos-eznc, jxmlease

.. note::

    Those who wish to use junos-eznc (PyEZ) version >= 2.1.0, must
    use the latest salt code from github until the next release.

Refer to :mod:`junos <salt.proxy.junos>` for information on connecting to junos proxy.

i(tabsolute_importtprint_functiontunicode_literalsN(twraps(tetree(tElementTree(tsix(tDevice(tConfig(tSW(tSCPujunoscC@s$trdtkrtStdfSdS(u�
    We need the Junos adapter libraries for this
    module to work.  We also need a proxymodule entry in __opts__
    in the opts dictionary
    uproxyuZThe junos module could not be loaded: junos-eznc or jxmlease or proxy could not be loaded.N(t	HAS_JUNOSt__opts__t__virtualname__tFalse(((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyt__virtual__<sc@st���fd��}|S(Nc@s�d|krztd�}|j}|jdd�|_y �||�}||_|SWq�tk
rv||_�q�Xn(y�||�SWntk
r��nXdS(Nudev_timeoutu
junos.conn(t	__proxy__ttimeouttpoptNonet	Exception(targstkwargstconntrestore_timeouttresult(tfunction(s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytwrapperJs
		
	

(R(RR((Rs6/usr/lib/python2.7/site-packages/salt/modules/junos.pyttimeoutDecoratorIscC@s�td�}i}t|d<y|j�Wn1tk
r^}dj|�|d<t|d<|SXtd�|d<ytd�Wn#tk
r�}tjd|�nX|S(	u0
    Reload the facts dictionary from the device. Usually only needed if,
    the device configuration is changed by some other actor.
    This function will also refresh the facts stored in the salt grains.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.facts_refresh
    u
junos.connuoutuExecution failed due to "{0}"umessageujunos.get_serialized_factsufactsusaltutil.sync_grainsu'Grains could not be updated due to "%s"(	RtTruet
facts_refreshRtformatRt__salt__tlogterror(Rtrett	exception((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyR`s


cC@s\i}ytd�|d<t|d<Wn0tk
rW}dj|�|d<t|d<nX|S(u�
    Displays the facts gathered during the connection.
    These facts are also stored in Salt grains.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.facts
    ujunos.get_serialized_factsufactsuoutu$Could not display facts due to "{0}"umessage(RRRRR(R#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytfactss
cK@s0td�}i}t|d<|dkrAd|d<t|d<|S|jdd�}|sbd}nt�}d|kr�|drt|ddt�r�|j|dd�q�qnXd	|krxItj	|�D](\}}|j
d
�s�|||<q�q�Wn
|j|�|dkr�d}	d
|krItj|d
�}	|d
=n|ji|d6�y.t
|j|jdd��|	d|�}
WqDtk
r�}dj|�|d<t|d<|SXn�d
|kr�tjd�ny2t
|j|jdd��i|d6|�}
Wn1tk
rC}dj|�|d<t|d<|SX|dkr`|
j|d<n5|dkry|
|d<ntjtj|
��|d<|r,|dkr�|
j}n9|dkr�tjjj|
dd�}ntj|
�}tjjj|d��#}
|
jtjjj |��WdQXn|S(u7
    This function executes the RPC provided as arguments on the junos device.
    The returned data can be stored in a file.

    cmd
        The RPC to be executed

    dest
        Destination file where the RPC output is stored. Note that the file
        will be stored on the proxy minion. To push the files to the master use
        :py:func:`cp.push <salt.modules.cp.push>`.

    format : xml
        The format in which the RPC reply is received from the device

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    filter
        Used with the ``get-config`` RPC to get specific configuration

    terse : False
        Amount of information you want

    interface_name
      Name of the interface to query

    CLI Example:

    .. code-block:: bash

        salt 'device' junos.rpc get_config /var/log/config.txt format=text filter='<configuration><system/></configuration>'
        salt 'device' junos.rpc get-interface-information /home/user/interface.xml interface_name='lo0' terse=True
        salt 'device' junos.rpc get-chassis-inventory
    u
junos.connuoutu"Please provide the rpc to execute.umessageuformatuxmlu	__pub_argi����u__pub_scheduleu__pub_u
get-configu
get_configufilteru-u_toptionsu!RPC execution failed due to "{0}"u7Filter ignored as it is only used with "get-config" rpcutextu	rpc_replyujsontindentiuwN(u
get-configu
get_config(!RRRRRtdictt
isinstancetupdateRt	iteritemst
startswithRtXMLtgetattrtrpctreplaceRRR!twarningttexttjxmleasetparsettostringtsalttutilstjsontdumpstfilestfopentwritetstringutilstto_str(tcmdtdestRRR#tformat_toptkeytvaluetfilter_replytreplyR$twrite_responsetfp((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyR/�s�&



		


	



	



%cK@s�td�}i}|dkr7d|d<t|d<|St�}d|kr�|dr�t|ddt�r�|j|dd�q�q�n
|j|�dj|�}y|jj|dd	�Wn1t	k
r�}d
j|�|d<t|d<|SXy|jj
�}Wn1t	k
r;}dj|�|d<t|d<|SX|r�y(|jj|�d|d<t|d<Wq�t	k
r�}t|d<d
j|�|d<|SXn!t|d<d|d<|jj
�|S(u�
    Set the device's hostname

    hostname
        The name to be set

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    comment
        Provide a comment to the commit

    confirm
      Provide time in minutes for commit confirmation. If this option is
      specified, the commit will be rolled back in the specified amount of time
      unless the commit is confirmed.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.set_hostname salt-device
    u
junos.connuPlease provide the hostname.umessageuoutu	__pub_argi����uset system host-name {0}Rusetu/Could not load configuration due to error "{0}"u)Could not commit check due to error "{0}"uSuccessfully changed hostname.u:Successfully loaded host-name but commit failed with "{0}"u:Successfully loaded host-name but pre-commit check failed.N(RRRR(R)R*RtcutloadRtcommit_checktcommitRtrollback(thostnameRRR#RBt
set_stringR$t	commit_ok((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytset_hostnamesR


	











cK@s�td�}i}t�}d|krg|drtt|ddt�rd|j|dd�qdqtn
|j|�|jdt�|d<y|jj�}Wn1tk
r�}dj	|�|d<t|d<|SX|r}yp|jj
|�}t|d<|r2|dr%tj
tj|��|d<qFd|d<nd	|d<t|d<Wq�tk
ry}t|d<d
j	|�|d<q�Xn!t|d<d|d<|jj�|S(u�
    To commit the changes loaded in the candidate configuration.

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    comment
      Provide a comment for the commit

    confirm
      Provide time in minutes for commit confirmation. If this option is
      specified, the commit will be rolled back in the specified amount of time
      unless the commit is confirmed.

    sync : False
      When ``True``, on dual control plane systems, requests that the candidate
      configuration on one control plane be copied to the other control plane,
      checked for correct syntax, and committed on both Routing Engines.

    force_sync : False
      When ``True``, on dual control plane systems, force the candidate
      configuration on one control plane to be copied to the other control
      plane.

    full
      When ``True``, requires all the daemons to check and evaluate the new
      configuration.

    detail
      When ``True``, return commit detail

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.commit comment='Commiting via saltstack' detail=True
        salt 'device_name' junos.commit dev_timeout=60 confirm=10
        salt 'device_name' junos.commit sync=True dev_timeout=90
    u
junos.connu	__pub_argi����udetailu+Could not perform commit check due to "{0}"umessageuoutuCommit Successful.uCommit failed.u:Commit check succeeded but actual commit failed with "{0}"uPre-commit check failed.(RR(R)R*tgetRRIRKRRRLRR3R4RR5RM(RRR#RBRPR$RL((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRLYsD*
	











c	K@s>|jdd�}i}td�}t�}d|kry|dr�t|ddt�rv|j|dd�qvq�n
|j|�y|jj|�|d<Wn1tk
r�}dj|�|d<t	|d<|SX|dr�d	|d<nd
|d<|Sd|kr�|dd
k	r�|jj�}|d
k	rttj
jj|dd��#}|jtj
jj|��Wd
QXq�tjd�ny|jj�}Wn1tk
r�}dj|�|d<t	|d<|SX|r&y|jj|�t|d<Wq:tk
r"}t	|d<dj|�|d<|SXnd|d<t	|d<|S(u5
    Roll back the last committed configuration changes and commit

    id : 0
        The rollback ID value (0-49)

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    comment
      Provide a comment for the commit

    confirm
      Provide time in minutes for commit confirmation. If this option is
      specified, the commit will be rolled back in the specified amount of time
      unless the commit is confirmed.

    diffs_file
      Path to the file where the diff (difference in old configuration and the
      committed configuration) will be stored. Note that the file will be
      stored on the proxy minion. To push the files to the master use
      :py:func:`cp.push <salt.modules.cp.push>`.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.rollback 10
    uidiu
junos.connu	__pub_argi����uoutuRollback failed due to "{0}"umessageuRollback successfuluRollback failedu
diffs_fileuwNukNo diff between current configuration and                 rollbacked configuration, so no diff file createdu#Could not commit check due to "{0}"u6Rollback successful but commit failed with error "{0}"u0Rollback succesfull but pre-commit check failed.(RRR(R)R*RIRMRRRRtdiffR6R7R:R;R<R=R>R!tinfoRKRLR(	Rtid_R#RRBR$RSRHRP((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRM�sZ
	





%






cK@s�tjjj|�}|jdd�}|rCtjjj|�ntd�}i}t|d<y|jj	d|�|d<Wn0t
k
r�}dj|�|d<t|d<nX|S(u�
    Returns the difference between the candidate and the current configuration

    id : 0
        The rollback ID value (0-49)

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.diff 3
    uidiu
junos.connuouttrb_idumessageu#Could not get diff with error "{0}"(
R6R7Rtclean_kwargsRtinvalid_kwargsRRRIRSRRR(RRURR#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRS
s



cK@sNtd�}i}|dkr7d|d<t|d<|Si|d6}d|kr�|dr�t|ddt�r�|j|dd�q�q�n
|j|�tj|jdd	��|d<d
|kr�tj|d
�|d
<nt	|d<y,t
jtj
|jj|���|d<Wn0tk
rI}dj|�|d<t|d<nX|S(
u�
    Send a ping RPC to a device

    dest_ip
      The IP of the device to ping

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    rapid : False
        When ``True``, executes ping at 100pps instead of 1pps

    ttl
        Maximum number of IP routers (IP hops) allowed between source and
        destination

    routing_instance
      Name of the routing instance to use to send the ping

    interface
      Interface used to send traffic

    count : 5
      Number of packets to send

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.ping '8.8.8.8' count=5
        salt 'device_name' junos.ping '8.8.8.8' ttl=1 rapid=True
    u
junos.connu*Please specify the destination ip to ping.umessageuoutuhostu	__pub_argi����ucountiuttluExecution failed due to "{0}"N(RRRR)R(R*Rt	text_typeRRR3R4RR5R/tpingRR(tdest_ipRRR#RBR$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRZ)s,"






,c	K@s�td�}|jdd�}|s.d}ni}|d
krXd|d<t|d<|St�}d|kr�|dr�t|ddt�r�|j|dd�q�q�n
|j|�y|j||d	t�}Wn1tk
r}d
j	|�|d<t|d<|SX|dkr"||d<n"t
j|�}tj
|�|d<d|kr�|dd
k	r�tjjj|dd��#}|jtjjj|��Wd
QXnt|d<|S(u_
    Executes the CLI commands and returns the output in specified format.     (default is text) The output can also be stored in a file.

    command (required)
        The command to execute on the Junos CLI

    format : text
        Format in which to get the CLI output (either ``text`` or ``xml``)

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds)

    dest
        Destination file where the RPC output is stored. Note that the file
        will be stored on the proxy minion. To push the files to the master use
        :py:func:`cp.push <salt.modules.cp.push>`.

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.cli 'show system commit'
        salt 'device_name' junos.cli 'show version' dev_timeout=40
        salt 'device_name' junos.cli 'show system alarms' format=xml dest=/home/user/cli_output.txt
    u
junos.connuformatutextu.Please provide the CLI command to be executed.umessageuoutu	__pub_argi����R1uExecution failed due to "{0}"udestuwN(RRRRR(R)R*tcliRRRR5R3R4R6R7R:R;R<R=R>R(	tcommandRRRAR#RBRR$RH((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyR\hs<
	

	



%
cK@s�td�}i}t|�}i}d|krp|dr}t|ddt�rm|j|dd�qmq}n
|j|�d|kr�d|kr�d|d<t|d<|Sy�d|kr�|dr�|j}n:d|kr�|dr�|j}nd	|d<t|d<|Sd
|kr,|d|d
�n'd|krL|d
|d�n|�d|d<t|d<Wn0t	k
r�}dj
|�|d<t|d<nX|S(u
    Shut down (power off) or reboot a device running Junos OS. This includes
    all Routing Engines in a Virtual Chassis or a dual Routing Engine system.

      .. note::
          One of ``shutdown`` or ``reboot`` must be set to ``True`` or no
          action will be taken.

    shutdown : False
      Set this to ``True`` if you want to shutdown the machine. This is a
      safety mechanism so that the user does not accidentally shutdown the
      junos device.

    reboot : False
      If ``True``, reboot instead of shutting down

    at
      Used when rebooting, to specify the date and time the reboot should take
      place. The value of this option must match the JunOS CLI reboot syntax.

    in_min
        Used when shutting down. Specify the delay (in minutes) before the
        device will be shut down.

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.shutdown reboot=True
        salt 'device_name' junos.shutdown shutdown=True in_min=10
        salt 'device_name' junos.shutdown shutdown=True
    u
junos.connu	__pub_argi����ushutdownurebootu8Provide either one of the arguments: shutdown or reboot.umessageuoutuNothing to be done.uin_mintin_minuattatu"Successfully powered off/rebooted.u(Could not poweroff/reboot beacause "{0}"(RR	R)R(R*RtreboottpoweroffRRR(RRR#tswRBtshutR$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytshutdown�s@!







cK@s�td�}i}t|d<|dkrAd|d<t|d<|Si}d|kr�|dr�t|ddt�r�|j|dd�q�q�n
|j|�|jdt�}i}d|kr�|d}ntj	j
j�}td	||d
|�t
jj|�s#d|d<t|d<|St
jj|�dkrSd
|d<t|d<|Sd}d|kr�|ddk	r�|d}|d=n||d<d|kr�|jd�r�d}	n|jd�r�d}	nd}	|	|d<nd|kr|drt|d<|d=nNd|kr/|dr/t|d<n+d|krZ|drZt|d<|d=n|jdd�}
t|d|
��V}zWy|j|�Wn?tk
r�}dj|�|d<|d|d<t|d<|SXWdtj	j
j|�X|j�}
|
dkrd|d<t|d<|Si}d|krB|d|d<nd|kr_|d|d<ny|j�}Wn1tk
r�}d j|�|d<t|d<|SX|r|ry|j|�d!|d<WqGtk
r�}d"j|�|d<t|d<|SXnE|s)|j�d#|d<t|d<n|j�d$|d<t|d<yV|r�|
dk	r�tj	j
j|d%��#}|jtj	jj|
��WdQXnWn0tk
r�}d&j|�|d<t|d<nXWdQX|S('u
    Installs the given configuration file into the candidate configuration.
    Commits the changes if the commit checks or throws an error.

    path (required)
        Path where the configuration/template file is present. If the file has
        a ``.conf`` extension, the content is treated as text format. If the
        file has a ``.xml`` extension, the content is treated as XML format. If
        the file has a ``.set`` extension, the content is treated as Junos OS
        ``set`` commands.

    mode : exclusive
        The mode in which the configuration is locked. Can be one of
        ``private``, ``dynamic``, ``batch``, ``exclusive``.

    dev_timeout : 30
        Set NETCONF RPC timeout. Can be used for commands which take a while to
        execute.

    overwrite : False
        Set to ``True`` if you want this file is to completely replace the
        configuration file.

    replace : False
        Specify whether the configuration file uses ``replace:`` statements. If
        ``True``, only those statements under the ``replace`` tag will be
        changed.

    format
        Determines the format of the contents

    update : False
        Compare a complete loaded configuration against the candidate
        configuration. For each hierarchy level or configuration object that is
        different in the two configurations, the version in the loaded
        configuration replaces the version in the candidate configuration. When
        the configuration is later committed, only system processes that are
        affected by the changed configuration elements parse the new
        configuration. This action is supported from PyEZ 2.1.

    comment
      Provide a comment for the commit

    confirm
      Provide time in minutes for commit confirmation. If this option is
      specified, the commit will be rolled back in the specified amount of time
      unless the commit is confirmed.

    diffs_file
      Path to the file where the diff (difference in old configuration and the
      committed configuration) will be stored. Note that the file will be
      stored on the proxy minion. To push the files to the master use
      :py:func:`cp.push <salt.modules.cp.push>`.

    template_vars
      Variables to be passed into the template processing engine in addition to
      those present in pillar, the minion configuration, grains, etc.  You may
      reference these variables in your template like so:

      .. code-block:: jinja

          {{ template_vars["var_name"] }}

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.install_config 'salt://production/network/routers/config.set'
        salt 'device_name' junos.install_config 'salt://templates/replace_config.conf' replace=True comment='Committed via SaltStack'
        salt 'device_name' junos.install_config 'salt://my_new_configuration.conf' dev_timeout=300 diffs_file='/salt/confs/old_config.conf' overwrite=True
        salt 'device_name' junos.install_config 'salt://syslog_template.conf' template_vars='{"syslog_host": "10.180.222.7"}'
    u
junos.connuoutu?Please provide the salt path where the configuration is presentumessageu	__pub_argi����utestu
template_varsucp.get_templatet
template_varsuInvalid file path.iuTemplate failed to renderuu
diffs_fileupathuformatusetuxmlutextureplaceumergeu	overwriteumodeu	exclusivetmodeu+Could not load configuration due to : "{0}"NuConfiguration already applied!uconfirmucommentu1Commit check threw the following exception: "{0}"u"Successfully loaded and committed!u4Commit check successful but commit failed with "{0}"uOLoaded configuration but commit check failed, hence rolling back configuration.uTCommit check passed, but skipping commit for dry-run and rolling back configuration.uwu-Could not write into diffs_file due to: "{0}"(RRRRR)R(R*RR6R7R:tmkstempR tostpathtisfiletgetsizetendswithRRJRRtsafe_rmRSRKRLRMR;R<R=R>(RiRRR#RBttestRettemplate_cached_patht
write_diffttemplate_formattdb_modeRIR$tconfig_difft
commit_paramstcheckRH((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytinstall_config�s�J













		







	













)
cC@sotd�}i}t|d<y|jd�d|d<Wn0tk
rj}dj|�|d<t|d<nX|S(u�
    Resets the device to default factory settings

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.zeroize
    u
junos.connuouturequest system zeroizeuCompleted zeroize and rebootedumessageu Could not zeroize due to : "{0}"(RRR\RRR(RR#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pytzeroize�s



cK@s.td�}i}t|d<i}d|krn|dr{t|ddt�rk|j|dd�qkq{n
|j|�|jdt�}|dkr�d|d<t|d<|S|s=tj	j
j�}td||�t
jj|�sd	|d<t|d<|St
jj|�d
kr4d|d<t|d<|S|}nz_y'|jj|dt|�d
|d<Wn1tk
r�}dj|�|d<t|d<|SXWd|s�tj	j
j|�nXd|kr*|dtkr*y|jj�Wn1tk
r}dj|�|d<t|d<|SXd|d<n|S(u
    Installs the given image on the device. After the installation is complete     the device is rebooted,
    if reboot=True is given as a keyworded argument.

    path (required)
        Path where the image file is present on the proxy minion

    remote_path :
        If the value of path  is a file path on the local
        (Salt host's) filesystem, then the image is copied from the local
        filesystem to the :remote_path: directory on the target Junos
        device. The default is ``/var/tmp``. If the value of :path: or
        is a URL, then the value of :remote_path: is unused.

    dev_timeout : 30
        The NETCONF RPC timeout (in seconds). This argument was added since most of
        the time the "package add" RPC takes a significant amount of time.  The default
        RPC timeout is 30 seconds.  So this :timeout: value will be
        used in the context of the SW installation process.  Defaults to
        30 minutes (30*60=1800)

    reboot : False
        Whether to reboot after installation

    no_copy : False
        If ``True`` the software package will not be SCP’d to the device

    bool validate:
        When ``True`` this method will perform a config validation against
        the new image

    bool issu:
        When ``True`` allows unified in-service software upgrade
        (ISSU) feature enables you to upgrade between two different Junos OS
        releases with no disruption on the control plane and with minimal
        disruption of traffic.

    bool nssu:
        When ``True`` allows nonstop software upgrade (NSSU)
        enables you to upgrade the software running on a Juniper Networks
        EX Series Virtual Chassis or a Juniper Networks EX Series Ethernet
        Switch with redundant Routing Engines with a single command and
        minimal disruption to network traffic.

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.install_os 'salt://images/junos_image.tgz' reboot=True
        salt 'device_name' junos.install_os 'salt://junos_16_1.tgz' dev_timeout=300
    u
junos.connuoutu	__pub_argi����uno_copyu>Please provide the salt path where the junos image is present.umessageucp.get_fileuInvalid image path.iuFailed to copy imagetprogressuInstalled the os.u!Installation failed due to: "{0}"Nurebootu8Installation successful but reboot failed due to : "{0}"u$Successfully installed and rebooted!(RRR)R(R*RRRRR6R7R:RgR RhRiRjRkRbtinstallRRRmR`(RiRRR#RBtno_copy_timage_cached_pathR$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyt
install_os�s\6









	
	


cC@std�}i}t|d<|dkrAd|d<t|d<|Stjj|�skd|d<t|d<|S|dkr�d|d<t|d<|SyEt|dt��}|j||�WdQXd	j	||�|d<Wn0t
k
r}d
j	|�|d<t|d<nX|S(u@
    Copies the file from the local device to the junos device

    src
        The source path where the file is kept.

    dest
        The destination path on the where the file will be copied

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.file_copy /home/m2/info.txt info_copy.txt
    u
junos.connuoutu:Please provide the absolute path of the file to be copied.umessageuInvalid source file pathuSPlease provide the absolute path of the destination where the file is to be copied.RxNu(Successfully copied file from {0} to {1}uCould not copy file : "{0}"(RRRRRhRiRjR
tputRR(tsrcR@RR#tscpR$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyt	file_copyOs0







cC@sxtd�}i}t|d<y|jj�d|d<Wn9tjjjk
rs}dj|�|d<t	|d<nX|S(u�
    Attempts an exclusive lock on the candidate configuration. This
    is a non-blocking call.

    .. note::
        When locking, it is important to remember to call
        :py:func:`junos.unlock <salt.modules.junos.unlock>` once finished. If
        locking during orchestration, remember to include a step in the
        orchestration job to unlock.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.lock
    u
junos.connuoutu&Successfully locked the configuration.umessageu"Could not gain lock due to : "{0}"(
RRRItlocktjnprtjunosR$t	LockErrorRR(RR#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyR�~s


cC@sxtd�}i}t|d<y|jj�d|d<Wn9tjjjk
rs}dj|�|d<t	|d<nX|S(u�
    Unlocks the candidate configuration.

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.unlock
    u
junos.connuoutu(Successfully unlocked the configuration.umessageu-Could not unlock configuration due to : "{0}"(
RRRItunlockR�R�R$tUnlockErrorRR(RR#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyR��s



c	K@s�td�}i}t|d<|dkrAd|d<t|d<|Si}d|kr�|dr�t|ddt�r�|j|dd�q�q�n
|j|�i}d|kr�|d}ntjj	j
�}td||d	|�tj
j|�sd
|d<t|d<|Stj
j|�dkrAd|d<t|d<|S||d
<d|kr�|jd�rod}n|jd�r�d}nd}||d<nd|kr�|dr�t|d<|d=nNd|kr�|dr�t|d<n+d|kr|drt|d<|d=nzdy|jj|�d|d<Wn?tk
rt}dj|�|d<|d|d<t|d<|SXWdtjj	j|�X|S(u
    Loads the configuration from the file provided onto the device.

    path (required)
        Path where the configuration/template file is present. If the file has
        a ``.conf`` extension, the content is treated as text format. If the
        file has a ``.xml`` extension, the content is treated as XML format. If
        the file has a ``.set`` extension, the content is treated as Junos OS
        ``set`` commands.

    overwrite : False
        Set to ``True`` if you want this file is to completely replace the
        configuration file.

    replace : False
        Specify whether the configuration file uses ``replace:`` statements. If
        ``True``, only those statements under the ``replace`` tag will be
        changed.

    format
        Determines the format of the contents

    update : False
        Compare a complete loaded configuration against the candidate
        configuration. For each hierarchy level or configuration object that is
        different in the two configurations, the version in the loaded
        configuration replaces the version in the candidate configuration. When
        the configuration is later committed, only system processes that are
        affected by the changed configuration elements parse the new
        configuration. This action is supported from PyEZ 2.1.

    template_vars
      Variables to be passed into the template processing engine in addition to
      those present in pillar, the minion configuration, grains, etc.  You may
      reference these variables in your template like so:

      .. code-block:: jinja

          {{ template_vars["var_name"] }}

    CLI Examples:

    .. code-block:: bash

        salt 'device_name' junos.load 'salt://production/network/routers/config.set'

        salt 'device_name' junos.load 'salt://templates/replace_config.conf' replace=True

        salt 'device_name' junos.load 'salt://my_new_configuration.conf' overwrite=True

        salt 'device_name' junos.load 'salt://syslog_template.conf' template_vars='{"syslog_host": "10.180.222.7"}'
    u
junos.connuoutu?Please provide the salt path where the configuration is presentumessageu	__pub_argi����u
template_varsucp.get_templateReuInvalid file path.iuTemplate failed to renderupathuformatusetuxmlutextureplaceumergeu	overwriteu&Successfully loaded the configuration.u+Could not load configuration due to : "{0}"N(RRRRR)R(R*R6R7R:RgR RhRiRjRkRlRIRJRRRm(	RiRRR#RBReRoRqR$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRJ�sr5











		







	cC@sotd�}i}t|d<y|jj�d|d<Wn0tk
rj}dj|�|d<t|d<nX|S(u�
    Perform a commit check on the configuration

    CLI Example:

    .. code-block:: bash

        salt 'device_name' junos.commit_check
    u
junos.connuoutuCommit check succeeded.umessageuCommit check failed with {0}(RRRIRKRRR(RR#R$((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyRK3s



(>t__doc__t
__future__RRRtloggingRht	functoolsRtlxmlRtImportErrortsalt._compatRtsalt.utils.argsR6tsalt.utils.filestsalt.utils.jsontsalt.utils.stringutilstsalt.extRt
jnpr.junosRtjnpr.junos.utils.configRtjnpr.junos.utils.swR	tjnpr.junos.utils.scpR
tjnpr.junos.utilsR�tjnpr.junos.cfgR3RRRt	getLoggert__name__R!R
t__proxyenabled__RRRR%RR/RQRLRMRSRZR\RdRvRwR|R�R�R�RJRK(((s6/usr/lib/python2.7/site-packages/salt/modules/junos.pyt<module>sj



		
			vLV[	>D	K�	p/		

Zerion Mini Shell 1.0