okay CLI gods out there...
I try to automate my host provisioning.. today i had a boot media SD card die, so rebuilding.
my non-enterprise + hosts i can build out no problem, including vmotion interfaces on vmotion network stack, etc.
where i am running into issues is distributed port groups, and adding vmk interfaces to a port group.
using an esxcli construct, as that is the only way to add to the vmotion netstack
on a new host, that looks something like (some code missing):
$esxcli = Get-EsxCli -VMHost $esx -v2
$esxcli.network.ip.netstack.add.invoke(@{netstack = "vmotion"})
$arguments = $esxcli.network.ip.interface.add.CreateArgs()
$arguments.mtu = 1500
$arguments.portgroupname = "vlan xx - vMotion A"
$arguments.netstack = "vmotion"
$arguments.interfacename = "vmk1"
$esxcli.network.ip.interface.add.Invoke($arguments)
$arguments = $esxcli.network.ip.interface.ipv4.set.CreateArgs()
$arguments.netmask = "255.255.255.0"
$arguments.gateway = "$ipvm$gw"
$arguments.ipv4 = "$ipvm$oct"
$arguments.type = "static"
$arguments.interfacename = "vmk1"
$esxcli.network.ip.interface.ipv4.set.Invoke($arguments)
okay.. above code works fine on a standard switch, specifically $arguments.portgroupname = "vlan xx - vMotion A"
for a Distributed switch, the syntax changes to use dvportID and dvsname instead of portgroupname
(and it's the same command as if you were CLI-ed into the box, and using esxcli).
so for DVS, it looks like:
$arguments = $esxcli.network.ip.interface.add.CreateArgs()
$arguments.mtu = 1500
$arguments.dvsname = "DVswitchName"
$arguments.netstack = "vmotion"
$arguments.interfacename = "vmk1"
$arguments.dvportid = 468
the dvsname corresponds to the Distributed switch name (not individual portgroup), also can be seen in output of esxcfg-vswitch -l
the DVPortID i'm assigning is an empty port on the portgroup i'm trying to add the interface to.
FYI, to find that, i'm using this:
$vSwitch = Get-VDSwitch -VMHost $esx -name DSName
$pg = Get-VDPortgroup -VDSwitch $vSwitch -Name "vlan xx - vMotion A"
$portID = ($pg | get-vdPort | where-object {! $_.ProxyHost } | Select -First 1).ID
all that looks ok.. but when i run the invoke..
Message: EsxCLI.CLIFault.summary;
InnerText: Invalid vswitch port group or DVPort parameters.EsxCLI.CLIFault.summary
so for debugging purposes.. i try from the host CLI, as follows:
esxcli network ip interface add --dvs-name "DSName" --dvport-id 472 --netstack "vmotion" --interface-name vmk1
and get the same error
Invalid vswitch port group or DVPort parameters.
So, what am i missing here?