slideshow 6 slideshow 4 slideshow 8 slideshow 1 slideshow 2 slideshow 3 slideshow 5 slideshow 7

vCAC and vCenter Orchestrator workflow to move Virtual Machines to a Resource Pool

This article describes how to create a workflow in vCenter Orchestrator that, when executed from vCAC, moves a provisioned Virtual Machine to a specified Resource Pool. If the Resource Pool does not exist it will be created.

Requirements:

- vCAC Plugin installed in vCO and configured (documentation and download for plugins)

- vCO Customizations installed in vCAC (vmtocloud article)

To successfully configure the workflow described in this article you must have some experience with both vCAC and vCO. If you have never created or modified a vCO workflow before then please learn how to do that from the article Create your first vCenter Orchestrator Workflow.

You can also download the entire configured workflow here (link).

Start with creating a new workflow based on the workflow template that comes with the vCAC Plugin. In the inventory of workflows browse to the vCAC folder (see the image blow) or search for the search key: template in the search box in the upper right corner.

Store the new workflow in your own custom folder. Before duplicating the workflow create a folder, but since it is a best practice to organize your workflows in a folder you might already have done that.

Duplicate default workflow template for vCAC

The workflow will already contain one scriptable task that is named Display Inputs. This was in the original template. If you do not have the vCloud Director plugin installed then you should remove the references to the input parameters of this type. 

remove vCloud vapp type when not needed

Also remove the lines in the scripting element that reference the vCloud App and remove the vCloud vApp input parameter from the default scripting element.

remove vCloud vapp type when not needed

Declare the attributes we need in this workflow:

  • parentResourcePool of type VC:ResourcePool (set the value to the resource pool where you will create new child resource pools)
  • resourcePoolString of type String
  • resourcePool of type VC:ResourcePool

The list of attributes should look like this:

Attribute declaration

Go to the Schema-tab and drag and drop two new scriptable tasks to your workflow and name them:

  • getCustomProperties
  • DefineResourcePool

Next drag and drop a workflow element to your workflow that points to the action of Move virtual machine to resource pool.

Your workflow should look like this:

Workflow overview

In the next steps we will configure the workflow elements.

getCustomProperties scriptable task

var resourcePoolString = vCACVmProperties.get("resourcePool");

defineResourcePool scriptable task

NOTE: There is an error in this image, you should also bind parentResourcePool as input parameter.

var resPools =
System.getModule("com.vmware.library.vc.resourcePool").getAllResourcePool();
var found = false;
var count = 0;
for each (rp in resPools) {

if (resPools[count].name == resourcePoolString{
    var resourcePool = resPools[count];
    found = true;  }
    count++;
}
if (found == false){
var resourcePool
System.getModule("com.vmware.library.vc.resourcePool").createResourcePool(parentResourcePool,resourcePoolString);
}

Move virtual machine to resource pool

At this point your workflow is ready. Click validate and check for any errors in your workflow. If there are no errors then save and close your workflow.

Create custom property in blueprint or build profile

When you have studied the workflow while creating it you have noticed that we need a property with the name of resourcePool that should come from vCAC into vCenter Orchestrator. Define that property in a blueprint, in a build profile or elsewhere where this custom property should be assigned.

add property to blueprint

Assign the workflow to a blueprint

The last step is to assign this workflow to a blueprint. Perform this action with the vCAC workflow named Assign a state change workflow to a blueprint and its virtual machines.

Now provision a machine from the blueprint and this workflow will be executed and will move the virtual machine to the specified Resource Pool.

Follow us on LinkedIn