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/na_ontap_firmware_upgrade.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddljjZddlmZddlZej�Zdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys:
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
  - Update ONTAP service-prosessor firmware
extends_documentation_fragment:
  - netapp.na_ontap
module: na_ontap_firmware_upgrade
options:
  state:
    description:
      - Whether the specified ONTAP firmware should  be upgraded or not.
    default: present
    type: str
  node:
    description:
      - Node on which the device is located.
    type: str
    required: true
  clear_logs:
    description:
      - Clear logs on the device after update. Default value is true
    type: bool
    default: true
  package:
    description:
      - Name of the package file containing the firmware to be installed. Not required when -baseline is true.
    type: str
  shelf_module_fw:
    description:
      - Shelf module firmware to be updated to.
    type: str
  disk_fw:
    description:
      - disk firmware to be updated to.
    type: str
  update_type:
    description:
      -  Type of firmware update to be performed. Options include serial_full, serial_differential, network_full.
    type: str
  install_baseline_image:
    description:
      - Install the version packaged with ONTAP if this parameter is set to true. Otherwise, package must be used to specify the package to install.
    type: bool
    default: false
  firmware_type:
    description:
      - Type of firmware to be upgraded. Options include shelf, ACP, service-processor, and disk.
      - For shelf firmware upgrade the operation is asynchronous, and therefore returns no errors that might occur during the download process.
      - Shelf firmware upgrade is idempotent if shelf_module_fw is provided .
      - disk firmware upgrade is idempotent if disk_fw is provided .
      - With check mode, SP, ACP, disk, and shelf firmware upgrade is not idempotent.
      - This operation will only update firmware on shelves/disk that do not have the latest firmware-revision.
    choices: ['service-processor', 'shelf', 'acp', 'disk']
    type: str
