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 ×

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

  1. Firstly, thanks for article. I wanna ask a question about choosing host. I choose the 0th element of host list (hostArray[0]) too. But there is a problem here. If first element of list is not available what will happen? Host can be not available for deployment of a vm(like maintenance mode.) How we can control this?

    Sorry, maybe the question is very easy but I’m new at vCO.

    • Hello,

      This workflow is the simplest one, of course it’s possible to exclude hosts in maintenance mode, by rewriting the vRO action “getAllHostSystemsOfCluster” used
      and return only hosts which meet the condition “host.runtime.inMaintenanceMode!=true”
      Basically to learn VMWare object properties and methods I recommend “Managed Object Browser”, you can reach it by going to : https://vcenter/mob.

Leave a Reply

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