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?
Try like this
$esxName = 'MyEsx'
$vdsName = 'MyVds'
$pnicName = 'vmnic1'
$uplinkName = 'Uplink 2'
$esx = Get-VMHost -Name $esxName
$vds = Get-VDSwitch -Name $vdsName -VMHost $esx
$uplinks = Get-VDPort -VDSwitch $vds -Uplink | where {$_.ProxyHost -like $esxName}
$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vds.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = $pnicName
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq $uplinkName} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am able to specify a vmnic to dvUplink successfully but I can only get it to apply to one port. Using the following script:
foreach ($VMHost in $VMHosts) {
Write-Host "Adding $VMHost vmnic0 to" $vds -ForegroundColor Yellow
$vmhostNetworkAdapter0 = Get-VMHost $VMHost | Get-VMHostNetworkAdapter -Physical -Name vmnic0
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter0 -Confirm:$false
#
$esxihost = Get-VMHost -name $VMHost
$pnicName = 'vmnic0'
$uplinkName = 'dvUplink0'
$vDS = Get-VDSwitch -Name $siteID-VDS -VMHost $VMHost
$uplinks = Get-VDPort -VDSwitch $vDS -Uplink | where {$_.ProxyHost -like $esxihost}
$netSys = Get-View -Id $esxihost.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vDS.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = $pnicName
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq $uplinkName} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
}
foreach ($VMHost in $VMHosts) {
Write-Host "Adding $VMHost vmnic4 to" $vds -ForegroundColor Yellow
$vmhostNetworkAdapter4 = Get-VMHost $VMHost | Get-VMHostNetworkAdapter -Physical -Name vmnic4
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter4 -Confirm:$false
#
$esxihost = Get-VMHost -name $VMHost
$pnicName = 'vmnic4'
$uplinkName = 'dvUplink4'
$vDS = Get-VDSwitch -Name $siteID-VDS -VMHost $VMHost
$uplinks = Get-VDPort -VDSwitch $vDS -Uplink | where {$_.ProxyHost -like $esxihost}
$netSys = Get-View -Id $esxihost.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vDS.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = $pnicName
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq $uplinkName} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
}
It applies vmnic4 to dvUplink4 but not vmnic0 to dvUplink0. Anyone have any suggestions?
Just out of interest is vmnic0 already assigned to a switch before running the script?
No. I was hoping this would add it and at the same time map to the correct dvUplink but for some reason (I suck at scripting) it only maps vmnic4.
So what vmnic is your esxi host management traffic running on?
Try with the following.
It assumes that you have corresponding uplinks and vmnics.
In other words, if you have dvUplink1, dvUplink2 and dvUplink3, you should have vmnic1,vmnic2 and vmnic3.
If you desire other mapping between the uplink numbers and the vmnic numbers, the script needs to be changed.
$esxName = 'MyEsx'
$vdsName = 'MyVds'
$esx = Get-VMHost -Name $esxName
$vds = Get-VDSwitch -Name $vdsName -VMHost $esx
$uplinks = Get-VDPort -VDSwitch $vds -Uplink | where {$_.ProxyHost -like $esxName}
$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vds.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
1..$vds.NumUplinkPorts | %{
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = "vmnic$($_)"
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq "dvUplink$($_)"} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
}
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The hosts have 6 nics that are setup as trunk ports on the switch. The goal is to add the hosts to the vds, assign vmnic0 to the correct dvUplink, migrate the management vmkernel to the vds and then assign all over vmnics to their correct dvUplinks.
Thanks LucD. I will give it a try this morning.
In the current form, the script will assign vmnic1 to dvUplink1, and so on.
Looks like you want vmnic0 assigned to dvUplink1, and so on, is that correct?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We have renamed the dvUplinks to dvUplink0, dvUplink1, dvUplink4, dvUplink5, dvUplink6 and dvUplink8. We want to map vmnic0 to dvUplink0, vmnic1 to dvUplink1, vmnic4 to dvUplink4, vmnic5 to dvUplink5, vmnic6 to dvUplink6 and vmnic8 to dvUplink8.
Then this
1..$vds.NumUplinkPorts | %{
should become this
0..($vds.NumUplinkPorts - 1) | %{
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Very new to PowerCLI but working on automating adding and configuring a new host to Vcenter. The only piece missing in my script is the assignment of the host's physical vmnic to my vdswitch uplinks in the same numerical order vmnic0 to vdUplink0, vmnic1 to vdUplink1, ....etc
Would LucD's code below allow me to do this?
$esxName = 'MyEsx'
$vdsName = 'MyVds'
$esx = Get-VMHost -Name $esxName
$vds = Get-VDSwitch -Name $vdsName -VMHost $esx
$uplinks = Get-VDPort -VDSwitch $vds -Uplink | where {$_.ProxyHost -like $esxName}
$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vds.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
0..($vds.NumUplinkPorts -1) | %{
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = "vmnic$($_)"
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq "dvUplink$($_)"} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
}
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
Thank you so much for your help!
You might want to review your ForEach loop (0..($vds.NumUplinkPorts -1) | %{), vmnic and Uplinks are not zero-based but start at 1.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Below is the desired association between the Host Physical Network Adapters and the Uplinks. How should the ForEach loop be modified to achieve this?
Try something like this
$esxName = 'MyEsx'
$vdsName = 'MyVds'
$upLinkNames = '0-VMK-VSPHERE-A','1-VMK-VSPHERE-B','2-VMK-ISCSI-A','3-VMK-ISCSI-B',
'4-VMK-VMOTION-A','5-VMK-VMOTION-B','6-VMK-TRUNK-A','7-VMK-TRUNK-B'
$esx = Get-VMHost -Name $esxName
$vds = Get-VDSwitch -Name $vdsName -VMHost $esx
$uplinks = Get-VDPort -VDSwitch $vds -Uplink | where {$_.ProxyHost -like $esxName}
$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $vds.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
for($i=0;$i -lt $vds.NumUplinkPorts;$i++){
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = "vmnic$($_)"
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq $upLinkNames[$i]} | Select -ExpandProperty Key
$proxy.Spec.Backing.PnicSpec += $pnic
}
$config.ProxySwitch += $proxy
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your quick reply and help with this!!! Will give this a shot.
Hey all, hopefully I'll be able to get some help here.
I'm having some problems adapting this code to work. My scenario is that I have a host that is connected to a VSS, and I need to move uplinks to a VDS, attaching them to LAG uplinks, and moving vmk0 in one shot.
I get an invalid argument error when I try to use the modeled code, adapted for my environment. My vmk0 move code is also not working, it reports an error about port group not found:
Exception calling "UpdateNetworkConfig" with "2" argument(s): "
Required property portgroup is missing from data object of type HostVirtualNicConfig
while parsing serialized DataObject of type vim.host.VirtualNic.Config
at line 1, column 666
while parsing property "vnic" of static type ArrayOfHostVirtualNicConfig
while parsing serialized DataObject of type vim.host.NetworkConfig
at line 1, column 269
while parsing call information for method UpdateNetworkConfig
at line 1, column 171
while parsing SOAP body
at line 1, column 64
while parsing SOAP envelope
at line 1, column 0
while parsing HTTP request for method updateNetworkConfig
on object of type vim.host.NetworkSystem
at line 1, column 0"
At line:36 char:13
+ $netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Add pnics to LAG:
Exception calling "UpdateNetworkConfig" with "2" argument(s): "A specified parameter was not correct: "
At line:1 char:2
+ $netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
hostd:
2018-05-31T15:29:11.651Z info hostd[D440B70] [Originator@6876 sub=Vimsvc.ha-eventmgr opID=4a3e04b1-b464 user=vpxuser:vpxuser] Event 81945 : Reconfigured ports in the vS phere Distributed Switch in ha-datacenter.
-->
--> Ports changed 1249, 1250.
-->
--> Changes are
2018-05-31T15:29:11.651Z info hostd[D440B70] [Originator@6876 sub=Vimsvc.TaskManager opID=4a3e04b1-b464 user=vpxuser:vpxuser] Task Completed : haTask-ha-host-vim.host.N etworkSystem.commitTransaction-167323790 Status success
2018-05-31T15:29:11.651Z info hostd[D0C1B70] [Originator@6876 sub=Hostsvc.DvsTracker] HandleDvsUpdate called
2018-05-31T15:29:11.651Z verbose hostd[D440B70] [Originator@6876 sub=PropertyProvider opID=4a3e04b1-b464 user=vpxuser:vpxuser] RecordOp ASSIGN: info, haTask-ha-host-vim .host.NetworkSystem.commitTransaction-167323790. Applied change to temp map.
2018-05-31T15:29:11.654Z verbose hostd[D440B70] [Originator@6876 sub=PropertyProvider opID=5782b466 user=vpxuser] RecordOp ASSIGN: info, haTask--vim.event.EventHistoryC ollector.readNext-167323791. Applied change to temp map.
2018-05-31T15:29:11.654Z verbose hostd[D440B70] [Originator@6876 sub=PropertyProvider opID=5782b466 user=vpxuser] RecordOp ASSIGN: info, haTask--vim.event.EventHistoryC ollector.readNext-167323791. Applied change to temp map.
2018-05-31T15:29:11.656Z verbose hostd[DF40B70] [Originator@6876 sub=PropertyProvider opID=5782b467 user=vpxuser] RecordOp ASSIGN: info, haTask--vim.event.EventHistoryC ollector.readNext-167323792. Applied change to temp map.
2018-05-31T15:29:11.656Z verbose hostd[DF40B70] [Originator@6876 sub=PropertyProvider opID=5782b467 user=vpxuser] RecordOp ASSIGN: info, haTask--vim.event.EventHistoryC ollector.readNext-167323792. Applied change to temp map.
2018-05-31T15:29:11.656Z info hostd[ABABB70] [Originator@6876 sub=Vimsvc.TaskManager opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Task Created : haTask-ha-host-vim.host. NetworkSystem.invokeHostTransactionCall-167323793
2018-05-31T15:29:11.656Z verbose hostd[ABABB70] [Originator@6876 sub=PropertyProvider opID=3c093e25-7a-b468 user=vpxuser:vpxuser] RecordOp ADD: recentTask["haTask-ha-ho st-vim.host.NetworkSystem.invokeHostTransactionCall-167323793"], ha-host. Sent notification immediately.
2018-05-31T15:29:11.656Z verbose hostd[ABABB70] [Originator@6876 sub=PropertyProvider opID=3c093e25-7a-b468 user=vpxuser:vpxuser] RecordOp ADD: recentTask["haTask-ha-ho st-vim.host.NetworkSystem.invokeHostTransactionCall-167323793"], ha-taskmgr. Applied change to temp map.
2018-05-31T15:29:11.656Z verbose hostd[DF40B70] [Originator@6876 sub=PropertyProvider opID=3c093e25-7a-b468 user=vpxuser:vpxuser] RecordOp ASSIGN: info, haTask-ha-host- vim.host.NetworkSystem.invokeHostTransactionCall-167323793. Applied change to temp map.
2018-05-31T15:29:11.666Z info hostd[DF40B70] [Originator@6876 sub=Hostsvc.NetworkVmkSimulator opID=3c093e25-7a-b468 user=vpxuser:vpxuser] DvsAddNic: pnic vmnic4 not fr ee
2018-05-31T15:29:11.666Z info hostd[DF40B70] [Originator@6876 sub=Hostsvc opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Simulate failed
2018-05-31T15:29:11.667Z info hostd[DF40B70] [Originator@6876 sub=Default opID=3c093e25-7a-b468 user=vpxuser:vpxuser] AdapterServer caught exception: vmodl.fault.Invali dArgument
2018-05-31T15:29:11.667Z info hostd[DF40B70] [Originator@6876 sub=Vimsvc.TaskManager opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Task Completed : haTask-ha-host-vim.hos t.NetworkSystem.invokeHostTransactionCall-167323793 Status error
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=PropertyProvider opID=3c093e25-7a-b468 user=vpxuser:vpxuser] RecordOp ASSIGN: info, haTask-ha-host- vim.host.NetworkSystem.invokeHostTransactionCall-167323793. Applied change to temp map.
2018-05-31T15:29:11.667Z info hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Activation [N5Vmomi10ActivationE:0x0cc75b30] : Invoke done [invokeHostTransactionCall] on [vim.host.NetworkSystem:networkSystem]
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg transactionId:
--> "4185"
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg timeout:
--> 120
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg methodName:
--> "updateNetworkConfig"
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg param1:
--> (vim.host.NetworkConfig) {
--> vswitch = <unset>,
--> proxySwitch = (vim.host.HostProxySwitch.Config) [
--> (vim.host.HostProxySwitch.Config) {
--> changeOperation = "edit",
--> uuid = "50 35 33 10 2a 58 c8 fe-e8 89 36 99 d2 31 93 de",
--> spec = (vim.host.HostProxySwitch.Specification) {
--> backing = (vim.dvs.HostMember.PnicBacking) {
--> pnicSpec = (vim.dvs.HostMember.PnicSpec) [
--> (vim.dvs.HostMember.PnicSpec) {
--> pnicDevice = "vmnic4",
--> uplinkPortKey = "1249",
--> uplinkPortgroupKey = "dvportgroup-331024",
--> connectionCookie = 554886514
--> },
--> (vim.dvs.HostMember.PnicSpec) {
--> pnicDevice = "vmnic5",
--> uplinkPortKey = "1250",
--> uplinkPortgroupKey = "dvportgroup-331024",
--> connectionCookie = 554888430
--> }
--> ]
--> }
--> }
--> }
--> ],
--> portgroup = <unset>,
--> pnic = <unset>,
--> vnic = <unset>,
--> consoleVnic = <unset>,
--> dnsConfig = (vim.host.DnsConfig) null,
--> ipRouteConfig = (vim.host.IpRouteConfig) null,
--> consoleIpRouteConfig = (vim.host.IpRouteConfig) null,
--> routeTableConfig = (vim.host.IpRouteTableConfig) null,
--> dhcp = <unset>,
--> nat = <unset>,
--> ipV6Enabled = <unset>,
--> netStackSpec = <unset>
--> }
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg param2:
--> "modify"
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg param3:
--> (null)
2018-05-31T15:29:11.667Z verbose hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Arg param4:
--> (null)
2018-05-31T15:29:11.667Z info hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Throw vmodl.fault.InvalidArgument
2018-05-31T15:29:11.667Z info hostd[DF40B70] [Originator@6876 sub=Solo.Vmomi opID=3c093e25-7a-b468 user=vpxuser:vpxuser] Result:
--> (vmodl.fault.InvalidArgument) {
--> faultCause = (vmodl.MethodFault) null,
--> faultMessage = <unset>,
--> invalidProperty = <unset>
--> msg = ""
--> }
Code:
$pnics = (Get-VMHostNetworkAdapter -VMHost $vmhost | where {$_.Name.StartsWith("vmnic")}) | where {$_.ExtensionData.LinkSpeed.SpeedMb -eq 10000}
$uplinks = Get-VDPort -VDSwitch $myVDSObj -Uplink | where {$_.ProxyHost -like $vmhost.name} | where {$_.name.StartsWith("lag1")}
$netsys = Get-View -Id $vmhost.ExtensionData.ConfigManager.NetworkSystem
$config = New-Object VMware.Vim.HostNetworkConfig
$proxy = New-Object VMware.Vim.HostProxySwitchConfig
$proxy.Uuid = $myVDSObj.ExtensionData.Uuid
$proxy.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$proxy.Spec = New-Object VMware.Vim.HostProxySwitchSpec
$proxy.Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking
for ($i=0; $i -lt $myVDSObj.NumUplinkPorts;$i++)
{
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.PnicDevice = $pnics[$i].name
$pnic.UplinkPortKey = $uplinks | where{$_.Name -eq "lag1-$i"} | Select -ExpandProperty Key
Write-host $pnic.UplinkPortgroupKey
$proxy.Spec.Backing.PnicSpec += $pnic
}
#time for another beer
#stage the migration of vmk0
$vnicConfig = new-object VMware.Vim.HostVirtualNicConfig
$vnicConfig.ChangeOperation = [VMware.Vim.HostConfigChangeOperation]::edit
$vnicConfig.Device = "vmk0"
$vnicConfig.Spec = New-Object VMware.Vim.HostVirtualNicSpec
$vnicConfig.Spec.Portgroup = "Management Network"
$vnicconfig.Spec.DistributedVirtualPort = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection
$vnicConfig.Spec.DistributedVirtualPort.SwitchUuid = $myVDSObj.ExtensionData.Uuid
$vnicConfig.Spec.DistributedVirtualPort.PortgroupKey = $hostmgmtPG.Key
$config.ProxySwitch += $proxy
# $config.vnic += $vnicConfig
$netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode]::modify)
Exception calling "UpdateNetworkConfig" with "2" argument(s): "A specified parameter was not correct: "At line:1 char:2+ $netSys.UpdateNetworkConfig($config,[VMware.Vim.HostConfigChangeMode ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : VimException
The problem seems to be "pnic vmnic4 not free".
I would need a bit more info on the current config of the switches, vmnics and pnics to further analyse.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
vmnic4 and 5 are both bound to a vSwitch0 and are providing the basic network connectivity after build.
Do i need to incorporate a spec that removes the bind from vSwitch0 as part of this?
Editing to add more context.
When the systems are built, all vmnics are tossed into vSwitch 0, but only x10 GB nics are actually cabled. The switch is configured with the two ports of the host in LACP, with failback mode enabled (i.e. if the switch does not receive LACP patches, it disables LACP)
The desired end state is that the hosts end up with on the VDS, uplinked to LAG1-0/1 so that it begins transmitting LACP packets, additionally we have to toss vmk0 along for the ride so that the host remains accessible.
We are able to do this in this in one shot in the web client with a sufficiently large network rollback timeout.