Hello, I am trying to sort the datastores on a cluster by the amount of freespace available so I can return the cluster and datastore to put a VM on so far I have this:
var datacenter = Server.findForType("VC:Datacenter", "vc06vc.lab.601travis.jpmchase.net/datacenter-22");
var clusters = datacenter.hostFolder.childEntity;
var hosts = new Array;
var dataStores = new Array;
var dataStoreMostFreeRank = new Array;
//System.log(clusters);
for each(VcComputeResource in clusters) {
var clusterName = VcComputeResource.name;
var datastore = VcComputeResource.datastore;
//dataStores.push(datastore);
System.log(clusterName + " " + dataStores);
for each(var i in datastore){
var dataStoreName = i.name;
var dataStoreFreeSpace = i.summary.freeSpace;
function sortDataStores(a,b){
return a.dataStoreFreeSpace - b.dataStoreFreeSpace
}
var dataStoreRank = new Arrary;
dataStoreRank.push(dataStoreFreeSpace);
dataStoreRank.sort(sortDataStores)
}
}
}
but I get a syntax error when I run it in vco cli