Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/storage/netapp/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddlmZmZmZddlmZmZmZdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: netapp_e_firmware
version_added: "2.9"
short_description: NetApp E-Series manage firmware.
description:
    - Ensure specific firmware versions are activated on E-Series storage system.
author:
    - Nathan Swartz (@ndswartz)
extends_documentation_fragment:
    - netapp.eseries
options:
    nvsram:
        description:
            - Path to the NVSRAM file.
        type: str
        required: true
    firmware:
        description:
            - Path to the firmware file.
        type: str
        required: true
    wait_for_completion:
        description:
            - This flag will cause module to wait for any upgrade actions to complete.
        type: bool
        default: false
    ignore_health_check:
        description:
            - This flag will force firmware to be activated in spite of the health check.
            - Use at your own risk. Certain non-optimal states could result in data loss.
        type: bool
        default: false
s9
- name: Ensure correct firmware versions
  netapp_e_firmware:
    ssid: "1"
    api_url: "https://192.168.1.100:8443/devmgr/v2"
    api_username: "admin"
    api_password: "adminpass"
    validate_certs: true
    nvsram: "path/to/nvsram"
    bundle: "path/to/bundle"
    wait_for_completion: true
- name: Ensure correct firmware versions
  netapp_e_firmware:
    ssid: "1"
    api_url: "https://192.168.1.100:8443/devmgr/v2"
    api_username: "admin"
    api_password: "adminpass"
    validate_certs: true
    nvsram: "path/to/nvsram"
    firmware: "path/to/firmware"
sq
msg:
    description: Status and version of firmware and NVSRAM.
    type: str
    returned: always
    sample:
N(tsleep(tsix(tNetAppESeriesModuletcreate_multipart_formdatatrequest(t	to_nativetto_texttto_bytestNetAppESeriesFirmwarecB`s�eZdZdZdZdZd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(i��ii<c
C`sAtdtdddt�dtdddt�dtdddt�d	tdddt��}tt|�jd
|ddd
t�|jj}|d|_|d|_	|d|_
|d	|_d|_
d|_d|_d|_d|_t|_t|_t�|_tjj|j�|_
tjj|j	�|_dS(Ntnvsramttypetstrtrequiredtfirmwaretwait_for_completiontbooltdefaulttignore_health_checktansible_optionstweb_services_versions02.00.0000.0000tsupports_check_mode(tdicttTruetFalsetsuperRt__init__tmoduletparamsRRRRtNonetnvsram_namet
firmware_nametis_bundle_cachetfirmware_version_cachetnvsram_version_cachetupgrade_requiredtupgrade_in_progresstmodule_infotostpathtbasename(tselfRtargs((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyR!Zs.



							c	C`s�|jdkr�t|jd��o}|jd�j�}d|krQt|_n;d|krit|_n#|jj	dd|j|j
f�WdQXn|jS(s.Determine whether supplied firmware is bundle.trbiRtcombined_contenttmsgs/Firmware file is invalid. File [%s]. Array [%s]N(R'R$topenRtreadtlowerRRR"t	fail_jsontssid(R0tfht	signature((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytis_firmware_bundledws,c	C`s|jdkrt|jd���}|j�}x�|r�|j�r�d|kr�xQ|djd�D]<}|jd�\}}|dkre|jd�|_qeqeWPq�n,d|kr�|j�d	jd�|_Pn|j�}q3W|jj	d
d|j|j
f�WdQXn|jS(
sDRetrieve firmware version of the firmware file. Return: bytes stringR2sdisplayableAttributeList=it,t|tVERSIONs
sVersion:i����R4s<Failed to determine firmware version. File [%s]. Array [%s].N(R(R$R5RtreadlineR<tsplittstripR"R8R9(R0R:tlinetitemtkeytvalue((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytfirmware_version�s"	,c	C`s�|jdkr�t|jd��u}|j�}x_|rnd|kr_|jd�d|_Pn|j�}q3W|jjdd|j|jf�WdQXn|jS(s?Retrieve NVSRAM version of the NVSRAM file. Return: byte stringR2s.NVSRAM Configuration Numbert"i����R4s?Failed to determine NVSRAM file version. File [%s]. Array [%s].N(	R)R$R5RR@RAR"R8R9(R0R:RC((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytnvsram_version�s	,cC`s_y|jdddditd6|jgd6�\}}x�trtd�yy|jd|d	�\}}|d
s�|ddd
St|ddd�|jkr�|jjdd|j�nWq;tk
r�}|jjdd|jt	|�f�q;Xq;WWn9tk
r@}|jjdd|jt	|�f�nX|jjdd|j�dS(sZEnsure E-Series storage system is healthy. Works for both embedded and proxy web services.shealth-checktmethodtPOSTtdatat
onlineOnlytstorageDeviceIdsishealth-check?requestId=%st	requestIdthealthCheckRunningtresultsit
successfultprocessingTimeMSR4s/Health check failed to complete. Array Id [%s].sAFailed to retrieve health check status. Array Id [%s]. Error[%s].s:Failed to initiate health check. Array Id [%s]. Error[%s].N(
RRR9RtinttHEALTH_CHECK_TIMEOUT_MSR"R8t	ExceptionR
(R0trct
request_idtresponseterror((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytcheck_system_health�s5	

!!2*cC`s|j�|j�dS(s9Verify files are compatible with E-Series storage system.N(t#embedded_check_nvsram_compatibilityt#embedded_check_bundle_compatibility(R0((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytembedded_check_compatibility�s
cC`sSyd|j|jfg}td|�\}}|jd|jddd|d|�\}}|ds�|jjd	d
|j�n|ds�|jjd	d|j�nxc|d
D]W}|d|dkr�t|_n|j	j
ii|dd6|dd6|d6�q�WWn9tk
rN}|jjd	d|jt|�f�nXdS(sFVerify the provided NVSRAM is compatible with E-Series storage system.tnvsramimagetfiless8firmware/embedded-firmware/%s/nvsram-compatibility-checkRJRKRLtheaderstsignatureTestingPassedR4sInvalid NVSRAM file. File [%s].tfileCompatibles$Incompatible NVSRAM file. File [%s].tversionContentstbundledVersiontonboardVersiontonboard_versiontbundled_versionR"sJFailed to retrieve NVSRAM compatibility results. Array Id [%s]. Error[%s].N(
R%RRRR9R"R8RR*R,tupdateRVR
(R0R`RaRLRWtnvsram_compatibleR"RZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyR\�s

9c
	C`s)y�dd|jfg}td|dt�\}}|jd|jddd|d	|�\}}|d