short_description:  NetApp ONTAP firmware upgrade for SP, shelf, ACP, and disk.
version_added: "2.9"
s�

    - name: SP firmware upgrade
      na_ontap_firmware_upgrade:
        state: present
        node: vsim1
        package: "{{ file name }}"
        clear_logs: True
        install_baseline_image: False
        update_type: serial_full
        firmware_type: service-processor
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
    - name: ACP firmware upgrade
      na_ontap_firmware_upgrade:
        state: present
        node: vsim1
        firmware_type: acp
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
    - name: shelf firmware upgrade
      na_ontap_firmware_upgrade:
        state: present
        firmware_type: shelf
        shelf_module_fw: 1221
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
    - name: disk firmware upgrade
      na_ontap_firmware_upgrade:
        state: present
        firmware_type: disk
        disk_fw: NA02
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
t
N(t
AnsibleModule(t	to_native(tNetAppModuletNetAppONTAPFirmwareUpgradecB`s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�ZRS(s3
    Class with ONTAP firmware upgrade methods
    cC`sUtj�|_|jjtdtdtdddd�dtdtdd�dtdtddd	d
ddd
g�dtdtdddt�dtdtdd�dtdtdddt�dtdtdd�dtdtdd�dtdtdd��	�td|jddddgfdd
dgfdd
ddgfgdt�|_t	�|_
|j
j|jj�|_
|j
jd�d
kr|j
jd�r�|j
jd�dk	r�|jjdd�n|j
jd�r|j
jd�dkr|jjdd�qnttkr9|jjdd�ntjd|j�|_dS(Ntstatetrequiredttypetstrtdefaulttpresenttnodet
firmware_typetchoicessservice-processortshelftacptdiskt
clear_logstbooltpackagetinstall_baseline_imagetupdate_typetshelf_module_fwtdisk_fwt
argument_spectrequired_iftsupports_check_modetmsgs<Do not specify both package and install_baseline_image: truetFalses9Specify at least one of package or install_baseline_images(the python NetApp-Lib module is requiredtmodule(tnetapp_utilstna_ontap_host_argument_specR tupdatetdictR$tTrueR	R%Rt	na_helpertset_parameterstparamst
parameterstgettNonet	fail_jsontHAS_NETAPP_LIBtsetup_na_ontap_zapitserver(tself((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyt__init__�s6'	*+cC`sktjjd�}tjjd�}tjjd�}|jd|jd�|j|�|j|�|S(s�
        Compose NaElement object to query current firmware version
        :return: NaElement object for firmware_image_get_iter with query
        sservice-processor-get-itertquerysservice-processor-infoR(R&tzapit	NaElementt
add_new_childR.tadd_child_elem(R5tfirmware_image_getR7tfirmware_image_info((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytfirmware_image_get_iter�s

cC`s�|j�}y|jj|dt�}WnOtjjk
ry}|jjdd|j	dt
|�fdtj��nX|j
d�r�t|jd��dkr�|j
d�j
d	�}|jd
�}|SdS(sm
        Get current firmware image info
        :return: True if query successful, else return None
        tenable_tunnelingR#s-Error fetching firmware image details: %s: %sRt	exceptionsnum-recordsisattributes-listsservice-processor-infosfirmware-versionN(R>R4tinvoke_successfullyR*R&R8t
NaApiErrorR%R1R.R
t	tracebackt
format_exctget_child_by_nametinttget_child_contentR0(R5t	node_nameR>tresultterrortsp_infotfirmware_version((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyR<�s*cC`stjjd�}tjjd�}tjjd�}|j|�|j|�y|jj|dt�}WnBtjjk
r�}|jj	ddt
|�dtj��nX|j
d�j
d�r|j
d�j
d�}|jd	�}|d
krtSntS(s�
        where acp firmware upgrade is required
        :return:  True is firmware upgrade is required else return None
        s!storage-shelf-acp-module-get-iterR7sstorage-shelf-acp-moduleR?R#s/Error fetching acp firmware details details: %sR@sattributes-listR
tfirmware_update_required(R&R8R9R;R4RAR*RBR%R1R
RCRDRERGR$(R5tacp_firmware_get_iterR7tacp_infoRIRJtacp_module_infoR
((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytacp_firmware_required_get�s"

	cC`s�tjjd�}|jd|jd�t�}y|jj|dt�}WnBtjj	k
r�}|j
jddt|�dt
j��nX|jd�jd�r�|jd�jd�}|jd	�|d	<|jd�|d<n|S(
s�
        Get current firmware image update progress info
        :return: Dictionary of firmware image update progress if query successful, else return None
        s+service-processor-image-update-progress-getRR?R#s:Error fetching firmware image upgrade progress details: %sR@t
attributess,service-processor-image-update-progress-infosis-in-progress(R&R8R9R:R.R)R4RAR*RBR%R1R
RCRDRERG(R5RHtfirmware_update_progress_gettfirmware_update_progress_infoRIRJtupdate_progress_info((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyt%sp_firmware_image_update_progress_get�s	cC`s�t�}tjjd�}tjjd�}tjjd�}tjjd�}tjjd�}|j|�|j|�|j|�|j|�y|jj|dt�}WnBtjjk
r�}|j	j
ddt|�d	tj
��nX|jd
�r�t|jd
��dkr�|jd�jd�}	|	jd�r�|	jd�jd�r�|	dj�}
x-|
D]"}|jd
�||jd�<qxWq�n|S(sp
        Get the current firmware of shelf module
        :return:dict with module id and firmware info
        sstorage-shelf-info-get-itersdesired-attributessstorage-shelf-infos
shelf-modulessstorage-shelf-module-infoR?R#s1Error fetching shelf module firmware  details: %sR@snum-recordsisattributes-listsmodule-fw-revisions	module-id(R)R&R8R9R;R4RAR*RBR%R1R
RCRDRERFRGtget_children(R5tshelf_id_fw_infotshelf_firmware_info_gettdesired_attributeststorage_shelf_infotshelf_moduletshelf_module_infoRIRJt
shelf_infotshelvesR((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyRY�s.	



*
&cC`s[t�}tjjd�}tjjd�}tjjd�}tjjd�}|j|�|j|�|j|�y|jj|dt�}WnBtjjk
r�}|j	j
ddt|�dtj
��nX|jd	�rWt|jd	��d
krW|jd�}|j�}	x6|	D]+}
|
jd�jd�||
jd
�<q%Wn|S(sK
        Get the current firmware of disks module
        :return:
        sstorage-disk-get-itersdesired-attributessstorage-disk-infosdisk-inventory-infoR?R#s0Error fetching disk module firmware  details: %sR@snum-recordsisattributes-listsfirmware-revisionsdisk-uid(R)R&R8R9R;R4RAR*RBR%R1R
RCRDRERFRGRW(R5tdisk_id_fw_infotdisk_firmware_info_getRZtstorage_disk_infotdisk_invRIRJt	disk_infotdisksR((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyRas&	


*
,cC`s<|j�}x)|D]!}|||jdkrtSqWtS(s�
        Check weather disk firmware upgrade is required or not
        :return: True if the firmware upgrade is required
        R(RaR.R*R$(R5tdisk_firmware_infoR((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytdisk_firmware_required_get*s

cC`s<|j�}x)|D]!}|||jdkrtSqWtS(s�
        Check weather shelf firmware upgrade is required or not
        :return: True if the firmware upgrade is required
        R(RYR.R*R$(R5tshelf_firmware_infoR%((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytshelf_firmware_required_get5s

cC`s}tjjd�}|jjd�dk	rD|jd|jd�n|jjd�dk	r||jdt|jd��n|jjd�dk	r�|jdt|jd��n|jd|jd�|jd|jd	�y|jj	|d
t
�Wnztjjk
rx}t|j
�dkr?|jjd�r?tS|jjd
d|jdt|�fdtj��nXt
S(s/
        Update current firmware image
        sservice-processor-image-updateRRs
clear-logsRsinstall-baseline-imageRsupdate-typeRR?t13001s Service Processor update skippedR#s(Error updating firmware image for %s: %sR@N(R&R8R9R.R/R0R:RR4RAR*RBR
tcodetmessaget
startswithR$R%R1RCRD(R5tfirmware_update_infoRJ((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytsp_firmware_image_update@s$  'cC`sytjjd�}y|jj|dt�tSWnBtjjk
rt}|jjddt	|�dt
j��nXdS(s.
        Upgrade shelf firmware image
        sstorage-shelf-firmware-updateR?R#s(Error updating shelf firmware image : %sR@N(R&R8R9R4RAR*RBR%R1R
RCRD(R5tshelf_firmware_update_infoRJ((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytshelf_firmware_upgradeYscC`s�tjjd�}|jd|jd�y|jj|dt�WnBtjjk
r�}|j	j
ddt|�dtj
��nXdS(	s.
        Upgrade shelf firmware image
        s!storage-shelf-acp-firmware-updates	node-nameRR?R#s&Error updating acp firmware image : %sR@N(R&R8R9R:R.R4RAR*RBR%R1R
RCRD(R5tacp_firmware_update_infoRJ((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytacp_firmware_upgradeescC`s�tjjd�}|jd|jd�y|jj|dt�WnBtjjk
r�}|j	j
ddt|�dtj
��nXtS(s'
        Upgrade disk firmware
        sdisk-update-disk-fws	node-nameRR?R#s'Error updating disk firmware image : %sR@(R&R8R9R:R.R4RAR*RBR%R1R
RCRD(R5tdisk_firmware_update_infoRJ((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytdisk_firmware_upgraderscC`sAtj|j�}tjd|jd|�}tjd|�dS(sF
        Autosupport log for software_update
        :return:
        R%tvservertna_ontap_firmware_upgradeN(R&tget_cserverR4R3R%t
ems_log_event(R5tresultstcserver((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytautosupport_log�scC`sLt}|j�t�}|jjd�dkr�|j|jd�}|jjd�dkr5|r5|jjs�|j�r�t	}n|j
|jd�}xE|jd�dkr�tjd�|j
|jd�}q�Wq�t	}q5nK|jjd�d	krk|jjd
�rG|j
�rh|jjs;|j�}qDt	}qhq5|jjsb|j�}q5t	}n�|jjd�dkr�|j�r5|jjs�|j�nt	}q5n�|jjd�dkr5|jjd
�r|j�r2|jjs|j�}qt	}q2q5|jjs,|j�}q5t	}n|jjd|�dS(s2
        Apply action to upgrade firmware
        Rsservice-processorRR
Rsis-in-progressttrueiRRRRRtchangedN(R$R|R)R.R/R<R%t
check_modeRoR*RVttimetsleepRiRqRQRsRgRut	exit_json(R5R~tfirmware_update_progresstcurrent((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytapply�sL
		
	
	(t__name__t
__module__t__doc__R6R>R<RQRVRYRaRgRiRoRqRsRuR|R�(((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyR|s 	%	
										
			cC`st�}|j�dS(sExecute actionN(RR�(t
community_obj((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pytmain�s	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRCtansible.module_utils.basicR	tansible.module_utils._textR
tansible.module_utils.netapptmodule_utilstnetappR&t"ansible.module_utils.netapp_moduleRR�thas_netapp_libR2tobjectRR�R�(((s\/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_firmware_upgrade.pyt<module>s&


;(�K	

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