VMware Cloud Community
nicholas1982
Hot Shot
Hot Shot

Assign vminc to Specific Uplink on VDS

Hi All,

I have requirement to assign vminic1 to Uplink 2 on my VDS.. vminic0 is assigned to VSS vSwitch0 and before migrating VMkernels to the VDS (via Powershell) I need to have an active Uplink on it. When assigning the vminc1 to the VDS it defaults to Uplink 1 is there anyway to specify Uplink 2.

My current work around in my script is to add the vminc1 to VSS, set active Nic Team as active for both vmnics then move vmnic0 to VDS?

Nicholas
46 Replies
LucD
Leadership
Leadership

I suspect the issue is due to the names of the uplinks.
For example, if they are named "Uplink 1", "Uplink 2", .. instead of "dvUplink1", "dvUplink2", ... you will have to change line

    $pnic.UplinkPortKey = $uplinks | Where-Object { $_.Name -eq "dvUplink$i" } | Select-Object -ExpandProperty Key

to

    $pnic.UplinkPortKey = $uplinks | Where-Object { $_.Name -eq "Uplink $i" } | Select-Object -ExpandProperty Key

   


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ehsani2017
Contributor
Contributor

Hi LucD

for ($i = 1; $i -lt $vds.NumUplinkPorts; $i++) {

$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec

$pnic.PnicDevice = "vmnic$($i)"

$pnic.UplinkPortKey = $uplinks | where {$_.Name -eq "Uplink $i"} | Select -ExpandProperty Key

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

}

$config.ProxySwitch += $proxy

$netSys.UpdateNetworkConfig($config, [VMware.Vim.HostConfigChangeMode]::modify)
Exception calling "UpdateNetworkConfig" with "2" argument(s): "There is an error in the XML document."
At line:41 char:1
+ $netSys.UpdateNetworkConfig($config, [VMware.Vim.HostConfigChangeMode ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

 

But I think dvUplink$i is correct because:

PS C:\> $uplinks

Key Name ConnectedEntity Portgroup IsLinkUp MacAddress Vlan Switch
--- ---- --------------- --------- -------- ---------- ---- ------
10 dvUplink0 Prod-vDS-Switch-D... Prod-vDS-S...
11 dvUplink1 Prod-vDS-Switch-D... Prod-vDS-S...
12 dvUplink2 Prod-vDS-Switch-D... Prod-vDS-S...
13 dvUplink3 Prod-vDS-Switch-D... Prod-vDS-S...
14 dvUplink4 Prod-vDS-Switch-D... Prod-vDS-S...
15 dvUplink5 Prod-vDS-Switch-D... Prod-vDS-S...
16 dvUplink6 Prod-vDS-Switch-D... Prod-vDS-S...
17 dvUplink7 Prod-vDS-Switch-D... Prod-vDS-S...
18 dvUplink8 Prod-vDS-Switch-D... Prod-vDS-S...
19 dvUplink9 Prod-vDS-Switch-D... Prod-vDS-S...

 

PS C:\> $uplinks[0]| fl


ExtensionData : VMware.Vim.DistributedVirtualPort
Key : 10
Description :
IsBlocked : False
IsBlockedInherited : True
IsLinkUp :
MacAddress :
VlanConfiguration : VLAN Trunk [0-4094]
ConnectedEntity :
ProxyHost : esxi-1.lab.local
Portgroup : Prod-vDS-Switch-DVUplinks-6027
Switch : Prod-vDS-Switch
Name : dvUplink0
Id : 10
Uid : /VIServer=vsphere.local\administrator@lab-vcsa.lab.local:443/DistributedPort=10/

Regards

Jawad

0 Kudos
LucD
Leadership
Leadership

Then you will have to check in the vpxd log if there is more info about the error.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ehsani2017
Contributor
Contributor

Hi LucD

when I try this one, it works.


foreach ($vhost in $hh) {

$vds = Get-VDSwitch

$uplinks = $vhost | Get-VDSwitch | Get-VDPort -Uplink | where {$_.ProxyHost -like $vhost.Name}

#$vhost | Get-VMHostNetworkAdapter -Name $vmnics | Remove-VirtualSwitchPhysicalNetworkAdapter -Confirm:$false

$config = New-Object VMware.Vim.HostNetworkConfig
$config.proxySwitch = New-Object VMware.Vim.HostProxySwitchConfig[] (1)
$config.proxySwitch[0] = New-Object VMware.Vim.HostProxySwitchConfig
$config.proxySwitch[0].changeOperation = "edit"
$config.proxySwitch[0].uuid = $vds.Key
$config.proxySwitch[0].spec = New-Object VMware.Vim.HostProxySwitchSpec
$config.proxySwitch[0].spec.backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
$config.proxySwitch[0].spec.backing.pnicSpec = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec[] (10)


for($i=1 ;$i -lt $vds.NumUplinkPorts;$i++){

$config.proxySwitch[0].spec.backing.pnicSpec[$i] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$config.proxySwitch[0].spec.backing.pnicSpec[$i].pnicDevice = "vmnic$i"
$config.proxySwitch[0].spec.backing.pnicSpec[$i].uplinkPortKey = ($uplinks | where {$_.Name -eq "dvUplink$i"}).key

$_this = Get-View (Get-View $vhost).ConfigManager.NetworkSystem
$_this.UpdateNetworkConfig($config, "modify")

}
}

Thanks in advance for your advice.

0 Kudos
KlinikenLB
Contributor
Contributor

I have exactly the same question like Nicholas at the beginning. And I hoped that there is a simple cmdlet with according parameters ...

Let's have a look, if I find my solution here.

Regards, Dietmar

0 Kudos
KlinikenLB
Contributor
Contributor

Lot of code up here where I do not really understand everything (especially the New- and Where-Object commands) 😞

At the moment I look for a special point: meanwhile I have a VDS with one unused NIC uplink and my "old" VSS with one NIC connection and there the vmk0 with management on it. How do I get now the vmk0 from VSS to VDS without loosing my connection to management? In the GUI it works well. But how can I do it with PowerCLI?

Thx and regards

Dietmar

0 Kudos
LucD
Leadership
Leadership

Use Code Capture to see the code behind the action(s) in the Web Interface.
See this thread for an example.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos