3 Replies Latest reply on Feb 27, 2019 5:35 AM by coolsport00

    Modify PortGroup Nic Teaming Policy

    coolsport00 Enthusiast
    vExpert

      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

        • 1. Re: Modify PortGroup Nic Teaming Policy
          Zsoldier Expert
          vExpert

          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

          • 2. Re: Modify PortGroup Nic Teaming Policy
            coolsport00 Enthusiast
            vExpert

            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.


            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!

            • 3. Re: Modify PortGroup Nic Teaming Policy
              coolsport00 Enthusiast
              vExpert

              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)