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

vmware_guest: Fix vApp property handling #2220

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions changelogs/fragments/2220-vmware_guest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- vmware_guest - setting vApp properties on virtual machines without vApp options raised an AttributeError.
Fix now gracefully handles a `None` value for vApp options when retrieving current vApp properties
(https://github.com/ansible-collections/community.vmware/pull/2220).
5 changes: 3 additions & 2 deletions plugins/modules/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,13 +2067,14 @@ def configure_vapp_properties(self, vm_obj):
if vm_obj:
# VM exists
orig_spec = vm_obj.config.vAppConfig
orig_properties = orig_spec.property if orig_spec is not None else []

vapp_properties_current = dict((x.id, x) for x in orig_spec.property)
vapp_properties_current = dict((x.id, x) for x in orig_properties)
vapp_properties_to_change = dict((x['id'], x) for x in self.params['vapp_properties'])

# each property must have a unique key
# init key counter with max value + 1
all_keys = [x.key for x in orig_spec.property]
all_keys = [x.key for x in orig_properties]
new_property_index = max(all_keys) + 1 if all_keys else 0

for property_id, property_spec in vapp_properties_to_change.items():
Expand Down