From 614390a310a0631d946cc83f386390a475e12189 Mon Sep 17 00:00:00 2001 From: aperigault Date: Thu, 26 Jan 2017 13:42:08 +0100 Subject: [PATCH] vmware_guest: Fix nic configuration with already present nics (#20640) --- lib/ansible/modules/cloud/vmware/vmware_guest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index d3e382bda6..da3499655b 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -811,6 +811,10 @@ class PyVmomiHelper(object): if hasattr(self.cache.get_network(network_devices[key]['name']), 'portKeys'): # VDS switch pg_obj = get_obj(self.content, [vim.dvs.DistributedVirtualPortgroup], network_devices[key]['name']) + + if nic.device.backing and ( nic.device.backing.port.portgroupKey != pg_obj.key or nic.device.backing.port.switchUuid != pg_obj.config.distributedVirtualSwitch.uuid ): + nic_change_detected = True + dvs_port_connection = vim.dvs.PortConnection() dvs_port_connection.portgroupKey = pg_obj.key dvs_port_connection.switchUuid = pg_obj.config.distributedVirtualSwitch.uuid