Perl Toolkit: Adjust Active/Standby NICs for Virtual Switches and Port Groups

I had the need to change the configuration of my ESX hosts so that the virtual switches had a single active and single standby adapter assigned to them. The reason for the need is rather irritating (the IBM I/O modules that we have in these particular blade centers are not really designed to handle a high amount of traffic), and it was causing some issues during vMotions.

This script allows me set the vmnics assigned to a vswitch to the desired active/standby configuration, and additionally allows me to set the port group’s vmnic active/standby policy. In my setup, I use two vSwitches, one for primary COS, vMotion and IP storage, and a second vSwitch for the virtual machines and secondary COS, each vSwitch has two NICs assigned (remember, they’re blade centers…limited network connectivity). In order to avoid vMotion taking all the bandwidth for storage I wanted to separate their traffic onto different NICs, but still provide redundancy.

The way that I accomplish this is by making the default for the vSwitch have, for example, vmnic0 active and vmnic2 standby. I then adjust the vMotion port group so that it has the opposite (vmnic2 active and vmnic0 standby). Redundancy is still present in the event of a NIC failure, but under normal circumstances, the traffic is separate.

Without further justification on my part….

The same philosophy will also work if you use a single vSwitch with four (or however many) NICs assigned to it. What will complicate things is if you are using a port channel (or LACP) setup. If you are, then the NICs must stay paired and both must be active. I say this assuming you are using only two links. If you have port channels that consist of two NICs and you have two channels per vSwitch (for a total of four NICs to a vSwitch), then just make sure that you keep the two channeled NICs together in the active/standby configuration.

To adjust the active/standby NICs from the command line is a little more obscure…you have to use the vmware-vim-cmd, or vimsh if you are using ESX < 3.5.

xtravirt has some outstanding documentation on the voodoo behind the vimsh/vmware-vim-cmd commands, so be sure to check them out if you are going to be modifying port groups and vSwitches from the command line.

Leave a Reply