Hello all, I need help tranfering a vmnic from an ESXi 5.5 to a specific Uplink Port Group on a Cisco Nexus 1000v.
Using PowerCLI 5.5, ESXi 5.5, vSphere 5.5
This is what I have:
$VMHost = ESXIHostname
$VDSwitch = XSW0010
#Get VMhost object data
$VMHostobj = Get-VMHost $VMHost
#Add to new DVSwitch
$VDSwitch = Get-VDSwitch $VDSwitch
$VDSwitch | Add-VDSwitchVMHost -VMHost $VMHost -Confirm:$false
#Get physical adapter to move
$vmhostadapter = $VMhostObj | Get-VMHostNetworkAdapter -Physical -Name vmnic5
#Define Port Group Uplink on VDS
$PE_PROD_UPLINK = Get-VDPortGroup -Name PE_PROD_UPLINK -VDSwitch XSW0010
$ME_MGMT_UPLINK = Get-VDPortGroup -Name ME_MANAGEMENT_UPLINK -VDSwitch XSW0010
# Add 1 physical adapter
Add-VDSwitchPhysicalNetworkAdapter -VirtualNicPortgroup "ME_MGMT_UPLINK" -DistributedSwitch $VDSwitch -VMHostPhysicalNic $vmhostadapter -Confirm:$false
I get the following error after the last line run's:
PowerCLI D:\Admin\Script> Add-VDSwitchPhysicalNetworkAdapter -VirtualNicPortgroup "ME_MGMT_UPLINK" -DistributedSwitch $VDSwitch -VMHostPhysicalNic $vmhostadapter -Confirm:$false
Add-VDSwitchPhysicalNetworkAdapter : No VirtualNics specified to be migrated to the specified portgroup(s)
At line:1 char:1
+ Add-VDSwitchPhysicalNetworkAdapter -VirtualNicPortgroup "ME_MGMT_UPLINK" -Distri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-VDSwitchPhysicalNetworkAdapter], InvalidArgument
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument,VMware.VimAutomation.Vds.Commands.Cmdlets.AddVDSwitchPhysicalNetworkAdapter
If I run the following it runs fine but places the vmnic in the wrong port group
Add-VDSwitchPhysicalNetworkAdapter -DistributedSwitch $VDSwitch -VMHostPhysicalNic $vmhostadapter -Confirm:$false
Thanks for any help
Afaik, on the Add-VDSwitchPhysicalNetworkAdapter cmdlet you also have to provide the VMHostVirtualNic parameter.
In your example that would be "vmnic5".
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the response Luc,
I tried your suggestion but unfortunately it still does not work, I get the following error:
PowerCLI D:\Admin\Script> Add-VDSwitchPhysicalNetworkAdapter -VirtualNicPortgroup "ME_MGMT_UPLINK" -DistributedSwitch $VDSwitch -VMHostPhysicalNic $vmnic5 -VMHostVirtualNic $vmnic5 -Confirm:$false
Add-VDSwitchPhysicalNetworkAdapter : Cannot bind parameter 'VMHostVirtualNic'. Cannot convert the "vmnic5" value of type "VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.Nic.PhysicalNicImpl" to
type "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.Nic.HostVirtualNic".
At line:1 char:148
+ ... HostVirtualNic $vmnic5 -Confirm:$false
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-VDSwitchPhysicalNetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.Vds.Commands.Cmdlets.AddVDSwitchPhysicalNetworkAdapter
If I run the original command without the -VirtualNicPortgroup parameter it works but does not attach the nic to the proper Uplink portgroup? There is not much on the web regarding PowerCLI and V1000's unfortunately.
Any other suggestions would be welcomed.
Regards,
I have the same problem. Any Suggestions?
I'm getting the same issue on my side; we have a specific port group to move the hosts into for LACP but the command puts it into the wrong dvportgroup without LACP.
Currently, I'm exploring an option to use the SDK (via commands from Onyx). I'll update this with another post if it works for my purposes.
After some testing and reprogramming, using the commands generated from Onyx, I was able to reconfigure the system into the desired port group with LACP. In doing so, I did need to specify:
VSM Key (UUID of VSM)
Uplink Names (vmnic0, vmnic1, etc.)
Portgroup key (dvPortgroup-###)
$VMHost.Networkinfo.Id where $vmhost is the result of "get-vmhost host01"
Besides that, the code I got from Onyx could be used for my environment. Your mileage will vary, due to different setups but I was able to move my 10G NICs over and then use Set-VMHostNetworkAdapter to move the VMKs.
Ran into the same, this worked for me...
Add Host to Nexus
get-vdswitch Nexus-1000v-VSM1 | add-vdswitchvmhost -vmhost (get-vmhost MyESX.ad.local) –Confirm:$false
Add NICs to Nexus with portgroup assignment (I assume vmnic1, 3, 4, and 5)
$vmhost="MyESX.ad.local"
$Nexus="Nexus-1000v-VSM1"
$portgroup="VEM_UPLINK_TRUNK"
$myraw = (get-vmhost $vmhost | get-view).MoRef
$myref = "$myraw".Split("-")[2]
$sw = get-vdswitch $Nexus
$pg = Get-VDPortGroup -Name $portgroup -VDSwitch $sw
$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 = $sw.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[] (4)
$config.proxySwitch[0].spec.backing.pnicSpec[0] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$config.proxySwitch[0].spec.backing.pnicSpec[0].pnicDevice = "vmnic1"
$config.proxySwitch[0].spec.backing.pnicSpec[0].uplinkPortgroupKey = $pg.key
$config.proxySwitch[0].spec.backing.pnicSpec[1] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$config.proxySwitch[0].spec.backing.pnicSpec[1].pnicDevice = "vmnic3"
$config.proxySwitch[0].spec.backing.pnicSpec[1].uplinkPortgroupKey = $pg.key
$config.proxySwitch[0].spec.backing.pnicSpec[2] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$config.proxySwitch[0].spec.backing.pnicSpec[2].pnicDevice = "vmnic4"
$config.proxySwitch[0].spec.backing.pnicSpec[2].uplinkPortgroupKey = $pg.key
$config.proxySwitch[0].spec.backing.pnicSpec[3] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$config.proxySwitch[0].spec.backing.pnicSpec[3].pnicDevice = "vmnic5"
$config.proxySwitch[0].spec.backing.pnicSpec[3].uplinkPortgroupKey = $pg.key
$_this = Get-View -Id "HostNetworkSystem-networkSystem-$myref"
$_this.UpdateNetworkConfig($config, "modify")
Add VMKernel on Nexus with portgroup assignment
$vmhost="MyESX.ad.local"
$Nexus="Nexus-1000v-VSM1"
$vmk="VEM_TO_VSM1_L3"
$vmkip="192.168.151.50"
$vmknm="255.255.254.0"
$myraw = (get-vmhost $vmhost | get-view).MoRef
$myref = "$myraw".Split("-")[2]
$sw = get-vdswitch $Nexus
$pg = Get-VDPortGroup -Name $vmk -VDSwitch $sw
$nic = New-Object VMware.Vim.HostVirtualNicSpec
$nic.ip = New-Object VMware.Vim.HostIpConfig
$nic.ip.dhcp = $false
$nic.ip.ipAddress = $vmkip
$nic.ip.subnetMask = $vmknm
$nic.distributedVirtualPort = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection
$nic.distributedVirtualPort.switchUuid = $sw.key
$nic.distributedVirtualPort.portgroupKey = $pg.key
$_this = Get-View -Id "HostNetworkSystem-networkSystem-$myref"
$_this.AddVirtualNic("", $nic)
Remove Host to Nexus (as long as there are no vmkernel, etc)
get-vdswitch Nexus-1000v-VSM1 | remove-vdswitchvmhost -vmhost (get-vmhost MyESX.ad.local) –Confirm:$false
A work in progress...