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_nvme_subsystem.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddljjZddlmZej�Zdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys�
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
  - Create/Delete NVME subsystem
  - Associate(modify) host/map to NVME subsystem
  - NVMe service should be existing in the data vserver with NVMe protocol as a pre-requisite
extends_documentation_fragment:
  - netapp.na_ontap
module: na_ontap_nvme_subsystem
options:
  state:
    choices: ['present', 'absent']
    description:
      - Whether the specified subsystem should exist or not.
    default: present
  vserver:
    description:
      - Name of the vserver to use.
    required: true
  subsystem:
    description:
      - Specifies the subsystem
    required: true
  ostype:
    description:
      - Specifies the ostype for initiators
    choices: ['windows', 'linux', 'vmware', 'xen', 'hyper_v']
  skip_host_check:
    description:
      - Skip host check
      - Required to delete an NVMe Subsystem with attached NVMe namespaces
    default: false
    type: bool
  skip_mapped_check:
    description:
      - Skip mapped namespace check
      - Required to delete an NVMe Subsystem with attached NVMe namespaces
    default: false
    type: bool
  hosts:
    description:
      - List of host NQNs (NVMe Qualification Name) associated to the controller.
    type: list
  paths:
    description:
      - List of Namespace paths to be associated with the subsystem.
    type: list
short_description: "NetApp ONTAP Manage NVME Subsystem"
version_added: "2.8"
s�

    - name: Create NVME Subsystem
      na_ontap_nvme_subsystem:
        state: present
        subsystem: test_sub
        vserver: test_dest
        ostype: linux
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

    - name: Delete NVME Subsystem
      na_ontap_nvme_subsystem:
        state: absent
        subsystem: test_sub
        vserver: test_dest
        skip_host_check: True
        skip_mapped_check: True
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

    - name: Associate NVME Subsystem host/map
      na_ontap_nvme_subsystem:
        state: present
        subsystem: "{{ subsystem }}"
        ostype: linux
        hosts: nqn.1992-08.com.netapp:sn.3017cfc1e2ba11e89c55005056b36338:subsystem.ansible
        paths: /vol/ansible/test,/vol/ansible/test1
        vserver: "{{ vserver }}"
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"

    - name: Modify NVME subsystem map
      na_ontap_nvme_subsystem:
        state: present
        subsystem: test_sub
        vserver: test_dest
        skip_host_check: True
        skip_mapped_check: True
        paths: /vol/ansible/test
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

