VMware Aria Automation Orchestrator

 View Only

 Getting list of vc:datastore of a vc:storagepod

Jump to  Best Answer
Thiba Nesan's profile image
Thiba Nesan posted Feb 25, 2025 10:49 PM

So, I am trying to create a logic to determine least used datastore when adding new disk. I tried SDRS recommendation but at times it is too slow as SDRS has to move some disks to provide a recommendation. So I am keep it as 2nd method if I am unable to identify an available datastore with sufficient space.

A vm object (vc:virtualmachine) is being parsed as input. From here, I can retrieve the clustercomputeresource (compute cluster).

const cluster = System.getModule("com.vmware.library.vc.cluster").getComputeResourceOfVm(vm);

This will return either a VcClusterComputeResource or VcComputeResource object depending on your organization standards. In my case, it's a clustercomputeresource.

From here, I have a custom action that would return an array of storagepod (datastore cluster) or datastore (vsan) object.

const storageCluster = System.getModule("com.custom.library.vc.cluster").getDatastoreClusterOrVsanOfCluster(cluster);

From here, I want to be able to retrieve the list of vc:datastore (array of datastores) that is part of the storagepod (datastore cluster).

I've done 

datastoreCluster.childEntity() but this only returned the Array/VcManagedEntity object. How to I convert this to vc:datastore object, so that I can use freespace attribute for the least used datastore in a datastore cluster.
WhiteForEver's profile image
WhiteForEver  Best Answer

Hi,

this should do the job:

for each (ds in dc.childEntity) {
    System.log("Name: " + ds.name + "; Free space: " + ds.info.freeSpace)
}

Once you have the numbers, you can do if/else.