vRealize Orchestrator – Workflow to change DRS setting to manual on single VM

0 Flares Filament.io 0 Flares ×

Multiple times in multiple workflows, I needed to have VM not being migrated during the workflow run. Easiest way is to disable DRS on the VM. Well, it seems that DRS setting does not belong to VirtualMachine object, DRS settings is part of the ESX Cluster object. We’re still able to to set setting individually per VM, however it has to be set on ESX Cluster level not on the VM itself. I was pretty sure, that there built-in vRO workflows for such simple setting … However, it’s not. That’s what VMWare offers by default

  • Add DRS virtual machine
  • Add virtual machines to DRS group
  • Create cluster
  • Delete cluster
  • Disable DRS on cluster
  • Disable HA on cluster
  • Enable DRS on cluster
  • Enable HA on cluster
  • Remove virtual machine DRS group from cluster
  • Remove virtual machines from DRS group
  • Rename cluster

If there is a need and there is no solution – it has to be created.

There is one workflow called “Disable DRS on cluster”. I’ll make copy of it and I’ll make modification to change DRS settings just on one VM, NOT disable DRS on whole cluster. I will name it “Set-DRS-To-Manual-On-VM”. The workflow looks like that

So the  “Disable DRS on cluster” has one input parameter “cluster” of type “VC:ClusterComputeResource”.

In my case, I need a virtual machine as input parameter, so I’ll add it

I’ll keep the “cluster”, but I’ll move it to attribues. as the changing DRS on VM is a reconfiguration task on cluster. So my workflow input parameters and attributes looks like that

Now lets see the code in the workflow Scriptable Task “Turn DRS on Cluster”.

It takes cluster of type VC:ClusterComputeResource as input parameter and returns a VC:Task, which reconfiguration task of ESX cluster. I’m gonna edit this workflow scriptable task, first changing name from “Turn DRS on Cluster” to “Change DRS to manual on VM”. As I’m gonna change DRS to manual on single VM, so this scriptable task parameter will be vm of type VC:VirtualMachine. Cluster parameter is not needed as input it can be safely declared inside the scriptable task, however I’ll keep it for the simplicity.

So I have a VM as input now I need a cluster to which VM belongs. Imagine, VM does not belong to the cluster, at least from the VirtualMachine object point of view. VM is hosted on ESX host, which is part of ESX Cluster, so to get cluster of the VM we need

Then I leave the check of DRS default and I will modify just the inside “if” code, so for the start it looks like

I will need to add a configuration of DRS for VM. I’m not gonna describe each line of the code. You can find the object attributes and attribute types in vRO “API Explorer”.

The main steps are :

  1. Define DRS VM specific config, there is an object for that and the code looks like that
  2. Then I need to declare an array and push the config to the array – it is required for the 3rd step
  3. Last step is to define Cluster confuguration specifiaction and set “drsVmConfigSpec” property with newly created array
  4. Last step is to create an output reconfiguration task and it’s done

So the final code looks like that

And that’s it, now just save the workflow and DRS can be set to manual on the VM, was it so hard to do VMWARE ??

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.