6 Replies Latest reply on Dec 7, 2019 7:42 AM by LucD

    How to Add host in LAG or

    nmbgdc Lurker

      Hi Team,

       

      I am trying to find the powercli script but not getting,

       

      So here is my scenario,

      1- Host has two physical nics vmnic-0 and vmnic1

      2- Host are already part of the dvs behind multiple port group  with uplink1- vmnic0 and uplink2-vmnic1.

       

      Now we have configure LACP & created LAG1 & LAG2, and after this steps just wanted to connect the host in LAGs, existing one and will connect new host also, does anyone has any powercli script which can does the job?

       

       

      Thanks

        • 1. Re: How to Add host in LAG or
          a.p. Guru
          Community WarriorsvExpertUser Moderators

          Discussion moved from Forums to VMware PowerCLI

          • 2. Re: How to Add host in LAG or
            LucD Guru
            User ModeratorsCommunity WarriorsvExpert

            Not sure exactly what you mean by "connect the host".
            Do you mean the Migrating network traffic to LAGs option in the Web Client?

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: How to Add host in LAG or
              nmbgdc Lurker

              ok so let elaborate you,

               

              basically I want to add host in vds but now vds is configured with lag Instid of uplink.

              • 4. Re: How to Add host in LAG or
                LucD Guru
                Community WarriorsvExpertUser Moderators

                Can you share a screenshot of the topology of the VDS?

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: How to Add host in LAG or
                  nmbgdc Lurker

                  Here is my VDS topology,

                   

                  If you see right now all host nic are behind the uplink1 & Uplink2

                   

                   

                  Thanks

                  • 6. Re: How to Add host in LAG or
                    LucD Guru
                    Community WarriorsUser ModeratorsvExpert

                    Try something like this

                     

                    $vdsName = 'dvs-1'

                    $lagName = 'mgmt-lag'

                    $tgtDevs = 'vmnic0', 'vmnic1'


                    $vds = Get-VDSwitch -Name $vdsName

                    $uplPg = Get-VDPortgroup -VDSwitch $vds -Name *UpLinks*

                    Get-View -Id  $vds.ExtensionData.Summary.Host |

                    ForEach-Object -Process {

                        $netSys = Get-View -Id $_.ConfigManager.NetworkSystem

                        $lagPorts = (($netSys.NetworkInfo.ProxySwitch | where { $_.DvsUuid -eq $vds.Key }).HostLag |

                            where { $_.LagName -eq $lagName }).UplinkPort.Key

                        $i = 0

                        $spec = New-Object VMware.Vim.HostNetworkConfig

                        $proxy = New-Object VMware.Vim.HostProxySwitchConfig

                        $proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit

                        $proxy.Uuid = $vds.Key

                        $proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec

                        $proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking


                        ($netSys.NetworkInfo.ProxySwitch | where { $_.DvsUuid -eq $vds.Key }).Spec.Backing.PnicSpec |

                        ForEach-Object -Process {

                            if ($tgtDevs -contains $_.PnicDevice)

                            {

                                $pNicSpec = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec

                                $pNicSpec.PnicDevice = $_.PnicDevice

                                $pNicSpec.UplinkPortKey = $lagPorts[$i]

                                $pNicSpec.UplinkPortgroupKey = $uplPg.Key

                                $proxy.Spec.Backing.PnicSpec += $pNicSpec

                                $i++

                            }

                            else

                            {

                                $proxy.Spec.Backing.PnicSpec += $_

                            }


                        }

                        $spec.ProxySwitch += $proxy

                        $netSys.UpdateNetworkConfig($spec, [VMware.Vim.HostConfigChangeMode]::modify)

                    }

                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz