Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #1772 #1846

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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