Automation

 View Only
Expand all | Collapse all

How to Add host in LAG or

  • 1.  How to Add host in LAG or

    Posted Dec 06, 2019 02:02 PM

    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



  • 2.  RE: How to Add host in LAG or

    Posted Dec 06, 2019 03:27 PM

    Discussion moved from Forums to VMware PowerCLI



  • 3.  RE: How to Add host in LAG or

    Posted Dec 06, 2019 04:14 PM

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



  • 4.  RE: How to Add host in LAG or

    Posted Dec 06, 2019 04:37 PM

    ok so let elaborate you,

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



  • 5.  RE: How to Add host in LAG or

    Posted Dec 06, 2019 05:11 PM

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



  • 6.  RE: How to Add host in LAG or

    Posted Dec 07, 2019 11:34 AM

    Here is my VDS topology,

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

    Thanks



  • 7.  RE: How to Add host in LAG or
    Best Answer

    Posted Dec 07, 2019 03:42 PM

    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)

    }



  • 8.  RE: How to Add host in LAG or

    Posted Jan 19, 2020 07:32 AM

    Thanks LucD its works for all host.

    but want specific host only to move behind the lag so how can we configure using the script?

    Thanks

    Bharat



  • 9.  RE: How to Add host in LAG or

    Posted Jan 19, 2020 08:26 AM

    Try replacing

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

    with

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

    where{$_.Name -eq 'MyHost'} |



  • 10.  RE: How to Add host in LAG or

    Posted Jan 24, 2020 02:05 PM

    Thanks you Luc it works,

    I have multiple Nics on my server hence can move nics based on mac address.

    Thanks

    Bharat



  • 11.  RE: How to Add host in LAG or

    Posted Mar 26, 2021 09:53 PM

    Hi Luc,

    I am trying this script on the  on vcenter version VMware ESXi 6.7.0 ( VMKernal Release Build 15160138)  but its not working any clue where i have tried this on below vcenter  version works .

    nmbgdc_0-1616795513485.jpeg

     

    Thanks



  • 12.  RE: How to Add host in LAG or

    Posted Mar 26, 2021 10:09 PM

    Really?!?
    21 months after I provided you with a working script and where you never bothered to mark it as the correct solution.
    Don't think so



  • 13.  RE: How to Add host in LAG or

    Posted May 20, 2021 10:48 AM

    Thanks