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

Finding the Next Free Spot on a VM to add a disk

$
0
0

I have a VM with this 2 different types of Disk Configuration scenerios Hard Disk 1 (0: 0), Hard Disk 2 (0: 1), Hard Disk 3 (0: 2), Hard Disk 4 (0: 3), Hard Disk 5 (1: 0)

Scenerio 1:

Hard Disk 1 (0: 0), Hard Disk 2 (0: 1), Hard Disk 3 (0: 2), Hard Disk 4 (0: 3), Hard Disk 5 (1: 0)

Scenerio 2:

Hard Disk 1 (0: 0), Hard Disk 2 (0: 1), Hard Disk 3 (0: 2), Hard Disk 4 (1: 0)

 

I have a workflow scriptable taks that has the input of SCSI Controller Hardware types (since it could be more than one in Scenerio 1 it has two (Bus 0 and bus 1) and in scenerio 2 it only has 1) and the input of all of the virtual disks.  I was wondering where my logic is going wrong because I am having trouble breaking out of loops.  What I am trying to do is find the first open slot on a VM to add a disk.  so for scenerio 1 the first open slot will be Hard Disk 6 (1:1) and for scenerio two Hard Disk 5 (0:3) but I am having trouble breaking out of my loops when as it will just itterate to the next controller

 

var scsiControllerSpots = [0,1,2];

var scsiControllerDisksArray = [];

var openSlots = [0,1,2,3];

 

 

 

 

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

    for (var j = 0; j < scsiControllers.length; j++) {

        if (scsiControllerSpots[i] == scsiControllers[j].busNumber) {

  //System.log("Evaluate this SCSI Controller with Bus Number " + scsiControllers[j].busNumber);

  var SCSIcontrollerKey = scsiControllers[j].key

  //System.log(SCSIcontrollerKey);

  for (var k = 0; k < virtualDisks.length; k++) {

  if (virtualDisks[k].controllerKey == SCSIcontrollerKey){

  scsiControllerDisksArray.push(virtualDisks[k].unitNumber);

  //System.log("this disk belongs to SCSI Controller with Bus Nubmer " + scsiControllers[j].busNumber);

  //System.log(virtualDisks[k].unitNumber);

  }

        } if (scsiControllerDisksArray.length < 4){

  var openslot = scsiControllerDisksArray.length;

  System.log(openslot);

  //System.log(scsiControllerDisksArray.pop());

  break;

  } else {

  System.log("go to the next scsi slot");

  }

    }

  }

}


Viewing all articles
Browse latest Browse all 6251

Trending Articles