VMWARE ESXi - 以编程方式取消勾选 "Override"

VMWARE ESXi - Untick "Override" programmatically

这是连接到 vSwitch0 的网络之一。 我想取消选中“覆盖”,因为我希望它从主要设置继承。问题是我有几十个,我想通过脚本来完成。我无法找到如何通过 ESXCLI 执行此操作。当您为端口组创建特征时会发生覆盖,请参阅以下 2 个已注释掉的内容。

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

我真的不想重新创建所有内容。一定有办法取消勾选这些方框。

你可以用 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

如果使用 esxcli:

首先我们获取当前设置(未选中覆盖)

[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

接下来我们 运行 设置我们想要的 nicorder 的命令并再次检查。

[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

这将勾选覆盖复选框并将活动网卡设置为 vmnic5 并将备用网卡设置为 vmnic4

祝你好运 帕吉特

我用 PowerCLI 编写了一个脚本。 不敢相信我没有想到使用它...

$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 ""
}