From 8a4c8ae20a8b4a7a359f9d127df762ae7e1cba01 Mon Sep 17 00:00:00 2001 From: Simon Dodsley Date: Tue, 24 Sep 2019 15:11:15 -0400 Subject: [PATCH] Add checks for Cloud Block Store (#62068) --- .../fragments/62068-add-pure-cbs-support.yml | 3 +++ .../modules/storage/purestorage/purefa_host.py | 16 ++++++++++++++++ .../modules/storage/purestorage/purefa_info.py | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/62068-add-pure-cbs-support.yml diff --git a/changelogs/fragments/62068-add-pure-cbs-support.yml b/changelogs/fragments/62068-add-pure-cbs-support.yml new file mode 100644 index 0000000000..a0012bb601 --- /dev/null +++ b/changelogs/fragments/62068-add-pure-cbs-support.yml @@ -0,0 +1,3 @@ +bugfixes: +- purefa_info - Add support for Cloud Block Store (https://github.com/ansible/ansible/pull/62068) +- purefa_host - Add support for Cloud Block Store (https://github.com/ansible/ansible/pull/62068) diff --git a/lib/ansible/modules/storage/purestorage/purefa_host.py b/lib/ansible/modules/storage/purestorage/purefa_host.py index a24ee27d00..3b0e471633 100644 --- a/lib/ansible/modules/storage/purestorage/purefa_host.py +++ b/lib/ansible/modules/storage/purestorage/purefa_host.py @@ -177,6 +177,20 @@ PREFERRED_ARRAY_API_VERSION = '1.15' NVME_API_VERSION = '1.16' +def _is_cbs(module, array, is_cbs=False): + """Is the selected array a Cloud Block Store""" + model = '' + ct0_model = array.get_hardware('CT0')['model'] + if ct0_model: + model = ct0_model + else: + ct1_model = array.get_hardware('CT1')['model'] + model = ct1_model + if 'CBS' in model: + is_cbs = True + return is_cbs + + def _set_host_initiators(module, array): """Set host initiators.""" if module.params['protocol'] in ['nvme', 'mixed']: @@ -417,6 +431,8 @@ def main(): module = AnsibleModule(argument_spec, supports_check_mode=True) array = get_system(module) + if _is_cbs(module, array) and module.params['wwns'] or module.params['nqn']: + module.fail_json(msg='Cloud block Store only support iSCSI as a protocol') api_version = array._list_available_rest_versions() if module.params['nqn'] is not None and NVME_API_VERSION not in api_version: module.fail_json(msg='NVMe protocol not supported. Please upgrade your array.') diff --git a/lib/ansible/modules/storage/purestorage/purefa_info.py b/lib/ansible/modules/storage/purestorage/purefa_info.py index 6c56ca9981..6d436d7dd4 100644 --- a/lib/ansible/modules/storage/purestorage/purefa_info.py +++ b/lib/ansible/modules/storage/purestorage/purefa_info.py @@ -965,7 +965,7 @@ def main(): info = {} - if 'minimum' in subset or 'all' in subset: + if 'minimum' in subset or 'all' in subset or 'apps' in subset: info['default'] = generate_default_dict(array) if 'performance' in subset or 'all' in subset: info['performance'] = generate_perf_dict(array) @@ -1000,7 +1000,10 @@ def main(): info['nfs_offload'] = generate_nfs_offload_dict(array) info['s3_offload'] = generate_s3_offload_dict(array) if 'apps' in subset or 'all' in subset: - info['apps'] = generate_apps_dict(array) + if 'CBS' not in info['default']['array_model']: + info['apps'] = generate_apps_dict(array) + else: + info['apps'] = {} if 'arrays' in subset or 'all' in subset: info['arrays'] = generate_conn_array_dict(array) if 'certs' in subset or 'all' in subset: