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

�
�Udac@`s	dZddlmZmZmZeZidd6dgd6dd6Zd	Zd
Z	dZ
ddlmZdd
l
mZddljjZddlmZej�ZyddlZWnek
r�eZnXdefd��YZd�Zedkre�ndS(s"Element OS Software Volume Manageri(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys	

module: na_elementsw_volume

short_description: NetApp Element Software Manage Volumes
extends_documentation_fragment:
    - netapp.solidfire
version_added: '2.7'
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
- Create, destroy, or update volumes on ElementSW

options:

    state:
        description:
        - Whether the specified volume should exist or not.
        required: true
        choices: ['present', 'absent']

    name:
        description:
        - The name of the volume to manage.
        - It accepts volume_name or volume_id
        required: true

    account_id:
        description:
        - Account ID for the owner of this volume.
        - It accepts Account_id or Account_name
        required: true

    enable512e:
        description:
        - Required when C(state=present)
        - Should the volume provide 512-byte sector emulation?
        type: bool
        aliases:
        - 512emulation

    qos:
        description: Initial quality of service settings for this volume. Configure as dict in playbooks.

    attributes:
        description: A YAML dictionary of attributes that you would like to apply on this volume.

    size:
        description:
        - The size of the volume in (size_unit).
        - Required when C(state = present).

    size_unit:
        description:
        - The unit used to interpret the size parameter.
        choices: ['bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb']
        default: 'gb'

    access:
        description:
        - Access allowed for the volume.
        - readOnly           Only read operations are allowed.
        - readWrite          Reads and writes are allowed.
        - locked             No reads or writes are allowed.
        - replicationTarget  Identify a volume as the target volume for a paired set of volumes.
        - If the volume is not paired, the access status is locked.
        - If unspecified, the access settings of the clone will be the same as the source.
        choices: ['readOnly', 'readWrite', 'locked', 'replicationTarget']

    password:
        description:
        - ElementSW access account password
        aliases:
        - pass

    username:
        description:
        - ElementSW access account user-name
        aliases:
        - user

s�
   - name: Create Volume
     na_elementsw_volume:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: present
       name: AnsibleVol
       qos: {minIOPS: 1000, maxIOPS: 20000, burstIOPS: 50000}
       account_id: 3
       enable512e: False
       size: 1
       size_unit: gb

   - name: Update Volume
     na_elementsw_volume:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: present
       name: AnsibleVol
       account_id: 3
       access: readWrite

   - name: Delete Volume
     na_elementsw_volume:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: absent
       name: AnsibleVol
       account_id: 2
sM

msg:
    description: Success message
    returned: success
    type: str

(t
AnsibleModule(t	to_nativeN(tNaElementSWModuletElementOSVolumecB`sMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s�
    Contains methods to parse arguments,
    derive details of  ElementSW objects
    and send requests to ElementOS via
    the ElementSW SDK
    cC`s�tj|_tj�|_|jjtdtdtdddg�dtdtdd�d	tdt�d
tdddd
g�dtdtdddd-�dtdtdddd-�dtdd�dtdddddddddddddg
dd�dtdtdddd-dd d!d"d#g��	�t
d$|jd%dddd
gfgd&t�|_|jj}|d|_
|d|_|d	|_|d
|_|d|_|d|_|d|_|d|_|dd-k	r|d|j|j|_n	d-|_ttkr0|jjd'd(�nIytjd)|j�|_Wn*tjjk
rx|jjd'd*�nXt|j�|_|jd-k	r�|jj|jjd+d,��n|jjd+d,�|_d-S(.sn
        Parse arguments, setup state variables,
        check parameters and ensure SDK is installed
        tstatetrequiredtchoicestpresenttabsenttnamettypetstrt
account_idt
enable512etbooltaliasest512emulationtqostdicttdefaultt
attributestsizetintt	size_unittgbtbytestbtkbtmbttbtpbtebtzbtybtaccesstreadOnlyt	readWritetlockedtreplicationTargett
argument_spectrequired_iftsupports_check_modetmsgs)Unable to import the ElementSW Python SDKtmodulesUnable to create the connectiontsourcetna_elementsw_volumeN( tnetapp_utilstSF_BYTE_MAPt_size_unit_maptontap_sf_host_argument_specR/tupdateRtTruetFalsetNoneRR3tparamsRRRRRRR*RRt
HAS_SF_SDKt	fail_jsontcreate_sf_connectiontsfet	solidfiretcommontApiServerErrorR
telementsw_helpertset_element_attributes(tselftparam((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyt__init__�sR	







	"cC`scy#|jj|j�|_|jSWn9tk
