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_drive_firmware.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZmZddlmZmZmZdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: netapp_e_drive_firmware
version_added: "2.9"
short_description: NetApp E-Series manage drive firmware
description:
    - Ensure drive firmware version is activated on specified drive model.
author:
    - Nathan Swartz (@ndswartz)
extends_documentation_fragment:
    - netapp.eseries
options:
    firmware:
        description:
            - list of drive firmware file paths.
            - NetApp E-Series drives require special firmware which can be downloaded from https://mysupport.netapp.com/NOW/download/tools/diskfw_eseries/
        type: list
        required: True
    wait_for_completion:
        description:
            - This flag will cause module to wait for any upgrade actions to complete.
        type: bool
        default: false
    ignore_inaccessible_drives:
        description:
            - This flag will determine whether drive firmware upgrade should fail if any affected drives are inaccessible.
        type: bool
        default: false
    upgrade_drives_online:
        description:
            - This flag will determine whether drive firmware can be upgrade while drives are accepting I/O.
            - When I(upgrade_drives_online==False) stop all I/O before running task.
        type: bool
        default: true
sI
- name: Ensure correct firmware versions
  nac_santricity_drive_firmware:
    ssid: "1"
    api_url: "https://192.168.1.100:8443/devmgr/v2"
    api_username: "admin"
    api_password: "adminpass"
    validate_certs: true
    firmware: "path/to/drive_firmware"
    wait_for_completion: true
    ignore_inaccessible_drives: false
s�
msg:
    description: Whether any drive firmware was upgraded and whether it is in progress.
    type: str
    returned: always
    sample:
        { changed: True, upgrade_in_process: True }
N(tsleep(tNetAppESeriesModuletcreate_multipart_formdata(t	to_nativetto_texttto_bytestNetAppESeriesDriveFirmwarecB`sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(	i<ic
C`s�tdtdddt�dtdddt�dtdddt�d	tdddt��}tt|�jd
|ddd
t�|jj}|d|_|d|_	|d|_
|d	|_d|_
d|_t|_d|_dS(Ntfirmwarettypetlisttrequiredtwait_for_completiontbooltdefaulttignore_inaccessible_drivestupgrade_drives_onlinetansible_optionstweb_services_versions02.00.0000.0000tsupports_check_mode(tdicttTruetFalsetsuperRt__init__tmoduletparamst
firmware_listRRRtNonetupgrade_list_cachetupgrade_required_cachetupgrade_in_progresstdrive_info_cache(tselfRtargs((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pyRPs"



			c		C`s�x�|jD]�}tjj|�}d||fg}t|�\}}y+|jdddd|d|�\}}Wq
tk
r�}|jjdd||j	t
|�f�q
Xq
Wd	S(
s2Ensure firmware has been upload prior to uploaded.tfiles/files/drivetmethodtPOSTtheaderstdatatmsgs=Failed to upload drive firmware [%s]. Array [%s]. Error [%s].N(R"tostpathtbasenameR
trequestt	ExceptionR t	fail_jsontssidR(	R(Rt
firmware_nametfilesR-R.trctresponseterror((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytupload_firmwaregs+c

C`s|jdkrt�|_y�|jd|j�\}}x�|jD]�}tjj|�}xo|dD]c}|d|krgg}x|dD]}y�|jd|j|df�\}}|d|dkrU|d|dkrU|j	s|d	r|d
r|j
|d�n|drU|jrU|jj
dd
|j|df�qUnWq�tk
r�}	|jj
dd|j|dt|	�f�q�Xq�W|r�|jji|d6|d6g�q�qgqgWqDWWqtk
r}	|jj
dd|jt|	�f�qXn|jS(sCDetermine whether firmware is compatible with the specified drives.s"storage-systems/%s/firmware/drivestcompatibilitiestfilenametcompatibleDrivessstorage-systems/%s/drives/%stdriveReftfirmwareVersiontsupportedFirmwareVersionstofflinet	availabletonlineUpgradeCapableR/s?Drive is not capable of online upgrade. Array [%s]. Drive [%s].sIFailed to retrieve drive information. Array [%s]. Drive [%s]. Error [%s].tdriveRefListsJFailed to complete compatibility and health check. Array [%s]. Error [%s].N(R$R#RR3R6R"R0R1R2RtappendRR R5R4Rtextend(
R(R9R:RR>tuploaded_firmwaretdrive_reference_listtdrivet
drive_infoR;((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytupgrade_listrs6&&3-c
	C`sqg|j�D]}|dD]}|^qq
}d}x4tt|jd��D]�}y�|jd|j�\}}x�|dD]t}|}|d|kr�|ddkr�q�q�|ddkr�Pq�|jjdd
|j|d|df�q�q�Wt	|_
PWn9tk
r>}	|jjdd|jt|	�f�nXt
d�qPW|jjdd|j|f�dS(s,Wait for drive firmware upgrade to complete.RFis(storage-systems/%s/firmware/drives/statetdriveStatusR@Rtokayt
inProgresstinProgressRecontpendingtnotAttemptedR/sCDrive firmware upgrade failed. Array [%s]. Drive [%s]. Status [%s].s8Failed to retrieve drive status. Array [%s]. Error [%s].sFTimed out waiting for drive firmware upgrade. Array [%s]. Status [%s].N(RPRQRRRS(RMR#trangetinttWAIT_TIMEOUT_SECR3R6R R5RR&R4RR(
R(RKt	referencetdrive_referencestlast_statustattemptR9R:RR;((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytwait_for_upgrade_completion�s(0 #	*cC`s�yP|jd|j|jr!dndfddd|j��\}}t|_Wn9tk
r�}|jjdd|jt	|�f�nX|j
r�|j�nd	S(
s$Apply firmware to applicable drives.sCstorage-systems/%s/firmware/drives/initiate-upgrade?onlineUpdate=%sttruetfalseR+R,R.R/s9Failed to upgrade drive firmware. Array [%s]. Error [%s].N(R3R6RRMRR&R4R R5RRR[(R(R9R:R;((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytupgrade�s	:
*	cC`sb|j�|j�r0|jjr0|j�n|jjd|j�rNtntd|j�dS(sCApply firmware policy has been enforced on E-Series storage system.tchangedtupgrade_in_processN(	R<RMR t
check_modeR^t	exit_jsonRRR&(R(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytapply�s


$i�(	t__name__t
__module__RVRR<RMR[R^Rc(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pyRMs			+		cC`st�}|j�dS(N(RRc(tdrive_firmware((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pytmain�s	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR0trettimeRtansible.module_utils.netappR	R
tansible.module_utils._textRRR
RRgRd(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_drive_firmware.pyt<module>s 


$�	

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