VCO Workflows from vCAC Workflows (Southbound)

I recently blogged about Powershell integration with vCAC and how easy scripts can be called from within the various machine states, see here for details. This post will provide an overview of VCAC/VCO Integration of a similar tract.

VCO is an awesome companion with vCAC, VCO has many out of the box plugins and workflows that can be simple to use & test all within the VCO design canvas.  When a workflow has been created within VCO it can be easily integrated into the machine lifecycle.

This example will show you how to setup VCO Integration within VCAC, and then create & run a simple workflow in both VCO and vCAC. The following is the (very simple) functional overview of this sample:

1) Create a new Workflow in VCO which takes an input username as a workflow argument
2) A workflow output argument will be created and set with a user CostCenter being the result.
3) A vCAC State Workflow will run in the Building Machine State and call out to VCO and execute the workflow, wait and store the result as a local vCAC workflow variable.
4) The vCAC Workflow will then save the result to a machine custom property.

All workflows in this post can be downloaded

Setup VCO Integration with vCAC

(Thanks @JoeSarabia for the VCO Integration images, I used your here 🙂  )
Create New Endpoint

Select New Endpoint, then vCO.


Configure name add Address which is the location of the VCO API
 (Default  port is 8281)

Create Credentials

Select New Credential

vCO endpoints must have a property to indicate the priority of each endpoint. 
Click New Property & create property with the name
VMware.VCenterOrchestrator.Priority and a value that is
greater than 0

Click Ok to save endpop



Create a new vCO Workflow

  1. Create a new workflow called GetCostCenteryUser
  2. Create input workflow argument:
    • Name: User
    • Type: string
  3. Create output workflow argument:
    • Name: costcenter
    • Type: string
  4. Within the schema you can add logic, this can be to interact with a 3rd party database, webservice etc. As a test we will just return “CC1” and store it in the costcenter workflow output argument:
    • Create a new scripting task.
    • Add this within the scripting tab of the new script task:
      • CostCenter=”CC1″

Create a new vCAC Workflow

I have blogged before about how to create workflows so wont repeat myself here on the how to.  What we will do here is create a workflow, use the vCAC VCO Activity in which a list of workflows in VCO will be selected.

VCO Setup

If you are using the vCAC Design Center there will be nothing required in order to setup Integration to VCO, where workflows can be seen and selected within the vCAC Workflow. 

If however you are using the CDK vCAC Workflow Designer there will be some initial steps required to set this up.




The details on creating the workflow are as follows:

  1. Create a Pre-BuildingMachine workflow, meaning the VCO workflow will run prior to the machine being created.
  2. Set this to run if a custom property called “User.CostCenter.Name”
  3. In order to get a machines owner details (we will get the whole machine including some extra properties, we can query the VirtualMachineExts table):
    • Create a variable calle Machine of Type “VirtualMachineExts”
    • Drag an Assign activity into the Custom Code area of the worklow:
      • Assign variable name = “Machine”
      • Assign variable value = “mgmtCtx.VirtualMachineExts.Where(Function (v) v.VirtualMachineId = VirtualMachineId).FirstOrDefault()”
  4. Add the VCO Activity “InvokeVCOWorkflow”:
    • Choose our newly created workflow called “GetCostCenterByUser”
    • A list of input workflow arguments will be presented, add the user value : “Machine.UserName”
    • Output workflow parameters will also be displayed, these can be bound to local variables. Create a variable:
      •  Name = costCenter
      • Type = string
    • Assign the VCO Activity costcentre to vcac variable costCenter
  5. Using the Out of the Box vCAC Activities drag the SetMachineProperty activity into the workflow:
    • Machine Id=VirtualMachineId
    • Property Name=”User.CostCenter.Name”
    • Property Value = costCenter
It should look like this:



















































SetMachineProperty Activity Expanded:

Configuration


  1. Deploy the workflow and any associated XML files as normal
  2. Update a blueprint with the custom property:
    • “User.CostCenter.Name” and the value can be left blank.

Request a machine from this blueprint and before the machine starts building VCO should be called and a new dynamic custom property is created in vCAC.

































Enjoy