coolsport00
Enthusiast
Enthusiast

Modify PortGroup Nic Teaming Policy

Jump to solution

Version Info:
vSphere 6.7U1
PowerCLI 6.5.1
Standalone Host (no vCenter yet)

Created a Standard Virtual Switch on my Host. Wanting to create 2 PortGroups used for iSCSI connection. Created a script that works... have created the PortGroups, then able to create the VMkernel Ports & assign them to the proper PortGroup. All seems fine when I run the script.. i.e. no errors. But, when I log into the Host UI and verify my configs 'took', I see the Nic Teaming Policy for each of my PortGroups did not get changed. If you recall, for iSCSI, you have to have ONLY ONE vmnic assigned per PG as 'active', and all others as 'unused'. In my script, I state to use 1 of my vmnic's as active and 1 as unused, but the PowerCLI configuration doesn't take affect on the Host. Just trying to figure out why. Below is the script I created for this configuration:

#Create vSwitch1 PortGroups and VMkernel PortGroups

$vmk1 = 'ISCSI-1','ISCSI-2'

$i = 0

if($i -lt 2) {

    foreach ($vmk in $vmk1) {

    #Get the vmnics for setting Active & Unused for each Portgroup

    $vmkAct = Read-Host "

    Enter Active Nic for $vmk teaming policy (vmnic#) "

    $vmkUnused = Read-Host "

    Enter Unused Nic for $vmk teamng policy (vmnic#) "

    #Create the Portgroups, then set the Nic Teaming Policy

    New-VirtualPortGroup -VirtualSwitch $vs1 -Name $vmk | Out-Null

    Get-VirtualPortgroup -Name $vmk | Get-NicTeamingPolicy | Set-NicTeamingPolicy -InheritFailoverOrder $false -MakeNicActive $vmkAct -MakeNicUnused $vmkUnused | Out-Null

    $i++

    }

#Create vSwitch1 VMkernel PortGroups

$n = 1

    foreach ($vmk in $vmk0) {

    $vs1vmkIP = Read-Host "Enter vmk$n IP "

    New-VMHostNetworkAdapter -VirtualSwitch $vs1 -PortGroup $vmk -IP $vs1vmkIP -SubnetMask $vmkSubnet -Mtu 9000 -Confirm:$false | Out-Null

    $n++

    }

}

Thanks for any assistance provided.

~coolsport00

(Shane)

#vExpert , #VeeamVanguard
Sr. Systems Engineer

0 Kudos
1 Solution

Accepted Solutions
coolsport00
Enthusiast
Enthusiast

Ok, so I ended up figuring out how to do this. When setting pNics as 'Active', 'Standby', or 'Unused', you do NOT need to do an explicit call to the parameter "-InhertitedFailoverOrder". All you need to do is an explicit call to the Nic types you want: -MakeNicActive -MakeNicStandby or -MakeNicUnused . The 'Inherit Failover Order' policy setting will get changed automatically when setting the pNics on the PG. So to state how I resolved this, I still used my original code, but simply removed the -InheritedFailoverOrder parameter and voila! It worked! Thanks Chris for chiming in. Much appreciated.

~@coolsport00

(Shane)

View solution in original post

0 Kudos
3 Replies
Zsoldier
Expert
Expert

I think it has to do w/ the way you are defining your physical adapters.  You are capturing them as strings, but the Set-TeamingPolicy "MakeNicActive" and "MakeNicUnused" are looking for physical nic objects.

#Get the vmnics for setting Active & Unused for each Portgroup

    $vmkAct = Read-Host "

    Enter Active Nic for $vmk teaming policy (vmnic#) "

$vmkAct = Get-VMhostNetworkAdapter -Name $vmkAct

    $vmkUnused = Read-Host "

    Enter Unused Nic for $vmk teamng policy (vmnic#) "

$vmkUnused = Get-VMhostNetworkAdapter -Name $vmkUnused

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos
coolsport00
Enthusiast
Enthusiast

Hi Chris -

Thanks for the response. I actually thought that exact same thing. I did test an 'explicit' pNic assignment with no luck. I call all my pNics earlier in my script this way:

$esxNics = Get-VMHostNetworkAdapter -VMhost $esxHost -Physical

Then to test an 'explicit' pNic assignment, I did this script:

Get-VirtualPortgroup -Name $vmk | Get-NicTeamingPolicy | Set-NicTeamingPolicy -InheritFailoverOrder $false -MakeNicActive $esxNics[4] -MakeNicUnused $esxNics[7]

...still didn't work. Smiley Sad


The reason I need to kind of do my script the way I'm doing it is because of how iSCSI pNic assignment and iSCSI Teaming works - only 1 Active pNic can be assigned to the PG, with all others marked as Unused.

The issue isn't syntax or anything like that with my script. The issue has to be I think, as we both think... something in how you call and/or assign the Nics. I just don't know what that "rule" is. And it isn't documented anywhere that I've searched, including VMware 'Code" and PCLI docs. Ugh. Well.. even though I tried that yesterday. Think I'll try it again and see. If you have any idea how to modify my script to assign an explicit pNic as Active on a PG and other Inactive, let me know.

Thanks!

0 Kudos
coolsport00
Enthusiast
Enthusiast

Ok, so I ended up figuring out how to do this. When setting pNics as 'Active', 'Standby', or 'Unused', you do NOT need to do an explicit call to the parameter "-InhertitedFailoverOrder". All you need to do is an explicit call to the Nic types you want: -MakeNicActive -MakeNicStandby or -MakeNicUnused . The 'Inherit Failover Order' policy setting will get changed automatically when setting the pNics on the PG. So to state how I resolved this, I still used my original code, but simply removed the -InheritedFailoverOrder parameter and voila! It worked! Thanks Chris for chiming in. Much appreciated.

~@coolsport00

(Shane)

View solution in original post

0 Kudos