Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/network/aci/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyc

�
�Udac@s�ddlmZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZer�d�Znd�Zd	�Zd
�Zd�Zd�Zd
�Zdefd��YZdS(i����(tdeepcopy(t
AnsibleModuletjson(tPY3(t	urlencodeturljoin(t	fetch_url(tto_bytest	to_nativecCs||k||kS(N((tatb((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytcmpscCsa||krtS||kr tSt|�t|�kr<tSx|j�D]\}}|dkretS||krutSt||�t|�kr�tSt|t�r�t|||�sYtSqIt|t�ry$t	|�t	||�ks�tSWqYt
k
rt|||�stSqYXqIt|t	�rE|||ksYtSqI|||ksItSqIWtS(s7 Recurse through nested dictionary and compare entries N(tTruettypetFalsetitemstNonet
isinstancetdicttissubsettlisttsett	TypeErrorR(tsubsettsupersettkeytvalue((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyRs:
cCs*td�|j�D��}dt|�S(s. Append key-value pairs to self.filter_string css-|]#\}}|dk	r||fVqdS(N(R(t.0tktv((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pys	<genexpr>Hst?(RRR(tparamstaccepted_params((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt	update_qsFscCs�tdtdddtddg�dtdddt�d	tddd
d�dtdddtd
t�dtddd
dddddg�dtddd
d�dtddd
t�dtddd
t�dtddd
t��	S(NthostR
tstrtrequiredtaliasesthostnametporttinttusernametdefaulttadmintpasswordtno_logtoutput_leveltnormaltchoicestdebugtinfottimeoutit	use_proxytbooltuse_ssltvalidate_certs(RRR(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmso_argument_specLs$c	Cs:tdtdddt�dtdd�dtdd��S(NtnameR
R#R$tschemattemplate(RR(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmso_reference_specZsc
Csmtdtdddtddg�dtdd�dtddd	d
dg�dtdd
�dtdd
��S(NtsubnetR
R#R$R%tiptdescriptiontscopeR0tprivatetpublictsharedR5tno_default_gateway(RR(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmso_subnet_specbscCs[tdtdddt�dtdd�dtdd�dtdddtddd	g��S(
NR9R
R#R$R:R;R0tconsumertprovider(RR(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmso_contractref_specls
t	MSOModulecBs�eZd�Zd�Zdddd�Zdd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zeddd�Zd�Zd�ZRS(cCsz||_|j|_tdt�|_idd6|_t�|_t�|_t�|_t�|_	t|_
d|_d|_
d|_d|_d|_d|_|jjdt�r�dnd|jd<d	|jkr|jd	dk	rd
j|j�|_ndj|j�|_|jjrI|jjd�d
|jd<n|jdrc|j�n|jjdd�dS(Ntchangeds	text/jsonsContent-TypetR6thttpsthttptprotocolR's"{protocol}://{host}:{port}/api/v1/s{protocol}://{host}/api/v1/s2Enable debug output because ANSIBLE_DEBUG was set.R1R.R,tmsgs3Parameter 'password' is required for authentication(tmoduleRRRtresulttheaderstexistingtprevioustproposedtsentthas_modifiedt
filter_stringRtmethodtpathtresponsetstatusturltgetRtformattbaseurit_debugtwarntlogint	fail_json(tselfRP((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt__init__ws2								("

cCs�t|jd�|_i|jdd6|jdd6}t|j|jdtj|�ddd|jd|jdd	|jd	�\}}|d
dkr�|d|_	|d
|_
|jdd
j|��ntj
|j��}dj|�|jd<dS(s Log in to MSO s
auth/loginR)R,tdataRYtPOSTRRR3R4R\i�ROsAuthentication failed: {msg}sBearer {token}t
AuthorizationN(RR`R]RRRPRtdumpsRRR[R\RdR_tloadstread(Retpayloadtresptauth((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyRc�s"			


c	Cs�||_|dk	r!||_n|dkr8|r8iSt|j|�|_|dk	rr|jt|�|_nt|j|jd|j	dt
j|�d|jd|jdd|jd�\}}|d|_
|d|_d	|kr:t|_|d	d
krt|jd<q:|d	dkr:t|jd<q:n|jdkrk|j�}|r�t
j|�Sn|jdkr�|jdkr�iS|jdkr�y|j�}t
j|�}Wn^ttfk
ryt
j|d�}Wqtk
r|jddd|d|�qXnXd|krV|jddj|�d|d|d|�q�|jddj|�d|d|d|�niS(s' Generic HTTP method for MSO requests. tPATCHRRRgRYR3R4ROR\tmodifiedtfalseRJttruei�i�i�i�tDELETEi�i�tbodys
MSO Error:R2tcodesMSO Error {code}: {message}RmN(i�i�i�i�(RZRRYRR`R]R!RRPRRRRjRR[R\RRWRRQRlRkt
ValueErrortAttributeErrort	ExceptionRdR_(	ReRZRYRgtqsRnR2toutputRm((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytrequest�sT					


	
$..c	Ks�g}|j|dd�}|ikr+|S|dkr@|}n||kre|jddd|�nxb||D]V}xM|j�D]2\}}|dkr�q�n|||kr�Pq�q�W|j|�qpW|S(s. Query the MSO REST API for objects in a path RYtGETROsKey '%s' missing from dataRgN(R|RRdRtappend(	ReRZRtkwargstfoundtobjstobjtkw_keytkw_value((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
query_objs�s 	cKs^|j||�}t|�dkr(iSt|�dkrV|jddj|��n|dS(s6 Get a specific object from a set of MSO REST objects iiROs/More than one object matches unique filter: {0}(R�tlenRdR_(ReRZRR�((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytget_objscCsy|dkr|S|jdd|�}|sE|jjdd|�nd|krq|jjdd||f�n|dS(s" Look up schema and return its id tschemastdisplayNameROs'Schema '%s' is not a valid schema name.tids(Schema lookup failed for schema '%s': %sN(RR�RPRd(ReR:ts((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
lookup_schemas cCs|d	kr|S|jdddd|�}|sK|jjdd|�nd|krw|jjdd||f�n|dS(
s$ Look up a domain and return its id sauth/domainsRtdomainsR9ROs'Domain '%s' is not a valid domain name.R�s(Domain lookup failed for domain '%s': %sN(RR�RPRd(Retdomaintd((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
lookup_domain(s cCs�|dkr|Sg}x�|D]�}|jdd|�}|sX|jjdd|�nd|kr�|jjdd||f�n|jtd|d��qW|S(	s$ Look up roles and return their ids trolesR9ROs#Role '%s' is not a valid role name.R�s$Role lookup failed for role '%s': %stroleIdN(RR�RPRdR~R(ReR�tidstroletr((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytlookup_roles4s
 cCsy|dkr|S|jdd|�}|sE|jjdd|�nd|krq|jjdd||f�n|dS(s" Look up a site and return its id tsitesR9ROs#Site '%s' is not a valid site name.R�s$Site lookup failed for site '%s': %sN(RR�RPRd(RetsiteR�((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytlookup_siteCs cCs�|d	kr|Sg}x�|D]�}|jdd|�}|sX|jjdd|�nd|kr�|jjdd||f�n|jtd|ddg��qW|S(
s$ Look up sites and return their ids R�R9ROs#Site '%s' is not a valid site name.R�s$Site lookup failed for site '%s': %stsiteIdtsecurityDomainsN(RR�RPRdR~R(ReR�R�R�R�((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytlookup_sitesOs
 $cCs|dkr|S|jdddd|�}|sK|jjdd|�nd|krw|jjdd||f�n|dS(	s$ Look up a tenant and return its id ttenantsRR9ROs%Tenant '%s' is not valid tenant name.R�s(Tenant lookup failed for tenant '%s': %sN(RR�RPRd(Rettenanttt((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
lookup_tenant^s cCs�|dkr|Sg}x�|D]�}|jdd|�}|sX|jjdd|�nd|kr�|jjdd||f�n|jtd|d��qW|S(	s$ Look up users and return their ids tusersR)ROs#User '%s' is not a valid user name.R�s$User lookup failed for user '%s': %stuserIdN(RR�RPRdR~R(ReR�R�tusertu((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytlookup_usersjs
 c
Cs(|jddddtd|d|��S(s Create a new label tlabelsRYRhRgR�R
(R|R(Retlabelt
label_type((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytcreate_labelyscCs�|dkrdSg}x{|D]s}|jdd|�}|sS|j||�}nd|kr|jjdd||f�n|j|d�qW|S(s; Look up labels and return their ids (create if necessary) R�R�R�ROs&Label lookup failed for label '%s': %sN(RR�R�RPRdR~(ReR�R�R�R�tl((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
lookup_labels}s
 cKs
dj|�S(s Create anpRef string s4/schemas/{schema_id}/templates/{template}/anps/{anp}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytanp_ref�scKs
dj|�S(s Create epgRef string s?/schemas/{schema_id}/templates/{template}/anps/{anp}/epgs/{epg}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytepg_ref�scKs
dj|�S(s Create bdRef string s2/schemas/{schema_id}/templates/{template}/bds/{bd}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytbd_ref�scKs*d|kr|d|d<ndj|�S(s Create contractRef string R9tcontracts>/schemas/{schema_id}/templates/{template}/contracts/{contract}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytcontract_ref�scKs
dj|�S(s Create a filterRef string s:/schemas/{schema_id}/templates/{template}/filters/{filter}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt
filter_ref�scKs
dj|�S(s Create vrfRef string s4/schemas/{schema_id}/templates/{template}/vrfs/{vrf}(R_(ReRg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytvrf_ref�scCs�|d
krd
S|jd�d
k	rs|jdd|d�}|sf|jddjd||��n|d}n|jd�d
k	r�|d}nd	|}i|d
|6|d6|d6S(s& Create a reference from a dictionary R:R�R�ROs;Referenced schema '{schema}' in {reftype}ref does not existtreftypeR�R;s%sNameR9tschemaIdttemplateNameN(RR^R�RdR_(ReRgR�t	schema_idR;t
schema_objtrefname((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmake_reference�s"


cCs�|dkrdSg}xt|D]l}|jtd|dd|jd|d�d|jdd�d|jdt�d|jdt���qW|S(	s" Create a subnets list from input R>R?R@RARCtnoDefaultGatewayRDN(RR~RR^R(ReRgtsubnetsR=((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytmake_subnets�s

cCs�|dkrg}n|dkr*g}nt|j�|_t|j�|_x`|jD]U}|jd�r�|j|=|j|=qXqX||krX|j|=|j|=qXqXqXWx�|D]�}||kr�nv|r||dkr||jkr�|j|=q�q�n=|rC||jkrC|||j|krC|j|=q�n||dk	r�|||j|<q�q�W|jj|j�dS(s, Clean up unset keys from a request payload tRefN(RRRSRURVtendswithtupdate(RetupdatestcollateR$tunwantedR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pytsanitize�s8		






-
cKso|jddkrh|jddkr9|j|jd<n|jrh|j|jkrht|jd<qhn|jddkr�|j|jd	<|j|jd
<|j|jd<|j	|jd<|jddkr�|j
|jd
<|j|jd<q�n|j|jd<|jj
rH|jdtkrHtd|jd|j�|jd<n|jj|�|jj|j�dS(s, Custom written method to exit from module. tstatetabsenttpresentR.R1R2RTRJRYR[R\R]RVRUtcurrenttbeforetaftertdiffN(R�R�(sdebugsinfo(R�R�(RRTRQRWRSRRYR[R\R]RVRURPt_diffRR�t	exit_json(ReR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyR��s(	cKsC|jddkrh|jddkr9|j|jd<n|jrh|j|jkrht|jd<qhn|jddkr|jdk	r�|j|jd	<|j	|jd
<|j
|jd<|j|jd<n|jddkr|j|jd
<|j|jd<qn|j|jd<|jj
|�|jjd||j�dS(s2 Custom written method to return info on failure. R�R�R�R.R1R2RTRJRYR[R\R]RVRUR�RON(sabsentspresent(sdebugsinfo(sabsentspresent(RRTRQRWRSRR]RRYR[R\RVRUR�RPRd(ReROR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyRds"N(t__name__t
__module__RfRcRR|R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RR�R�Rd(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyRIus2	*	B																			.	 N(tcopyRtansible.module_utils.basicRRtansible.module_utils.sixRt+ansible.module_utils.six.moves.urllib.parseRRtansible.module_utils.urlsRtansible.module_utils._textRRRRR!R8R<RERHtobjectRI(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/aci/mso.pyt<module>s	3				
		

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