VMware Cloud Community
bradger33
Enthusiast
Enthusiast

Adding new disk to VM from vRA ASD using vRO workflow

Hi guys,

I currently have a workflow that adds a new vdisk to an existing virtual machine. This is presented via vRA ASD forms, however we currently have to enter the next sequential disk index in order for the workflow to execute. I would like this to be filled in automatically. Is there an easy way to do this?

current code is the out the box

var configSpec = new VcVirtualMachineConfigSpec();

var deviceConfigSpecs = new Array();

var deviceConfigSpec;

// Add/Create the disk

deviceConfigSpec = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualDiskFlatVer2ConfigSpec(

    diskSize, datastore, scsiControllerKey, diskIndex, VcVirtualDiskMode.fromString(diskMode.name), thinProvisioned );

deviceConfigSpecs[0] = deviceConfigSpec;

// List of devices

configSpec.deviceChange = deviceConfigSpecs;

// Launch the reconfigVM task

task = vm.reconfigVM_Task( configSpec );

thanks,

Reply
0 Kudos
3 Replies
bradger33
Enthusiast
Enthusiast

resolved by additonal coding

var validNumbers = [0,1,2,3,4,5,6];

var devices = vm.config.hardware.device;

if ( devices != null )  {

     for ( device in devices )  {

          if ( devices[device] instanceof VcVirtualDisk) {

               var u = devices[device].unitNumber;

                for (i in validNumbers) {

                    if (validNumbers[i] == u) {

                        validNumbers.splice(i,1); // Remove number in use

                    }

Reply
0 Kudos
kiranht
Enthusiast
Enthusiast

Once added the disk automatically disk are not formatting  please include formatting of disk script also

Reply
0 Kudos
kiranht
Enthusiast
Enthusiast

please include format of script  also

Reply
0 Kudos