r^}|jjdd|jdt|��nXdS(s0
            Return account id if found
        R2s#Error: account_id %s does not existt	exceptionN(RFtaccount_existsRt	ExceptionR3R@R	(RHterr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pytget_account_id�s
cC`sP|jj|j|j�}|dk	rL|jj|�}|dk	rL|SndS(s4
            Return volume details if found
        N(RFt
volume_existsRRR=t
get_volume(RHt	volume_idtvolume_details((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyRQ�sc
C`s�yG|jjd|jd|jd|jd|jd|jd|j�WnBtk
r�}|j	j
dd|j|jfd	t|��nXd
S(sQ
        Create Volume

        :return: True if created, False if fails
        RRt
total_sizeRRRR2s'Error provisioning volume %s of size %sRKN(RBt
create_volumeRRRRRRRMR3R@R	(RHRN((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyRU�s				"cC`sfy*|jjd|�|jjd|�Wn5tk
ra}|jjd|jdt|��nXdS(sq
         Delete and purge the volume using volume id

         :return: Success : True , Failed : False
        RRR2RKN(RBt
delete_volumetpurge_deleted_volumeRMR3R@tmessageR	(RHRRRN((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyRVscC`s}yA|jj|d|jd|jd|jd|jd|j�Wn5tk
rx}|jj	d|j
dt|��nXdS(	sn

        Update the volume with the specified param

        :return: Success : True, Failed : False
        RR*RRTRR2RKN(RBt
modify_volumeRR*RRRRMR3R@RXR	(RHRRRN((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyt
update_volumes				c	C`s�t}t}t}|j�|j�}|r
t}|j}|jdkrUt}q"|jdkr"|jdk	r�|jdk	r�|j|jkr�t}t}n�|jdk	r�|jdk	r�|j|jkr�t}t}n�|j	dk	rc|j	dk	rc|j	j
}|d|j	dksQ|d|j	dksQ|d|j	dkrct}t}qcn|jdk	r�|j|jkr�t
t|j|j��}||jd	kr�t}t}q�n|jdk	r|jdk	r|j|jkrt}t}qq"n|jdkr"t}nd
}|r�|jjrCd}q�|jdkr�|sk|j�d}q�|r�|j|�d
}q�q�|jdkr�|j|�d}q�n|jjd|d|�dS(NRRtmin_iopstminIOPStmax_iopstmaxIOPSt
burst_iopst	burstIOPSg����MbP?tsCheck mode, skipping changessVolume createdsVolume updatedsVolume deletedtchangedR2(R<RORQR;RRRR*R=RRt__dict__RTRtabstfloatRR3t
check_modeRURZRVt	exit_json(	RHRbRPRZt
volume_detailRRt
volume_qostsize_differencetresult_message((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pytapply2sd
		0		.!		
	

(
t__name__t
__module__t__doc__RJRORQRURVRZRl(((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyR�s	A					cC`st�}|j�dS(N(RRl(R5((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pytmain�s	t__main__(Rot
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRtansible.module_utils._textR	tansible.module_utils.netapptmodule_utilstnetappR6t,ansible.module_utils.netapp_elementsw_moduleR
t
has_sf_sdkR?tsolidfire.commonRCtImportErrorR<tobjectRRpRm(((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_volume.pyt<module>s*


S"	

�	

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