Anons79 Mini Shell

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

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
mZd
ZdZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: purefa_volume
version_added: '2.4'
short_description:  Manage volumes on Pure Storage FlashArrays
description:
- Create, delete or extend the capacity of a volume on Pure Storage FlashArray.
author:
- Pure Storage Ansible Team (@sdodsley) <[email protected]>
options:
  name:
    description:
    - The name of the volume.
    type: str
    required: true
  target:
    description:
    - The name of the target volume, if copying.
    type: str
  state:
    description:
    - Define whether the volume should exist or not.
    default: present
    choices: [ absent, present ]
    type: str
  eradicate:
    description:
    - Define whether to eradicate the volume on delete or leave in trash.
    type: bool
    default: 'no'
  overwrite:
    description:
    - Define whether to overwrite a target volume if it already exists.
    type: bool
    default: 'no'
  size:
    description:
    - Volume size in M, G, T or P units.
    type: str
  qos:
    description:
    - Bandwidth limit for volume in M or G units.
      M will set MB/s
      G will set GB/s
      To clear an existing Qos setting using 0 (zero)
    version_added: '2.8'
    type: str
extends_documentation_fragment:
- purestorage.fa
s�
- name: Create new volume named foo with a QoS limit
  purefa_volume:
    name: foo
    size: 1T
    qos: 58M
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: present

- name: Extend the size of an existing volume named foo
  purefa_volume:
    name: foo
    size: 2T
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: present

- name: Delete and eradicate volume named foo
  purefa_volume:
    name: foo
    eradicate: yes
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

- name: Create clone of volume bar named foo
  purefa_volume:
    name: foo
    target: bar
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: present

- name: Overwrite volume bar with volume foo
  purefa_volume:
    name: foo
    target: bar
    overwrite: yes
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: present

- name: Clear volume QoS from volume foo
  purefa_volume:
    name: foo
    qos: 0
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: present
s�
volume:
    description: A dictionary describing the changed volume.  Only some
        attributes below will be returned with various actions.
    type: dict
    returned: success
    contains:
        source:
            description: Volume name of source volume used for volume copy
            type: str
        serial:
            description: Volume serial number
            type: str
            sample: '361019ECACE43D83000120A4'
        created:
            description: Volume creation time
            type: str
            sample: '2019-03-13T22:49:24Z'
        name:
            description: Volume name
            type: str
        size:
            description: Volume size in bytes
            type: int
