While creating a command-line configuration guide for a design that I’d prepared, I found myself in need of a command that sets the NIC failover order explicitly for a portgroup. I suspected—and was correct—that vmware-vim-cmd would do the job, but was having a hard time finding documentation on the correct syntax. Even the extensive XtraVirt vimsh white paper did not have information on the syntax. After a little bit of digging around, I found the information for which I was looking. Here it is for future benefit.
The syntax for using vmware-vim-cmd to modify the NIC failover order for a portgroup looks like this:
vmware-vim-cmd hostsvc/net/portgroup_set --nicorderpolicy-active=<List of NICs> <vSwitch#> <Portgroup>
If the portgroup name includes spaces, then wrap the portgroup name in double quotes, like this:
vmware-vim-cmd hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic0 vSwitch0 "Service Console"
That sets only the active NICs. Any NICs not included in the command above are set to Unused, which is generally not the desired result. Usually, we’d want those to be Standby NICs. To set the standby NICs, use this command:
vmware-vim-cmd hostsvc/net/portgroup_set --nicorderpolicy-standby=<List of VMNICs> <vSwitch#> <Portgroup>
Run the command to set the active NICs first, then run the command to set the standby NICs. The following example will set vmnic0 as Active and vmnic1 as standby for the Service Console port group on vSwitch0:
vmware-vim-cmd hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic0 vSwitch0 "Service Console"
vmware-vim-cmd hostsvc/net/portgroup_set –nicorderpolicy-standby=vmnic1 vSwitch0 “Service Console”
I hope this is helpful to some readers.
UPDATE: A reader clarified in the comments that the parameters can actually be combined into a single command, like so:
vmware-vim-cmd hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic0 --nicorderpolicy-standby=vmnic1 vSwitch0 "Service Console"
I tested this syntax on VMware ESX 3.5 Update 3 and it does work as expected. Thanks, Timo!
Tags: ESX, Networking, Virtualization, VMware
-
This is indeed helpful for network PXE & automatic installations
If I’m not mistaken, i think you can set active / standby nics with only one command, just using the “two options” on the command line.
ex: vim-cmd hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic0 –nicorderpolicy-standby=vmnic1 vSwitch0 ‘Management Network’
I use it to post-conf VMware ESXi portgroups.
PS: i think this syntax will give you a minimalistic help for the command
# vim-cmd help hostsvc/net/portgroup_set
-
I blogged my scripted install kickstart script a while back that actually contains these commands : http://www.yellow-bricks.com/2008/06/27/scripted-install/
-
Scott,
Thanks for the tip! I’ve incorporated this into my kickstart process.
I’ve been using vmware-vim-cmd more and more instead of vimsh, and it works very well with the exception of one command:
vmware-vim-cmd “hostsvc/net/vswitch_setpolicy –nicteaming-policy loadbalance_ip vSwitchX”
Every time I try to use vmware-vim-cmd to change the NIC teaming policy to loadbalance_ip (or anything, really,) it returns “Invalid Command” (at least, as of ESX 3.5 Update 2. I haven’t tried it in Update 3 yet, though.)
Have you come across this one yourself? I’d prefer to use vmware-vim-cmd across the board in my scripts since it’s cleaner than vimsh and returns completion codes.
-
Pingback from SVMotion Syntax « H9Newser’s Blog on Friday, January 16, 2009 at 4:47 pm
-
Is it recommended that the Service Console and VMotion VMKernal port groups not be set to an active/active nic configuration? My vSwitches are set to active/active with “Route based on ip hash” load balancing policy as I am using stacked Cisco 3120 switches.
-
This is all great
but
how do I associate a ESX4i guest to a port-group remotly? -
How do i list multiple vmnics when using this command, i tried “,” and brackets but didn’t seem to like it.
Thanks!
-
Okay, this rocks! Exactly what I need. Now I’m writing a script to ensure that a server has been built correctly and doesn’t have any settings wrong. What command is equivalent to “get” rather than “set” the active nic and standby nic please?
cheers,
Kevin




13 comments
Comments feed for this article
Trackback link: http://blog.scottlowe.org/2008/12/16/using-vmware-vim-cmd-to-modify-a-portgroup/trackback/