purestorage: Various changes, and one check-mode fix (#28485)

These were the changes I propose twice, a nullified PR edit, and then as
review comments when the PR was being merged.

I made those changes now to all purestorage modules.
pull/25986/merge
Dag Wieers 7 years ago committed by GitHub
parent b150f49187
commit 6d015294c2

@ -2,74 +2,58 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2017, Simon Dodsley (simon@purestorage.com) # (c) 2017, Simon Dodsley (simon@purestorage.com)
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
# from __future__ import absolute_import, division, print_function
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = r'''
DOCUMENTATION = '''
--- ---
module: purefa_hg module: purefa_hg
version_added: "2.4" version_added: '2.4'
short_description: Create, Delete and Modify hostgroups on Pure Storage FlashArray short_description: Manage hostgroups on Pure Storage FlashArrays
description: description:
- This module creates, deletes or modifies hostgroups on Pure Storage FlashArray. - Create, delete or modifiy hostgroups on Pure Storage FlashArrays.
author: Simon Dodsley (@sdodsley) author:
- Simon Dodsley (@sdodsley)
options: options:
hostgroup: hostgroup:
description: description:
- Host Name. - The name of the hostgroup.
required: true required: true
state: state:
description: description:
- Creates or modifies hostgroup. - Define whether the hostgroup should exist or not.
required: false
default: present default: present
choices: [ "present", "absent" ] choices: [ absent, present ]
host: host:
description: description:
- List of existing hosts to add to hostgroup. - List of existing hosts to add to hostgroup.
required: false
volume: volume:
description: description:
- List of existing volumes to add to hostgroup. - List of existing volumes to add to hostgroup.
required: false
extends_documentation_fragment: extends_documentation_fragment:
- purestorage - purestorage
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Create new hostgroup - name: Create new hostgroup
purefa_hg: purefa_hg:
hostgroup: foo hostgroup: foo
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Delete hostgroup - this will disconnect all hosts and volume in the hostgroup # This will disconnect all hosts and volumes in the hostgroup
- name: Delete hostgroup
purefa_hg: purefa_hg:
hostgroup: foo hostgroup: foo
state: absent
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
- name: Create host group with hosts and volumes - name: Create host group with hosts and volumes
purefa_hg: purefa_hg:
@ -84,16 +68,16 @@ EXAMPLES = '''
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
''' '''
RETURN = ''' RETURN = r'''
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pure import get_system, purefa_argument_spec from ansible.module_utils.pure import get_system, purefa_argument_spec
HAS_PURESTORAGE = True
try: try:
from purestorage import purestorage from purestorage import purestorage
HAS_PURESTORAGE = True
except ImportError: except ImportError:
HAS_PURESTORAGE = False HAS_PURESTORAGE = False
@ -143,14 +127,12 @@ def delete_hostgroup(module, array):
def main(): def main():
argument_spec = purefa_argument_spec() argument_spec = purefa_argument_spec()
argument_spec.update( argument_spec.update(dict(
dict( hostgroup=dict(type='str', required=True),
hostgroup=dict(required=True), state=dict(type='str', default='present', choices=['absent', 'present']),
state=dict(default='present', choices=['present', 'absent']),
host=dict(type='list'), host=dict(type='list'),
volume=dict(type='list'), volume=dict(type='list'),
) ))
)
module = AnsibleModule(argument_spec, supports_check_mode=True) module = AnsibleModule(argument_spec, supports_check_mode=True)

@ -7,55 +7,49 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = r'''
DOCUMENTATION = '''
--- ---
module: purefa_host module: purefa_host
version_added: "2.4" version_added: '2.4'
short_description: Create, Delete and Modify Hosts on Pure Storage FlashArray short_description: Manage hosts on Pure Storage FlashArrays
description: description:
- This module creates, deletes or modifies hosts on Pure Storage FlashArray. - Create, delete or modify hosts on Pure Storage FlashArrays.
author: Simon Dodsley (@sdodsley) author:
- Simon Dodsley (@sdodsley)
options: options:
host: host:
description: description:
- Host Name - The name of the host.
required: true required: true
state: state:
description: description:
- Creates host. - Define whether the host should exist or not.
- When removing host all connected volumes will be disconnected. - When removing host all connected volumes will be disconnected.
required: false
default: present default: present
choices: [ "present", "absent" ] choices: [ absent, present ]
protocol: protocol:
description: description:
- Defines the host connection protocol for volumes. - Defines the host connection protocol for volumes.
required: false
default: iscsi default: iscsi
choices: [ "iscsi", "fc" ] choices: [ fc, iscsi ]
wwns: wwns:
description: description:
- List of wwns of the host if protocol is fc - List of wwns of the host if protocol is fc.
required: false
iqn: iqn:
description: description:
- List of IQNs of the host if protocol is iscsi - List of IQNs of the host if protocol is iscsi.
required: false
volume: volume:
description: description:
- Volume name to map to the host - Volume name to map to the host.
required: false
extends_documentation_fragment: extends_documentation_fragment:
- purestorage - purestorage
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Create new new host - name: Create new new host
purefa_host: purefa_host:
host: foo host: foo
@ -65,17 +59,17 @@ EXAMPLES = '''
- name: Delete host - name: Delete host
purefa_host: purefa_host:
host: foo host: foo
state: absent
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
- name: Make sure host bar is available with wwn ports - name: Make sure host bar is available with wwn ports
purefa_host: purefa_host:
host: bar host: bar
protocol: fc protocol: fc
wwns: wwns:
- "00:00:00:00:00:00:00" - 00:00:00:00:00:00:00
- "11:11:11:11:11:11:11" - 11:11:11:11:11:11:11
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
@ -84,7 +78,7 @@ EXAMPLES = '''
host: bar host: bar
protocol: iscsi protocol: iscsi
iqn: iqn:
- "iqn.1994-05.com.redhat:7d366003913" - iqn.1994-05.com.redhat:7d366003913
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
@ -96,16 +90,16 @@ EXAMPLES = '''
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
''' '''
RETURN = ''' RETURN = r'''
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pure import get_system, purefa_argument_spec from ansible.module_utils.pure import get_system, purefa_argument_spec
HAS_PURESTORAGE = True
try: try:
from purestorage import purestorage from purestorage import purestorage
HAS_PURESTORAGE = True
except ImportError: except ImportError:
HAS_PURESTORAGE = False HAS_PURESTORAGE = False
@ -156,16 +150,14 @@ def delete_host(module, array):
def main(): def main():
argument_spec = purefa_argument_spec() argument_spec = purefa_argument_spec()
argument_spec.update( argument_spec.update(dict(
dict( host=dict(type='str', required=True),
host=dict(required=True), state=dict(type='str', default='present', choices=['absent,' 'present']),
state=dict(default='present', choices=['present', 'absent']), protocol=dict(type='str', default='iscsi', choices=['fc', 'iscsi']),
protocol=dict(default='iscsi', choices=['iscsi', 'fc']),
iqn=dict(type='list'), iqn=dict(type='list'),
wwns=dict(type='list'), wwns=dict(type='list'),
volume=dict() volume=dict(type='str'),
) ))
)
module = AnsibleModule(argument_spec, supports_check_mode=True) module = AnsibleModule(argument_spec, supports_check_mode=True)

@ -2,73 +2,53 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2017, Simon Dodsley (simon@purestorage.com) # (c) 2017, Simon Dodsley (simon@purestorage.com)
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = r'''
DOCUMENTATION = '''
--- ---
module: purefa_pg module: purefa_pg
version_added: "2.4" version_added: '2.4'
short_description: Create, Delete and Modify Protection Groups on Pure Storage FlashArray short_description: Manage protection groups on Pure Storage FlashArrays
description: description:
- This module creates, deletes or modifies protection groups on Pure Storage FlashArray. - Create, delete or modify protection groups on Pure Storage FlashArrays.
author: Simon Dodsley (@sdodsley) author:
- Simon Dodsley (@sdodsley)
options: options:
pgroup: pgroup:
description: description:
- Host Name - The name of the protection group.
required: true required: true
state: state:
description: description:
- Creates or modifies protection group. - Define whether the protection group should exist or not.
required: false
default: present default: present
choices: [ "present", "absent" ] choices: [ absent, present ]
volume: volume:
description: description:
- List of existing volumes to add to protection group. - List of existing volumes to add to protection group.
required: false
host: host:
description: description:
- List of existing hosts to add to protection group. - List of existing hosts to add to protection group.
required: false
hostgroup: hostgroup:
description: description:
- List of existing hostgroups to add to protection group. - List of existing hostgroups to add to protection group.
required: false
eradicate: eradicate:
description: description:
- Define whether to eradicate the protection group on delete and leave in trash. - Define whether to eradicate the protection group on delete and leave in trash.
required: false
type : bool type : bool
default: false default: 'no'
extends_documentation_fragment: extends_documentation_fragment:
- purestorage - purestorage
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Create new protection group - name: Create new protection group
purefa_pg: purefa_pg:
pgroup: foo pgroup: foo
@ -78,10 +58,10 @@ EXAMPLES = '''
- name: Delete protection group - name: Delete protection group
purefa_pg: purefa_pg:
pgroup: foo pgroup: foo
state: absent
eradicate: true eradicate: true
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
- name: Create protection group for hostgroups - name: Create protection group for hostgroups
purefa_pg: purefa_pg:
@ -111,16 +91,16 @@ EXAMPLES = '''
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
''' '''
RETURN = ''' RETURN = r'''
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pure import get_system, purefa_argument_spec from ansible.module_utils.pure import get_system, purefa_argument_spec
HAS_PURESTORAGE = True
try: try:
from purestorage import purestorage from purestorage import purestorage
HAS_PURESTORAGE = True
except ImportError: except ImportError:
HAS_PURESTORAGE = False HAS_PURESTORAGE = False
@ -169,16 +149,14 @@ def delete_pgroup(module, array):
def main(): def main():
argument_spec = purefa_argument_spec() argument_spec = purefa_argument_spec()
argument_spec.update( argument_spec.update(dict(
dict( pgroup=dict(type='str', required=True),
pgroup=dict(required=True), state=dict(type='str', default='present', choices=['absent', 'present']),
state=dict(default='present', choices=['present', 'absent']),
volume=dict(type='list'), volume=dict(type='list'),
host=dict(type='list'), host=dict(type='list'),
hostgroup=dict(type='list'), hostgroup=dict(type='list'),
eradicate=dict(default='false', type='bool'), eradicate=dict(type='bool', default=False),
) ))
)
module = AnsibleModule(argument_spec, supports_check_mode=True) module = AnsibleModule(argument_spec, supports_check_mode=True)

@ -1,98 +1,94 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2017, Simon Dodsley (simon@purestorage.com) # (c) 2017, Simon Dodsley (simon@purestorage.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = r'''
DOCUMENTATION = '''
--- ---
module: purefa_snap module: purefa_snap
version_added: 2.4 version_added: '2.4'
short_description: Create or Delete volume snapshots on Pure Storage FlashArray short_description: Manage volume snapshots on Pure Storage FlashArrays
description: description:
- This module creates or deletes volume snapshots and creates volumes from snapshots on Pure Storage FlashArray. - Create or delete volumes and volume snapshots on Pure Storage FlashArray.
author: Simon Dodsley (@sdodsley) author:
- Simon Dodsley (@sdodsley)
options: options:
name: name:
description: description:
- Source volume name of snapshot - The name of the source volume.
required: true required: true
suffix: suffix:
description: description:
- Suffix of snapshot name - Suffix of snapshot name.
required: false
target: target:
description: description:
- Name of target volume if creating from snapshot - Name of target volume if creating from snapshot.
required: false
overwrite: overwrite:
description: description:
- Define whether to overwrite existing volume when creating from snapshot - Define whether to overwrite existing volume when creating from snapshot.
required: false
default: false
type: bool type: bool
default: 'no'
state: state:
description: description:
- Create or delete volume snapshot - Define whether the volume snapshot should exist or not.
required: false choices: [ absent, copy, present ]
default: present default: present
choices: [ "present", "absent", "copy" ]
eradicate: eradicate:
description: description:
- Define whether to eradicate the snapshot on delete or leave in trash - Define whether to eradicate the snapshot on delete or leave in trash.
required: false
default: false
type: bool type: bool
default: 'no'
extends_documentation_fragment: extends_documentation_fragment:
- purestorage - purestorage
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Create snapshot foo.ansible - name: Create snapshot foo.ansible
purefa_snap: purefa_snap:
name: foo name: foo
suffix: ansible suffix: ansible
state: present
fa_url: 10.10.10.2 fa_url: 10.10.10.2
fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592 fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: present
- name: Create R/W clone foo_clone from snapshot foo.snap - name: Create R/W clone foo_clone from snapshot foo.snap
purefa_snap: purefa_snap:
name: foo name: foo
suffix: snap suffix: snap
target: foo_clone target: foo_clone
state: copy
fa_url: 10.10.10.2 fa_url: 10.10.10.2
fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592 fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: copy
- name: Overwrite existing volume foo_clone with snapshot foo.snap - name: Overwrite existing volume foo_clone with snapshot foo.snap
purefa_snap: purefa_snap:
name: foo name: foo
suffix: snap suffix: snap
target: foo_clone target: foo_clone
state: copy
overwrite: true overwrite: true
fa_url: 10.10.10.2 fa_url: 10.10.10.2
fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592 fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: copy
- name: Delete and eradicate snapshot named foo.snap - name: Delete and eradicate snapshot named foo.snap
purefa_snap: purefa_snap:
name: foo name: foo
suffix: snap suffix: snap
eradicate: true eradicate: true
state: absent
fa_url: 10.10.10.2 fa_url: 10.10.10.2
fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592''' fa_api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
'''
RETURN = ''' RETURN = r'''
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
@ -100,9 +96,9 @@ from ansible.module_utils.pure import get_system, purefa_argument_spec
from datetime import datetime from datetime import datetime
HAS_PURESTORAGE = True
try: try:
from purestorage import purestorage from purestorage import purestorage
HAS_PURESTORAGE = True
except ImportError: except ImportError:
HAS_PURESTORAGE = False HAS_PURESTORAGE = False
@ -144,15 +140,16 @@ def create_snapshot(module, array):
def create_from_snapshot(module, array): def create_from_snapshot(module, array):
"""Create Volume from Snapshot""" """Create Volume from Snapshot"""
if not module.check_mode:
source = module.params['name'] + "." + module.params['suffix'] source = module.params['name'] + "." + module.params['suffix']
tgt = get_target(module, array) tgt = get_target(module, array)
if tgt is None: if tgt is None:
changed = True changed = True
if not module.check_mode:
array.copy_volume(source, array.copy_volume(source,
module.params['target']) module.params['target'])
elif tgt is not None and module.params['overwrite']: elif tgt is not None and module.params['overwrite']:
changed = True changed = True
if not module.check_mode:
array.copy_volume(source, array.copy_volume(source,
module.params['target'], module.params['target'],
overwrite=module.params['overwrite']) overwrite=module.params['overwrite'])
@ -179,16 +176,14 @@ def delete_snapshot(module, array):
def main(): def main():
argument_spec = purefa_argument_spec() argument_spec = purefa_argument_spec()
argument_spec.update( argument_spec.update(dict(
dict( name=dict(type='str', required=True),
name=dict(required=True), suffix=dict(type='str'),
suffix=dict(), target=dict(type='str'),
target=dict(), overwrite=dict(type='bool', default=False),
overwrite=dict(default='false', type='bool'), eradicate=dict(type='bool', default=False),
eradicate=dict(default='false', type='bool'), state=dict(type='str', default='present', choices=['absent', 'copy', 'present']),
state=dict(default='present', choices=['present', 'absent', 'copy']), ))
)
)
required_if = [('state', 'copy', ['target', 'suffix'])] required_if = [('state', 'copy', ['target', 'suffix'])]
@ -202,6 +197,7 @@ def main():
if module.params['suffix'] is None: if module.params['suffix'] is None:
suffix = "snap-" + str((datetime.utcnow() - datetime(1970, 1, 1, 0, 0, 0, 0)).total_seconds()) suffix = "snap-" + str((datetime.utcnow() - datetime(1970, 1, 1, 0, 0, 0, 0)).total_seconds())
module.params['suffix'] = suffix.replace(".", "") module.params['suffix'] = suffix.replace(".", "")
state = module.params['state'] state = module.params['state']
array = get_system(module) array = get_system(module)
volume = get_volume(module, array) volume = get_volume(module, array)

@ -7,103 +7,98 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = r'''
DOCUMENTATION = '''
--- ---
module: purefa_volume module: purefa_volume
version_added: "2.4" version_added: '2.4'
short_description: Create, Delete, Copy or Extend a volume on Pure Storage FlashArray short_description: Manage volumes on Pure Storage FlashArrays
description: description:
- This module creates, deletes or extends the capacity of a volume on Pure Storage FlashArray. - Create, delete or extend the capacity of a volume on Pure Storage FlashArray.
author: Simon Dodsley (@sdodsley) author:
- Simon Dodsley (@sdodsley)
options: options:
name: name:
description: description:
- Volume Name. - The name of the volume.
required: true required: true
target: target:
description: description:
- Target Volume Name if copying. - The name of the target volume, if copying.
required: false
state: state:
description: description:
- Create, delete, copy or extend capacity of a volume. - Define whether the volume should exist or not.
required: false
default: present default: present
choices: [ "present", "absent" ] choices: [ absent, present ]
eradicate: eradicate:
description: description:
- Define whether to eradicate the volume on delete or leave in trash. - Define whether to eradicate the volume on delete or leave in trash.
required: false
type: bool type: bool
default: false default: 'no'
overwrite: overwrite:
description: description:
- Define whether to overwrite a target volume if it already exisits. - Define whether to overwrite a target volume if it already exisits.
required: false
type: bool type: bool
default: false default: 'no'
size: size:
description: description:
- Volume size in M, G, T or P units. See examples. - Volume size in M, G, T or P units.
required: false
extends_documentation_fragment: extends_documentation_fragment:
- purestorage - purestorage
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Create new volume named foo - name: Create new volume named foo
purefa_volume: purefa_volume:
name: foo name: foo
size: 1T size: 1T
state: present
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: present
- name: Extend the size of an existing volume named foo - name: Extend the size of an existing volume named foo
purefa_volume: purefa_volume:
name: foo name: foo
size: 2T size: 2T
state: present
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: present
- name: Delete and eradicate volume named foo - name: Delete and eradicate volume named foo
purefa_volume: purefa_volume:
name: foo name: foo
eradicate: true eradicate: yes
state: absent
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
- name: Create clone of volume bar named foo - name: Create clone of volume bar named foo
purefa_volume: purefa_volume:
name: foo name: foo
target: bar target: bar
state: present
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592 api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: present
- name: Overwrite volume bar with volume foo - name: Overwrite volume bar with volume foo
purefa_volume: purefa_volume:
name: foo name: foo
target: bar target: bar
overwrite: true overwrite: yes
state: present
fa_url: 10.10.10.2 fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592''' api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: present
'''
RETURN = ''' RETURN = r'''
''' '''
HAS_PURESTORAGE = True
try: try:
from purestorage import purestorage from purestorage import purestorage
HAS_PURESTORAGE = True
except ImportError: except ImportError:
HAS_PURESTORAGE = False HAS_PURESTORAGE = False
@ -184,9 +179,9 @@ def copy_from_volume(module, array):
def update_volume(module, array): def update_volume(module, array):
"""Update Volume""" """Update Volume"""
changed = True changed = True
if not module.check_mode:
vol = array.get_volume(module.params['name']) vol = array.get_volume(module.params['name'])
if human_to_bytes(module.params['size']) > vol['size']: if human_to_bytes(module.params['size']) > vol['size']:
if not module.check_mode:
array.extend_volume(module.params['name'], module.params['size']) array.extend_volume(module.params['name'], module.params['size'])
else: else:
changed = False changed = False
@ -204,16 +199,14 @@ def delete_volume(module, array):
def main(): def main():
argument_spec = purefa_argument_spec() argument_spec = purefa_argument_spec()
argument_spec.update( argument_spec.update(dict(
dict( name=dict(type='str', required=True),
name=dict(required=True), target=dict(type='str'),
target=dict(), overwrite=dict(type='bool', default=False),
overwrite=dict(default=False, type='bool'), eradicate=dict(type='bool', default=False),
eradicate=dict(default=False, type='bool'), state=dict(type='str', default='present', choices=['absent', 'present']),
state=dict(default='present', choices=['present', 'absent']), size=dict(type='str'),
size=dict() ))
)
)
mutually_exclusive = [['size', 'target']] mutually_exclusive = [['size', 'target']]

Loading…
Cancel
Save