VMware Cloud Community
doslager
Contributor
Contributor

Use vmware-vim-cmd to reset a vSwitch and/or portgroup to its default

Does anyone know what the syntax is to use vmware-vim-cmd to reset a parameter on a portgroup back to the default?

Here's the scenario:

I'm running the following lines of code in a script to set some security settings:

/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-forgedxmit=false vSwitch0 "Service Console"
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-macchange=false vSwitch0 "Service Console"
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-promisc=false vSwitch0 "Service Console"
/usr/bin/vmware-vim-cmd hostsvc/net/refresh

/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-forgedxmit=false vSwitch0 "VMotion"
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-macchange=false vSwitch0 "VMotion"
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --securepolicy-promisc=false vSwitch0 "VMotion"
/usr/bin/vmware-vim-cmd hostsvc/net/refresh

Everything works great....except that it also forces some of the other settings from the default of "unchecked". For example, vmware-vim-cmd sets the Load Balancing parameter (NIC Teaming tab), Checks "Override vSwitch failover order", "Notify Switches" and "failback".

In the spirit of "tread lightly", I want to reset these to default. In fact, it has caused us a bit of an issue with the failover order. See attached screen captures to show the "before" and "after". I want to figure out how to scriptomatically get back to the "before" state.

So....if I try the following command, or similar, how do I set it back to default of "unchecked" for override failover checkbox? I tried -nicorderpolicy-active="", =0, =vmnic99, and nothing works to "uncheck" the box.

vmware-vim-cmd /hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic0 vSwitch0 "Service Console"

Technically, the same question goes for the following options, as well:

--nicteaming-policy=nicteaming-policy

--nicteaming-notify-switch=bool

Thanks!

Reply
0 Kudos
1 Reply
lamw
Community Manager
Community Manager

Not sure why that is the case...it could be that there are values that are defaulted within the implementation of configuring the portgroup when specifying those parameters. There are certain oddities that I've seen with the vimsh and since its not an official supported tool by VMware...will never know. I did some testing and what I've found is that if you created the portgroup versus trying to set the params that you wanted disable are preserved.

Here is the line you would use:

vmware-vim-cmd hostsvc/net/portgroup_add --failurecriteria-check-beacon=false --securepolicy-forgedxmit=false --securepolicy-macchange=false --securepolicy-promisc=false vSwitch1 "Service Console"

The only thing I was not able to figure out was disabling the Failover Order for Override vSwitch Failover order, I did not see any params that would allow you to disable that, you can only set the active/standby vmnic if you wish.

Hopefully this helps a little but if you're looking to automate the advanced configurations on the vSwitch and portgroups you can take a look at the VI API to explicitly set all required parameters such as in the VI Client.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos