【问题标题】:VMWARE ESXi - Untick "Override" programmaticallyVMWARE ESXi - 以编程方式取消选中“覆盖”
【发布时间】:2022-01-23 19:00:57
【问题描述】:

这是连接到 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

我真的不想重新创造一切。一定有办法取消这些框。

【问题讨论】:

    标签: vmware esxi esx


    【解决方案1】:

    我使用 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 ""
    }
    

    【讨论】:

      【解决方案2】:

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

      这将勾选覆盖复选框并将活动 nic 设置为 vmnic5 并将 stby 设置为 vmnic4

      祝你好运 帕吉特

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-05-10
        • 2014-12-10
        • 1970-01-01
        • 1970-01-01
        • 2012-02-27
        • 2015-04-07
        • 2018-08-26
        相关资源
        最近更新 更多