i try to find out the dvsport id from a given vmname and vnic.
Maybe someone can give some hints or solution.
I tried to get it from the VM object
The VM has 3 Interfaces.
I want to find out for example the portKey for inteface key 4001.
IRRC, you only get the DvPortgroup key associated with a VM's interface, it will not provide you with the dvport ID. You can however use the FetchDVPortKeys() http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.Distribute... method and basically search for your VM and return it's dvport ID and match that up with the VM
Here is a vSphere SDK for Perl script which leverages this method along with providing various data about a VDS and one of the examples provides a mapping to the DvPortgroup portID
I tried this script some times before.
My problem is, that we have 500 VM's, so i wrote some functions to retrive the infos from one VM.
The main thing is, that Script uses 11 seconds to complete.
5 Seconds for fetching only.
I wite on a client to change the portgroups via script for automatic testing.
So my idea was, to get the changed port after the change (set) of the portgroup via
Not sure I understand what you're trying to do, but if you have a large environment it could take a bit of time to lookup. You may want to tweak the criteria to futher limit the scope to help reduce the amount of time it takes to run. Another option that you could try is if you know which VMs you wish to retrieve the dvport id, you could store the dvportgroup portkey and then lookup the dvportgroup on the VDS and then quickly map that to the VM in question.