Anons79 Mini Shell

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

�
�Udac	@s]ddlZddlZddlmZddlmZddlmZddlmZy�ddl	m
Z
mZddlm
Z
ddlmZmZmZdd	lmZmZmZdd
lmZmZmZeZWnek
r�eZnXdZdZied
edgf�d6ed
edgf�d6ed
edgfde�d6eddded
edgf�d6eddded
edgf�d6Zde fd��YZ!de fd��YZ"d e!fd!��YZ#d"e!fd#��YZ$d$e$fd%��YZ%d&e$fd'��YZ&d(e#e$fd)��YZ'd*e#e$fd+��YZ(dS(,i����N(t	iteritems(titerkeys(tto_text(tenv_fallback(tNodetEdge(t
RESTClient(tNodeAddedMsgTypetNodeUpdatedMsgTypetNodeDeletedMsgType(tEdgeAddedMsgTypetEdgeUpdatedMsgTypetEdgeDeletedMsgType(tWSClienttWSClientDefaultProtocolt	WSMessages	G.V().Hass	G.E().HastfallbacktSKYDIVE_ENDPOINTtendpointtSKYDIVE_USERNAMEtusernametSKYDIVE_PASSWORDtno_logtpasswordttypetbooltdefaulttSKYDIVE_INSECUREtinsecuretSKYDIVE_SSLtssltskydive_client_checkcBs3eZdZieddde�d6Zd�ZRS(s. Base class for implementing Skydive Rest API RtdicttoptionstprovidercKs�tstd��nt|j��jtj��sEtd��nx~tt�D]p\}}||krRd|kr�|d||<nd|j�}|tj	kr�tj	j
|�||<q�qRqRWdS(s. Base class for implementing Skydive Rest API s�skydive-client is required but does not appear to be installed.  It can be installed using the command `pip install skydive-client`sJinvalid or unsupported keyword argument for skydive_restclient connection.Rs
SKYDIVE_%sN(tHAS_SKYDIVE_CLIENTt	ExceptiontsettkeystissubsettSKYDIVE_PROVIDER_SPECRtuppertostenvirontget(tselftkwargstkeytvaluetenv((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyt__init__As!(t__name__t
__module__t__doc__R R(t
provider_specR2(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR<stskydive_inject_protocolcBseZdZd�ZRS(s6 Implements inject protocol for node and edge modules c
Cs>|jjd}|jjd}|jjd}drkd|jjkrk|jjd}|jjd}n|jr�|j�dSz�yy|d}|dr�|j|d�}ni}d|kr�|d	|d
<|d|d<|d}|sd
|d	|df}n|jddks1|jddkr�ttjtj	|��}	t
|	|d|�}
|jddkr�tdt|
�}q�tdt
|
�}q�|d}	t
|	|d|�}
tdt|
�}nd|kr�|d|d<|jddks|jddkr�ttjtj	d|||df��}	t|	|||d|�}|jddkr�tdt|�}q�tdt|�}q�|jd}	t|	|||d|�}tdt|�}n|j|�|	r�|	|d<nt|d<Wn*tk
r*}
|jdd|
|�nXWd|j�XdS(Ntmoduletparamstresulttnode1tnode2thosttmetadatat	node_typetnametNametTypetseeds%s:%ststatetpresenttupdatetGraphtidt
relation_typetRelationTypes%s:%s:%stUUIDtchangedtmsgsError during topology update %s(tfactoryR.t
check_modetstopt_check_type_dictR9tstrtuuidtuuid5t
NAMESPACE_OIDRRRRR	RR
RRt
sendWSMessagetTrueR$t	fail_json(R-R8R9R:R;R<R=R>RCtuidtnodeRMtedgete((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pytonOpenZsd	



&
&


	(R3R4R5R](((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR7Wstskydive_wsclientcBs eZdZd�Zd�ZRS(s3 Base class for implementing Skydive Websocket API cKs,tt|�j|�dttfd��Y}d|d<d|kr_|dr_d|d<q_nd|krxt|d<n|d}tdt�|_d	|jkr<t	d
t
tj��d|jdd
||dfdt
dttft��dtd|dd|dd|dd|d|jd|j�|_n�d|jkr(|j|jd�|_|j|jd�|_t	d
t
tj��d|jdd
||dfdt
dttft��dtd|dd|dd|dd|d|jd|jd|jd|j�
|_ndS(Ntskydive_full_inject_protocolcBseZRS((R3R4(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR_�stwstschemeRtwssRRLR?sansible-t-R=s%s://%s/ws/publisherRtprotocolt
persistentRRR8R9R:RItparent_nodet
child_nodeR;R<(tsuperR^R2R7RtFalseR R:R9R
RRR*tgetpidRRWtwsclient_objecttget_node_idRfRg(R-R8R.R_Ra((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR2�sL



%	


	%	


			cCs�|jd�s|jd�r�|jj|�}t|�dkri|jjdtdj|����n9t|�dkr�|jjdtdj|����nt|dj	�S|S(sH Checks if Gremlin expresssion is passed as input to get the nodes UUID sG.sg.iRMsNode not found: {0}is/Node selection should return only one node: {0}(
t
startswithtrestclient_objecttlookup_nodestlenR8RXRtformatRRRH(R-t
node_selectortnodes((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyRl�s'(R3R4R5R2Rl(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR^�s	+tskydive_restclientcBseZdZd�ZRS(s. Base class for implementing Skydive Rest API cKs�tt|�j|�d|d<d|krF|drFd|d<qFnd|kr_t|d<nt|dd|dd|dd|dd|d�|_dS(	NthttpRaRthttpsRRRR(RhRtR2RiRRn(R-R.((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR2�s






(R3R4R5R2(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyRt�stskydive_lookupcBs<eZdZieddde�d6Zd�Zd�ZRS(s# Implements Skydive Lookup queries RR R!R"cCs#tt|�j|�d|_dS(Nt(RhRwR2t	query_str(R-R"((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR2�scCs~|j�d}|||_|jj|j�}g}x|D]}|j|j�q?Wt|�dkrztd��n|S(Nis2Cannot find any entry for the input Gremlin query!(R&RyRnRotappendt__dict__RpR$(R-tfilter_datat	query_keyRsR:teach((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pytlookup_query�s

(R3R4R5R R(R6R2R(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyRw�s	tskydive_flow_capturecBs eZdZd�Zd�ZRS(s) Implements Skydive Flow capture modules cCs0||_|jd}tt|�j|�dS(NR"(R8R9RhR�R2(R-R8R"((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR2�s	
c
Csz|jjd}|dkr6|jjdd|�nitd6}tgt|�D]1\}}|jd�rS||jj|f^qS�}i}xAt|�D]3}|jj|dk	r�|jj|||<q�q�W|dr�|d}	nJ|d	r#|d
r#t	dj
|d	|d
�}	n|jjdd��|jj�}
d}x2|
D]*}|	|j
dkrT|j
d
}PqTqTW|dkr|sy>|jj|	|d|d|d|d|d|d�Wn,tk
r}
|jjdt|
��nXt|d<qn|dkrv|rvy|jj|�Wn,tk
re}
|jjdt|
��nXt|d<qvn|S(NRDREtabsentRMs2state must be one of `present`, `absent`, got `%s`RLtib_reqtquerytinterface_nameRs('Name', '{0}', 'Type', '{1}')sDInterface name and Type is required if gremlin query is not defined!RStcapture_nametdescriptiontextra_tcp_metrict	ip_defragtreassemble_tcptlayer_key_mode(spresentR�(R8R9RXRiR RR,RtNonetSKYDIVE_GREMLIN_QUERYRqRntcapture_listR{tcapture_createR$RRWtcapture_delete(R-tib_specRDR:tktvt
obj_filtertproposed_objectR/tcature_querytcaptured_list_objstcurrent_ref_uuidteach_captureR\((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pytrunsN
J



(R3R4R5R2R�(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR��s	tskydive_nodecBs eZdZd�Zd�ZRS(s! Implements Skydive Node modules cCs6||_|jd}tt|�j|j|�dS(NR"(R8R9RhR�R2(R-R8R"((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR25s	
cCsUytdj|jjd|jjd�}|jj|�}|ry|jjddkry|jj�|jj�n�t	|�dkr�|jjddkr�|jj�|jj�n`t	|�dkr|jjddkr|dj
d	|jjd	<|jj�|jj�nWn,tk
rM}|jjd
t
|��nX|jS(Ns('Name', '{0}', 'Type', '{1}')R@R?RDREiRFR�RHRM(R�RqR8R9RnRoRktconnecttstartRpR{R$RXRR:(R-Rtnode_existsR\((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR�:s"
(
(
(R3R4R5R2R�(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR�2s	tskydive_edgecBs eZdZd�Zd�ZRS(s! Implements Skydive Edge modules cCs6||_|jd}tt|�j|j|�dS(NR"(R8R9RhR�R2(R-R8R"((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR2Rs	
cCsJyt}tdj|j|j�}|jj|�}|rS|dj}t}n|r�|j	j
ddkr�|jj�|jj
�n�|r�|j	j
ddkr�|jj�|jj
�nM|r|j	j
ddkr|d|j	j
d<|jj�|jj
�nWn,tk
rB}|j	jdt|��nX|jS(	Ns!('Parent', '{0}', 'Child', '{1}')iRDRERFR�RHRM(RitSKYDIVE_GREMLIN_EDGE_QUERYRqRfRgRntlookup_edgesR{RWR8R9RkR�R�R$RXRR:(R-tedge_existst
edge_querytquery_resultR\((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR�Xs*

	


(R3R4R5R2R�(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyR�Os	()R*RStansible.module_utils.sixRRtansible.module_utils._textRtansible.module_utils.basicRt
skydive.graphRRtskydive.rest.clientRtskydive.websocket.clientRRR	R
RRR
RRRWR#tImportErrorRiR�R�R R(tobjectRR7R^RtRwR�R�R�(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/skydive/api.pyt<module>s<


%(?;:

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