t
N(t
AnsibleModule(t	to_native(tNetAppModuletNetAppONTAPNVMESubsystemcB`sheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(s*
    Class with NVME subsytem methods
    cC`s�tj�|_|jjtdtdtdddddgdd�d	tdtdd�d
tdtdd�dtdtddddd
dddg�dtdtdddt�dtdtdddt�dtdtdd�dtdtdd���td|jdt�|_t	�|_
|j
j|jj�|_
ttkra|jjdd�n%tjd|jd	|j
d	�|_dS(Ntstatetrequiredttypetstrtchoicestpresenttabsenttdefaulttvservert	subsystemtostypetwindowstlinuxtvmwaretxenthyper_vtskip_host_checktbooltskip_mapped_checkthoststlisttpathst
argument_spectsupports_check_modetmsgs(the python NetApp-Lib module is requiredtmodule(tnetapp_utilstna_ontap_host_argument_specR#tupdatetdicttFalsetTrueR	R&Rt	na_helpertset_parameterstparamst
parameterstHAS_NETAPP_LIBt	fail_jsontsetup_na_ontap_zapitserver(tself((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pyt__init__�s$'*	cC`s�tjjd�}iii|jjd�d6d6d6}|j|�y|jj|dt�}WnBtjj	k
r�}|j
jddt|�dt
j��nX|jd	�r�t|jd	��d
kr�tSdS(si
        Get current subsystem details
        :return: dict if subsystem exists, None otherwise
        snvme-subsystem-get-iterRsnvme-subsytem-infotquerytenable_tunnelingR%s!Error fetching subsystem info: %st	exceptionsnum-recordsiN(R'tzapit	NaElementR0tgetttranslate_structR4tinvoke_successfullyR+t
NaApiErrorR&R2R
t	tracebackt
format_exctget_child_by_nametinttget_child_contentR,tNone(R5t
subsystem_getR7tresultterror((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pyt
get_subsystem�s
*cC`s�|jjd�d	kr.|jjdd�ni|jdd6|jdd6}tjjd�}|j|�y|j	j
|dt�WnTtjjk
r�}|jjdd|jjd�t
|�fdtj��nXd	S(
s)
        Create a NVME Subsystem
        RR%sBError: Missing required parameter 'os_type' for creating subsystemRsnvme-subsystem-createR8s#Error creating subsystem for %s: %sR9N(R0R<RER&R2R'R:R;R=R4R>R,R?R
R@RA(R5toptionstsubsystem_createRH((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytcreate_subsystem�s
cC`s�i|jdd6|jjd�r)dndd6|jjd�rHdndd6}tjjjd|�}y|jj|d	t�WnTtjj	k
r�}|j
jd
d|jjd�t|�fdt
j��nXd
S(s)
        Delete a NVME subsystem
        RRttruetfalsesskip-host-checkRsskip-mapped-checksnvme-subsystem-deleteR8R%s#Error deleting subsystem for %s: %sR9N(R0R<R'R:R;tcreate_node_with_childrenR4R>R,R?R&R2R
R@RA(R5RJtsubsystem_deleteRH((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytdelete_subsystem�s"cC`sY|dkrd\}}}n|dkr<d\}}}ntjj|�}iii|jjd	�d	6|6d
6}|j|�y|jj|dt�}WnBtjj	k
r�}|j
jdd
t|�dt
j��nX|jd�rUt|jd��dkrU|jd�}	g}
x%|	j�D]}|
j||�q/Wi|
|6SdS(si
        Get current subsystem host details
        :return: list if host exists, None otherwise
        R snvme-subsystem-host-get-itersnvme-target-subsystem-host-infoshost-nqnR"snvme-subsystem-map-get-itersnvme-target-subsystem-map-infotpathRR7R8R%s!Error fetching subsystem info: %sR9snum-recordsisattributes-list(snvme-subsystem-host-get-itersnvme-target-subsystem-host-infoshost-nqn(snvme-subsystem-map-get-itersnvme-target-subsystem-map-infospathN(R'R:R;R0R<R=R4R>R+R?R&R2R
R@RARBRCRDtget_childrentappendRE(R5Rtzapi_gett	zapi_infot	zapi_typeRFR7RGRHt
attrs_listtreturn_listtitem((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytget_subsystem_host_map�s.
*c	C`s�|dkrd
\}}n|dkr6d\}}nx�|D]�}i|jdd6||6}tjjj||�}y|jj|dt�Wq=tjjk
r�}|j	j
d	d
||jjd�t|�fdt
j��q=Xq=WdS(s�
        Add a NVME Subsystem host/map
        :param: data: list of hosts/paths to be added
        :param: type: hosts/paths
        R snvme-subsystem-host-addshost-nqnR"snvme-subsystem-map-addRRRR8R%s$Error adding %s for subsystem %s: %sR9N(snvme-subsystem-host-addshost-nqn(snvme-subsystem-map-addspath(R0R'R:R;ROR4R>R,R?R&R2R<R
R@RA(	R5tdataRtzapi_addRWRZRJt
subsystem_addRH((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytadd_subsystem_host_map�s

"c	C`s�|dkrd
\}}n|dkr6d\}}nx�|D]�}i|jdd6||6}tjjj||�}y|jj|dt�Wq=tjjk
r�}|j	j
d	d
||jjd�t|�fdt
j��q=Xq=WdS(s�
        Remove a NVME Subsystem host/map
        :param: data: list of hosts/paths to be added
        :param: type: hosts/paths
        R snvme-subsystem-host-removeshost-nqnR"snvme-subsystem-map-removeRRRR8R%s&Error removing %s for subsystem %s: %sR9N(snvme-subsystem-host-removeshost-nqn(snvme-subsystem-map-removespath(R0R'R:R;ROR4R>R,R?R&R2R<R
R@RA(	R5R\Rtzapi_removeRWRZRJtsubsystem_removeRH((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytremove_subsystem_host_map
s

"c	C`si}i}x�|D]�}|jj|�r|j|�}|r�|jj||jdt�j|�}g||D]$}||jj|�krr|^qr}n|j|}i}|r�|||<t|j_n|r�|||<t|j_q�qqW||fS(sW
        Check if there are hosts or paths to be associated with the subsystem
        t
get_list_diff(R0R<R[R-tget_modified_attributesR,tchanged(	R5ttypestaction_add_dicttaction_remove_dictRtcurrentt	add_itemsRZtremove_items((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytassociate_host_map$s$
	8


cC`s^x*|j�D]\}}|j||�q
Wx*|j�D]\}}|j||�q:WdS(N(titemsR_Rb(R5tadd_host_maptremove_host_mapRR\((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytmodify_host_map<scC`s)tjd|j�ddg}|j�}t�t�}}|jj||j�}|dkr�|jddkr�|j|�\}}n|jj	r|j
jr�q|dkr�|j�|j
||�q|dkr�|j�q|d	kr|j
||�qn|j
jd|jj	�d	S(
s0
        Apply action to NVME subsystem
        tna_ontap_nvme_subsystemR R"tdeleteR
RtcreateReN(R't
ems_log_eventR4RIR*R-t
get_cd_actionR0RlReR&t
check_modeRLRpRQREt	exit_json(R5RfRiRnRot	cd_action((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytapplyBs$

(
t__name__t
__module__t__doc__R6RIRLRQR[R_RbRlRpRy(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pyR}s					 				cC`st�}|j�dS(sExecute actionN(RRy(t
community_obj((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pytmain\s	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR@tansible.module_utils.basicR	tansible.module_utils._textR
tansible.module_utils.netapptmodule_utilstnetappR't"ansible.module_utils.netapp_moduleRthas_netapp_libR1tobjectRR~Rz(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_nvme_subsystem.pyt<module>s"


41�	

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