Skip to content

Commit

Permalink
Fix vmware_guest idempotency when using dvswitch (fixes #498) (#2000)
Browse files Browse the repository at this point in the history
SUMMARY
This fixes the idempotency issue reported in #498 caused by nic.device.deviceInfo.summary containing DVSwitch: d5 6e 22 50 dd f2 94 7b-a6 1f b2 c2 e6 aa 0f instead of a readable portgroup name.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_guest

Reviewed-by: Mario Lenz <[email protected]>
  • Loading branch information
Yannik authored Nov 21, 2024
1 parent 394a5a6 commit e249a03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- vmware_guest - Fix vmware_guest always reporting change when using dvswitch.
(https://github.com/ansible-collections/community.vmware/pull/2000).
11 changes: 9 additions & 2 deletions plugins/modules/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,8 +1936,15 @@ def configure_network(self, vm_obj):
nic_change_detected = True

if nic.device.deviceInfo.summary != network_name:
nic.device.deviceInfo.summary = network_name
nic_change_detected = True
if 'DVSwitch' not in nic.device.deviceInfo.summary:
nic.device.deviceInfo.summary = network_name
nic_change_detected = True
else:
pg = find_obj(self.content, [vim.DistributedVirtualPortgroup], network_name)
if pg is None or nic.device.backing.port.portgroupKey != pg.key:
nic.device.deviceInfo.summary = network_name
nic_change_detected = True

if 'device_type' in network_devices[key]:
device = self.device_helper.nic_device_type.get(network_devices[key]['device_type'])
if not isinstance(nic.device, device):
Expand Down

0 comments on commit e249a03

Please sign in to comment.