mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
Update Pure Storage FA Host module to allow for mixed protocol hosts (#37078)
This commit is contained in:
parent
62957c9fc0
commit
f97f81ec2e
1 changed files with 35 additions and 19 deletions
|
@ -35,13 +35,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- Defines the host connection protocol for volumes.
|
- Defines the host connection protocol for volumes.
|
||||||
default: iscsi
|
default: iscsi
|
||||||
choices: [ fc, iscsi ]
|
choices: [ fc, iscsi, mixed ]
|
||||||
wwns:
|
wwns:
|
||||||
description:
|
description:
|
||||||
- List of wwns of the host if protocol is fc.
|
- List of wwns of the host if protocol is fc or mixed.
|
||||||
iqn:
|
iqn:
|
||||||
description:
|
description:
|
||||||
- List of IQNs of the host if protocol is iscsi.
|
- List of IQNs of the host if protocol is iscsi or mixed.
|
||||||
volume:
|
volume:
|
||||||
description:
|
description:
|
||||||
- Volume name to map to the host.
|
- Volume name to map to the host.
|
||||||
|
@ -63,7 +63,7 @@ EXAMPLES = r'''
|
||||||
api_token: e31060a7-21fc-e277-6240-25983c6c4592
|
api_token: e31060a7-21fc-e277-6240-25983c6c4592
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Make sure host bar is available with wwn ports
|
- name: Make host bar with wwn ports
|
||||||
purefa_host:
|
purefa_host:
|
||||||
host: bar
|
host: bar
|
||||||
protocol: fc
|
protocol: fc
|
||||||
|
@ -73,7 +73,7 @@ EXAMPLES = r'''
|
||||||
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: Make sure host bar is available with iSCSI ports
|
- name: Make host bar with iSCSI ports
|
||||||
purefa_host:
|
purefa_host:
|
||||||
host: bar
|
host: bar
|
||||||
protocol: iscsi
|
protocol: iscsi
|
||||||
|
@ -82,6 +82,18 @@ EXAMPLES = r'''
|
||||||
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: Make mixed protocol host
|
||||||
|
purefa_host:
|
||||||
|
host: bar
|
||||||
|
protocol: mixed
|
||||||
|
iqn:
|
||||||
|
- iqn.1994-05.com.redhat:7d366003914
|
||||||
|
wwns:
|
||||||
|
- 00:00:00:00:00:00:01
|
||||||
|
- 11:11:11:11:11:11:12
|
||||||
|
fa_url: 10.10.10.2
|
||||||
|
api_token: e31060a7-21fc-e277-6240-25983c6c4592
|
||||||
|
|
||||||
- name: Map host foo to volume bar
|
- name: Map host foo to volume bar
|
||||||
purefa_host:
|
purefa_host:
|
||||||
host: foo
|
host: foo
|
||||||
|
@ -104,6 +116,15 @@ except ImportError:
|
||||||
HAS_PURESTORAGE = False
|
HAS_PURESTORAGE = False
|
||||||
|
|
||||||
|
|
||||||
|
def _set_host_initiators(module, array):
|
||||||
|
if module.params['protocol'] in ['iscsi', 'mixed']:
|
||||||
|
if module.params['iqn']:
|
||||||
|
array.set_host(module.params['host'], addiqnlist=module.params['iqn'])
|
||||||
|
if module.params['protocol'] in ['fc', 'mixed']:
|
||||||
|
if module.params['wwns']:
|
||||||
|
array.set_host(module.params['host'], addwwnlist=module.params['wwns'])
|
||||||
|
|
||||||
|
|
||||||
def get_host(module, array):
|
def get_host(module, array):
|
||||||
|
|
||||||
host = None
|
host = None
|
||||||
|
@ -117,25 +138,20 @@ def get_host(module, array):
|
||||||
|
|
||||||
|
|
||||||
def make_host(module, array):
|
def make_host(module, array):
|
||||||
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
|
try:
|
||||||
host = array.create_host(module.params['host'])
|
host = array.create_host(module.params['host'])
|
||||||
if module.params['protocol'] == 'iscsi':
|
_set_host_initiators(module, array)
|
||||||
if module.params['iqn']:
|
|
||||||
array.set_host(module.params['host'], addiqnlist=module.params['iqn'])
|
|
||||||
if module.params['protocol'] == 'fc':
|
|
||||||
if module.params['wwns']:
|
|
||||||
array.set_host(module.params['host'], addwwnlist=module.params['wwns'])
|
|
||||||
if module.params['volume']:
|
if module.params['volume']:
|
||||||
array.connect_host(module.params['host'], module.params['volume'])
|
array.connect_host(module.params['host'], module.params['volume'])
|
||||||
|
changed = True
|
||||||
|
except:
|
||||||
|
changed = False
|
||||||
module.exit_json(changed=changed)
|
module.exit_json(changed=changed)
|
||||||
|
|
||||||
|
|
||||||
def update_host(module, array):
|
def update_host(module, array):
|
||||||
changed = False
|
changed = False
|
||||||
host = module.params['host']
|
|
||||||
module.exit_json(changed=changed)
|
module.exit_json(changed=changed)
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +169,7 @@ def main():
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
host=dict(type='str', required=True),
|
host=dict(type='str', required=True),
|
||||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||||
protocol=dict(type='str', default='iscsi', choices=['fc', 'iscsi']),
|
protocol=dict(type='str', default='iscsi', choices=['fc', 'iscsi', 'mixed']),
|
||||||
iqn=dict(type='list'),
|
iqn=dict(type='list'),
|
||||||
wwns=dict(type='list'),
|
wwns=dict(type='list'),
|
||||||
volume=dict(type='str'),
|
volume=dict(type='str'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue