GeekAfterFive

Infrastructure as Code

dvPortgroup Inheritance

04 Apr 2011

This is a little Johnny-come-lately, but since I recently ran into this issue dealing with vCloud Director, I thought I would share my solution.
Duncan's post from August 2010 talks about the missing default settings for portgroup inheritance in the dvSwitches. Even though it is missing in the vSphere client, the default settings still exist, and can be set in the API.
The original problem was that every new dvPortgroup does not have the correct settings for the environment, so you have to go in and manually set them AFTER the dvPortgroup is created. vCloud Director compounds the issue because users can create dvPortgroups, but don't have access to change the settings (e.g. failover, security).
My temporary solution to the problem was to create a "trolling" script to look for dvPortgroups that were set up incorrectly. The script ran as a scheduled task every 10 minutes. It worked great, but this was a big band-aid that I really didn't like.
I decided over the weekend to dig deeper into the dvSwitch object in the API, and sure enough, there was the defaultPortConfig!
So, using the ReconfigureDvs_Task, I wrote the following PowerCLI script:
(Note: Your failover settings may be very different. This script is just an example. See the VMwareDVSPortSetting object type for more information...)