0

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.

JustAGuy
  • 5,151
  • 11
  • 41
  • 55

2 Answers2

1

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

mor.per
  • 38
  • 3
0

I rigged up a script with PowerCLI. Cant believe I didnt think of using it...

$vmhost = 'server_name'
$portgroups = Get-VirtualPortGroup -VirtualSwitch vSwitch0 -VMHost $vmhost | select -ExpandProperty Name | sort

foreach ( $portgroup in $portgroups ) {

    $portgroup
    Write-Output ""

    $policy1 = Get-VirtualPortGroup -VirtualSwitch vSwitch0 -VMHost $vmhost -Name $portgroup | Get-NicTeamingPolicy

    Write-Output "Load Balancing: "
    $policy1.IsLoadBalancingInherited
    if (!($policy1.IsLoadBalancingInherited)) { $policy1 | Set-NicTeamingPolicy -InheritLoadBalancingPolicy $true }
  
    
    Write-Output "Network Failure Detection: "
    $policy1.IsNetworkFailoverDetectionInherited
    if (!($policy1.IsNetworkFailoverDetectionInherited)) { $policy1 | Set-NicTeamingPolicy -InheritNetworkFailoverDetectionPolicy $true }
        
    Write-Output "Notify Switches: "
    $policy1.IsNotifySwitchesInherited
    if (!($policy1.IsNotifySwitchesInherited)) { $policy1 | Set-NicTeamingPolicy -InheritNotifySwitches $true }
    

    Write-Output "Failback: "
    $policy1.IsFailbackInherited
    if (!($policy1.IsFailbackInherited)) { $policy1 | Set-NicTeamingPolicy -InheritFailback $true }
    
    Write-Output "Failover Order: "
    $policy1.IsFailoverOrderInherited
    if (!($policy1.IsFailoverOrderInherited)) { $policy1 | Set-NicTeamingPolicy -InheritFailoverOrder $true }
    
    
    Write-Output ""
    Write-Output ""
}
JustAGuy
  • 5,151
  • 11
  • 41
  • 55