VMware Cloud Community
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Create VMK with vmotion TCP Stack

Hey all,

Trying to create a vmkernal interface with TCP stack vmotion but doesn't seem to be an option. Also is it possible to choose the vmk id rather than it just incre

New-VMHostNetworkAdapter -VMHost $h -VirtualSwitch DSwitch -PortGroup DPortGroupVMK3 -IP 1.1.1.1 -SubnetMask 255.255.255.0 -Mtu 9000 -VMotionEnabled $true

Nicholas
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No, not for VDS.
The esxcli command doesn't have a number of functions for working with VDS.

I did some tests with V2, but I encounter issues.

Not sure yet if these issues are my poor coding or actual "features" in Get-EsxCli -V2

Update: for a VDS you can do it trough calling the API methods (similar to the method in my first reply)


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

View solution in original post

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

No, no TCP stack parameter on that cmdlet yet.

And no, no way to define that vmk number, the system assigns those sequentially.

And there is a problem in the Get-EsxCli -V2 cmdlet to add a vmk as well.

See Error adding vm kernel port to distributed switch with ESXCLI V2.

which also contains a bypass solution.


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did some further testing, and it does seem to be possible after all.

Looks like the stackname is case-sensitive and needs to be in lowercase.
And yes, you can assign the vmk number out of sequence.

$esxName = 'esx1.local.lab'

$vssName = 'vSwitch2'

$pgName = 'NewPG'

$stackName = 'vmotion'

$vmkName = 'vmk7'

$vmkIp = '192.168.1.111'

$vmkMask = '255.255.255.0'

$vmkGW = '192.168.1.254'

$esx = Get-VMHost -Name $esxName

$esxcli = Get-EsxCli -VMHost $esx

$vss = $esxcli.network.vswitch.standard.list() | where{$_.Name -eq $vssName}

if(!($esxcli.network.vswitch.standard.portgroup.list() | where{$_.Name -eq $pgName})){

    $esxcli.network.vswitch.standard.portgroup.add($pgName,$vss.Name)

}

$esxcli.network.ip.interface.add($null,$null,$vmkName,$null,1500,$stackName,$pgName)

$esxcli.network.ip.interface.ipv4.set($vmkGW,$vmkName,$vmkIp,$vmkMask,$null,'static')


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

Reply
0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Thanks Luc, that’s awesome. woukd this work on distribted switch and is esxcli v2 not an option?

Nicholas
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, not for VDS.
The esxcli command doesn't have a number of functions for working with VDS.

I did some tests with V2, but I encounter issues.

Not sure yet if these issues are my poor coding or actual "features" in Get-EsxCli -V2

Update: for a VDS you can do it trough calling the API methods (similar to the method in my first reply)


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

Reply
0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Hi Luc,

Do you have the complete script with Variables handy from this script, Re: Error adding vm kernel port to distributed switch with ESXCLI V2. 

Also what do you think of the approach of creating the vmkernel on VSS first then migrating to VDS similar to this blog post https://wesleygeelhoed.nl/2017/10/10/configure-vmkernel-adapters-in-a-specific-netstack-via-powercli...

$esxcli.network.ip.netstack.add.invoke(@{netstack = "vmotion"})

$portgoup = Get-VirtualPortGroup -virtualswitch $SysSwitch | ?{$_.Name -ilike "*vmotion*"}

$nic = New-Object VMware.Vim.HostVirtualNicSpec

$distributedVirtualPort = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection

$nic.distributedVirtualPort = $distributedVirtualPort

$nic.distributedVirtualPort.portgroupKey = $portgoup.key

$nic.distributedVirtualPort.switchUuid = $portgoup.VirtualSwitch.key

$nic.netStackInstanceKey = 'vmotion'

$nic.mtu = $mtu

$ip = New-Object VMware.Vim.HostIpConfig

$ip.subnetMask = $mask

$ip.ipAddress = $vmotionip

$ip.dhcp = $false

$ip.ipV6Config = New-Object VMware.Vim.HostIpConfigIpV6AddressConfiguration

$ip.ipV6Config.dhcpV6Enabled = $false

$ip.ipV6Config.autoConfigurationEnabled = $false

#$ip.IpV6Config = $ipV6Config

$nic.Ip = $ip

$networkSystem = $vmHost.ExtensionData.configManager.NetworkSystem

$_this = Get-view -Id ($networkSystem.Type + "-" + $networkSystem.Value)

