From 0334b3fd99eb1501d1448d66a3b668a34da9dfd1 Mon Sep 17 00:00:00 2001 From: strattner Date: Sun, 19 Nov 2017 08:47:57 -0500 Subject: [PATCH] check if existing network is VDS and has port attribute (#31322) --- lib/ansible/modules/cloud/vmware/vmware_guest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index c4d7858e3e..fa354219ae 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -768,9 +768,10 @@ class PyVmomiHelper(PyVmomi): # VDS switch pg_obj = find_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)): + if (nic.device.backing and not hasattr(nic.device.backing, 'port')): + nic_change_detected = True + elif (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()