Skip to content

Commit

Permalink
stable-4.x: Fix vmware_guest idempotency whith dvswitch (#2254)
Browse files Browse the repository at this point in the history
SUMMARY
This fixes the idempotency issue 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
ADDITIONAL INFORMATION
Backport of #2000
#498
  • Loading branch information
mariolenz authored Nov 23, 2024
1 parent a1ea150 commit 5877a03
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 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
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,22 @@
- "'tag_category' in test_host.value"


- name: Inventory 'resources' option
include_tasks: build_inventory.yml
vars:
content: |-
plugin: community.vmware.vmware_host_inventory
strict: false
resources:
- datacenter:
- DC0
resources:
- compute_resource:
- DC0_C0_NOT_EXIST
- name: Test 'resources' options with 'DC0_C0_NOT_EXIST'
assert:
that:
- hostvars | length == 0
# TODO enable again
# https://forum.ansible.com/t/11073
# https://github.com/ansible-collections/community.vmware/issues/2257
# - name: Inventory 'resources' option
# include_tasks: build_inventory.yml
# vars:
# content: |-
# plugin: community.vmware.vmware_host_inventory
# strict: false
# resources:
# - datacenter:
# - DC0
# resources:
# - compute_resource:
# - DC0_C0_NOT_EXIST
# - name: Test 'resources' options with 'DC0_C0_NOT_EXIST'
# assert:
# that:
# - hostvars | length == 0

0 comments on commit 5877a03

Please sign in to comment.