Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pure Storage FA Host module to allow for mixed protocol hosts #37078

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 35 additions & 19 deletions lib/ansible/modules/storage/purestorage/purefa_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
description:
- Defines the host connection protocol for volumes.
default: iscsi
choices: [ fc, iscsi ]
choices: [ fc, iscsi, mixed ]
wwns:
description:
- List of wwns of the host if protocol is fc.
- List of wwns of the host if protocol is fc or mixed.
iqn:
description:
- List of IQNs of the host if protocol is iscsi.
- List of IQNs of the host if protocol is iscsi or mixed.
volume:
description:
- Volume name to map to the host.
Expand All @@ -63,7 +63,7 @@
api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent

- name: Make sure host bar is available with wwn ports
- name: Make host bar with wwn ports
purefa_host:
host: bar
protocol: fc
Expand All @@ -73,7 +73,7 @@
fa_url: 10.10.10.2
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:
host: bar
protocol: iscsi
Expand All @@ -82,6 +82,18 @@
fa_url: 10.10.10.2
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
purefa_host:
host: foo
Expand All @@ -104,6 +116,15 @@
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):

host = None
Expand All @@ -117,25 +138,20 @@ def get_host(module, array):


def make_host(module, array):

changed = True

if not module.check_mode:
host = array.create_host(module.params['host'])
if module.params['protocol'] == 'iscsi':
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']:
array.connect_host(module.params['host'], module.params['volume'])
try:
host = array.create_host(module.params['host'])
_set_host_initiators(module, array)
if module.params['volume']:
array.connect_host(module.params['host'], module.params['volume'])
changed = True
except:
changed = False
module.exit_json(changed=changed)


def update_host(module, array):
changed = False
host = module.params['host']
module.exit_json(changed=changed)


Expand All @@ -153,7 +169,7 @@ def main():
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']),
protocol=dict(type='str', default='iscsi', choices=['fc', 'iscsi', 'mixed']),
iqn=dict(type='list'),
wwns=dict(type='list'),
volume=dict(type='str'),
Expand Down