Product Announcements

Automating Auto Expand Configuration for a dvPortgroup in vSphere 5

By William Lam, Sr. Technical Marketing Engineer

There was a recent blog article that references VMware KB 1022312 that provides a manual method of enabling a new feature in vSphere 5 for a distributed portgroup called Auto Expand. As the KB explains, Auto Expand is a new advanced option for a distributed portgroup (Static Binding only) that allows for the number of ports to automatically increase by a predefined amount (increment of 10) when it is about to run out of ports. This is a really neat feature with the distributed vSwitch and allows users to still continue to provision new virtual machines and not require a system administrator to manually increase the number of ports.

The one caveat is that this advanced option is disabled by default and there is no option within the vSphere Client UI to enable this feature. The VMware KB outlines the steps to enable Auto Expand using the vSphere MOB, but the the process is not very user friendly and can be tedious for enabling several dozen distributed portgroups.

Though enabling Auto Expand is not available through the vSphere Client, it is available using the vSphere API. The property autoExpand is under distributed portgroup and can be queried or reconfigured by calling the ReconfigureDVPortgroup_Task API method. 

We will walk through an example of how Auto Expand works and provide a sample vSphere SDK for Perl script that allows you to check whether or not Auto Expand is enabled for your distributed portgroups and allowing you to enable or disable the feature.

Disclaimer: This script is provided for informational/educational purposes only. It should be thoroughly tested before attempting to use in a production environment.

vSphere SDK for Perl

Download script: updatedvPortgroupAutoExpand.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.

Here is an example of a distributed vSwitch with several portgroups, we will focus on the Stage portgroup which currently is only configured with 2 ports:
Screen shot 2012-02-13 at 11.24.10 AM
To get a listing of all portgroups (Static Binding only), the number of ports configured and whether Auto Expand is enabled or not, use the “list” operation:
vi-admin@vma5:~> ./updatedvPortgroupAutoExpand.pl –server pod-vc –username root –operation list
Enter password:
dvSwitch: dvSwitch1
dvSwitch-DVUplinks-462    4    false
Development    10    false
Stage    2    false
dvSwitch: dvSwitch2
dvSwitch2-DVUplinks-476    0    false
dvPortGroup    128    false

You can also specify the optional –dvswitch flag to only view from a specific distributed vSwitch:
vi-admin@vma5:~> ./updatedvPortgroupAutoExpand.pl –server pod-vc –username root –operation list –dvswitch dvSwitch1
Enter password:
dvSwitch: dvSwitch1
dvSwitch-DVUplinks-462    4    false
Development    10    false
Stage    2    false

To enable Auto Expand for a particular dvPortgroup, use the “enable” operation and specifying the portgroup by using the –dvportgroup param (to disable just use “disable” operation):
vi-admin@vma5:~> ./updatedvPortgroupAutoExpand.pl –server pod-vc –username root –operation enable –dvportgroup Stage
Enter password:
Enabling Auto Expand for dvPortgroup “Stage” …
Successfully reconfigured dvPortgroup!

To view the changes, you can run the “list” operation again:
vi-admin@vma5:~> ./updatedvPortgroupAutoExpand.pl –server pod-vc –username root –operation list –dvswitch dvSwitch1
Enter password:
dvSwitch: dvSwitch1
dvSwitch-DVUplinks-462    4    false
Development    10    false
Stage    2    true

Now we will create a new virtual machine with three network cards and assign all three to “Stage” distributed portgroup. Once the portgroup is about to run out, it will automatically increase the number of ports by 10 and bring the new total to 12 as you can see from the screenshot below:
Screen shot 2012-02-13 at 11.39.07 AM
Though this feature can be really useful, it would also be good to know when this occurs to ensure that the networking environment is being sized and configured correctly. You can easily do so by configuring a custom vCenter  alarm to notify you when this occurs for distributed portgroups that have Auto Expand feature.

The alarm must be created on a per distributed portgroup level, click on the “Alarms” tab of the portgroup and create a new alarm:
Screen Shot 2012-02-13 at 11.55.21 AMNext you under the “Event”, add a new trigger called “dvPort group reconfigured” and then click on Advanced Conditions. Select “configSpec.autoExpand” and use the “equal to” to “true”.

Screen Shot 2012-02-13 at 11.55.50 AMThis will allow you to monitor when port count is automatically increased and take the appropriate action such as an email or an SNMP trap.

Get notification of new blog postings and more by following lamw on Twitter:  @lamw