Hello,
We currently have a vRO (Shell Generator) of sorts to provision shells within our environment that can then be used to run through the MDT build sequence to build servers. Currently our custom action will pull all datastores from a host in a selected cluster, exclude any datastore that has the name preface of 'SU'. Once that is done a datastore is selected based off a bit of math that will take into account the new VM size and ensure a datastore is selected with sufficient space to build the shell. I am by no means an expert in vRO javascript and admittedly I need to learn more about this language. Can someone assist in adding in the fact we want to exclude any datastore that has the preface of 'SU' AND 'LD'? This would then exclude any datastore from being selected as "Special Use" or "Local Disk". Below is the snippet, thanks in advance and much appreciated!
}
dsarray.sort(function(a, b){
return parseFloat(b.summary.freeSpace) - parseFloat(a.summary.freeSpace);
});
return dsarray;
function addDatastore(datastores) {
for (var i in datastores) {
if (keys.get(datastores[i].sdkId) == null) {
keys.put(datastores[i].sdkId, datastores[i].sdkId);
if (datastores[i].name.match('SU')) {
continue;
} else {
var rawCap = (datastores[i].summary.capacity); //raw capacity of the datastore
var cap = Math.round(rawCap / 1024 / 1024 /1024); //rounded capacity in GB
var usableCap = (90 / 100) * cap; //90% of capacity
var rawpSpace = VcPlugin.getProvisionedSpace(datastores[i]); //gets raw provisioned space
var pSpace = Math.round(rawpSpace / 1024 / 1024 /1024); //rounded provisioned space in GB
var disk1size = Math.round(SysDiskSize)
var disk2size = Math.round(AppDiskSize)
var vmemsize = Math.round(MemSize / 1024)
var useableSpace = (usableCap - pSpace - disk1size - disk2size - vmemsize ); //Usable capacity minus provisioned and disk&ram
if (useableSpace > 50){ //any datastore that has more than 50GB usable is returned
dsarray.push(datastores[i]);
}
}
}
}
}
If you just want to check for a datastore name containing either SU or LD then you just need to update one line in the code.
Change the following line
if (datastores[i].name.match('SU')) {
to be
if (datastores[i].name.match('SU')||(datastores[i].name.match('LD')) {
The || is the javascript operator for OR.
If you just want to check for a datastore name containing either SU or LD then you just need to update one line in the code.
Change the following line
if (datastores[i].name.match('SU')) {
to be
if (datastores[i].name.match('SU')||(datastores[i].name.match('LD')) {
The || is the javascript operator for OR.
Thank You for that info. I have gone ahead and tried it and it seems to be working! One note however was there is a missing closing ) in the line.
So it should read:
if (datastores[i].name.match('SU')||(datastores[i].name.match('LD'))) {
glad it worked, and good spot on the missing ). My mac was giving me all sorts of weird formatting as I tried to copy the line of code so it doesn't surprise me that something went missing!