Fix workload profileId indexing in netapp_e_volume module

This commit reflects the changes in PR #56747 in the devel branch
This commit is contained in:
Swartz, Nathan 2019-05-21 14:13:24 -05:00 committed by Toshio Kuratomi
parent 73484808c8
commit e71b4e2e57
2 changed files with 10 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- netapp_e_volumes - fix workload profileId indexing when no previous workload tags exist on the storage array.

View file

@ -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_", ""))
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()]) + 1
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,