vSphere SDK - create VM with NIC connected to a non-existent portgroup

810 Views Asked by At

Is it possible to create a VM with a virtual ethernet card connected to a non-existent port group? In my project there are two components one responsible for creating VM (VM Manager) and one responsible for creating port-groups and other n/w related tasks (N/W manager). The N/W manager will watch for new VMs or NICs and create portgroups with proper VLAN connection. The VM manager will be knowing the name of the portgroup and vDS. So I want the VM manager to create VMs with VirtualEthernetCards with backing pointing to the portgroup name and vDs name where the port group may be non-existent at that point of time. Later on the N/W manager will create the required portgroup and then the VM manager does a reconfigure VM and powers it on.

Is this flow possible. If not how should I go about this?

Regards, Litty

2

There are 2 best solutions below

0
Mario Lenz On

I don't think this is possible. (And anyway, the name of a port group is not it's identifier, it's just an attribute.)

Create the port group first and then the VM. Alternatively, you could create a VM without a NIC, then create the port group and a add a NIC to the VM connected to the port group.

Why do you want to create a port group for every VM?

0
coderonthemount On

For VDS portgroup, if you host was added to the VDS, you can see all the portgroups, but you can't see the non-existed portgroup.

Option 1: After creating portgroup, then create VNIC Option 2: After creating VNIC and bind to default NETWORK "VM NETOWORK", after creating portgroup, you can modify the portgroup binding.