s�|jjdd|j�n|d
s�|jjdd|j�nx6|dD]*}|djd�}|djd�}tt	|�t	|��}	||	 ||	 kr�t|_
|djd�d }
|djd�d }|
d|dks�|
d|dkr�|
d|dkr�|jjdd|d|df�q�n|jjii|dd6|dd6|d6�q�WWn9t
k
r$}|jjdd|jt|�f�nXdS(sOVerify the provided firmware bundle is compatible with E-Series storage system.sfiles[]tblobR`tsend_8kbs8firmware/embedded-firmware/%s/bundle-compatibility-checkRJRKRLRaRbR4s(Invalid firmware bundle file. File [%s].Rcs-Incompatible firmware bundle file. File [%s].RdRet.Rfiiis9Downgrades are not permitted. onboard [%s] > bundled[%s].RgRhR"sJFailed to retrieve bundle compatibility results. Array Id [%s]. Error[%s].N(RRRRR9R"R8RAtmintlenR*R,RiRVR
(
R0R`RaRLRWtbundle_compatibleR"tbundle_module_versiontonboard_module_versiontversion_minimum_lengthtbundle_versionRgRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyR]�s.

	<9cC`sxtd|j�D]�}y�|jd|j�\}}g|dddD] }|ddkrK|d^qKd}|dkr�tj|�|j�kr�tj|dd	�|j�kr�t|_	PnWnt
k
r�}nXtd
�qW|jj
dd|j�d
S(sGWait for SANtricity Web Services Embedded to be available after reboot.is6storage-systems/%s/graph/xpath-filter?query=/sa/saDatatextendedSADatatcodeVersionst
codeModulet
bundleDisplayt
versionStringi�t
nvsramVersioniR4s@Timeout waiting for Santricity Web Services Embedded. Array [%s]N(trangetREBOOT_TIMEOUT_SECRR9R	tbRGRIRR+RVRR"R8(R0tcountRWRYtmtbundle_displayRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytembedded_wait_for_upgrades=J	cC`s�d|j|jfd|j|jfg}td|�\}}y4|jdddd|d|�\}}t|_Wn9tk
r�}|j	j
d	d
|jt|�f�nX|j
r�|j�ndS(s-Upload and activate both firmware and NVSRAM.t
nvsramfiletdlpfileR`s3firmware/embedded-firmware?staged=false&nvsram=trueRJRKRLRaR4sAFailed to upload and activate firmware. Array Id [%s]. Error[%s].N(R%RR&RRRRR+RVR"R8R9R
RR�(R0R`RaRLRWRYRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytembedded_upgrades'
*	cC`sji|jgd6}y|jdddd|�\}}x�tdt|jd��D]�}td�y�|jd|d	�\}}|d
s�x1|dddD]}|d
|jkr�dSq�W|jjdd|j|jf�nWqTt	k
r$}|jjdd|jt
|�f�qTXqTWWn9t	k
re}|jjdd|jt
|�f�nXdS(s9Verify nvsram is compatible with E-Series storage system.RNsfirmware/compatibility-checkRJRKRLiis)firmware/compatibility-check?requestId=%sROtcheckRunningRQtnvsramFilestfilenameNR4s2NVSRAM is not compatible. NVSRAM [%s]. Array [%s].sKFailed to retrieve NVSRAM status update from proxy. Array [%s]. Error [%s].sKFailed to receive NVSRAM compatibility information. Array [%s]. Error [%s].(R9RR{RTt(FIRMWARE_COMPATIBILITY_CHECK_TIMEOUT_SECRR%R"R8RVR
(R0RLRWtcheckR~RYtresultRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyt proxy_check_nvsram_compatibility#s !#

*2cC`sji|jgd6}y|jdddd|�\}}x�tdt|jd��D]�}td�y�|jd|d	�\}}|d
s�x1|dddD]}|d
|jkr�dSq�W|jjdd|j|jf�nWqTt	k
r$}|jjdd|jt
|�f�qTXqTWWn9t	k
re}|jjdd|jt
|�f�nXdS(s;Verify firmware is compatible with E-Series storage system.RNsfirmware/compatibility-checkRJRKRLiis)firmware/compatibility-check?requestId=%sROR�RQtcfwFilesR�NR4s=Firmware bundle is not compatible. firmware [%s]. Array [%s].sMFailed to retrieve firmware status update from proxy. Array [%s]. Error [%s].sMFailed to receive firmware compatibility information. Array [%s]. Error [%s].(R9RR{RTR�RR&R"R8RVR
(R0RLRWR�R~RYR�RZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyt"proxy_check_firmware_compatibility6s !#

*2c
C`sy�|jd�\}}x�|D]}|d|jkrPqqWdg}d|j|jfg}td|d|�\}}y+|jdd	d
d|d|�\}}Wn?tk
r�}	|jjd
d|j|jt|	�f�nX|j	�x�|D]}|d|j
kr�Pq�q�Wdg}d|j
|jfg}td|d|�\}}y+|jdd	d
d|d|�\}}Wn?tk
r�}	|jjd
d|j
|jt|	�f�nX|j�Wn0tk
r}	|jjd
dt|	��nXdS(s5Ensure firmware is uploaded and verify compatibility.sfirmware/cfw-filesR�tvalidatettruetfirmwareFileR`tfieldssfirmware/uploadRJRKRLRaR4s@Failed to upload NVSRAM file. File [%s]. Array [%s]. Error [%s].sIFailed to upload firmware bundle file. File [%s]. Array [%s]. Error [%s].s?Failed to retrieve existing existing firmware files. Error [%s]N(R�R�(R�R�(
RR%RRRVR"R8R9R
R�R&RR�(
R0RWt	cfw_filestfileR�R`RaRLRYRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyt$proxy_upload_and_check_compatibilityJs8
	+!

	+!cC`s�y!|j�rE|jd|j�\}}tj|dd�}n/|jd|j�\}}tj|d�}||j�kr |jd�d }|j�jd�d }|d|dks�|d|dkr�|d|dkr�t|_q |j	j
