Anons79 Mini Shell

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

�
�Udac@@s�ddlmZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZdefd��YZ
defd��YZd	efd
��YZeZy4ddlmZddlmZdd
lmZWn)ek
r%eZe
ZeZeZnXeje�Ziad�Zdd�Z defd��YZ!defd��YZ"de"fd��YZ#defd��YZ$defd��YZ%defd��YZ&defd��YZ'dS(i(tabsolute_importN(tdatetimet	timedelta(tSSLErrortMockResponsecB@seZd�ZRS(cO@std��dS(Ns;Requests library Response object not found. Using fake one.(t	Exception(tselftargstkwargs((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt__init__
s(t__name__t
__module__R	(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRstMockRequestsConnectionErrorcB@seZRS((R
R(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRstMockSessioncB@seZd�ZRS(cO@std��dS(Ns:Requests library Session object not found. Using fake one.(R(RRR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	s(R
RR	(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR
s(tConnectionError(tResponse(tSessioncC@sTt|�tkrt��ntjdkr<|j�}n|jd|j}|S(s�
    This is a wrapper class to workaround python 2.6 builtin datetime.timedelta
    does not have total_seconds method
    :param timedelta object
    iiii(iii�Q(ttypeRt	TypeErrortsystversion_infot
total_secondstsecondstdays(ttdtts((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt
avi_timedelta+ssavi.sdkcC@s�ddlm}d}tj|�}tjjdd�}|rY|jtt|��ntj	|�}|dtjjdd��}|j
|�|j|�|S(	Ni(t
SysLogHandlersL[%(asctime)s] %(levelname)s [%(module)s.%(funcName)s:%(lineno)d] %(message)st
AVI_LOG_LEVELtDEBUGtaddresstAVI_SYSLOG_ADDRESSs/dev/log(tlogging.handlersRtloggingt	getLoggertostenvirontgettsetLeveltgetattrt	FormattertsetFormattert
addHandler(tlogger_nameRtlftlogt	log_levelt	formattertsh((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytavi_sdk_syslog_logger:s

tObjectNotFoundcB@seZRS((R
R(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR2OstAPIErrorcB@seZdd�ZRS(cC@s||g|_||_dS(N(Rtrsp(RtargR4((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	TsN(R
RtNoneR	(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR3SstAviServerErrorcB@seZdd�ZRS(cC@stt|�j||�dS(N(tsuperR7R	(RR5R4((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	ZsN(R
RR6R	(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR7YstAPINotImplementedcB@seZRS((R
R(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR9^stApiResponsecB@s8eZdZd�Zd�Zd�Zed��ZRS(s�
    Returns copy of the requests.Response object provides additional helper
    routines
        1. obj: returns dictionary of Avi Object
    cC@sMtt|�j�x3t|jj��D]\}}t|||�q)WdS(N(R8R:R	tlistt__dict__titemstsetattr(RR4tktv((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	hs"cC@s�|jdkr/|jsdStt|�j�S|jdkrBdS|jdkrstd|j|jf|��nP|jdkr�td|j|jf|��ntd|j|jf|��dS(	s�
        Extends the session default json interface to handle special errors
        and raise Exceptions
        returns the Avi object as a dictionary from rsp.text
        i�i�i�i�sHTTP Error: %s Error Msg %si�N(i�i�(	tstatus_codettextR6R8R:tjsonR2R7R3(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRCms	cC@s$|j�}d|kr |dSdS(s�
        return the number of objects in the collection response. If it is not
        a collection response then it would simply return 1.
        tcounti(RC(Rtobj((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRD�scC@s t|�tkrt|�S|S(N(RRR:(tresp((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytto_avi_response�s
(R
Rt__doc__R	RCRDtstaticmethodRG(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR:bs
			tAviCredentialscB@seeZdZdZdZdZdZdZdZ	dZ
dZdZdZ
d�Zd�Zd�ZRS(ts16.4.4i,cK@s1x*|j�D]\}}t|||�q
WdS(N(R=R>(RRR?R@((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	�scC@s||jjd�r[xF|jdj�D].\}}t||�r&t|||�q&q&Wn|jdr{|jd|_n|jdr�|jd|_n|jdr�|jd|_n|jdr�|jddkr�|jd|_n|jdr|jd|_	n|jdr.|jd|_
n|jjd	�rS|jd	|_n|jjd
�rx|jd
|_ndS(s;
        :param m: ansible module
        :return:
        tavi_credentialst
controllertusernametpasswordtapi_versions16.4.4ttenantttenant_uuidt
session_idt	csrftokenN(
tparamsR%R=thasattrR>RMRNRORPRQRRRSRT(RtmR?R@((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytupdate_from_ansible_module�s* 





cC@s d|j|j|j|jfS(Ns&controller %s user %s api %s tenant %s(RMRNRPRQ(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt__str__�sN(R
RRMRNRORPR6RQRRttokentportttimeoutRSRTR	RXRY(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRJ�s		t
ApiSessioncB@sJeZdZdZd5ZddddgZdZd6d6d6d6d6d6ed6dd6e	ed6d6d6ed6d	�Z
ed
��Zej
d��Zed��Zed
��Zej
d��Zed��Zej
d��Zed��Zej
d��Zed��Zej
d��Zed��Zej
d��Zed��Zej
d��Zed��Zej
d��Zed��Zd�Zed��Zed6d6d6d6d6d6ed6de	d6ed6d6d6ed6d��Zd�Zd �Zd!�Zd6d6d6d6d"�Zd#�Zd$d$d6d6d6d%�Z d$d$d6d6d6d&�Z!d6d$d$d6d6d6d6d'�Z"d6d$d$d6d6d6d(�Z#d6d$d$d6d6d6d)�Z$d6d$d$d6d6d6d*�Z%d$d$d6d6d6d6d+�Z&d$d$d6d6d6d,�Z'd-�Z(d.�Z)d6d/�Z*d0d$d6d1�Z+d2�Z,ed3��Z-d4�Z.RS(7s�
    Extends the Request library's session object to provide helper
    utilities to work with Avi Controller like authentication, api massaging
    etc.
    tSlugii<sX-CSRFTokens
Session-IdtReferersContent-TypeicC@s�tt|�j�|
s||r%|nd}td|d|d|d|
d|d|d|d	|d
|	d|d|�|_n	|
|_i|_||_||_i|_d
|_	i|_
||_d|_d|_
|dkr�|jn	t|�|_|r|nd}|jjjd�r�|jjs3dn|}|jjdks]|jjdkro|jj|_q�djd|jjd|jj�|_n]|dks�|dkr�djd|jj�|_n'djd|jjd|jj�|_|	|_d|jj|jj|f|_|jjrki|d6|jjd6|jjd6tj�d6t|j<nC|r�tj|ji�j i|d6tj�d6�n
|j!�d|_t"j#�|_$tj%�dS(s,
         ApiSession takes ownership of avi_credentials and may update the
         information inside it.

        Initialize new session object with authenticated token from login api.
        It also keeps a cache of user sessions that are cleaned up if inactive
        for more than 20 mins.

        Notes:
        01. If mode is https and port is none or 443, we don't embed the
            port in the prefix. The prefix would be 'https://ip'. If port
            is a non-default value then we concatenate https://ip:port
            in the prefix.
        02. If mode is http and the port is none or 80, we don't embed the
            port in the prefix. The prefix would be 'http://ip'. If port is
            a non-default value, then we concatenate http://ip:port in
            the prefix.
        tadminRMRNRORPRQRRRZR[R\RSRTRKii�thttpiPs{x}:{y}txtyshttps://{x}shttps://{x}:{y}s%s:%s:%stapit	last_usedN(&R8R]R	RJRLtheaderstverifytretry_conxn_errorstremote_api_versiontsession_cookie_namet	user_hdrstdata_logtnum_session_retriestretry_wait_timeR6tMAX_API_RETRIEStinttmax_session_retriesRMt
startswithR[tprefixtformatR\RNtkeyRTRSRtutcnowtsessionDictR%tupdatetauthenticate_sessionR#tgetpidtpidt_clean_inactive_sessions(Rt
controller_ipRNRORZRQRRRgR[R\RPRhRlRLRSRTtlazy_authenticationtmax_api_retriestk_port((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR	�sh															


	
cC@s
|jjS(N(RLRM(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR}0scC@s||j_dS(N(RLRM(RR}((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR}4scC@s
|jjS(N(RLRN(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRN8scC@stj|ji�jdt�S(Nt	connected(RwR%RutFalse(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�<scC@s||j_dS(N(RLRN(RRN((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRN@scC@s
|jjS(N(RLRO(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRODscC@s||j_dS(N(RLRO(RRO((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyROHscC@stj|ji�jdd�S(NRT(RwR%RuR6(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytkeystone_tokenLscC@s|t|jd<dS(NRT(RwRu(RRZ((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�PscC@s|jjdS(N(RLRR(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRRTscC@s||j_dS(N(RLRR(RRR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRRXscC@s
|jjS(N(RLRQ(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRQ\scC@s%|r||j_nd|j_dS(NR`(RLRQ(RRQ((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRQ`scC@s|jjdS(N(RLR[(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR[gscC@s||j_dS(N(RLR[(RR[((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR[kscC@s
|jjS(N(RLRP(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRPoscC@s||j_dS(N(RLRP(RRP((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRPsscC@st|jdS(NRS(RwRu(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRSwscC@s(it|jdd6t|jdd6S(NRSRT(RwRu(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytget_context{scC@s
iadS(N(Rw(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytclear_cached_sessions�scC@sj|sf|r|nd}td|d|d|d|
d|d|d|d	|d
|d|
d|�}n|jrx|jnd
}|jjd�r�|js�dn|}nd|j|j|f}tj|�}|r|d}|jjp�|sf|j	�qfndt
|||d|d|d|d|d	|d
|d|	d|
d|d|d|d|�}t
j�|S(s�
        returns the session object for same user and tenant
        calls init if session dose not exist and adds it to session cache
        :param controller_ip: controller IP address
        :param username:
        :param password:
        :param token: Token to use; example, a valid keystone token
        :param tenant: Name of the tenant on Avi Controller
        :param tenant_uuid: Don't specify tenant when using tenant_id
        :param port: Rest-API may use a different port other than 443
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param retry_conxn_errors: retry on connection errors
        :param api_version: Controller API version
        R`RMRNRORPRQRRRZR[R\RSRTi�RaiPs%s:%s:%sRdRgRhRlRLR~R(RJR[RMRrRNRwR%RLRTRyR]R|(R}RNRORZRQRRRgR[R\RhRPRlRLRSRTR~RR�Rutcached_sessiontuser_session((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytget_session�s8	
	
cC@s�tt|jd<tjd|j�i|_x<|jj�D]+\}}||jkr=||j|<q=q=Wi|_|j	�dS(sB
        resets and re-authenticates the current session.
        R�sresetting session for %sN(
R�RwRutloggertinfoRkRfR=tSHARED_USER_HDRSRy(RR?R@((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt
reset_session�s		cC@si|jjd6}|jjr2|jj|d<n+|jjrQ|jj|d<ntd��tjd|jj|j�|jj	�d}y�tt|�j
|jd|d|jd|j�}|jd	kr�d
|_|j�jdi�|_|j�jdd
�|_|jj|j�|jr�d|jkr�|jd}i|d6|j|jd6tj�d6|d6td6t|j<ntjd|jj�dS|jdkr�tjd|j|j�td|j|jf|�}|�n8tjd|j|j�td|j|jf|�}Wn>t t!fk
ro}|j"sV�ntj#d|�|}nX|j$r�t%j&|j$�n|jd7_|j|j'kr�d
|_tjd|j't�|r�|ntd|j'tf�}|�n|j(�dS(s�
        Performs session authentication with Avi controller and stores
        session cookies and sets header options like tenant.
        RNRORZs'Neither user password or token provideds authenticating user %s prefix %ss/loginR\Rgi�itversionRjt	sessionidRTRSReRdR�s"authentication success for user %sNi�i�sStatus Code %s msg %ssError status code %s msg %ssConnection error retrying %sis0giving up after %d retries connection failure %s(i�i�()RLRNRORZR3R�tdebugRstcookiestclearR6R8R]tpostR\RgRARmRCR%RiRjRfRxRkRRvtTrueRwRuterrorRBtRequestsConnectionErrorRRhtwarningRnttimetsleepRqRy(RtbodyterrR4RTtetret_err((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyRy�sn	
%	

	
	
	
			
	
cC@s�tj|j�}|ji|jd6dd6�t|�|d<|jtkr�dtj|j�kr�tj|j�d|d<n$|j	�tj|j�d|d<|r�||d<n|j
jr�|j
j|d<n|r�d}n'|r�d}n|j
j
}|j
j}|rA|jid|d	6�|jd
d�n1|rr|jid|d
6�|jd	d�n|jr�|j|j�n|r�|j|�n|S(sX
        returns the headers that are passed to the requests.Session api calls.
        R_sapplication/jsonsContent-TypeR\RTsX-CSRFTokens
X-Avi-Versions%ssX-Avi-Tenant-UUIDsX-Avi-TenantN(tcopytdeepcopyRfRxRststrRuRwR%RyRLRPR6RQRRtpopRk(RRQRRR\RfRPtapi_hdrs((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt_get_api_headerss<	
'

			c	K@s�|jtj�krMtjd|jtj��|j�tj�|_n|dkre|j}n|j|�}
t	t
t|�|�}|j|||||�}t
}
d}i|dd6}y(|jr�t|jd||j<nWntk
r�nXy||dk	rTt|�tkrT||
dtj|�d|d|d||	�}n'||
d|d|d|d||	�}Wnittfk
r�}tjd	|�|js��nt}
|}n&tk
r�}tjd
|��nX|
s(tjd|
|j�||	||jr|j nd�n|
s=|j!dkr�|
r�y|j�Wntk
rdnXtjd�|j"r�t#j$|j"�q�ntjd|j!|j �tj%|�|j&d7_&|j&|j'krPd|_&|
s	t(d|j!|j f|�}ntjd|j'|
|�|r.|nt(d|j'tf�}|�n|j)|||||d|d|d||	�}d|_&n|j*r�d|j*kr�|j*d}|j+j,i|d6�n|j-�t.j/|�S(s>
        It calls the requests.Session APIs and handles session expiry
        and other situations where session needs to be reset.
        returns ApiResponse object
        :param path: takes relative path to the AVI api.
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param headers: dictionary of headers that override the session
            headers.
        s.pid %d change detected new %d. Closing sessionsX-CSRFTokenRTRStdataRfR\R�sConnection error retrying %ssError in Requests library %ss=path: %s http_method: %s hdrs: %s params: %s data: %s rsp: %sR6i�i�sConnection failed, retrying.s,received error %d %s so resetting connectioniisStatus Code %s msg %ss1giving up after %d retries conn failure %s err %ss0giving up after %d retries connection failure %sRPN(i�i�(0R{R#RzR�R�tcloseR6R\t
_get_api_pathR'R8R]R�R�RjRwRutKeyErrorRtdictRCtdumpsR�RR�RhR�RR�R�tupperRlRBRARnR�R�R�RmRqR3t_apiR�RfRxt_update_session_last_usedR:RG(Rtapi_nametpathRQRRR�RfR\RPRtfullpathtfnR�tconnection_errorR�R�RFR�R�RT((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�6s�	
		
				

		
		

cC@si|jd6|jd6}|S(NR}tcontroller_api_version(R}Ri(Rtresult((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytget_controller_details�s

RKcK@s+|jd|||d|d|d||�S(sN
        It extends the Session Library interface to add AVI API prefixes,
        handle session exceptions related to authentication and update
        the global user session cache.
        :param path: takes relative path to the AVI api.
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        get method takes relative path to service and kwargs as per Session
            class get method
        returns session's response object
        R%R\RURP(R�(RR�RQRRR\RURPR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR%�sc
K@skd}	|si}n||d<|j|d|d|d|d|d||�}
|
jdkr�tj|�|j||||d|d||�}
n|
jd	ks�d
|
jkr�tjd|||
j�t	|
jd|
��n|
jd
kr�|	Sy9d|
j
�kr#|
j
�dd}	n|
j
�}	Wn*tk
r\tjd||�d}	nX|j
�|	S(sy
        Helper function to access Avi REST Objects using object
        type and name. It behaves like python dictionary interface where it
        returns None when the object is not present in the AviController.
        Internally, it transforms the request to api/path?name=<name>...
        :param path: relative path to service
        :param name: name of the object
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns dictionary object if successful else None
        tnameRQRRR\RURPi�i�i�sInvalid versions6Error in get object by name for %s named %s. Error: %sR4i+tresultsis)Warning: Object Not found for %s named %sN(i�i�(R6R%RAR]R�tget_object_by_nameRBR�R�R7RCt
IndexErrorR�R�(RR�R�RQRRR\RURPRRERF((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR��s8	

	
	


c	K@si|dk	r8|	jdi�}
||
|j<|
|	d<n|jd|||d|d|d|d||	�S(s�
        It extends the Session Library interface to add AVI API prefixes,
        handle session exceptions related to authentication and update
        the global user session cache.
        :param path: takes relative path to the AVI api.It is modified by
        the library to conform to AVI Controller's REST API interface
        :param data: dictionary of the data. Support for json string
            is deprecated
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        RfR�R�R\RURPN(R6R%tAVI_SLUGR�(RR�R�RQRRR\t
force_uuidRURPRRf((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR��s

c	K@s1|jd|||d|d|d|d||�S(s�
        It extends the Session Library interface to add AVI API prefixes,
        handle session exceptions related to authentication and update
        the global user session cache.
        :param path: takes relative path to the AVI api.It is modified by
            the library to conform to AVI Controller's REST API interface
        :param data: dictionary of the data. Support for json string
            is deprecated
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        tputR�R\RURP(R�(	RR�R�RQRRR\RURPR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�sc	K@s1|jd|||d|d|d|d||�S(s�
        It extends the Session Library interface to add AVI API prefixes,
        handle session exceptions related to authentication and update
        the global user session cache.
        :param path: takes relative path to the AVI api.It is modified by
            the library to conform to AVI Controller's REST API interface
        :param data: dictionary of the data. Support for json string
            is deprecated
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        tpatchR�R\RURP(R�(	RR�R�RQRRR\RURPR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�sc	K@sY|j||||d|�}
d||
f}|j||||d|d|d||	�S(sV
        Helper function to perform HTTP PUT on Avi REST Objects using object
        type and name.
        Internally, it transforms the request to api/path?name=<name>...
        :param path: relative path to service
        :param name: name of the object
        :param data: dictionary of the data. Support for json string
            is deprecated
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        RPs%s/%sR\RU(t_get_uuid_by_nameR�(RR�R�R�RQRRR\RURPRtuuid((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytput_by_name4s
c	K@s1|jd|||d|d|d|d||�S(s�
        It extends the Session Library interface to add AVI API prefixes,
        handle session exceptions related to authentication and update
        the global user session cache.
        :param path: takes relative path to the AVI api.It is modified by
        the library to conform to AVI Controller's REST API interface
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param data: dictionary of the data. Support for json string
            is deprecated
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        tdeleteR�R\RURP(R�(	RR�RQRRR\RUR�RPR((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR�Osc
K@su|j||||d|�}	|	s=td||f��nd||	f}|j|||d|d|d||�S(s�
        Helper function to perform HTTP DELETE on Avi REST Objects using object
        type and name.Internally, it transforms the request to
        api/path?name=<name>...
        :param path: relative path to service
        :param name: name of the object
        :param tenant: overrides the tenant used during session creation
        :param tenant_uuid: overrides the tenant or tenant_uuid during session
            creation
        :param timeout: timeout for API calls; Default value is 60 seconds
        :param params: dictionary of key value pairs to be sent as query
            parameters
        :param api_version: overrides x-avi-header in request header during
            session creation
        returns session's response object
        RPs%s/?name=%ss%s/%sR\RU(R�R2R�(
RR�R�RQRRR\RURPRR�((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytdelete_by_namegs	cC@s�|s
dSt|t�r.tj|j�}n|jdd�rL|ddS|jdd�rf|dS|jdd�r�|dddSdSdS(s&returns reference url from dict objectiturlR�N(R6t
isinstanceRRCtloadsRBR%(RRE((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytget_obj_ref�scC@s�|std|��nt|t�r=tj|j�}n|jdd�r[|ddS|jdd�ru|dS|jdd�r�|dddSdSdS(sreturns uuid from dict objectsObject %s Not foundiR�R�N(R2R�RRCR�RBR%R6(RRE((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytget_obj_uuid�scC@sK|dkr|jd|S|r8|jd|d|S|jd|SdS(sQ
        This function returns the full url from relative path and uuid.
        tlogoutt/s/api/N(Rs(RR�R�((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR��s
R`cC@sJ|j||||d|�}|s=td||f��n|j|�S(s5gets object by name and service path and returns uuidRPs%s/%s(R�R2R�(RR�R�RQRRRPRF((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR��s
cC@s-|jtkr)tj�t|jd<ndS(NRe(RuRwRRv(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR��scC@s�t}tjdtj�t|��g}x\t|j��D]H\}}tt	j
�|d�}|tjkryq>n|j
|�q>Wx%|D]}||=tjd|�q�WdS(s4Removes sessions which are inactive more than 20 mins0cleaning inactive sessions in pid %d num elem %dResRemoved session for : %sN(RwR�R�R#RztlenR;R=RRRvR]tSESSION_CACHE_EXPIRYtappend(t
session_cachetkeys_to_deleteRutsessionttdiff((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR|�s	
cC@s*tjd|j�tj|jd�dS(s  Removes the session for cleanupsRemoved session for : %sN(R�R�RuRwR�R6(R((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pytdelete_session�si�N(/R
RRHR�R�R�RoR6R�R�R	tpropertyR}tsetterRNR�ROR�RRRQR[RPRSR�RIR�R�R�RyR�R�R�R%R�R�R�R�R�R�R�R�R�R�R�R�R|R�(((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyR]�s�			S			.	
	E	*a	2						((t
__future__RR#RR�RCR!R�RRtsslRtobjectRRRR
R�tHAS_AVItrequestsRR�Rtrequests.sessionsRtImportErrorR�R"R
R�RwRR1R2R3R7R9R:RJR](((sL/usr/lib/python2.7/site-packages/ansible/module_utils/network/avi/avi_api.pyt<module>s@

	61

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