So I am in the process of building a script to provision vm's.
I am having it pick the node to stick the newly provision vm on based off the cluster I tell it to use. I am just using the Random function to do this so I picks a node from the cluster.
Where I have questions is, how do I
find the least utilized datastore based off of a particular datastore naming scheme.
what I mean is:
Hypathetically, I have for example datastores named:
datastore-prod-01 200GB free
datastore-prod-02 500GB free
datastore-prod-03 10GB free
datastore-qa-01 200 GB free
datastore-qa-02 1000 GB free
I want to throw in a piece of code to tell it to look at datastores "datastore-prod*" and place the VM on the datastore with the most free space. (this is assuming the vm will fit on the DS and leave overhead)
I guess I want to know if tis is possible?
I also would have to worry about scenario that maybe the vm I need to build just will not fit on any of my remaining datastore. I guess I would need some logic to check if it is even possible.
This is more of a wish rather than a necessity. I am pondering if I just want to read the info in or use a cvs file once initiating the script. Any recomendations would be greatly appreacted.