Hello,
I need to collect a lot of details for our vCloud Director VMs. Main Problem is, that the collecton of the VM Details is verry slow.
Code Snippet (this for all of my vApps):
vms = vapps[j].getChildrenVms();
//fill output
var data_vms = new Array();
for (var k = 0, klen = vms.length; k < klen; k++) {
System.debug("** " + vapps[j].name + ": Get VDC vApp VMs Details for " + vms[k].name);
var date = new Date().toISOString().slice(0, 19).replace('T', ' ');
var data_vm = new Properties();
data_vm.put("VdcUId", host.internalId + "_" + org.id + "_" + vdcs[i].id);
data_vm.put("VmUId", host.internalId + "_" + org.id + "_" + vdcs[i].id + "_" + vms[k].id);
data_vm.put("VmId", vms[k].id);
data_vm.put("VmName", vms[k].name);
data_vm.put("VappName", vapps[j].name);
System.debug("*** Start get VM OS Info");
data_vm.put("VmOs", vms[k].getOperatingSystemSection().description.value);
System.debug("*** Start get VM CPU Info");
data_vm.put("VmVcpus", vms[k].getCpu().noOfCpus);
System.debug("*** Start get VM Memory Info");
data_vm.put("VmMemoryMb", vms[k].getMemory().memorySize);
data_vm.put("vmStatus", vms[k].vmStatus.value);
//switch VM State to human readable
switch(vms[k].vmStatus.value) {
case "3":
data_vm.put("vmStatusFull", "Powered_Off");
break;
case "4":
data_vm.put("vmStatusFull", "Powered_On");
break;
default:
data_vm.put("vmStatusFull", "Other");
}
data_vm.put("date", date);
//get Disk Info
System.debug("*** Start get VM Disk Info");
var vmdisks = new Array();
vmdisks = vms[k].getDisks();
var sumvmdisksizes = 0;
for (var x = 0; x < vmdisks.length; x++) {
if (vmdisks[x].isHardDisk()){
sumvmdisksizes += vmdisks[x].hardDiskSize;
}
}
data_vm.put("VmDiskTotalMb", sumvmdisksizes);
data_vms.push(data_vm);
//allvms.push(vm);
}
The getCpu() and getMemory() Method for example takes between 0,5 an 2 seconds, that is way to long in my case...
Doe anyone have a more elegant way to collect all this informations with vRO from vCD?
Best regards,
Markus
Hi,
not sure if it's really faster, but an alternative strategy could be to get the information from vCenter rather than vCD. But likely the step to get vCenter VM for the vCD VM is even more "expensive".
Perhaps you could separate it, to just store the VM ids in an array, and then later do some bunch reporting on them from vCenter.
I'll attach some workflows I used for reporting, one with "the opposite" direction, to get vClVm from vCenter vms.
Regards,
Joerg