Why wouldn't you just expand the datastore on which those VMs reside so you don't have to reconfig your reservations?
We have a fixed size of datastores of say 10GB and the vm expansion will require going beyond the existing size. E.g
we need to expand disk of vm2 to 4gb in the given reservations.
datastore 1 = 10gb but 1gb free
datastore 1- vm1 =8gb
datastore 1- vm2 = 1gb
datastore 2 = 10gb but 5gb free
datastore2 - vm1 = 3gb
datastore2 - vm2 = 2gb
so we still have more space on datastore 2 to accommodate the request if vm2 in datastore 1 can simply migrated (storage-vmotion by workflow triggered by expand disk)
so we need a workflow logic to help identify free datastores within a reservation to automatically move vms to whenever the expand disk operation is requested.
This can be incorporated in the expand disk workflow.
Any further suggestion will be appreciated.
Ok, what you're asking for is some pretty complex code based around a specific automation need you have. If you had something to start with and wanted some guidance or had pointed questions, that'd be one thing. But if you're asking for someone to write all this and hand it over to you, that's something else.
Is there a reason you are not using datastore clusters?