Managing a DRS group with vRealize Orchestrator

The use case for this challenge was a small (8-10 ESXi hosts) cluster, that only a subset of servers were ‘assigned’ with Windows datacenter licenses – so in order to maintain compliance all the Windows VMs would need to run on those hosts. The natural choice for ensuring this happens is a “must run” DRS rule between a group of VMs and a group of hosts and the automation step for this is ensuring that the VM group is accurate by only containing VMs that are still in the cluster and contains all Windows VMs in the cluster. Thus, the plan is use vRealize Orchestrator to manage the DRS group.

This technique (and workflow) will be left open enough for it to be used with any type of Operating System, after all I believe Red Hat also license on a per-hypervisor basis.


The schema of the workflow is pictured below.

The flow is one of the simplest we can make ! The steps are:

  • Retrieve the configuration variables from the ConfigurationElement.
  • Get the VMs from the cluster (exit the workflow if it has none).
  • Get the DRS Group from the name (exit if it does not exist).
  • Loop through the VMs and add/remove them to the DRS group as necessary.
  • Send an email report if changes are made.

It has a single input of a ConfigurationElement, with the following variables. The description should make it apparent what each variable is used for.

The magic of the workflow is the updating of the DRS rule, which the below script covers:

Where next

As it stands now, we can schedule the workflow to run at the end of the day and allow DRS to place the VMs correctly.

However, to really ensure that the VM is running on the correct host we would invoke this workflow on every creation and addition to the cluster. This is possible when using LogInsight – configured as a destination for the ESXi hosts’ syslogs – to call Orchestrator via a Webhook when the appropriate events are received.

Now that we can dynamically change a DRS rule, this is starting to open up possibilities. Stay tuned 🙂


You can download the workflow package using the button below. Please let me know if you found this useful !