Mattie84
Contributor
Contributor

[vsphere 7] Create new TCP/IP vmotion stack

In 6.7, i use a script to install ESX hosts. A part of that script is not working anymore when testing this to an ESX server running on 7. Its the part where setup the vmotion vmk to use a newly create vmotion tcp/ip stack.

 

import-csv $dir\hosts.txt -Header vmhost,ip1,ip2 | foreach {

$line = $_
$line.vmhost
$vmhost = get-vmhost $_.vmhost
$esxcli = get-esxcli -vmhost $vmhost.name -v2


New-VMHostNetworkAdapter -VMHost $_.vmhost -PortGroup $vmotion1 -VirtualSwitch $vdswitch -IP $_.ip1 -SubnetMask 255.255.255.0 -VMotionEnabled $true #vmotion
sleep 5
New-VMHostNetworkAdapter -VMHost $_.vmhost -PortGroup $vmotion2 -VirtualSwitch $vdswitch -IP $_.ip2 -SubnetMask 255.255.255.0 -VMotionEnabled $true #vmotion
sleep 5

$line = $_
$line.vmhost
$vmhost = get-vmhost $_.vmhost
$esxcli = get-esxcli -vmhost $vmhost.name -v2

write-host -foregroundcolor green "create vmotion stack"
$esxcli.network.ip.netstack.add.Invoke(@{netstack = 'vmotion'})
sleep 10

write-host -foregroundcolor green "create vmk1, vmotion1"
$vmk1 = New-VMHostNetworkAdapter -VMHost $line.vmhost -PortGroup $vmotion1 -virtualSwitch $vdswitch
sleep 10
$np1 = ( get-vdswitch -vmhost $vmhost | get-vdportgroup $vmotion1 | get-vdPort | ? {$_.ProxyHost -match $vmhost.name})
sleep 10
$arguments = $esxcli.network.ip.interface.remove.CreateArgs()
$arguments.dvportid = $np1.Id
$arguments.dvsname = $np1.Switch
$esxcli.network.ip.interface.remove.Invoke($arguments)

sleep 10
$arguments = $esxcli.network.ip.interface.add.CreateArgs()
$arguments.mtu = 9000
$arguments.dvsname = $np1.Switch
$arguments.netstack = "vmotion"
$arguments.interfacename = $np1.ConnectedEntity
$arguments.dvportid = $np1.Id
$esxcli.network.ip.interface.add.Invoke($arguments)
sleep 10
$vmhost | get-vmhostnetworkadapter -name vmk1 | set-vmhostnetworkadapter -ip $_.ip1 -subnet $vmotionsubnet -mtu 9000 -confirm:$false
sleep 10

write-host -foregroundcolor green "create vmk2, vmotion2"
$vmk2 = New-VMHostNetworkAdapter -VMHost $line.vmhost -PortGroup $vmotion2 -virtualSwitch $vdswitch
sleep 10
$np2 = ( get-vdswitch -vmhost $vmhost | get-vdportgroup $vmotion2 | get-vdPort | ? {$_.ProxyHost -match $vmhost.name})
sleep 10
$arguments = $esxcli.network.ip.interface.remove.CreateArgs()
$arguments.dvportid = $np2.Id
$arguments.dvsname = $np2.Switch
$esxcli.network.ip.interface.remove.Invoke($arguments)

sleep 10
$arguments = $esxcli.network.ip.interface.add.CreateArgs()
$arguments.mtu = 9000
$arguments.dvsname = $np2.Switch
$arguments.netstack = "vmotion"
$arguments.interfacename = $np2.ConnectedEntity
$arguments.dvportid = $np2.Id
$esxcli.network.ip.interface.add.Invoke($arguments)

sleep 10
$vmhost | get-vmhostnetworkadapter -name vmk2 | set-vmhostnetworkadapter -ip $_.ip2 -subnet $vmotionsubnet -mtu 9000 -confirm:$false
}

 

 

The creation of the vmotion stack works, but removing of the tmp vmk doenst work. In stead, there are four VMK's created

 

create vmk1, vmotion1
A specified parameter was not correct: argument[0]
At ~removed.ps1:110 char:1
+ $esxcli.network.ip.interface.remove.Invoke($arguments)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidArgument
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument

A specified parameter was not correct: argument[0]
At~removed.ps1:119 char:1
+ $esxcli.network.ip.interface.add.Invoke($arguments)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidArgument
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument

 

Runnning on PowerCLI 12.0.0 build 15947286

 

Anyone got an idea got point me in the right direction?

Labels (1)
0 Kudos
5 Replies
vXav
Expert
Expert

Try using New-VMHostNetworkAdapter -NetworkStack vmotion ...

0 Kudos
LucD
Leadership
Leadership

Are you sure that $np1 only contains 1 port?
Btw, the $vmotion1 variable doesn't seem to be initialised in your code


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

0 Kudos
Mattie84
Contributor
Contributor

@vXav 

Ah nice, i will try and see if it works. Will come back to this! Thanks

@LucD 

Indeed not sure, can double check that.

and about $vmotion1, that has been initialised earlier in the code. This is just a snip of the entire code

0 Kudos
Mattie84
Contributor
Contributor

New-VMHostNetworkAdapter -VMHost $_.vmhost -PortGroup $vmotion1 -VirtualSwitch $vdswitch -IP $_.ip1 -SubnetMask 255.255.255.0 -NetworkStack vmotion  -VMotionEnabled $true 

 

Gives me:

 

New-VMHostNetworkAdapter : Cannot bind parameter 'NetworkStack'. Cannot convert the "vmotion" value of type "System.String" to type "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.HostNetworkSt
ack".

0 Kudos
LucD
Leadership
Leadership

You need the object returned by Get-VMHostNetworkStack, not the string


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

0 Kudos