4 Replies Latest reply on Dec 12, 2017 8:24 AM by LucD

    Add physical nic to a specific ulplick port of VDS

    Kanstantsin Novice

      Hi there,

      I have an issue with adding physical nic to a specific uplink port on the VDS

      In powercli we have this example

      >man Add-VDSwitchPhysicalNetworkAdapter -Examples

      --------------  Example 1 --------------

         

          C:\PS>$vmhostNetworkAdapter = Get-VMHost "MyVMHost" | Get-VMHostNetworkAdapter -Physical -Name vmnic2

          Get-VDSwitch "MyVDSwitch" | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $vmhostNetworkAdapter

       

          --------------  Example 2 --------------

         

          C:\PS>$myVMHost = Get-VMHost "MyVMHost"

          $physicalNic = Get-VMHostNetworkAdapter -VMHost $myVMHost -Name "vmnic0"

          $virtualNic = Get-VMHostNetworkAdapter -VMHost $myVMHost -Name "vmk0"

          Get-VDSwitch -Name "MyVDSwitch" | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $physicalNic -VMHostVirtualNic $virtualNic -VirtualNicPortgroup 'MyVDPortGroup'

       

       

      In command Add-VDSwitchPhysicalNetworkAdapter there aren't any parameter for specific uplink port

       

      But, I have 6 uplink ports on my VDS uplink portgroup.

      And I want to add nic to a specific uplink port. For example uplink1

      How I can do it?

       

      Thanks in advance.

        • 1. Re: Add physical nic to a specific ulplick port of VDS
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          Have a look at my DvSwitch Scripting – Part 4 – NIC Teaming post.

          The Add-dvSwHostpNic function in there shows how to add a pNIC to a free Uplink port, but it could easily be changed to add replace a pNIC on a specific Uplink.

          Let me know if you need some sample code?

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Add physical nic to a specific ulplick port of VDS
            LucD Guru
            User ModeratorsvExpertCommunity Warriors

            To replace a pNic on a specific Uplink, you can do something like this.

            In the script the existing vmnic1 is replaced by vmnic2.

            Note that the script doesn't do any sanity checking, for example checking if the pNics are already in use or not.

             

            $vdsName = 'vds1'

            $oldPNic = 'vmnic1'

            $newPNic = 'vmnic2'

             

            $vds = Get-VDSwitch -Name $vdsName

             

            foreach($esx in (Get-View -Id $vds.ExtensionData.Summary.HostMember)){

                $vds = $esx.Config.Network.ProxySwitch | where{$_.DvsName -eq $vdsName}

             

                $netSys = Get-View -Id $esx.ConfigManager.NetworkSYstem

                $proxy = $netSys.NetworkInfo.ProxySwitch | where{$_.DvsName -eq $vdsName}

               

                $spec = New-Object VMware.Vim.HostNetworkConfig

               

                $newProxy = New-Object VMware.Vim.HostProxySwitchConfig

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

                $newProxy.Uuid = $proxy.DvsUuid

             

                $proxySpec = New-Object VMware.Vim.HostProxySwitchSpec

             

                $proxySpec.Backing = $proxy.Spec.Backing

                $proxySpec.Backing | %{

                    $_.PnicSpec | %{

                        if($_.PnicDevice -eq $oldPNic){

                            $_.PnicDevice = $newPNic

                        }

             

                    }

                }

             

                $newProxy.Spec = $proxySpec

             

                $spec.ProxySwitch += $newProxy

             

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

            }

             

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: Add physical nic to a specific ulplick port of VDS
              robbielozier Enthusiast

              I am migrating my vmnics one at a time to the vDS using the following script:

               

              foreach ($VMHost in $VMHosts) {

              $vmhostNetworkAdapter0 = Get-VMHost $vmhost | Get-VMhostNetworkAdapter -Physical -Name vmnic0

              $vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter0

               

              foreach ($VMHost in $VMHosts) {

              $vmhostNetworkAdapter4 = Get-VMHost $vmhost | Get-VMhostNetworkAdapter -Physical -Name vmnic4

              $vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter4

               

              Is there a way to map vmnic0 to dvUplink0 and vmnic4 to dvUplink4 during this process?

              • 4. Re: Add physical nic to a specific ulplick port of VDS
                LucD Guru
                Community WarriorsUser ModeratorsvExpert
                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz