mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vmware_guest: fix dvs idempotency issue (#34208)
* vmware_guest: fix dvs idempotency issue * Rewrite VDS section * Fix PEP 8 error
This commit is contained in:
parent
63536944a4
commit
7fbe19c047
1 changed files with 8 additions and 11 deletions
|
@ -944,18 +944,15 @@ class PyVmomiHelper(PyVmomi):
|
||||||
# VDS switch
|
# VDS switch
|
||||||
pg_obj = find_obj(self.content, [vim.dvs.DistributedVirtualPortgroup], network_devices[key]['name'])
|
pg_obj = find_obj(self.content, [vim.dvs.DistributedVirtualPortgroup], network_devices[key]['name'])
|
||||||
|
|
||||||
if (nic.device.backing and not hasattr(nic.device.backing, 'port')):
|
if (nic.device.backing and not hasattr(nic.device.backing, 'port')) or \
|
||||||
|
(nic.device.backing and (nic.device.backing.port.portgroupKey != pg_obj.key or
|
||||||
|
nic.device.backing.port.switchUuid != pg_obj.config.distributedVirtualSwitch.uuid)):
|
||||||
|
dvs_port_connection = vim.dvs.PortConnection()
|
||||||
|
dvs_port_connection.portgroupKey = pg_obj.key
|
||||||
|
dvs_port_connection.switchUuid = pg_obj.config.distributedVirtualSwitch.uuid
|
||||||
|
nic.device.backing = vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo()
|
||||||
|
nic.device.backing.port = dvs_port_connection
|
||||||
nic_change_detected = True
|
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()
|
|
||||||
dvs_port_connection.portgroupKey = pg_obj.key
|
|
||||||
dvs_port_connection.switchUuid = pg_obj.config.distributedVirtualSwitch.uuid
|
|
||||||
nic.device.backing = vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo()
|
|
||||||
nic.device.backing.port = dvs_port_connection
|
|
||||||
nic_change_detected = True
|
|
||||||
else:
|
else:
|
||||||
# vSwitch
|
# vSwitch
|
||||||
if not isinstance(nic.device.backing, vim.vm.device.VirtualEthernetCard.NetworkBackingInfo):
|
if not isinstance(nic.device.backing, vim.vm.device.VirtualEthernetCard.NetworkBackingInfo):
|
||||||
|
|
Loading…
Reference in a new issue