Skip to content

Commit

Permalink
vmware_guest: Fix vApp property handling
Browse files Browse the repository at this point in the history
The vmware_guest module did not properly handle setting vApp properties if the
VmConfigSpec never contained an active vAppConfig. This resulted in an exception
due to trying to access `property` on `None`. This commit changes the behavior
to default the current list of vApp properties to an empty list if there has
never been any vAppConfig.
  • Loading branch information
ppmathis committed Oct 24, 2024
1 parent 9d51ab9 commit 2f239f3
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 2f239f3

Please sign in to comment.