Anons79 Mini Shell

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

�
�Udac@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZddlmZddlmZydd	lmZWnek
r�d
ZnXyddlmZeZWnek
r
eZnXyddlZeZWnek
r=eZnXddlZyddl m Z m!Z!Wn'ek
r�ddl"m Z m!Z!nXeZ#e$d
ddddddd?dd@ddAddBddCddDddE�
Z%e$d
ddddd ddFddGddHddIddJddKddL�
Z&y@dd!l'm(Z(dd"l)m*Z*dd#l+m,Z,m-Z-eZ#Wne.k
rweZ#nXd$�Z/d%�Z0d&�Z1d'�Z2d(�Z3dd)�Z5dd*�Z6dd+�Z7d,�Z8d-e9fd.��YZ:ded/�Z;ddd0eedd1edddeed2�
Z<d3d4ed5d6d7d8�Z=d9�Z>ed:�Z?d;e9fd<��YZ@d=e9fd>��YZAdS(Mi����N(tpformat(tsix(t
AnsibleModuletmissing_required_lib(t	HTTPErrortURLError(topen_url(tbasic_auth_argument_spec(t	to_native(t__version__tunknown(tzapi(turlparset
urlunparsetbytesitbtkbi�tmbitgbittbitpbitebitzbitybii(tElementFactory(tTimeIntervalFrequency(tScheduletScheduleInfocCstS(N(tHAS_NETAPP_LIB(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pythas_netapp_libjscCstS(N(t
HAS_SF_SDK(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt
has_sf_sdknscCs�tdtdtdd�dtdtddddg�dtdtdddd	gd
t�dtdtddd
t�dtdtddd
t�dtdtdd�dtdtdd�dtdtddd
dddddg��S(Nthostnametrequiredttypetstrtusernametaliasestusertpasswordtpasstno_logthttpstbooltdefaulttvalidate_certst	http_porttinttontapituse_resttAutotchoicestNevertAlways(tdicttTruetFalse(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytna_ontap_host_argument_specrs$cCs^tdtdtdd�dtdtddddg�dtdtdddd	gd
t��S(NR R!R"R#R$R%R&R'R(R)(R6R7(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytontap_sf_host_argument_spec�scCsmtdtdtdd�dtdtdddt�dtdtddd	t�d
tdtddd	t��S(Ntapi_urlR!R"R#R-R+R,tapi_keyR)t
secret_key(R6R7R8(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytaws_cvs_host_argument_spec�s
c	Cs�|jd}|jd}|jd}tr�|r�|r�|r�y#tj|||d|�}|SWq�tk
r�td��q�Xn|jdd�dS(NR R$R'tportsUnable to create SF connectiontmsgs+the python SolidFire SDK module is required(tparamsRRtcreatet	Exceptiont	fail_json(tmoduleR?R R$R't
return_val((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytcreate_sf_connection�s



cCs�|jd}|jd}|jd}|jd}|jd}|jd}|jd}tr{tj|�}	|	j|�|	j|�|r�|	j|�n|r�|}
nd}
|	jd	d
d|
�|r5|dkr�d}nd
}|t	krPt
jjdd�r2t
tdd�r2tjt_q2qPn|dkrJd}nd}|	j|�|	j|�|	jd�|	S|jdd�dS(NR R$R'R*R-R.R0intmajoritminori�tHTTPStPYTHONHTTPSVERIFYtt_create_unverified_contextiPtHTTPtFILERR@s(the python NetApp-Lib module is required(RARRtNaServertset_usernametset_passwordtset_vservertset_api_versiontNoneR8tostenvirontgettgetattrtsslRMt_create_default_https_contexttset_transport_typetset_porttset_server_typeRD(REtvserverR R$R'R*R-R?tversiontserverRIttransport_type((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytsetup_na_ontap_zapi�s@








		(	


cCs�|jd}|jd}|jd}tr�tj|�}|j|�|j|�|rl|j|�n|jdddd�|jd�|j	d	�|j
d
�|S|jdd�dS(
NR R$R'RHiRIiniPRORNR@s(the python NetApp-Lib module is required(RARRRPRQRRRSRTR]R^R\RD(RER_R R$R'Ra((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytsetup_ontap_zapi�s







cCs�t�}|jtdtdddt�dtdddtdt�dtdddt�dtdddtd	d
�dtdddtd	t���|S(
sLRetrieve a base argument specification common to all NetApp E-Series modulestapi_usernameR"R#R!tapi_passwordR)R;tssidR,t1R-R+(RtupdateR6R7R8(t
argument_spec((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyteseries_host_argument_spec�s	tNetAppESeriesModulecBs�eZdZdZdZdZdZidd6dd6ded	6Zd
eZ	e
ddd
ddddd#dd$dd%dd&dd'dd(dd)�
Zd*e
d*d*d*d*ed�Zd�Zd �Zd*d!d*e
d"�ZRS(+sBase class for all NetApp E-Series modules.

    Provides a set of common methods for NetApp E-Series modules, including version checking, mode (proxy, embedded)
    verification, http requests, secure http redirection for embedded web services, and logging setup.

    Be sure to add the following lines in the module's documentation section:
    extends_documentation_fragment:
        - netapp.eseries

    :param dict(dict) ansible_options: dictionary of ansible option definitions
    :param str web_services_version: minimally required web services rest api version (default value: "02.00.0000.0000")
    :param bool supports_check_mode: whether the module will support the check_mode capabilities (default=False)
    :param list(list) mutually_exclusive: list containing list(s) of mutually exclusive options (optional)
    :param list(list) required_if: list containing list(s) containing the option, the option value, and then
    a list of required options. (optional)
    :param list(list) required_one_of: list containing list(s) of options for which at least one is required. (optional)
    :param list(list) required_together: list containing list(s) of options that are required together. (optional)
    :param bool log_requests: controls whether to log each request (default: True)
    i<t8443s
devmgr/v2/sdevmgr/utils/aboutsapplication/jsonsContent-TypetAccepts
Ansible-%ssnetapp-client-typesAnsible / %sRiRRiRiRiRiRiRiRiRic	
Cs�t�}	|	j|�td|	d|d|d|d|d|�|_|jj}
|r^|nd|_|
d|_|
d	|_||_t	d
|
dd|
d
d|
d�|_
|jjd�s�|jd7_nd|_
d|_dS(NRjtsupports_check_modetmutually_exclusivetrequired_iftrequired_one_oftrequired_togethers02.00.0000.0000RgR;turl_usernameReturl_passwordRfR-t/(RkRiRRERAtweb_services_versionRgturltlog_requestsR6tcredstendswithRUtis_embedded_modetis_web_services_valid_cache(tselftansible_optionsRwRoRpRqRrRsRyRjtargs((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt__init__
s"	


	
	c
CsW|jsSt|j�}|js,|jrI|jjdd|j�n|jdkru|jjdd|j�nd|j|jf|_|j|j}t|d|j	d|j
d	t|j�\}}|d
kr�|jj
d|j�d|jjd
�d|_|j|j}y.t|d|j	d|j
|j�\}}Wq�tk
r�}|jjdd|jt|�f�q�Xn|djd�\}}}}	|jjd�\}
}}}||
kp
||
kr�||kp
||
ko
||ko
|	|ks7|jjdd|d|jf�n|jjd�t|_ndS(sVerify proxy or embedded web services meets minimum version required for module.

        The minimum required web services version is evaluated against version supplied through the web services rest
        api. AnsibleFailJson exception will be raised when the minimum is not met or exceeded.

        This helper function will update the supplied api url if secure http is not used for embedded web services

        :raise AnsibleFailJson: raised when the contacted api service does not meet the minimum required version.
        R@sYFailed to provide valid API URL. Example: https://192.168.1.100:8443/devmgr/v2. URL [%s].thttpR*s)Protocol must be http or https. URL [%s].s%s://%s/ttimeouttheaderst
ignore_errorsi�s]Failed to retrieve web services about information! Retrying with secure ports. Array Id [%s].shttps://%s:8443/t:isPFailed to retrieve the webservices about information! Array Id [%s]. Error [%s].R`t.skWeb services version does not meet minimum version required. Current version: [%s]. Version required: [%s].s?Web services rest api version met the minimum required version.N(R�shttps(R}RRxtschemetnetlocRERDtDEFAULT_REST_API_ABOUT_PATHtrequesttDEFAULT_TIMEOUTtDEFAULT_HEADERSR7RztwarnRgtsplitRCRRwtlog(
R~t	url_partst	about_urltrctdataterrorRHRItothertrevisiont
minimum_majort
minimum_minortminimum_revision((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt_check_web_services_version&s6
	0.$cCs�|j�|jdkr�|j|j}y<t|d|jd|j|j�\}}|d|_Wq�t	k
r�}|j
jdd|jt
|�f�q�Xn|jS(s�Determine whether web services server is the embedded web services.

        If web services about endpoint fails based on an URLError then the request will be attempted again using
        secure http.

        :raise AnsibleFailJson: raised when web services about endpoint failed to be contacted.
        :return bool: whether contacted web services is running from storage array (embedded) or from a proxy.
        R�R�trunningAsProxyR@sPFailed to retrieve the webservices about information! Array Id [%s]. Error [%s].N(R�R|RURxR�R�R�R�RzRCRERDRgR(R~R�R�R�R�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytis_embeddedSs	
*tGETcCs|j�|dkr"|j}nt|t�rT|ddkrTtj|�}n|jd�rp|d}n|j|j	|}|j
s�tr�|jj
ttd|d|d|���ntd|d|d|d|d	td
tddd|jd
|jdtd||j�S(sIssue an HTTP request to a url, retrieving an optional JSON response.

        :param str path: web services rest api endpoint path (Example: storage-systems/1/graph). Note that when the
        full url path is specified then that will be used without supplying the protocol, hostname, port and rest path.
        :param data: data required for the request (data may be json or any python structured data)
        :param str method: request method such as GET, POST, DELETE.
        :param dict headers: dictionary containing request headers.
        :param bool ignore_errors: forces the request to ignore any raised exceptions.
        sContent-Typesapplication/jsonRviRxR�tmethodR�t	use_proxytforcet
last_mod_timeR�t
http_agenttforce_basic_authR�N(R�RUR�t
isinstanceR#tjsontdumpst
startswithRxtDEFAULT_REST_API_PATHRyR7RER�RR6R�R8R�t
HTTP_AGENTRz(R~tpathR�R�R�R�trequest_url((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�is

 
.0ii@IIIll N(t__name__t
__module__t__doc__R�tDEFAULT_SECURE_PORTR�R�tansible_versionR�R�R6t
SIZE_UNIT_MAPRUR8R7R�R�R�R�(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyRl�s 
*	-	cCs�ddjgtd�D]}ttjdd��^q�}t�}d}tjr`d}|dk	r�x8|D]-\}}	|j	d|d|d|	g�qoWnx�|D]�\}
}}t
|d	��i}
|r�|
jd
�n	|
j�}	|j	d|d|
|fdtj
|�dpd
d|	g�WdQXq�W|j	d|dg�|j|�}natjd�}|dk	r�x\|D]Q\}}	|j	tjd|�tjd|�tjd�tj|	�g�q�Wnx�|D]�\}
}}t
|d	���}
|r|
jd
�n	|
j�}	|j	tjd|�tjd|
|f�tjdtj
|�dpnd
�tjd�|	g�WdQXq�W|j	tjd|�dg�|j|�}id|d6tt|��d6}||fS(s"Create the data for a multipart/form request.

    :param list(list) files: list of lists each containing (name, filename, path).
    :param list(list) fields: list of lists each containing (key, value).
    :param bool send_8kb: only sends the first 8kb of the files (default: False).
    s---------------------------RLiii	s
s--%ss)Content-Disposition: form-data; name="%s"trbi s8Content-Disposition: form-data; name="%s"; filename="%s"sContent-Type: %ssapplication/octet-streamNs--%s--s multipart/form-data; boundary=%ssContent-TypesContent-Length(tjointrangeR#trandomtrandinttlistRURtPY2textendtopentreadt	mimetypest
guess_typeRtlen(tfilestfieldstsend_8kbtxtboundaryt
data_partsR�tnewlinetkeytvaluetnametfilenameR�tfhR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytcreate_multipart_formdata�sT>		
!

!# R�i
cCs^|dkr#idd6dd6}n|jidtd6�|sNdt}ny[td|d|d	|d
|d|d|d
|d|d|d|	d|
d|d|�
}Wntk
r�}|j}nXy.|j�}|r�tj|�}nd}Wn&t	k
r|
rqt	|��nX|j
�}|dkrP|
rPt	||��n
||fSdS(sEIssue an HTTP request to a url, retrieving an optional JSON response.sapplication/jsonsContent-TypeRns
Ansible-%ssnetapp-client-typesAnsible / %sRxR�R�R�R�R�R�R�R-RtRuR�R�i�N(RURiR�RRtfpR�R�tloadsRCtgetcode(RxR�R�R�R�R�R�R�R-RtRuR�R�R�trterrtraw_datat	resp_code((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR��s2
$



tAnsiblet12345tInformationtsetuptfalsec	Cs�tjd�}|jd|�|jd|�|jd|�|jd|�|jd|�|jd|�|jdd	�|jd
|�|j|t�dS(Nsems-autosupport-logs
computer-namesevent-idsevent-sourcesapp-versiontcategorysevent-descriptions	log-levelt6sauto-support(Rt	NaElementt
add_new_childtinvoke_successfullyR7(	tsourceRaR�tidR`R�teventtautosupporttems_log((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt
ems_log_event�scCs�tjd�}tjjdidd6�}tjd�}|j|�|j|�|j|dt�}|jd�}|jd�}|jd�S(	Nsvserver-get-itersvserver-infotadminsvserver-typetquerytenable_tunnelingsattributes-listsvserver-name(RR�tcreate_node_with_childrentadd_child_elemR�R8tget_child_by_nametget_child_content(Ratvserver_infot
query_detailsR�tresulttattribute_listtvserver_list((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytget_cserver_zapi�s

	cCs�|st|�Sidd6}d}|j||�\}}|dksS|dk	rWdS|jd�}|dk	r�x&|D]}|ddkry|dSqyWt|�dkr�|ddSndS(	NR"R�sprivate/cli/vservertrecordsR�R_ii(R�RXRUR�(t
connectiontis_restRAtapiR�R�tvserversR_((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytget_cservers


tOntapRestAPIcBs�eZdd�Zd�Zded�Zd�Zdd�Zdd�Z	dd�Z
dd�Zdd	�Zd
�Z
d�ZRS(
i<cCs�||_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_||_d|jd|_t	�|_
t	�|_|j�dS(NR$R'R R1R-shttps://s/api/(
RERAR$R'R R1tverifyR�RxR�terrorst
debug_logstcheck_required_library(R~RER�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�!s		cCs&ts"|jjdtd��ndS(NR@trequests(tHAS_REQUESTSRERDR(R~((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�.sc
Cs�|j|}d}d}d}	d}
d}d�}yttj||d|jd|j|jfd|d|jd|�}
|
j}|
j	}|
j
�||
�\}	}
Wn�tjjk
r}||
�\}}
|
dkro|j
|d|�t|�}qonktjjk
r<}|j
|d|�t|�}n3tk
rn}|j
|d	|�t|�}nX|
dk	r�|j
|d
||
f�|
}n|j||�|r�||fS|	|fS(sC send http request and process reponse, including error conditions cSs>y|j�}Wntk
r$dSX|jd�}||fS(s, extract json, and error message if present R�N(NN(R�t
ValueErrorRURX(tresponseR�R�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytget_json;s
R�tauthRAR�R�sHTTP error: %ssConnection error: %ssOther error: %ssEndpoint error: %d: %sN(RxRUR�R�R�R$R'R�tcontenttstatus_codetraise_for_statust
exceptionsRt	log_errorR#tConnectionErrorRCt	log_debug(R~R�R�RAR�treturn_status_codeRxRRt	json_dictt
json_errort
error_detailsRR�R�t__((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytsend_request2s>
		B		
	
cCsd}|j|||�S(NR�(R(R~R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyRX_scCsd}|j|||d|�S(NtPOSTR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytpostcscCsd}|j|||d|�S(NtPATCHR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytpatchgscCsd}|j|||d|�S(NtDELETER�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytdeletekscCs�|jdkr?|r2ddj|�}t|fStdfSn|jdksT|r^tdfSd}d}|j||dddt�\}}|d	kr�tdfStdfS(
NR5s(REST API currently does not support '%s's, R4tHEADscluster/softwareRAR	i�(R1R�R7RUR8R(R~t used_unsupported_rest_propertiesR�R�R�RR
((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt_is_restos


$
cCs/|j|�\}}|dkr%|S||fS(s+ only return error if there is a reason to N(RRU(R~RR1R�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR��scCs*|jj|�|jj||f�dS(N(R�tappendR�(R~Rtmessage((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�scCs|jj||f�dS(N(R�R(R~RR((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�sN(R�R�R�R�RUR8RRXRRRRR�RR(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR� s
	-		t
AwsCvsRestAPIcBsneZdd�Zd�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d�Z
d	�ZRS(i<cCs�||_|jjd|_|jjd|_|jjd|_|jjd|_||_d|jd|_|j�dS(NR<R=R;R-shttps://s/v1/(	RERAR<R=R;R�R�RxR�(R~RER�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR��s		cCs&ts"|jjdtd��ndS(NR@R�(R�RERDR(R~((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR��sc	CsL|j|}d}d}d}d}	d}
idd6|jd6|jd6dd6}d�}yFtj||d|d	|jd
|�}
|
j}||
�\}}	Wn�tjj	k
r�}||
�\}}	|	dkr-t
|�}
q-nCtjjk
r}t
|�}
ntk
r,}t
|�}
nX|	dk	rB|	}
n||
fS(sC send http request and process reponse, including error conditions sapplication/jsonsContent-typesapi-keys
secret-keysno-caches
Cache-ControlcSsey|j�}Wntk
r$dSXdddg}|j|krU|jd�}nd}||fS(s, extract json, and error message if present i�i�i�RN(NN(R�R�RURRX(R�R�tsuccess_codeR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�s
R�R�R�N(
RxRUR<R=R�R�R�RRRR#RRC(R~R�R�RAR�RxRRR
RRR�RR�R�R
((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�s6



	
'		cCsd}|j|||�S(NR�(R(R~R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyRX�scCsd}|j|||d|�S(NRR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�scCsd}|j|||d|�S(NRR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�scCsd}|j|||d|�S(NtPUTR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pytput�scCsd}|j|||d|�S(NRR�(R(R~R�R�RAR�((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�scCsYd}|jd|�\}}x3t|d�dkrT|jd|�\}}q"WdS(s$ Method to get the state of the job R�sJobs/%ststatetdone(RXR#(R~tjobIdR�R�R((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt	get_state�s
N(R�R�R�R�RURRXRRRRR!(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyR�s
	/i@Biʚ;I���I�Ƥ~�Id����
l@=7M.clB�3v^!<ii@IIIll (BR�RVR�R�tpprintRtansible.module_utilsRtansible.module_utils.basicRRt+ansible.module_utils.six.moves.urllib.errorRRtansible.module_utils.urlsRtansible.module_utils.apiRtansible.module_utils._textRt$ansible.module_utils.ansible_releaseR	R�tImportErrortnetapp_lib.api.zapiRR7RR8R�R�RZRR
turllib.parseRR6tSF_BYTE_MAPt
POW2_BYTE_MAPtsolidfire.factoryRtsolidfire.custom.modelsRtsolidfire.modelsRRRCRRR9R:R>RURGRcRdRktobjectRlR�R�R�R�R�R�R(((s?/usr/lib/python2.7/site-packages/ansible/module_utils/netapp.pyt<module>s�








		


						
*	
�<&		
p

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