Similar to previous discussion:vMotion TCP/IP Stack- Created by Powercli
But has anyone got this working on 6.5?
Code:
$networkSystem = Get-View $hostsystem.ConfigManager.NetworkSystem
$pg = Get-VDPortgroup -Name $portgroup_name
$ip = New-Object VMware.Vim.HostIpConfig
$ip.Dhcp = $false
$ip.IpAddress = "192.168.X.X"
$ip.SubnetMask = "255.255.255.0"
$dvspc = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection
#$dvspc.SwitchUuid = $pg.VDSwitch.ExtensionData.config.Uuid
$dvspc.SwitchUuid = $pg.VirtualSwitch.Key
$dvspc.PortgroupKey = $pg.Key
$nic = New-Object VMware.Vim.HostVirtualNicSpec
$nic.Ip = $ip
$nic.netStackInstanceKey = "vmotion"
$nic.Mtu = 9000
$nic.TsoEnabled = $true
$nic.DistributedVirtualPort = $dvspc
$networkSystem.AddVirtualNic('',$nic)
But output is always:
Exception calling "AddVirtualNic" with "2" argument(s): "A specified parameter was not correct: spec.distributedVirtualPort"
At line:25 char:1
+ $networkSystem.AddVirtualNic('',$nic)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
So it looks like the distributedVirtualPort setting is wrong, but if I dump this out it looks fine, and looks like code that was working at previous versions.
$nic | convertto-json
{
"Ip": {
"Dhcp": false,
"IpAddress": "192.168.X.X",
"SubnetMask": "255.255.255.0",
"IpV6Config": null
},
"Mac": null,
"DistributedVirtualPort": {
"SwitchUuid": "50 2f 84 aa a7 0f 18 84-8c 2b 64 48 e6 f4 11 99",
"PortgroupKey": "dvportgroup-1106",
"PortKey": null,
"ConnectionCookie": null
},
"Portgroup": null,
"Mtu": 9000,
"TsoEnabled": true,
"NetStackInstanceKey": "vmotion",
"OpaqueNetwork": null,
"ExternalId": null,
"PinnedPnic": null,
"IpRouteSpec": null
}
Any pointers would be greatly appreciated.
I didn't connect to the ESXi node, but to the vCenter.
Does that explain the difference in result?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just tested that code in 6.5U1 lab, and it works without an issue for me.
Is that specific portgroup on a vSwitch that has the ESXi connected?
Is there any additional info in the vpxd log?
Perhaps after you switch vCenter logging temporarily to 'verbose'?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It is a specific port group that exists on a Distributed Virtual Switch.
I'm running the code directly against an ESXI 6.5 host (to add the vmotion interface).
There is nothing at all useful that I can see in the vpxd.logs on the vsphere appliance, nor in the vpxa.log file on the ESXi hosts itself and this is the hostd.log
2017-08-25T11:12:54.451Z info hostd[3DAC1B70] [Originator@6876 sub=Vimsvc.TaskManager opID=c6307be9 user=root] Task Created : haTask-ha-host-vim.host.NetworkSystem.addVirtualNic-1739
2017-08-25T11:12:54.451Z info hostd[3DAC1B70] [Originator@6876 sub=Default opID=c6307be9 user=root] AdapterServer caught exception: vmodl.fault.InvalidArgument
2017-08-25T11:12:54.451Z info hostd[3DAC1B70] [Originator@6876 sub=Vimsvc.TaskManager opID=c6307be9 user=root] Task Completed : haTask-ha-host-vim.host.NetworkSystem.addVirtualNic-1739 Status error
2017-08-25T11:12:54.451Z info hostd[3DAC1B70] [Originator@6876 sub=Solo.Vmomi opID=c6307be9 user=root] Activation [N5Vmomi10ActivationE:0xffec5650] : Invoke done [addVirtualNic] on [vim.host.NetworkSystem:networkSystem]
2017-08-25T11:12:54.451Z verbose hostd[3DAC1B70] [Originator@6876 sub=Solo.Vmomi opID=c6307be9 user=root] Arg portgroup:
--> ""
2017-08-25T11:12:54.451Z verbose hostd[3DAC1B70] [Originator@6876 sub=Solo.Vmomi opID=c6307be9 user=root] Arg nic:
--> (vim.host.VirtualNic.Specification) {
--> ip = (vim.host.IpConfig) {
--> dhcp = false,
--> ipAddress = "192.168.20.25",
--> subnetMask = "255.255.255.0",
--> ipV6Config = (vim.host.IpConfig.IpV6AddressConfiguration) null
--> },
--> mac = <unset>,
--> distributedVirtualPort = (vim.dvs.PortConnection) {
--> switchUuid = "63 6b 18 50 44 a0 48 05-92 e8 87 5f dc e2 e8 04",
--> portgroupKey = "dvportgroup-4384",
--> portKey = <unset>,
--> connectionCookie = <unset>
--> },
--> portgroup = <unset>,
--> mtu = 9000,
--> tsoEnabled = true,
--> netStackInstanceKey = "vmotion",
--> opaqueNetwork = (vim.host.VirtualNic.OpaqueNetworkSpec) null,
--> externalId = <unset>,
--> pinnedPnic = <unset>,
--> }
2017-08-25T11:12:54.452Z info hostd[3DAC1B70] [Originator@6876 sub=Solo.Vmomi opID=c6307be9 user=root] Throw vmodl.fault.InvalidArgument
2017-08-25T11:12:54.452Z info hostd[3DAC1B70] [Originator@6876 sub=Solo.Vmomi opID=c6307be9 user=root] Result:
--> (vmodl.fault.InvalidArgument) {
--> faultCause = (vmodl.MethodFault) null,
--> invalidProperty = "spec.distributedVirtualPort",
--> msg = ""
--> }
This is 'home lab' but I'm getting the same error on different distributed virtual Switch (v6 - with 6.5 vcsa) and different hosts (6.0.0). I'll keep trying over the next few days,
esxcli on test host shows
[root@esx4:~] esxcli network vswitch dvs vmware list
FunkySwitch
Name: FunkySwitch
VDS ID: 63 6b 18 50 44 a0 48 05-92 e8 87 5f dc e2 e8 04
Class: etherswitch
Num Ports: 1752
Used Ports: 4
Configured Ports: 512
MTU: 9000
CDP Status: listen
Beacon Timeout: -1
Uplinks: vmnic3, vmnic2
VMware Branded: true
DVPort:
...
...
...
Client:
DVPortgroup ID: dvportgroup-4384
In Use: false
Port ID: 66
The reasoning behind doing it this way because it appears that - at the time of writing - that the cmdlet New-VMHostNetworkAdapter doesn't let us specify the TCP/IP network stack to be vmotion.
I didn't connect to the ESXi node, but to the vCenter.
Does that explain the difference in result?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes. I had the same thought overnight and tried this morning.
The difference is:
works when you start with:
Connect-VIServer -Server $VCENTER_NAME -Credential $me | Out-Null
$hostsystem = (Get-VMHost -Name $esxi_name).ExtensionData
does not work with:
Connect-VIServer -Server $ESXIHOST_NAME -Credential $me | Out-Null
$hostsystem = (Get-VMHost -Name $esxi_name).ExtensionData
hostd logs:
2017-08-25T21:37:09.321Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] GetManagementInterface: Tagging vmk0 as Management
2017-08-25T21:37:09.321Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] SetTaggedManagementInterface: Writing vmk0 to the ManagementIface node
2017-08-25T21:37:09.321Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] VmkNic::SetIpConfigInternal: IPv4 address set up successfully on vmknic vmk5
2017-08-25T21:37:09.321Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] VmkNic::SetIpConfigInternal: IPv6 address set up successfully on vmknic vmk5
2017-08-25T21:37:09.321Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] RoutingInfo: LoadConfig called on RoutingInfo
2017-08-25T21:37:09.322Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] GetManagementInterface: Tagging vmk0 as Management
2017-08-25T21:37:09.322Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] SetTaggedManagementInterface: Writing vmk0 to the ManagementIface node
2017-08-25T21:37:09.324Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] VmkNic::Enable: netstack:'vmotion', interface:'vmk5', portStr:'63 6b 18 50 44 a0 48 05-92 e8 87 5f dc e2 e8 04:65'
2017-08-25T21:37:09.324Z info hostd[3E101B70] [Originator@6876 sub=Libs opID=3a929330-76-b2a4 user=vpxuser:VSPHERE.LOCAL\Administrator] VmKernelNicInfo::AddVmKernelNic: Added vmkNic, netstack:'vmotion', interface:''
So there must be some underlying difference between operating via vCenter and operating directly.