aix_lvol: PEP8, imports, cosmetics (#24717)

- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
This commit is contained in:
Dag Wieers 2017-05-18 09:31:07 +02:00 committed by John R Barker
parent 400991f635
commit 7a5e46c732

View file

@ -22,10 +22,10 @@ ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.0'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
author:
- "Alain Dejoux (@adejoux)"
- Alain Dejoux (@adejoux)
module: aix_lvol
short_description: Configure AIX LVM logical volumes
description:
@ -42,83 +42,84 @@ options:
required: true
lv_type:
description:
- The type of the logical volume. Default to jfs2.
- The type of the logical volume.
default: jfs2
size:
description:
- The size of the logical volume with one of the [MGT] units.
copies:
description:
- the number of copies of the logical volume. By default, 1 copy. Maximum copies are 3.
- The number of copies of the logical volume. Maximum copies are 3.
default: '1'
policy:
choices: [ "maximum", "minimum" ]
choices: [ maximum, minimum ]
default: maximum
description:
- Sets the interphysical volume allocation policy. "maximum" allocates logical partitions across the maximum number of physical volumes.
"minimum" allocates logical partitions across the minimum number of physical volumes.
- 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.
state:
choices: [ "present", "absent" ]
choices: [ absent, present ]
default: present
description:
- Control if the logical volume exists. If C(present) and the
volume does not already exist then the C(size) option is required.
opts:
description:
- Free-form options to be passed to the mklv command
- Free-form options to be passed to the mklv command.
pvs:
description:
- Comma separated list of physical volumes e.g. hdisk1,hdisk2
- Comma separated list of physical volumes e.g. C(hdisk1,hdisk2).
'''
EXAMPLES = '''
# Create a logical volume of 512M.
- aix_lvol:
EXAMPLES = r'''
- name: Create a logical volume of 512M
aix_lvol:
vg: testvg
lv: testlv
size: 512M
# Create a logical volume of 512M with disks hdisk1 and hdisk2
- aix_lvol:
- name: Create a logical volume of 512M with disks hdisk1 and hdisk2
aix_lvol:
vg: testvg
lv: test2lv
size: 512M
pvs: hdisk1,hdisk2
# Create a logical volume of 512M mirrored.
- aix_lvol:
- name: Create a logical volume of 512M mirrored
aix_lvol:
vg: testvg
lv: test3lv
size: 512M
copies: 2
# Create a logical volume of 1G with a minimum placement policy .
- aix_lvol:
- name: Create a logical volume of 1G with a minimum placement policy
aix_lvol:
vg: rootvg
lv: test4lv
size: 1G
policy: minimum
# Create a logical volume with special options like mirror pool
- aix_lvol:
- 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
# Extend the logical volume to 1200M.
- aix_lvol:
- name: Extend the logical volume to 1200M
aix_lvol:
vg: testvg
lv: test4lv
size: 1200M
# Remove the logical volume.
- aix_lvol:
- name: Remove the logical volume
aix_lvol:
vg: testvg
lv: testlv
state: absent
'''
RETURN = '''
RETURN = r'''
msg:
type: string
description: A friendly message describing the task result.
@ -126,15 +127,16 @@ msg:
sample: Logical volume testlv created.
'''
from ansible.module_utils.basic import AnsibleModule
import re
from ansible.module_utils.basic import AnsibleModule
def convert_size(module, size):
unit = size[-1].upper()
units = ['M', 'G', 'T']
try:
multiplier = 1024**units.index(unit)
multiplier = 1024 ** units.index(unit)
except ValueError:
module.fail_json(msg="No valid size unit specified.")
@ -208,14 +210,14 @@ def parse_vg(data):
def main():
module = AnsibleModule(
argument_spec=dict(
vg=dict(required=True, type='str'),
lv=dict(required=True, type='str'),
lv_type=dict(default='jfs2', type='str'),
vg=dict(type='str', required=True),
lv=dict(type='str', required=True),
lv_type=dict(type='str', default='jfs2'),
size=dict(type='str'),
opts=dict(default='', type='str'),
copies=dict(default='1', type='str'),
state=dict(choices=["absent", "present"], default='present'),
policy=dict(choices=["maximum", "minimum"], default='maximum'),
opts=dict(type='str', default=''),
copies=dict(type='str', default='1'),
state=dict(type='str', default='present', choices=['absent', 'present']),
policy=dict(type='str', default='maximum', choices=['maximum', 'minimum']),
pvs=dict(type='list', default=list())
),
supports_check_mode=True,