�
�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
Z
d d l m Z d
� Z
d d � Z d � Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys
---
author:
- Alain Dejoux (@adejoux)
module: aix_lvol
short_description: Configure AIX LVM logical volumes
description:
- This module creates, removes or resizes AIX logical volumes. Inspired by lvol module.
version_added: "2.4"
options:
vg:
description:
- The volume group this logical volume is part of.
type: str
required: true
lv:
description:
- The name of the logical volume.
type: str
required: true
lv_type:
description:
- The type of the logical volume.
type: str
default: jfs2
size:
description:
- The size of the logical volume with one of the [MGT] units.
type: str
copies:
description:
- The number of copies of the logical volume.
- Maximum copies are 3.
type: int
default: 1
policy:
description:
- Sets the interphysical volume allocation policy.
- C(maximum) allocates logical partitions across the maximum number of physical volumes.
- C(minimum) allocates logical partitions across the minimum number of physical volumes.
type: str
choices: [ maximum, minimum ]
default: maximum
state:
description:
- Control if the logical volume exists. If C(present) and the
volume does not already exist then the C(size) option is required.
type: str
choices: [ absent, present ]
default: present
opts:
description:
- Free-form options to be passed to the mklv command.
type: str
pvs:
description:
- A list of physical volumes e.g. C(hdisk1,hdisk2).
type: list
sy
- name: Create a logical volume of 512M
aix_lvol:
vg: testvg
lv: testlv
size: 512M
- name: Create a logical volume of 512M with disks hdisk1 and hdisk2
aix_lvol:
vg: testvg
lv: test2lv
size: 512M
pvs: [ hdisk1, hdisk2 ]
- name: Create a logical volume of 512M mirrored
aix_lvol:
vg: testvg
lv: test3lv
size: 512M
copies: 2
- name: Create a logical volume of 1G with a minimum placement policy
aix_lvol:
vg: rootvg
lv: test4lv
size: 1G
policy: minimum
- name: Create a logical volume with special options like mirror pool
aix_lvol:
vg: testvg
lv: testlv
size: 512M
opts: -p copy1=poolA -p copy2=poolB
- name: Extend the logical volume to 1200M
aix_lvol:
vg: testvg
lv: test4lv
size: 1200M
- name: Remove the logical volume
aix_lvol:
vg: testvg
lv: testlv
state: absent
s�
msg:
type: str
description: A friendly message describing the task result.
returned: always
sample: Logical volume testlv created.
N( t
AnsibleModulec C` sl | d j � } d d d g } y d | j | � } Wn! t k
rY | j d d � n Xt | d � | S( Ni����t Mt Gt Ti t msgs No valid size unit specified.( t uppert indext
ValueErrort fail_jsont int( t modulet sizet unitt unitst
multiplier( ( sC /usr/lib/python2.7/site-packages/ansible/modules/system/aix_lvol.pyt convert_size� s
i c C` s= t | t t | � | � � } | | k r9 | | 7} n | S( N( R t roundt float( t xt baset new_size( ( sC /usr/lib/python2.7/site-packages/ansible/modules/system/aix_lvol.pyt round_ppsize� s
c C` s8 d } x� | j � D]� } t j d | � } | d k r[ | j d � } | j d � } q n t j d | � } | d k r� t | j d � � } q n t j d | � } | d k r� t | j d � � } q n t j d | � } | d k r | j d � } q q q W| sd S| | } i | d 6| d 6| d 6| d
6S( Ns/ LOGICAL VOLUME:\s+(\w+)\s+VOLUME GROUP:\s+(\w+)i i s LPs:\s+(\d+).*PPss PP SIZE:\s+(\d+)s INTER-POLICY:\s+(\w+)t namet vgR t policy( t Nonet
splitlinest ret searcht groupR ( t dataR t linet matchR t lpst pp_sizeR R ( ( sC /usr/lib/python2.7/site-packages/ansible/modules/system/aix_lvol.pyt parse_lv� s.
c C` s x� | j � D]� } t j d | � } | d k rF | j d � } q
n t j d | � } | d k r t | j d � � } q
n t j d | � } | d k r� t | j d � � } q
n t j d | � } | d k r
t | j d � � } q
q
q
Wi | d 6| d 6| d 6| d 6S(
Ns VOLUME GROUP:\s+(\w+)i s TOTAL PP.*\((\d+)s PP SIZE:\s+(\d+)s FREE PP.*\((\d+)R R t freeR* ( R"