Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/network/eos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyo

�
�Udac@s�ddlZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZmZddl
mZmZddlmZddlmZdaie�d	6ed
d�d6ed
edgf�d6ed
edgfde�d6ed
edgfd
d�d6ed
edgfd
d�d6eded
edgf�d6eded
d�d6eded
d�d6eded
d�d6ed
d�d6edd d!d d"g�d#6Zied
d$d%e�d&6Zied'd(�d	6ed'd(d
d�d6ed'd(�d6ed'd(de�d6ed'd(d
d�d6ed
edgfd
d�d6ed'd(de�d6ed'd(d
d�d6ed'd(d
d�d6ed'd(d
d�d6ed'd(d!d d"g�d#6Zeje�d)�Zd*�Zd+�Zd,�Zd-d<d.��YZ d/d=d0��YZ!d1d>d2��YZ"d3�Z#d4�Z$d5�Z%dd6�Z&ed7�Z'e(e(d8�Z)ddd9ddd9d:�Z*d;�Z+dS(?i����N(tto_text(tenv_fallback(t
ConnectiontConnectionError(t
NetworkConfigtdumps(tto_listtComplexList(t	iteritems(t	fetch_urlthostttypetinttporttfallbacktANSIBLE_NET_USERNAMEtusernametANSIBLE_NET_PASSWORDtno_logtpasswordtANSIBLE_NET_SSH_KEYFILEtpathtssh_keyfiletANSIBLE_NET_AUTHORIZEtboolt	authorizetANSIBLE_NET_AUTH_PASSt	auth_passtdefaulttuse_sslt	use_proxytvalidate_certsttimeouttclitchoicesteapit	transporttdicttoptionstprovidertremoved_in_versiong333333@cCstS(N(teos_provider_spec(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pytget_provider_argspecSscCsdS(N((tmoduletwarnings((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt
check_argsWscCs|jjd�pt�}x]t|�D]O\}}|tkr(|jj|�dkrw|dk	rw||j|<qwq(q(WdS(NR'(tparamstgetR%Rteos_argument_spectNone(R+R'tkeytvalue((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pytload_params[s
$cCs�ts�t|�t|�r+t|�}nbt|j�}tj|j��}|ddkrnt	|�}n|ddkr�t
|�}n|antS(Ntnetwork_apitcliconfR#(t_DEVICE_CONNECTIONR4t
is_local_eapit	LocalEapiRt_socket_pathtjsontloadstget_capabilitiestClitHttpApi(R+tconntconnection_proxytcap((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pytget_connectioncs
	R>cBsteZd�Zed��Zd�Zd	d�Zed�Z	e
e
d�Zd	d	dd	d	dd�Zd�Z
RS(
cCs(||_i|_d|_d|_dS(N(t_modulet_device_configsR1t_session_supportt_connection(tselfR+((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt__init__vs			cCs.|jdkr'|j�j�|_n|jS(N(RFR1t_get_connectiontsupports_sessions(RH((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRK|scCs,|jr|jSt|jj�|_|jS(N(RGRRDR:(RH((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRJ�s	cCs�|dkrgn|}d}|dj|�7}|j�}y|j|SWn�tk
r�|j�}y|jd|�}Wn2tk
r�}|jj	dt
|dd��nXt
|dd�j�}||j|<|SXdS(s>Retrieves the current config from the device or cache
        sshow running-config t tflagstmsgterrorstsurrogate_then_replaceN(R1tjointstripREtKeyErrorRJt
get_configRRDt	fail_jsonR(RHRMtcmdR@touttexctcfg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRT�s
#
cCsa|j�}y|jd|d|�}Wn2tk
r\}|jjdt|dd��nX|S(sARun list of commands on remote device and return results
        tcommandstcheck_rcRNRORP(RJtrun_commandsRRDRUR(RHRZR[t
connectiontresponseRX((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR\�s#cCs�|j�}y|j|||�}Wn�tk
r�}t|dt|��}d|kr{|jjd�itd6}q�|jjdd|dt|dd	��nX|S(
s9Loads the config commands onto the remote device
        terrs9check mode is not supported without configuration sessions/EOS can not check config without config sessiontchangedRNs%stdataRORP(	RJtedit_configRtgetattrRRDtwarntTrueRU(RHRZtcommittreplaceR@R^RXtmessage((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pytload_config�s-tlinec

Csy|j�}y4|jd|d|d|d|d|d|�}Wn2tk
rt}	|jjdt|	dd	��nX|S(
Nt	candidatetrunningt
diff_matchtdiff_ignore_linesRtdiff_replaceRNRORP(RJtget_diffRRDRUR(
RHRkRlRmRnRRoR@tdiffRX((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRp�s'
#cCs�t|jd�r|jjS|j�}y|j�}Wn2tk
rl}|jjdt|dd��nXtj	|�|j_|jjS(s3Returns platform info of the remove device
        t
_capabilitiesRNRORP(
thasattrRDRrRJR=RRURR;R<(RHR]tcapabilitiesRX((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR=�s
#N(t__name__t
__module__RItpropertyRKRJR1RTReR\tFalseRiRpR=(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR>ts		
	R9cBs�eZd�Zed��Zdd�Zdd�Zed�Z	dd�Z
d�Zeed�Z
dd	ddd	d
�ZRS(cCs||_d|_d|_i|_|jdd}|jdd}|jjd|jjd<|jjd|jjd<|jddr�d	}nd
}|jdd|jd<d|||f|_|jd
r�idd6|jd
d6|_n	d|_dS(NR'R
R
Rturl_usernameRturl_passwordRthttpsthttpRs%s://%s:%s/command-apiRtenableRVtinput(RDR1t_enableRFRER.t_url(RHR+R
R
tproto((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRI�s 					
!cCs:|jdkr3|jdg�}d|k|_n|jS(Nsshow configuration sessionsterror(RFR1tsend_request(RHR^((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRK�sc	Cs:tddd|d|�}tddd|dd	d
|�S(Ntversionitcmdstformattjsonrpcs2.0tidtmethodtrunCmdsR.(R%(RHRZtoutputtreqidR.((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt_request_builder�sttextc	
Csdt|�}|jr+|jd|j�n|j||�}|jj|�}idd6}|jjd}|jjdd}t|j|jd|d|d	d
d|d|�\}}|ddkr�|jj	|�ny.|j
�}|jjt|d
d��}Wn*t
k
r6|jj	ddd|�nX|jr`d|kr`|djd�n|S(Nisapplication/json-rpcsContent-TypeR R'RRatheadersR�tPOSTtstatusi�RORPRNs#unable to load response from devicetresult(RRtinsertR�RDtjsonifyR.R	R�RUtreadt	from_jsonRt
ValueErrortpop(	RHRZR�tbodyRaR�R RR^((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR��s*	
"
c	sDd}t�}t�}�fd�}x�t|�D]�}t|d�rwt|d�jdd�|d<d|d<n|r�||dkr�|j|||��t�}n|dp�d}|j|d�q4W|r�|j|||��nxJt|�D]<\}}y||dj	�||<Wqt
k
r;qXqW|S(sCRuns list of commands on remote device and returns results
        csW�j|d|�}d|krO|d}�jjd|dd|d�n|dS(NR�R�RNRhtcodeR�(R�RDRU(RZR�R^R_(RH(sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt_sends

$tcommands| jsontR;R�N(R1tlistRtis_jsontstrRgtextendtappendt	enumerateRRRS(	RHRZR[R�tqueuet	responsesR�titemtindex((RHsH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR\s*		 

cCs�|dkrgn|}d}|dj|�7}|j�}y|j|SWnLtk
r�|j|�}t|ddd�j�}||j|<|SXdS(s>Retrieves the current config from the device or cache
        sshow running-config RLR�iR�N(R1RQRRRERSR�R�(RHRMRVRWRY((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRT=s

cCsgdg}|j|�|j|�}d|kr_|d}|jjd|dd|d�n|dS(s8Sends the ordered set of commands to the device
        sconfigure terminalR�RNRhR�i(R�R�RDRU(RHRZR�R�R_((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt	configureNs	

$c
Cstjdt�}yt|�}Wntk
r5nXtt|�|jf�s�|rd|j|�S|j	j
d�itd6}|Sndttj��}i|d6}d|g}|r�|jd�n|j
|�|j|�}d|kr�d|d	g}|j|�|d}	g}
x+|	d
D]}|
j
|jdg��q.Wdj|
�pg|	d
}
|j	jd|
d|	d�nd|dg}|r�|jd�n
|jd	�|j|dd�}|ddd}t|�dkr||d<n|S(sLoads the configuration onto the remote devices

        If the device doesn't support configuration sessions, this will
        fallback to using configure() to load the commands.  If that happens,
        there will be no returned diff or session values
        tANSIBLE_EOS_USE_SESSIONSs/EOS can not check config without config sessionR`s
ansible_%stsessionsconfigure session %ssrollback clean-configR�tabortRaROs
RhRNR�sshow session-config diffsRfR�R�R�iiRq(tostgetenvReRR�tallRRKR�RDRdttimeR�R�R�R/RQRUtlen(
RHtconfigRfRgtuse_sessionR�R�RZR^R_t
error_textRaRq((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRi[sH







 

Rjc
Cs�i}tdd�}|j|�|r|dkr|dkrtddd|d|�}	|j|	d|d|d	|�}
n	|j}
|
r�t|
d
�nd}|
r�|ni|d<|S(
NtindentitnoneR�tcontentstignore_linesRtmatchRgRZR�tconfig_diff(Rtloadt
differencetitemsR(RHRkRlRmRnRRoRqt
candidate_objtrunning_objtconfigdiffobjst
configdiff((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRp�s
$	N(RuRvRIRwRKR1R�R�ReR\RTR�RxRiRp(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR9�s	 %	
7R?cBs�eZd�Zed��Zed��Zed�Zd
d�Z	d
d
dd
d
dd�Z
eed�Zeed�Z
d	�ZRS(cCs(||_i|_d|_d|_dS(N(RDRER1RFt_connection_obj(RHR+((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRI�s			cCs(|js!t|jj�|_n|jS(N(R�RRDR:(RH((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRG�s	cCs+|jdkr$|jj�|_n|jS(N(RFR1RGRK(RH((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRK�sc
sd	}t�}t�}��fd�}x�t|�D]�}d}t|t�rx|d}	d|kr~|d}q~n|}	t|	�r�|	jdd�d}	d}n|r�||kr�|j|||��t�}n|}|j|	�q7W|r|j|||��n|S(
sCRuns list of commands on remote device and returns results
        cs�y"t�jj|d|��}Wn,tk
rP}�r@�ntt|��SX|dkr�g|D]}tj|�^qd}n|S(NR�R;(RRGR�RRR;R<(R�R�R^RXR�(R[RH(sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt	run_queue�s"%R�R�R�t|iiR;N(	R1R�Rt
isinstanceR%R�trsplitR�R�(
RHRZR[R�R�R�R�R�t
cmd_outputR�((R[RHsH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR\�s,		
	cCs�|dkrgn|}d}|dj|�7}|j�}y|j|SWn|tk
r�y|jj|�}Wn2tk
r�}|jj	dt
|dd��nXt
|�j�}||j|<|SXdS(s>Retrieves the current config from the device or cache
        sshow running-config RLRNRORPN(R1RQRRRERSRGR�RRDRUR(RHRMRVRWRXRY((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRT�s
#
Rjc
Cs�i}tdd�}|j|�|r|dkr|dkrtddd|d|�}	|j|	d|d|d	|�}
n	|j}
|
r�t|
d
�ni|d<|S(NR�iR�R�R�R�RR�RgRZR�(RR�R�R�R(RHRkRlRmRnRRoRqR�R�R�((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRp�s
$	cCs|j|||�S(sLoads the configuration onto the remote devices

        If the device doesn't support configuration sessions, this will
        fallback to using configure() to load the commands.  If that happens,
        there will be no returned diff or session values
        (Rb(RHR�RfRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRiscCs�dttj��}i|d6}d}g}d|g}|rR|jd�nx�|D]�}	|	jd�r}|	}g}qY|r�|	dkr�i|d6dj|�d	6}	d}|j|	�q�|j|	�qYqY|j|	�qYWy|jj|�}
Wn<tk
r:d|d
g}|jj|dd�}
�nXd|d
g}|ra|jd�n
|jd
�|jj|dd�}
|
dj	�}|r�||d<n|S(sLoads the configuration onto the remote devices

        If the device doesn't support configuration sessions, this will
        fallback to using configure() to load the commands.  If that happens,
        there will be no returned diff or session values
        s
ansible_%sR�sconfigure session %ssrollback clean-configtbannertEOFRVs
R~R�R�R�sshow session-config diffsRfiRqN(
RR�R1R�t
startswithRQRGR�t	ExceptionRR(RHR�RfRgR�R�t
banner_cmdtbanner_inputRZR�R^Rq((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRbsD


	



cCsUy|jj�}Wn2tk
rG}|jjdt|dd��nXtj|�S(s3Returns platform info of the remove device
        RNRORP(RGR=RRDRURR;R<(RHRtRX((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR=Js
#N(RuRvRIRwRGRKReR\R1RTRpRxRiRbR=(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR?�s	-	3cCst|dd�jd�S(NRORPs| json(Rtendswith(RV((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR�UscCs`g}|j|jjdd��|jjd�}|rV|j|jdd��nd|kS(NR$R�R'R#(R�R.R/(R+t
transportsR'((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR8YscCs�t|�rd}nd}ttdtdt�dtd|�dtdd	�d
tdd	�dtdddt�d
tdddt�dtdddt��|�}|t|��S(NR;R�R�R2R�RtpromptRR�tanswertnewlineRtsendonlyt	check_all(R8RR%ReRxR(R+RZtdefault_outputt	transform((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt
to_commandbs			cCs1|dkrdn|}t|�}|j|�S(N(R1RCRT(R+RMR@((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRTuscCs(t|�}|jt||�d|�S(NR[(RCR\R�(R+RZR[R@((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR\|scCst|�}|j|||�S(N(RCRi(R+R�RfRgR@((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRi�sRjc
Cs:|j�}|jd|d|d|d|d|d|�S(NRkRlRmRnRRo(RCRp(RHRkRlRmRnRRoR@((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyRp�scCst|�}|j�S(N(RCR=(R+R@((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyR=�s((((,R;R�R�tansible.module_utils._textRtansible.module_utils.basicRtansible.module_utils.connectionRRt*ansible.module_utils.network.common.configRRt)ansible.module_utils.network.common.utilsRRtansible.module_utils.sixRtansible.module_utils.urlsR	R1R7R%ReR)R0teos_top_spectupdateR*R-R4RCR>R9R?R�R8R�RTR\RxRiRpR=(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/eos.pyt<module>sj

				]��				

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]