I am trying to add/move vmnic0 from a standard switch to an already existing vDS that has vmnic1 attached. Everything is good until it tries to add vmnic0 (see attached code screenshot). I believe it has something do with the highlighted section. It is creating an array, but for some reason the second pnicSpec is not defined and throws the error below. I am able to do one vmnic at a time so it seems like I have to define that array for 2 pnicSpec's and I'm unsure how to go about it. @iiliev any ideas?
TypeError: Cannot set property "pnicDevice" of undefined to "vmnic0"
Hi,
It is an implementation detail of vCenter plug-in that such arrays cannot be dynamically resized by simply adding new elements to them.
To define the array to have 2 elements, you can replace the line:
config.proxySwitch[0].spec.backing.pnicSpec = [new VcDistributedVirtualSwitchHostMemberPnicSpec()];
with:
config.proxySwitch[0].spec.backing.pnicSpec = [new VcDistributedVirtualSwitchHostMemberPnicSpec(), new VcDistributedVirtualSwitchHostMemberPnicSpec()];
Or something like the following that will save some repetitive typing:
var spec1 = new VcDistributedVirtualSwitchHostMemberPnicSpec();
spec1.pnicDevice = ...;
// other setters for the first element's spec go here
var spec2 = new VcDistributedVirtualSwitchHostMemberPnicSpec();
spec2.pnicDevice = ...;
// other setters for the second element's spec go here
// and now set the 2-elements array property
config.proxySwitch[0].spec.backing.pnicSpec = [ spec1, spec2 ];
And that worked perfectly! Thanks for the quick response and the accurate answer. Cheers my friend..HNY!