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.
This commit is contained in:
Dag Wieers 2017-08-22 02:25:13 +02:00 committed by GitHub
commit 6d015294c2
5 changed files with 173 additions and 232 deletions

View file

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