How to trigger a VCF Operations Orchestrator Workflow from VCF Operations 9.1
- josephldibella
- 1 day ago
- 3 min read
You can trigger an automated action in VCF Operations 9.1 by using a webhook.
The process that we will be using in this example is to have a VCF Operations alert trigger a webhook which would then call VCF Operations Orchestrator (Formerly known as vRealize Orchestrator). In this case, the alert will be for a VM that exceeds 95% CPU utilization. There is already an existing alert for this, so no need to make one.
What we want to do is first configure the webhook.
Go into Operate > Administration > Configurations > Outbound Settings > Add

The orchestrator URL will need to follow this format: https://<your_VCF_Automation_FQDN>/vro/runs/ You will also need to add some type of credentials. I created a service account and requested a bearer token which I provided here under credentials. The rest can remain as is. Next we will want to create a VCF Operations Orchestrator Workflow. My workflow is fairly straightforward; it blindly adds 2 CPU to the VM that the alert was triggered on.
NOTE: The script I will create assumes Hot Add is enabled. Go into your VCF Automation Orchestrator instance. In this case I am using an Orchestrator instance that is part of my VM App Organization: Navigate to Orchestrator > Library > Workflows > Add New Provide a name and optional description. Leave everything else as is. NOTE: Copy down the ID. This will be needed later.

In the inputs/outputs tab, create a new input variable called vmName (type = string) and add an optional description.

In the Schema tab, drag and drop in a scriptable task. Click on the scriptable task, and under scripting, add this code: // 1. Locate the VM in the vCenter inventory by its string name
var vms = VcPlugin.getAllVirtualMachines(null, vmName);
if (!vms || vms.length === 0) {
throw "Error: No Virtual Machine found with the name: " + vmName;
} else if (vms.length > 1) {
System.log("Warning: Multiple VMs found with this name. Modifying the first one found.");
}
var myVM = vms[0];
System.log("Found VM: " + myVM.name + " (ID: " + myVM.id + ")");
// 2. Calculate the new vCPU target
var currentCPUs = myVM.config.hardware.numCPU;
var targetCPUs = currentCPUs + 2;
System.log("Current vCPU: " + currentCPUs + ". Upgrading target to: " + targetCPUs);
// 3. Build the vCenter Config Specification
var configSpec = new VcVirtualMachineConfigSpec();
configSpec.numCPUs = targetCPUs;
// 4. Execute the reconfigure task asynchronously
try {
var task = myVM.reconfigVM_Task(configSpec);
System.log("Reconfigure task initiated successfully for " + myVM.name);
} catch (exception) {
throw "Failed to reconfigure VM: " + exception;
}

Now let’s return back to VCF Operations to create a payload template. Navigate to Operate > Administration > Configurations > Payload Template > Add Provide a name and optional description. Next, add in the object type, in this case, virtual machine. You will also have to add in at least one metric here (which metric should not matter).
Next, enter in the payload details, specifically Content Type - application/json and HTTP Method - Post. The rest you can leave as is.
NOTE: you should NOT enter in a URL at this point.
Next add in the payload of the request. Mine was as follows: {
"workflowId": "636cec06-0aae-4aa5-bd37-97b5f6f80c2f",
"parameters": [
{
"name": "vmName",
"type": "string",
"value": {
"string": {
"value": "${RESOURCE_NAME}"
}
}
}
]
}
NOTE: the workflow ID I pulled from the Orchestrator Workflow in a previous step.

Lastly, we will go to Operate > Administration > Configurations > Notifications > Add
Here you will add in a name and description, next, define the criteria (aka scope - I left mine as the defaults purely because this is an example), next, set outbound method. You will choose Webhook Notification Plugin and the previously created webhook:

Next, select the previously created payload template:

Finally, we can test that it all works by pressing initiate process:

You will have to select your alert and object to use for the test. In this case, I am testing this on Cloud_vSphere_Machine_1-0367. Prior to initiating the test, we can see in vCenter that the VM has 3 CPU:

After we initiate the test…

We can see in VCF Operations Orchestrator that the test has run!

And finally, in vCenter, we now have 5 CPU!

Hope this helps!



Comments