pyvmomi-community-samples
pyvmomi-community-samples copied to clipboard
No need to search port for VM VNIC connection to DVS
Describe the bug
In this example: https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/add_vm_nic_to_dvs.py
When connect VM VNIC to a DVPG of DVS, we first try to get a free port. That is not necessary. Auto expand of the port in DVPG has been here for years and it is enabled by default on DVPG. That's, if there is no enough port, vCenter will automatically create a port for the VM.
Thanks to the auto expand, the client doesn't need to specify the portKey in the VNIC backing: nic_spec.device.backing.port.portKey = port.key
Reproduction steps
Create DVS and use add_vm_nic_to_dvs.py to connect VM VNIC to DVS. There will be 16 ports by default created. So you will find after run the script for 16 times, you can't add any vnic to that DVPG.
Expected behavior
The script should not search free port for the VM VNIC. Just let the vCenter auto expand the port if there is no free ones.
Additional context
No response