I have been puzzling over this issue for a few days and I hope that this is the correct location for this post.
I have been using perl to configure the ESXi 4 hosts once they have been built. But have a problem in trying to get the correct Portgroup created as a host (VMKernel) type for use by vMotion.
I am aware that I can use the command such as:
New-VMHostNetworkAdapter -VMHost $host -PortGroup VMkernel -VirtualSwitch $vs -IP 6.78.33.169 -SubnetMask 255.255.255.128 -VMotionEnabled 1
That will create the PortGroup of the correct type and configure the IP address and SubnetMask and also Enable it for vMotion.
However, if I want to do the same thing using Perl, I do not get the same results.
If I try to use the command 'AddVirtualNic' for example -
eval { $netMgr->AddVirtualNic(portgroup => $pg, nic => new HostVirtualNicSpec (ip => new HostIpConfig(dhcp => 0, ipAddress => @address, subnetMask => @mask))); };
Where - my $netMgr = Vim::get_view(mo_ref => $host->configManager->networkSystem);
my $pg = "VMkernel";
This then results in the error of "A specified parameter was not correct".
In this case the PortGroup does not already exist, so I assume the new HostVirtualNicSpec is complaining because there has been no VirtualSwitch defined to add the new PortGroup to.
If I create the PortGroup in advance, by using the AddPortGroup command, there does not seem to be anyway to define that the PortGroupConnecteeType should be 'host'.
I have found other posts related to the error "A specified parameter was not correct". However, they just seem to deal with esxcfg-vswitch or vicfg-vmknic (which does use the AddVirtualNic command).
Any suggestions would be most welcome. Thanks.