From e71b4e2e57fc687842f65e3540aba64ef0f63446 Mon Sep 17 00:00:00 2001 From: "Swartz, Nathan" Date: Tue, 21 May 2019 14:13:24 -0500 Subject: [PATCH] Fix workload profileId indexing in netapp_e_volume module This commit reflects the changes in PR #56747 in the devel branch --- ...56747-netapp_e_volume-fix-profileId-indexing.yaml | 2 ++ .../modules/storage/netapp/netapp_e_volume.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/56747-netapp_e_volume-fix-profileId-indexing.yaml diff --git a/changelogs/fragments/56747-netapp_e_volume-fix-profileId-indexing.yaml b/changelogs/fragments/56747-netapp_e_volume-fix-profileId-indexing.yaml new file mode 100644 index 00000000000..9b0e125bc6a --- /dev/null +++ b/changelogs/fragments/56747-netapp_e_volume-fix-profileId-indexing.yaml @@ -0,0 +1,2 @@ +bugfixes: + - netapp_e_volumes - fix workload profileId indexing when no previous workload tags exist on the storage array. diff --git a/lib/ansible/modules/storage/netapp/netapp_e_volume.py b/lib/ansible/modules/storage/netapp/netapp_e_volume.py index 868dc5b6492..0483b998b89 100644 --- a/lib/ansible/modules/storage/netapp/netapp_e_volume.py +++ b/lib/ansible/modules/storage/netapp/netapp_e_volume.py @@ -470,10 +470,14 @@ class NetAppESeriesVolume(NetAppESeriesModule): self.module.fail_json(msg="Failed to retrieve storage array workload tags. Array [%s]" % self.ssid) # Generate common indexed Ansible workload tag - tag_index = max([int(pair["value"].replace("ansible_workload_", "")) - for tag in workload_tags for pair in tag["workloadAttributes"] - if pair["key"] == "profileId" and "ansible_workload_" in pair["value"] and - str(pair["value"]).replace("ansible_workload_", "").isdigit()]) + 1 + current_tag_index_list = [int(pair["value"].replace("ansible_workload_", "")) + for tag in workload_tags for pair in tag["workloadAttributes"] + if pair["key"] == "profileId" and "ansible_workload_" in pair["value"] and + str(pair["value"]).replace("ansible_workload_", "").isdigit()] + + tag_index = 1 + if current_tag_index_list: + tag_index = max(current_tag_index_list) + 1 ansible_profile_id = "ansible_workload_%d" % tag_index request_body = dict(name=self.workload_name,