$_this.AddVirtualNic('', $nic)

$cArgs = $null

$cArgs = $esxcli.network.ip.route.ipv4.add.CreateArgs()

$cArgs.gateway = $gateway

$cArgs.netstack = "vmotion"

$cArgs.network = "default"

$esxcli.network.ip.route.ipv4.add.invoke($cArgs)

$cArgs = $null

$cArgs = $esxcli.network.ip.dns.server.add.CreateArgs()

$cArgs.server = $dns

$cArgs.netstack = "vmotion"

$esxcli.network.ip.dns.server.add.invoke($cArgs)

Nicholas
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That first link is in fact a bypass for the lack of VDS functions on the esxcli command.

And no,I don't have that complete script handy I'm afraid, but it shouldn't be too hard to reverse engineer I guess.

Yes, that 2nd link seems like a good idea.
The drawback is that you will need to create a VSS, even though you could be in a VDS only environment.

But it avoids the lack of esxcli functionality for VDS (if you don't want to call the vSphere API methods at least).


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

Reply
0 Kudos
WickedMaster
Contributor
Contributor
Jump to solution

I was wondering if you've got a working script already. I want to do exactly the same thing on a VDS.
Reply
0 Kudos
VitalyBal
Contributor
Contributor
Jump to solution

Finally got it working under V2. Possibly can be useful for someone. Thanks Jared Gudnason for workaround (https://communities.vmware.com/thread/601409)

$ESXiName = "test"

$PGName = "vMotion"

$DVSName = "TEST"

$VMKMTU = "1500"

$VMKNetStack = "vmotion"

 

$esx = Get-VMHost -Name $ESXiName

$esxcli = Get-EsxCli -VMHost $esx -V2

 

#Create temporary VMK

New-VMHostNetworkAdapter -VMhost $ESXiName -PortGroup $PGName -VirtualSwitch $DVSName

 

#Get PG ID and VMK name

$DVSPG = Get-VDSwitch -VMHost $ESXiName -name $DVSName | Get-VDPortgroup -Name $PGName | get-vdPort | where-object { $_.ProxyHost.Name -match $ESXiName } | Select-Object id, ConnectedEntity

 

#Remove temporary VMK

$arguments  = $esxcli.network.ip.interface.remove.CreateArgs()

$arguments.dvportid = $DVSPG.Id

$arguments.dvsname = $DVSName

$esxcli.network.ip.interface.remove.Invoke($arguments)

 

#Add VMK with proper stack

$arguments  = $esxcli.network.ip.interface.add.CreateArgs()

$arguments.mtu = $VMKMTU

$arguments.dvsname = $DVSName

$arguments.netstack = $VMKNetStack

$arguments.interfacename = $DVSPG.ConnectedEntity.Name

$arguments.dvportid = $DVSPG.Id

 

$esxcli.network.ip.interface.add.Invoke($arguments)

 
$ESXiName = "test"
$PGName = "vMotion"
$DVSName = "TEST"
$VMKMTU = "1500"
$VMKNetStack = "vmotion"
 
$esx = Get-VMHost -Name $ESXiName
$esxcli = Get-EsxCli -VMHost $esx -V2
 
#Create temporary VMK
New-VMHostNetworkAdapter -VMhost $ESXiName -PortGroup $PGName -VirtualSwitch $DVSName
 
#Get PG ID and VMK name
$DVSPG = Get-VDSwitch -VMHost $ESXiName -name $DVSName | Get-VDPortgroup -Name $PGName | get-vdPort | where-object { $_.ProxyHost.Name -match $ESXiName } | Select-Object id, ConnectedEntity
 
#Remove temporary portgroup
$arguments  = $esxcli.network.ip.interface.remove.CreateArgs()
$arguments.dvportid = $DVSPG.Id
$arguments.dvsname = $DVSName
$esxcli.network.ip.interface.remove.Invoke($arguments)
 
#Add VMK with proper stack
$arguments  = $esxcli.network.ip.interface.add.CreateArgs()
$arguments.mtu = $VMKMTU
$arguments.dvsname = $DVSName
$arguments.netstack = $VMKNetStack
$arguments.interfacename = $DVSPG.ConnectedEntity.Name
$arguments.dvportid = $DVSPG.Id
 
$esxcli.network.ip.interface.add.Invoke($arguments)
Reply
0 Kudos