From e4239d94243242e21441073e4bf0b3336f0fa7e9 Mon Sep 17 00:00:00 2001 From: Nathan Swartz Date: Wed, 22 May 2019 08:43:21 -0500 Subject: [PATCH] Fix workload profileId indexing in netapp_e_volume module (#56747) --- .../modules/storage/netapp/netapp_e_volume.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/storage/netapp/netapp_e_volume.py b/lib/ansible/modules/storage/netapp/netapp_e_volume.py index 868dc5b649..0483b998b8 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,