vmware / pyvmomi-community-samples

A place for community contributed samples for the pyVmomi library.
Apache License 2.0
1.02k stars 923 forks source link

Unable to set Portgroup (connection) type while creating a Portgroup #271

Open luminostech1089 opened 8 years ago

luminostech1089 commented 8 years ago

I am able to create port group using AddPortGroup() method of host.configManager.networkSystem object. But the port group type (vim.host.PortGroup.PortConnecteeType) is 'host' by default. AddPortGroup How can i change this value to some other value e.g. to 'virtualMachine'?

As per documentation : A Port data object type is a runtime representation of network connectivity between a network service or virtual machine and a virtual switch. This is different from a port group in that the port group represents the configuration aspects of the network connection. The Port object provides runtime statistics. What does this mean? Does it mean i can't change this value?

prziborowski commented 8 years ago

Perhaps the documentation doesn't mention it, but once you attach a VM to that portgroup, it will be of type virtualMachine automatically (which means you won't be able to add a vmknic to it). I haven't checked, but once all the VMs are off the portgroup, it might revert back to 'host'.

luminostech1089 commented 8 years ago

Basically, i want to add VLAN to vSwitch. The exact manual steps are mentioned here : http://www.rustyhann.com/ESXi-06-Create-vLAN.pdf

I thought of the using AddPortGroup() of host.configManager.networkSystem but blocked at how to set vim.host.PortGroup.port.type to desired connection type. Probably i am taking a wrong approach.

Could anybody suggest how can i achieve it. Any suggestions in this regard will be a great help. Thanks.