VMware Cloud Community
csalcedo
Contributor
Contributor
Jump to solution

Unable to create a vmkernel interface attached to a N-VDS segment

Hello!

I have deployed a vCenter 6.7U3 with 3 ESXi hosts (6.7U3 as well) pertaining a host cluster. In addition, I have deployed and configured an NSX-T installation (latest version 2.5) and automatically migrated management vmkernel interface to a N-VDS (NSX distributed switch) portgroup during NSX-T installation.

Every ESXi host in the cluster only has 2x10G physical NICs that have been migrated to NSX Distributed Switch (not regular VDS). The question is that I want to create additional vmkernel interfaces (for example for vMotion or vSAN) in an automated way using PowerCLI, but any of the ways I've tried works.

Just for you to know, it actually can be done through the UI (HTML5 client) but neither from PowerCLI nor esxcli.

What I have tried:

OPTION 1) Use New-VMHostNetworkAdapter cmdlet:

New-VMHostNetworkAdapter -VMHost (Get-VMHost -Name "myhost.vmwaretest.com") -IP "10.10.10.25" -SubnetMask "255.255.255.0" -PortGroup (Get-VirtualNetwork -NetworkType "Opaque" -Name "test-segment1") -Confirm:$false

New-VMHostNetworkAdapter : 18/12/2019 15:33:24 New-VMHostNetworkAdapter Value cannot be found for the mandatory parameter VirtualSwitch

At line:1 char:1

+ New-VMHostNetworkAdapter -VMHost (Get-VMHost -Name "myhost.vmwarete ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-VMHostNetworkAdapter], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVMHostNetworkAdapter

So it seems there is no support for Opaque Virtual Portgroups and vmkernel adapters?? But for VM networking it does work:

Get-VirtualNetwork -NetworkType "Opaque"

Name                                               NetworkType   

----                                               -----------   

test-segment1                                       Opaque        

OPTION 2) Use Get-Esxcli cmdlet

$esxcli = Get-EsxCli -VMhost "myhost.vmwaretest.com" -V2

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

$vmkArgs.set_Item("interfacename","vmk1")

$vmkArgs.set_Item("portgroupname","test-segment1")

$vmkArgs.set_Item("mtu","1500")

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

Message: EsxCLI.CLIFault.summary;

InnerText: Invalid vswitch port group name test-segment1. Error was: Unable to get node: Sysinfo error: Not foundSee VMkernel log for details.EsxCLI.CLIFault.summary

At line:37 char:1

+ $esxcli.network.ip.interface.add.Invoke($vmkArgs)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], MethodFault

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault

I'm using PowerCLI 11.3.0 build 13990089.

Do you have any clue on how to achieve this in an automated way without the need of doing it manually from the vSphere Client?

Thank you very much in advance!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does Code Capture show anything?


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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Does Code Capture show anything?


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

Reply
0 Kudos
csalcedo
Contributor
Contributor
Jump to solution

Great, LucD​!

You saved my day, many thanks!

I wasn't aware that a replacement of my beloved Onyx was already there for HTML5 client!!

For those interested, this is the output:

#---------------AddVirtualNic---------------

$portgroup = ''

$nic = New-Object VMware.Vim.HostVirtualNicSpec

$nic.IpRouteSpec = New-Object VMware.Vim.HostVirtualNicIpRouteSpec

$nic.IpRouteSpec.IpRouteConfig = New-Object VMware.Vim.HostIpRouteConfig

$nic.Ip = New-Object VMware.Vim.HostIpConfig

$nic.Ip.IpAddress = '10.11.12.13'

$nic.Ip.SubnetMask = '255.255.255.0'

$nic.Ip.Dhcp = $false

$nic.Mtu = 1500

$nic.OpaqueNetwork = New-Object VMware.Vim.HostVirtualNicOpaqueNetworkSpec

$nic.OpaqueNetwork.OpaqueNetworkId = '1a9af86f-acf3-4075-bfcc-b82b0b044f73'

$nic.OpaqueNetwork.OpaqueNetworkType = 'nsx.LogicalSwitch'

$_this = Get-View -Id 'HostNetworkSystem-networkSystem-12'

$_this.AddVirtualNic($portgroup, $nic)

#---------------SelectVnicForNicType---------------

$nicType = 'vmotion'

$device = 'vmk3'

$_this = Get-View -Id 'HostVirtualNicManager-virtualNicManager-12'

$_this.SelectVnicForNicType($nicType, $device)

Thanks again!!

Reply
0 Kudos