By William Lam, Sr. Technical Marketing Engineer
Recently, we have been receiving numerous questions about extracting information from a VMware vSphere Distributed Virtual Switch (VDS) and whether it was possible to do the same with 3rd party Distributed Virtual Switches that have integrated with the vSphere platform such as the Cisco’s Nexus 1000v. The answer is yes and we can easily do so with the help from the vSphere API.
To give you a little background from the API perspective, both a VMware VDS and Cisco Nexus 1000v are represented as a DistributedVirtualSwitch managed object base type in the vSphere API. This allows us to extract common properties for the two different types of Virtual Distributed Switches, all while staying within the vSphere infrastructure. In addition, the VMware VDS is also represented as a sub-type of the DistributedVirtualSwitch managed objected called VmwareDistributedVirtualSwitch. For a VMware VDS, you can configure and manage all within the vCenter Server, whereas for 3rd party Distributed Virtual Switches, this is done using an external management system. In the case of the Nexus 1000v, this is done using Cisco’s VSM (Virtual Supervisor Module) which then in-turn talks to the vCenter Server for the actual deployment.
Below are two example scripts showing how you can extract information from a VMware VDS and other 3rd party Distributed Virtual Switches leveraging our vSphere API/CLI.
vSphere SDK for Perl
Download script: vdsInfo.pl
Usage: To run the script you will need to have VMware vCLI installed on either a Windows/Linux system or you can use the VMware vMA appliance.
$ ./vdsInfo.pl –server vcenter-01 –username root
VDSName: dvSwitch-01
VDSDescription: This is a VMware Distributed Virtual Switch
VDSVendor: VMware
VDSModel: DVS
VDSBuild: 00000
VDSBundleId: N/A
VDSVersion: 4.1.0
NumPorts: 128
NumDVPortgroups: 2
NumHosts: 1
NumVMs: 1
VDSName: VSM
VDSDescription: Cisco_Nexus_1000V_136945814
VDSVendor: Cisco Systems Inc.
VDSModel: Cisco Nexus 1000V
VDSBuild: 00000
VDSBundleId: VEM400-201101030-RG
VDSVersion: 4.0
NumPorts: 160
NumDVPortgroups: 11
NumHosts: 3
NumVMs: 3
Note: If you are interested in extracting more details from a VMware VDS and or Nexus 1000v, you can also check out this script here.
PowerCLI
Download script: http://communities.vmware.com/docs/DOC-19253
Usage: To run this script you will need the latest version of PowerCLI installed and PowerShell v2, paste the script into your editor or Powercli window once connected to the vCenter server using the Connect-VIServer cmdlet.
VDSName : VSM
VDSDescription : Cisco_Nexus_1000V_136945814
VDSVendor : Cisco Systems Inc.
VDSModel : Cisco Nexus 1000V
VDSBuild : 00000
VDSBundleId : VEM400-201101030-RG
VDSVersion : 4.0
NumPorts : 160
NumDVPortGroups : 11
NumHosts : 3
NumVMs : 1
VDSName : dvSwitch-01
VDSDescription : This is a VMware Distributed Virtual Switch
VDSVendor : VMware
VDSModel : DVS
VDSBuild : 00000
VDSBundleId :
VDSVersion : 4.1.0
NumPorts : 128
NumDVPortGroups : 2
NumHosts : 1
NumVMs : 1
Conclusion
With the help of the vSphere APIs we are able to easily extract information from both a VMware VDS as well as from 3rd party Distributed Virtual switches. The examples shown in this post is just a customized subset of the information that is available from the vSphere API.
Additional Info:
Steve Jin also recently wrote an article about this topic if you would like to learn more about the underlying APIs.
Get notification of new blog postings and more by following lamw on Twitter: @lamw

The only issue I see is the info is pulled from vCenter. We deployed the Nexus 1000v version 4.0(4)SV1(2) originally. Later, we upgraded to 4.2(1)SV1(4), but vCenter (and yours & Alan’s scripts) still show 4.0. The VSM VM itself shows 4.0(4)SV1(2), and the switch in the networking area shows simply 4.0.
We followed cisco’s guide to upgrade, so you’d think it would roll up to vCenter with the new version.
@Luke,
The information that is published to these various fields is done by the vendor. It looks like with the case of Cisco, when an upgrade is performed on the VSM, they don’t update that info back into the VDS object and hence you’re getting the old information. I would recommend you file a bug with Cisco asking them to update their VDS information for any chances they may make on their end. These APIs are completely open and they just need to push their info up and you can then leverage these scripts to collect information about VMware VDS and other 3rd party Distributed Virtual Switches
VMware is one of the best virtual server and this is gr8 stuff they are offering
Nice way to retrieve all information from VMware.
thanks. Is there any way to get the VLAN ID of cisco Nexus 1000 v switch from vmware API.
really appreciate any help.
No, that information is not exposed from N1KV. You would need to login to the VSM to extract that information.