From 93e8f4cef09c2689972f278ba94d83cd03a66dad Mon Sep 17 00:00:00 2001 From: Simon Dodsley Date: Fri, 6 Sep 2019 09:04:49 -0400 Subject: [PATCH] Fix failure due to API version check (cherry picked from commit dfe02d1ff4b9a6f84e66881fb99619b29338389a) --- .../61925-fix_purefa_fact_info_api_check.yml | 3 +++ .../storage/purestorage/_purefa_facts.py | 17 ++++++++++------- .../modules/storage/purestorage/purefa_info.py | 17 ++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/61925-fix_purefa_fact_info_api_check.yml diff --git a/changelogs/fragments/61925-fix_purefa_fact_info_api_check.yml b/changelogs/fragments/61925-fix_purefa_fact_info_api_check.yml new file mode 100644 index 0000000000..b71c69c720 --- /dev/null +++ b/changelogs/fragments/61925-fix_purefa_fact_info_api_check.yml @@ -0,0 +1,3 @@ +bugfixes: +- purefa_info - Fix missing API version check when calling I(admins) or I(all) as the subset +- _purefa_facts - Fix missing API version check when calling I(admins) or I(all) as the subset diff --git a/lib/ansible/modules/storage/purestorage/_purefa_facts.py b/lib/ansible/modules/storage/purestorage/_purefa_facts.py index 905fa60386..a33e6430e5 100644 --- a/lib/ansible/modules/storage/purestorage/_purefa_facts.py +++ b/lib/ansible/modules/storage/purestorage/_purefa_facts.py @@ -340,6 +340,7 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pure import get_system, purefa_argument_spec +ADMIN_API_VERSION = '1.14' S3_REQUIRED_API_VERSION = '1.16' LATENCY_REQUIRED_API_VERSION = '1.16' AC_REQUIRED_API_VERSION = '1.14' @@ -461,14 +462,16 @@ def generate_config_dict(array): def generate_admin_dict(array): + api_version = array._list_available_rest_versions() admin_facts = {} - admins = array.list_admins() - for admin in range(0, len(admins)): - admin_name = admins[admin]['name'] - admin_facts[admin_name] = { - 'type': admins[admin]['type'], - 'role': admins[admin]['role'], - } + if ADMIN_API_VERSION in api_version: + admins = array.list_admins() + for admin in range(0, len(admins)): + admin_name = admins[admin]['name'] + admin_facts[admin_name] = { + 'type': admins[admin]['type'], + 'role': admins[admin]['role'], + } return admin_facts diff --git a/lib/ansible/modules/storage/purestorage/purefa_info.py b/lib/ansible/modules/storage/purestorage/purefa_info.py index 32114dd400..491659de4b 100644 --- a/lib/ansible/modules/storage/purestorage/purefa_info.py +++ b/lib/ansible/modules/storage/purestorage/purefa_info.py @@ -408,6 +408,7 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pure import get_system, purefa_argument_spec import time +ADMIN_API_VERSION = '1.14' S3_REQUIRED_API_VERSION = '1.16' LATENCY_REQUIRED_API_VERSION = '1.16' AC_REQUIRED_API_VERSION = '1.14' @@ -530,13 +531,15 @@ def generate_config_dict(array): def generate_admin_dict(array): admin_info = {} - admins = array.list_admins() - for admin in range(0, len(admins)): - admin_name = admins[admin]['name'] - admin_info[admin_name] = { - 'type': admins[admin]['type'], - 'role': admins[admin]['role'], - } + api_version = array._list_available_rest_versions() + if ADMIN_API_VERSION in api_version: + admins = array.list_admins() + for admin in range(0, len(admins)): + admin_name = admins[admin]['name'] + admin_info[admin_name] = { + 'type': admins[admin]['type'], + 'role': admins[admin]['role'], + } return admin_info