Automating Auto Expand Configuration for a dvPortgroup in vSphere 5

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

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:
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

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:
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:Next 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”.

This 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

Jason

February 4th, 2014

Is it possible to change the increment of how many ports are added? If I set a port group to have 1 port and a second port is needed the number of dvPorts increments to 10. With 100’s of port groups this puts me over the supported maximum quickly. The only way around it seems to be to run a script every couple hours that will bring the number of ports back down to the number used.