Skip to content

Commit

Permalink
fix issue #1772 (#1846)
Browse files Browse the repository at this point in the history
fix issue #1772

SUMMARY
Fixes  #1772
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_guest_custom_attributes

Reviewed-by: Mario Lenz <[email protected]>
  • Loading branch information
ihumster authored Oct 8, 2023
1 parent c67163c commit 3b7c3aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/issue_1772.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- fix problem when module try apply non global or non VM type custom attribute to
VM object (https://github.com/ansible-collections/community.vmware/issues/1772)
6 changes: 5 additions & 1 deletion plugins/modules/vmware_guest_custom_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ def check_exists(self, vm, user_fields):
"""
# Gather the available existing custom attributes based on user_fields
existing_custom_attributes = []
for k, n in [(x.key, x.name) for x in self.custom_field_mgr for v in user_fields if x.name == v['name']]:
for k, n in [(x.key, x.name) for x in self.custom_field_mgr
# vmware_guest_custome_attributes must work with self moref type of custom attributes or with global custom attributes
if x.managedObjectType == vim.VirtualMachine or x.managedObjectType is None
for v in user_fields
if x.name == v['name']]:
existing_custom_attributes.append({
"key": k,
"name": n
Expand Down

0 comments on commit 3b7c3aa

Please sign in to comment.