VMware Cloud Community
admin
Immortal
Immortal

Managing Datastore Capacity Workflow

So here is what I am trying to do:

Find Datastore with <10% Free

Find largest vmdk file on LUN

Move related VM/vmdk to Datastore with highest freespace

So I have been able to use some of the out of the box workflows and I have the datastores selected by size, and I have all the files on this datastore. Where I am stuck is how can I ID which VM on these datastores are the largest.

If I can get those then I would ideally like to create a presentation layer that allows the user to chose which VM's to use to trigger the canned SVmotion workflow. Any assistance or direction would be much appreciated.

Anybody done something like this?

Regards,

Joe

Reply
0 Kudos
1 Reply
admin
Immortal
Immortal

Hi Joe,

To find the VM of the largest size on a particular datastore, you could try following:

1. Retrieve the datastore MoRef.

2. Loop around the VMs present on the datastore, by referring to the Datastore.vm property.

3. For each VM, retrieve the vm.summary.storage.committed value and compare this with the same property of every VM. You can apply the logic to find the largest by first assigning maxsizevm to the first VM and then compare each VMs committed property with this maxsizevm. In the end of the loop(which runs for all the VMs), you will have the size of the largest vm in the maxsizevm variable. You also need to store the MoRef corresponding to every VM whose committed gets assigned to maxsizevm, in a separate variable,so that you have the reference of the VM as well, for which to perform the storage vMotion.

I hope this helps you.