VMware vCO – cloning VM, using cluster name instead of host and getting less used datastore of chosen host. – Part 1.

0 Flares Filament.io 0 Flares ×

Like I wrote in one of my previous host I’m currently playing with VMware Orchestrator. We’re working on full automated VM deployment, where one of the actions is cloneVM task.Some of the input values for this action are host and datastore. One can define this values as fixed ones in vCO, but what going on when in ones environment there is more than one cluster in vCenter. What I did, I created few simple workflows to find the ESX host of provided vCenter cluster name and then a workflow which finds less used datastore of this cluster. I was lucky, because I had an Orchestrator product consultant who showed me how to do this properly (according to the best practices).
First vCO workflow I’ve created is getHostByCluster – which simply returns the first element of the array of VC:HostSystem objects.
In this workflow I’m using one custom vCO action “getAllClusterMatchingRegexp”

This action returns array of VC:ClusterComputeResource object.
Truth is that in my case this action should return array with one element, because the first step “CleanuptStringtoRegexp” of my workflow is to prepare a input regex for this action

The really bad named “Custom decision” checks if size(length) of returned Cluster array is one, if it’s so, I’m changing type from “array of VC:ClusterComputeResource” to VC:ClusterComputeResource, by getting first element of the array in the “getClusterOutOfArray” scriptable task.

Next step is to get all the hosts in the cluster using predefined action “getAllHostSystemsOfCluster”, which simply returns the array of the VC:HostSystem objects. And in last scriptable task “getSingleHostOfArray”

I’m getting first element of this array. I’m getting first element of the array, because in my case it’s not important on which host I will create the new VM using “cloneVM” task, because I have DRS enabled.

So with this workflow I’ve got the host of the VC Cluster as input for my cloneVM task. In the “Part 2” I will show you the workflows for the less used datastore of the host and then just simply less used datastore of the cluster.

0 Flares LinkedIn 0 Google+ 0 Facebook 0 Twitter 0 Filament.io 0 Flares ×

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.