Nic Teaming Policy

I have another question based on the example of adding a virtual switch.   What if you also wanted to set the nicTeaming policy of the vSwitch to  loadbalance_ip  and network failover detection to Link Status Only?  I  see that those properities are under HostNetworkPolicy, but I'm not sure  how you would use that to add that information to this.  I'm probably  just making this a lot harder than it actually is.

$HS = Find-EntityView -ViewType "HostSystem"
$nwSys = $HS.ConfigManager.NetworkSystem
$mor = Get-View -MoRef $nwSys
$networkConfig = New-Object Vmware.Vim.HostNetworkConfig
$vswtch = New-Object VMware.Vim.HostVirtualSwitchConfig
$networkConfig.vswitch = @($vswtch)
$networkConfig.vswitch[0].name = "SwitchName"
$spec = New-Object Vmware.Vim.HostVirtualSwitchSpec
$spec.numPorts = 1
$portgrp = New-Object VMware.Vim.HostPortGroupConfig
$networkConfig.portgroup = @($portgrp)
$portgropspec = New-Object VMware.Vim.HostPortGroupSpec
$portgropspec.vswitchName = "SwitchName"
$portgropspec.Name = "SwitchNamePort"
$portgropspec.Policy = New-Object VMware.Vim.HostNetworkPolicy
$networkConfig.vswitch[0].spec = $spec
$networkConfig.portgroup[0].spec = $portgropspec
$mor.AddVirtualSwitch("SwitchName",$spec ) $mor.AddPortGroup($portgropspec)

Thanks,Jaime


As you probably know NIC teaming can be defined on the switch and on the portgroup.
This example shows how it is done on a portgroup like you asked.
I left out the vSwitch objects and method so as not confuse you.

{noformat}
$HS = Get-View -ViewType "HostSystem" -Filter @{"Name" = <ESX-name>}
$nwSys = $HS.ConfigManager.NetworkSystem
$mor = Get-View $nwSys

$portgropspec = New-Object VMware.Vim.HostPortGroupSpec
$portgropspec.vswitchName = <vswitch-name>
$portgropspec.Name = <portgroup-name>

$portgropspec.Policy = New-Object VMware.Vim.HostNetworkPolicy

$portgropspec.Policy.NicTeaming = New-Object VMware.Vim.HostNicTeamingPolicy
$portgropspec.Policy.NicTeaming.failureCriteria = New-Object VMware.Vim.HostNicFailureCriteria
$portgropspec.Policy.NicTeaming.failureCriteria.checkBeacon = $false
$portgropspec.Policy.NicTeaming.failureCriteria.checkDuplex = $false
$portgropspec.Policy.NicTeaming.failureCriteria.checkErrorPercent = $false

$portgropspec.Policy.NicTeaming.nicOrder = New-Object VMware.Vim.HostNicOrderPolicy
$portgropspec.Policy.NicTeaming.nicOrder.activeNic = @(<NIC1-name>)
$portgropspec.Policy.NicTeaming.nicOrder.standbyNic = @(<NIC2-name>)
$portgropspec.Policy.NicTeaming.policy = "loadbalance_ip"

$mor.AddPortGroup($portgropspec)
{noformat}

Note1: in v1 of the VITK the functionality of the Find-EntityView cmdlet has been replaced by the Get-View cmdlet
Note2: for <vswitch-name> you use the name of an existing switch
Note3: "Link Status Only" is the default setting. All flags in the failureCriteria object are set to $false
Note4: for NIC1-name and NIC2-name you use 2 NICs that are already allocated to the vswitch
Note5: the choice for Active-Active or Active-Standby is up to you. If  you place the 2 NICs in the activeNic array , as  @(<NIC1-name>,<NIC2-name>), you will have Active-Active  teaming.


Awesome, thanks for helping me out again.  I am using v1 so I have been  using the Get-View cmlet.  I just copied the example from the FAQ page.

Jaime

This document was generated from the following thread: Nic Teaming Policy