posted

7 Comments

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