�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z d
Z d Z d Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z e d k re � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust 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_systemt purefa_argument_specs 1.14s 1.13c C` s� | d } | d } | j � r� t | � } | d k rE | d 9} q� | d k r^ | d 9} q� | d k rw | d 9} q� | d k r� | d 9} q� d
} n d
} | 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����t PI t TI t Gi @t Mi i ( t isdigitt int( t sizet bytest unit( ( sU /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt human_to_bytes� s
c C` s1 y | j | j d � SWn t k
r, d SXd S( s Return Volume or Nonet nameN( t
get_volumet paramst Exceptiont None( t modulet array( ( sU /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyR � s
c C` sK y2 | j | j d d t �d d k r- t St SWn t k
rF t SXd S( s Return Destroyed Volume or NoneR t pendingt time_remainingt N( R R t Truet FalseR ( R R ( ( sU /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt get_destroyed_volume� s &
c C` s1 y | j | j d � SWn t k
r, d SXd S( s Return Volume or Nonet targetN( R R R R ( R R ( ( sU /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt
get_target� s
c C` s� t } | j � } t | k r� | j d j d � d } y | j � } Wn! t k
rk | j d d � n XxN t d t | � � D]$ } | | | d k r� t
} Pq� q� Wn | j d d � | S( s4 Check is the requested VG to create volume in existsR t /i t msgs. Failed to get volume groups list. Check array.s= VG volumes are not supported. Please upgrade your FlashArray.( R t _list_available_rest_versionst VGROUPS_API_VERSIONR t splitt list_vgroupsR t fail_jsont ranget lenR ( R R t vg_existst api_versiont vg_namet vgst vgroup( ( sU /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_volume.pyt check_vgroup� s
c C` s� t } | j � } t | k r� | j d j d � d } y | j � } Wn! t k
rk | j d d � n XxN t d t | � � D]$ } | | | d k r� t
} Pq� q� Wn | j d d � | S( s5 Check is the requested pod to create volume in existsR s ::i R% s$ Failed to get pod list. Check array.s>