vmwareesxiesx

VMWARE ESXi - Untick "Override" programmatically


enter image description here

This is one of the Networks attached to vSwitch0. I'd like to untick "Override" as I'd like for it to inherit from the main settings. The thing is I have a few dozens of those and I want to do it via a script. I was not able to find how to do it via ESXCLI. The override occures when you create characteristics for the portgroup, see the following 2 commented out.

esxcli network vswitch standard portgroup add --portgroup-name=Grid --vswitch-name=vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name=Grid --vlan-id 123
#esxcli network vswitch standard portgroup policy failover set --portgroup-name=Grid --active-uplinks=vmnic0,vmnic2
#esxcli network vswitch standard portgroup policy failover set --portgroup-name=Grid -l portid

I really dont want to re-create everything. There must be a way to untick those boxes.


Solution

  • you can do that with powercli:

    $vs = Get-VirtualSwitch -VMHost $vmhost -Name "vSwitch0"
    $nics = (Get-VirtualSwitch -VMHost $vmhost).Nic
    $policy1 = Get-VirtualPortgroup -VirtualSwitch $vs -VMHost $vmhost -Name 'net2' | Get-NicTeamingPolicy
    $policy1 | Set-NicTeamingPolicy -MakeNicActive $nics[0] -MakeNicStandby $nics[1] # this will set the order
    $policy1 | Set-NicTeamingPolicy -InheritFailoverOrder $true # this will uncheck/check the failover inherit tick
    

    if doing with esxcli:

    first we get current settings (override is not checked)

    [root@esx:~] esxcli network vswitch standard portgroup policy failover get -p net2
       Load Balancing: srcport
       Network Failure Detection: link
       Notify Switches: true
       Failback: true
       Active Adapters: vmnic5, vmnic4
       Standby Adapters:
       Unused Adapters:
       Override Vswitch Load Balancing: false
       Override Vswitch Network Failure Detection: false
       Override Vswitch Notify Switches: false
       Override Vswitch Failback: false
       Override Vswitch Uplinks: false
    

    next we run the command to set the nicorder we would like to have and check again.

    [root@esx:~] esxcli network vswitch standard portgroup policy failover set -a vmnic5 -s vmnic4 -p net2
    [root@esx:~] esxcli network vswitch standard portgroup policy failover get -p net2
       Load Balancing: srcport
       Network Failure Detection: link
       Notify Switches: true
       Failback: true
       Active Adapters: vmnic5
       Standby Adapters: vmnic4
       Unused Adapters:
       Override Vswitch Load Balancing: false
       Override Vswitch Network Failure Detection: false
       Override Vswitch Notify Switches: false
       Override Vswitch Failback: false
       Override Vswitch Uplinks: true
    

    this will tick the override checkbox and set the active nic to vmnic5 and stby to vmnic4

    Good luck Pargit