(t
AnsibleModule(t
get_systemtpurefa_argument_specs1.14s1.13cC`s�|d }|d}|j�r�t|�}|dkrE|d9}q�|dkr^|d9}q�|dkrw|d9}q�|dkr�|d	9}q�d
}nd
}|S(s�Given a human-readable byte string (e.g. 2G, 30M),
       return the number of bytes.  Will return 0 if the argument has
       unexpected form.
    i����tPItTItGi@tMii(tisdigittint(tsizetbytestunit((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pythuman_to_bytes�s





	cC`s1y|j|jd�SWntk
r,dSXdS(sReturn Volume or NonetnameN(t
get_volumetparamst	ExceptiontNone(tmoduletarray((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyR�s
cC`sKy2|j|jddt�ddkr-tStSWntk
rFtSXdS(sReturn Destroyed Volume or NoneRtpendingttime_remainingtN(RRtTruetFalseR(RR((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pytget_destroyed_volume�s&
cC`s1y|j|jd�SWntk
r,dSXdS(sReturn Volume or NonettargetN(RRRR(RR((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt
get_target�s
cC`s�t}|j�}t|kr�|jdjd�d}y|j�}Wn!tk
rk|jdd�nXxNtdt	|��D]$}|||dkr�t
}Pq�q�Wn|jdd�|S(s4Check is the requested VG to create volume in existsRt/itmsgs.Failed to get volume groups list. Check array.s=VG volumes are not supported. Please upgrade your FlashArray.(R t_list_available_rest_versionstVGROUPS_API_VERSIONRtsplittlist_vgroupsRt	fail_jsontrangetlenR(RRt	vg_existstapi_versiontvg_nametvgstvgroup((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pytcheck_vgroup�s
cC`s�t}|j�}t|kr�|jdjd�d}y|j�}Wn!tk
rk|jdd�nXxNtdt	|��D]$}|||dkr�t
}Pq�q�Wn|jdd�|S(s5Check is the requested pod to create volume in existsRs::iR%s$Failed to get pod list. Check array.s>Pod volumes are not supported. Please upgrade your FlashArray.(R R&tPOD_API_VERSIONRR(t	list_podsRR*R+R,R(RRt
pod_existsR.tpod_nametpodstpod((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt	check_pod�s
c
C`s�t}d|jdkrLt||�rL|jddj|jd��nd|jdkr�t||�r�|jddj|jd��ng}|j�}|jdr}t|kr}dtt	|jd��ko�d	knrZy7|j
|jd|jd
d|jd�}t}Wqztk
rV|jddj|jd��qzXq�|jdd
j|jd��n^y*|j
|jd|jd
�}t}Wn1tk
r�|jddj|jd��nX|j
d|d|�dS(s
Create VolumeR$RR%s9Failed to create volume {0}. Volume Group does not exist.s::s0Failed to create volume {0}. Poid does not existtqosI�iRtbandwidth_limitsVolume {0} creation failed.sQoS value {0} out of range.tchangedtvolumeN(R RR2R*tformatR9R&tQOS_API_VERSIONRRt
create_volumeRRt	exit_json(RRR<tvolfactR.((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyR@�s.####/


'# 

$cC`s=t}g}t||�}|dkr�y*|j|jd|jd�}t}Wq#tk
r�|jddj|jd|jd��q#Xn�|dk	r#|jdr#y7|j|jd|jdd|jd�}t}Wq#tk
r|jddj|jd|jd��q#Xn|j	d|d|�dS(	sCreate Volume CloneRR"R%s%Copy volume {0} to volume {1} failed.t	overwriteR<R=N(
R R#Rtcopy_volumeRRRR*R>RA(RRR<RBttgt((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pytcopy_from_volumes*




cC`s�t}g}|j�}|j|jd�}t|krv|j|jddt�}|ddkrvd|d<qvn|jdr$t|jd�|dkr$t|jd�|dkr!y*|j|jd|jd�}t}Wqt	k
r|j
ddj|jd��qXq!q$n|jdr�t|kr�t|jd�|dkr�|jddkr�y&|j|jddd	�}t}Wq}t	k
r�|j
dd
j|jd��q}Xq�dt
t|jd��ko�dknr]y-|j|jdd|jd�}t}Wq}t	k
rY|j
dd
j|jd��q}Xq�|j
ddj|jd��q�n|jd|d|�dS(sUpdate Volume size and/or QoSRR:R;iRR%sVolume {0} resize failed.t0RsVolume {0} QoS removal failed.I�isVolume {0} QoS change failed.s0QoS value {0} out of range. Check documentation.R<R=N(R R&RRR?RRRt
extend_volumeRR*R>t
set_volumeRRA(RRR<RBR.tvoltvol_qos((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt
update_volume*sB
 

-

'/

'&cC`s�t}g}y||j|jd�|jdr�y|j|jd�}Wq�tk
r}|jddj|jd��q�Xnt}Wn1tk
r�|jddj|jd��nX|jd|d|�dS(	s Delete VolumeRt	eradicateR%sEradicate volume {0} failed.sDelete volume {0} failed.R<R=N(	R tdestroy_volumeRteradicate_volumeRR*R>RRA(RRR<RB((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt
delete_volumeQs

'

$cC`s�t}g}|jdrny|j|jd�t}Wqntk
rj|jddj|jd��qnXn|jd|d|�dS(s Eradicate Deleted VolumeRMRR%s Eradication of volume {0} failedR<R=N(R RRORRR*R>RA(RRR<RB((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyRObs


'c
C`s�t�}|jtdtdddt�dtdd�dtdddt�d	tdddt�d
tdddddd
dg�dtdd�dtdd���ddgddgg}t|d|dt�}|jd}|jd}|jd
}t|�}t||�}|s0t	||�}nt
||�}	|dkrh|rh|rht||�n|dkr�|r�|s�|r�t||�n�|dkr�|r�|	r�t
||�n�|dkr�|r�|	r�t
||�n�|d
kr	|r	t||�nu|d
kr+|r+t||�nS|dkr>|sE|rX|jdt�n&|d
kr~|r~|jdt�ndS(NRttypetstrtrequiredR"RCtbooltdefaultRMtstatetpresenttchoicestabsentR:Rtmutually_exclusivetsupports_check_modeR<(R
tupdatetdictRR RRR	RR!R#R@RLRFRPRORA(
t
argument_specRZRRR:RVRR=t	destroyedR"((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pytmainosJ	!		


t__main__N(t
__future__RRRRQt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRtansible.module_utils.pureR	R
R?R'R3RRR!R#R2R9R@RFRLRPROR`t__name__(((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt<module>s4


34									'		
	-

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