Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

reconfigVM_Task

$
0
0

I have the following in my workflow (vm, vmNetwork, macAddr, customTagNames, and customTagValues are inputs to the script).

 

var spec = new VcVirtualMachineConfigSpec();

 

spec.deviceChange = new Array();

var deviceChange = new VcVirtualDeviceConfigSpec();

deviceChange.operation = VcVirtualDeviceConfigSpecOperation.add;

deviceChange.device = new VcVirtualVmxnet3();

deviceChange.device.key = -100;

deviceChange.device.backing = new VcVirtualEthernetCardNetworkBackingInfo();

deviceChange.device.backing.deviceName = vmNetwork;

deviceChange.device.connectable = new VcVirtualDeviceConnectInfo();

deviceChange.device.connectable.startConnected = true;

deviceChange.device.connectable.allowGuestControl = true;

deviceChange.device.connectable.connected = true;

deviceChange.device.controllerKey = 100;

deviceChange.device.addressType = "Manual";

deviceChange.device.macAddress = macAddr;

deviceChange.device.wakeOnLanEnabled = true;

spec.deviceChange[0] = deviceChange;  // i've also tried doing spec.deviceChange.push(deviceChange)

 

// custom tags are vApp properties

if (customTagNames.length > 0) {

  spec.vAppConfig = new VcVmConfigSpec();

  spec.vAppConfig.property = new Array();

  for (var i=0 ; i<customTagNames.length ; i++) {

    System.log("adding vApp Property "+ customTagNames[i] +" with value "+ customTagValues[i]);

    var vAppProperty = new VcVAppPropertySpec();

    vAppProperty.operation = VcArrayUpdateOperation.add;

    vAppProperty.info =  new VcVAppPropertyInfo();

    vAppProperty.info.key = i;

    vAppProperty.info.classId = "";

    vAppProperty.info.instanceId = "";

    vAppProperty.info.id = customTagNames[i];

    vAppProperty.info.category = "";

    vAppProperty.info.label = customTagNames[i];

    vAppProperty.info.type = "string";

    vAppProperty.info.userConfigurable = true;

    vAppProperty.info.defaultValue = customTagValues[i];

    vAppProperty.info.value = "";

    vAppProperty.info.description = "";

    spec.vAppConfig.property[i] = vAppProperty;  // i've also tried spec.vAppConfig.property.push(vAppProperty)

  }

}

 

reconfigTask = vm.reconfigVM_Task(spec);  // VirtualMachine

 

When I run the workflow I can see the VM get reconfigured inside vCenter but no changes are made.  Is there something incorrect in the script that I'm missing?  I have something very similar in PowerCLI that works fine - I'm just trying to convert it from PowerCLI.


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>