dd	|j|jf�nWn9tk
r\}|j	j
dd
|jt
|�f�nXyK|jd|j�\}}tj|d�|j�kr�t|_nWn9tk
r�}|j	j
dd|jt
|�f�nXd
S(sPStaging is required to collect firmware information from the web services proxy.s`storage-systems/%s/graph/xpath-filter?query=/controller/codeVersions[codeModule='bundleDisplay']iRys@storage-systems/%s/graph/xpath-filter?query=/sa/saData/fwVersionRmiiR4s8Downgrades are not permitted. Firmware [%s]. Array [%s].sJFailed to retrieve controller firmware information. Array [%s]. Error [%s]sDstorage-systems/%s/graph/xpath-filter?query=/sa/saData/nvsramVersionsJFailed to retrieve storage system's NVSRAM version. Array [%s]. Error [%s]N(R<RR9R	R}RGRARR*R"R8RRVR
RI(R0RWRYtcurrent_firmware_versiontcurrenttupgradeRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytproxy_check_upgrade_requiredns(<**c
C`s�|j�r�x�tr�yqtd�|jd|�\}}|ddkrXt|_Pn-|ddkr�|jjdd|j�nWqt	k
r�}|jjdd	|jt
|�f�qXqWn�x�td
t|j
d��D]�}y�td�|jd|j�\}}|jd|j�\}}	tj|d
�|j�kr|tj|	d
�|j�kr|t|_PnWq�t	k
r�}q�Xq�W|jjdd
|j�dS(sAWait for SANtricity Web Services Proxy to report upgrade completeisbatch/cfw-upgrade/%sRtcompletetfailedt	cancelledR4s0Firmware upgrade failed to complete. Array [%s].sCFailed to retrieve firmware upgrade status. Array [%s]. Error [%s].is@storage-systems/%s/graph/xpath-filter?query=/sa/saData/fwVersionsDstorage-systems/%s/graph/xpath-filter?query=/sa/saData/nvsramVersions?Timed out waiting for firmware upgrade to complete. Array [%s].N(R�R�(R<RRRRR+R"R8R9RVR
R{RTR|R	R}RGRI(
R0RXRWRYRZR~trc_firmwareRt	rc_nvsramR((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytproxy_wait_for_upgrade�s.	
	!1#
>	cC`s�d}|j�r�itd6|jd6|jd6i|jd6|jd6gd6}y/|jddd	d
|�\}}|d}Wq\tk
r�}|j	j
dd
|jt|�f�q\Xn�itd6|jd6|jd6|jd6}y6|jd|jdd	d
|�\}}|d}Wn9tk
r[}|j	j
dd
|jt|�f�nXt|_
|jr~|j|�ndS(s4Activate previously uploaded firmware related files.tactivateR�t
nvsramFiletsystemIdtallowNonOptimalActivationtsystemInfossbatch/cfw-upgradeRJRKRLROR4s<Failed to initiate firmware upgrade. Array [%s]. Error [%s].t
stageFirmwaretskipMelChecktcfwFilesstorage-systems/%s/cfw-upgradeN(R$R<RR&R%R9RRRVR"R8R
RR+RR�(R0RXRLRWRYRZ((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyt
proxy_upgrade�s0



!-



(*		cC`s�|j�|j�r#|j�n |j�|jrC|j�n|jr|jjr|j�rr|j�q|j	�n|jj
d|jd|jd|j�dS(sUpgrade controller firmware.tchangedtupgrade_in_processRN(
R[tis_embeddedR^R�R*R�R"t
check_modeR�R�t	exit_jsonR+R,(R0((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytapply�s


	


i�i�(t__name__t
__module__RUR|R�tDEFAULT_TIMEOUTR!R<RGRIR[R^R\R]R�R�R�R�R�R�R�R�R�(((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyRTs*								$		
			$	 		cC`st�}|j�dS(N(RR�(R((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pytmain�s	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR-ttimeRtansible.module_utilsR	tansible.module_utils.netappR
RRtansible.module_utils._textR
RRRR�R�(((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_firmware.pyt<module>s"


#��	

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