esstokes1
Enthusiast
Enthusiast

reconfigureDvs_Task

Jump to solution

I have scriptable task as follows (two inputs - vmhost VC:HostSystem & myDvs VC:VmwareDistributedVirtualSwitch):

dvsConfig = new VcDVSConfigSpec();

dvsConfig.configVersion = myDvs.config.configVersion;


hostMemConfigSpec = new VcDistributedVirtualSwitchHostMemberConfigSpec()

hostMemConfigSpec.operation = VcConfigSpecOperation.add;

hostMemConfigSpec.host = vmhost;

hostMemConfigSpec.backing = new VcDistributedVirtualSwitchHostMemberPnicBacking();

pnicSpec = new VcDistributedVirtualSwitchHostMemberPnicSpec();

pnicSpec.pnicDevice = "vmnic4";

hostMemConfigSpec.backing.pnicSpec = new Array();

hostMemConfigSpec.backing.pnicSpec.push(pnicSpec);

dvsConfig.host = new Array();

dvsConfig.host.push(hostMemConfigSpec);

myDvs.reconfigureDvs_Task(dvsConfig);

The task completes successfully but the host is not added to the dvs.  The pnicDevice (vmnic4) is not part of any dvs or vss.  Is there something I'm missing?

Thanks

Eric

0 Kudos
1 Solution

Accepted Solutions
esstokes1
Enthusiast
Enthusiast

For anyone interested, the issue was with the Array definitions - apparently they cannot be done line PoweCLI.  Here's the updated code that works:

var configSpec = new VcDVSConfigSpec();

configSpec.configVersion = myDvs.config.configVersion;

var memberConfigSpec = new VcDistributedVirtualSwitchHostMemberConfigSpec();

memberConfigSpec.operation = VcConfigSpecOperation.add;

memberConfigSpec.Host = vmhost.reference;

memberConfigSpec.backing = new VcDistributedVirtualSwitchHostMemberPnicBacking();

var memberPnicSpec = new VcDistributedVirtualSwitchHostMemberPnicSpec();

memberPnicSpec.pnicDevice = "vmnic4";

var pnicSpecs = new Array();

pnicSpecs[0] = memberPnicSpec;

memberConfigSpec.backing.pnicSpec = pnicSpecs;

var HostMemberConfigSpecs = new Array();

HostMemberConfigSpecs[0] = memberConfigSpec;

configSpec.host = HostMemberConfigSpecs;

// System.getModule("com.vmware.library.vcocli").startSession() ;

task = myDvs.reconfigureDvs_Task(configSpec);

vcocli was a HUGE help in figuring this out.  Nice work!

View solution in original post

0 Kudos
1 Reply
esstokes1
Enthusiast
Enthusiast

For anyone interested, the issue was with the Array definitions - apparently they cannot be done line PoweCLI.  Here's the updated code that works:

var configSpec = new VcDVSConfigSpec();

configSpec.configVersion = myDvs.config.configVersion;

var memberConfigSpec = new VcDistributedVirtualSwitchHostMemberConfigSpec();

memberConfigSpec.operation = VcConfigSpecOperation.add;

memberConfigSpec.Host = vmhost.reference;

memberConfigSpec.backing = new VcDistributedVirtualSwitchHostMemberPnicBacking();

var memberPnicSpec = new VcDistributedVirtualSwitchHostMemberPnicSpec();

memberPnicSpec.pnicDevice = "vmnic4";

var pnicSpecs = new Array();

pnicSpecs[0] = memberPnicSpec;

memberConfigSpec.backing.pnicSpec = pnicSpecs;

var HostMemberConfigSpecs = new Array();

HostMemberConfigSpecs[0] = memberConfigSpec;

configSpec.host = HostMemberConfigSpecs;

// System.getModule("com.vmware.library.vcocli").startSession() ;

task = myDvs.reconfigureDvs_Task(configSpec);

vcocli was a HUGE help in figuring this out.  Nice work!

View solution in original post

0 Kudos