Extensibility has a long history within VMware’s Automation and Operations suites. Extensibility has traditionally been defined as how we create interactions with platforms outside of our management platform. Some of the most common examples of this are…

  • Interacting with IPAM Systems (Infoblox, BlueCat, etc)
  • Pushing records into Configuration Management Databases (CMDB’s)
  • Creating Records in DNS
  • Interactions with various REST platforms

In vRealize Automation, we have refined the existing and introduced new extensibility capabilities in the platform. The goal of this blog is to give you an overview of the ABX Multi-Script Language Flows that exist in the platform today.

This is how we can get you started:

Create & Import ABX Actions and Flow :

We will create an ABX Action NodeJS-Based, Import an ABX Action Python-Based, stitch them together with an ABX Flow and we will call it via a conditioned subscription based in our own custom property.

  1. Log in to vRA Cloud and go to Cloud Assembly then to Extensibility 
  2. Go to Library then Actions
  3. Create a NEW ACTION named  “Set VM Tags
  4. Select an existing Project
  5. You will be presented with the default ABX editor, by default you are set in Type : Script but there are other types such as Flow that we’ll address later
  6. Change the default Scripting Engine for NodeJS, you will notice that the option WRITE SCRIPT is set, this will allow you to write your own script in the canvas, however you can also “Import Package”, this is very convenient, specially whenever you need to use Scripting libraries or Modules that are not found in the standard set of libraries or available in any repository, e.g. your home-brew libraries and modules and/or vRealize Automation doesn’t have Internet access and cannot fetch libraries on-demand, more in this blog: HOW-TO: ABX/vRO Powershell actions which include additional Modules
  7. Replace the whole sample Script following NodeJS Code:

 

/** Assigns tags to a machine
* @param {Object} inputs
* @param {Object} inputs.tags - The initial tags for the machine, supplied from the event data
* during actual provisioning or from user input for testing purposes.
* @param {Object} inputs.newTags - The tags to assign to the machine, which can be
* in the form {"name": "value"} for name=value tags
* or {"name": ""} for a simple name tag.
* @returns {Object} The desired tags.
*/
exports.handler = function handler(context, inputs) {
let newTags = inputs.newTags;
let outputs = {};
outputs.tags = inputs.tags;outputs.tags["UserName"] = inputs.__metadata.userName;
outputs.tags["EventTopic"] = inputs.__metadata.eventTopicId;console.log("Setting tags: " + JSON.stringify(outputs.tags));return outputs;
};

This code will input the Metadata Tag information from vRealize Automation during provisioning allocations ( more later ) and include a couple of new tags capturing the UserName and EventTopic used for the Subscription

Set up the ABX Action Settings:

  1. Main Function, this is the point of entry function for your script to execute so it is very important to match, you will notice our script above it is calling for exports.handler, this main our Main Function: handler ( which it is the default ).
  2. You need to modify the Default Inputs, this is very useful if you are testing the Function independently and no as part of an actual Extensibility or API call, in this case replace the default input with the following two ones:

 

 

  1. There is no external dependences for this specific Script, however it is very common for other complex Scripts to require external modules that can be downloaded on the first Action execution, e.g Python normally requires to include here “request” library as dependency for making API calls.
  2. You need to select your FaaS Provider, it is often recommended to use Auto Select, as this allow you to leverage several ABX endpoints based on your available Cloud Zones, e.g. ABX on-prem, AWS Lambda and Azure FaaS, please note that your Cloud Accounts need to have enough permission for FaaS execution, it is also possible to define extensibility constraints at the Project Level so you can control where the extensibility endpoint will be used for any given Project.
  3. It is also a good idea to set custom limits and retry options to fit our Script needs.
  4. Save your ABX Action.
  5. Your ABX Action should look similar to this:

 

 Import the EMAIL Notification ABX Action to your Project:

  1. Please follow the instructions to Create an Extensibility Action (Python Based) as described at  Email Notification Action Python Based blog.
  2. Make sure to set it up to meet your local environment as indicated in that specific blog section.
  3. When complete a new ABX Action named Email-Notification will be available.

Set up the ABX Flow:

    1. Create a NEW ACTION named  “Set VM Tags and Email Notification “
    2. Select your working Project
    3. You will be presented once again with the default ABX editor, by default it is set to Type : Script but switch it now to Type : Flow
    4. Remove the last two lines ( as we won’t accommodate any error handling for this testing although it is a good practice to always include it )
      onError:
      action: error_handler_placeholder # ID of the action to be triggered should an error occur
    5. Under action1 → action: remove the placeholder “action_placeholder” and set the name of the previously created action, e.g. “Set VM Tags”
    6. Under action2 → action: remove the placeholder “action_placeholder” and set “Email-Notification“, This is a Python Based ABX Action that can send customized emails
    7. It should look similar to this:  
    8. You can verify the right Action and Code is the right one by checking in the Graph representation “eye” for the Action, you can see that the 2nd Action is a more complex Python Based that includes dependencies.
    9. Save and Close

 

Now we need to create a subscription that will call the ABX Action Flow and the associated Actions

  1. Log in to vRA Cloud and go to Cloud Assembly then to Extensibility 
  2. Go to Subscriptions
  3. Create a NEW SUBSCRIPTION named  “Extensibility Flow “
  4. Make sure Status is enabled.
  5.  Event Topic : + ADD then search for Compute Allocation, please note the schema, this one includes Tags and customProperties both complex types used for our ABX Flow and Actions
  6. Enable he condition and provide the following filter: event.data.customProperties[‘enable_ext’] == “true” , “enable_ext”  is our own customized Property provided at the Cloud Template
    • you can use many other options as per subscription support, couple of samples:
      // Run subscription for specific user. Use when testing blocking subscriptions.
      event.userName == ‘username@example.com‘ 
    • // Run subscription for specific blueprint. Take the blueprint ID from blueprint page URL. This can be done only for provisioning related topics. event.data.blueprintId ==’cb5c3112-3a7e-46c5-be3a-2917d0aa7741

     

  7. For Action/Workflow, select our Set VM Tags and Email Notification flow.
  8. Make sure Blocking is also enabled
  9. Subscription scope: Any Project disable then select your current working Project on which you will define your test Cloud Template.
  10. Save

 

Let’s create a simple Cloud Template that will call the ABX Action Flow and the associated Actions

  1. Log in to vRA Cloud and go to Cloud Assembly then to Design
  2. Create or re-use any existing Cloud Template having a Cloud.Machine Resource, and make sure it is associated to our working project.
  3. Under resources you could add a customized property named enable_ext and have it associated a boolean input, this is the property we will use as the criteria to trigger our subscription

 

    1. Let’ DEPLOY and give it a name, select “Current Draft”, NEXT
    2. Make sure to check on Enable Extensibility ( this is will set ‘enable_ext’ == “true” ), then DEPLOY
    3. Go back to Extensibility then Events
    4. You will notice that right after the registered Compute Allocation Event Topic, the ABX Flow is called and actions 
    5. Go to Activity, then Action Runs
    6. You will discover 3 entries as follows: 
    7. You can see that the ABX Flow is called which essentially triggers the multi-language ABX Actions
    8. The first one per our ABX Flow is the Python based ABX Action that will send an Email Notification to the end user who deployed the Cloud Template. 
    9. The second one per our ABX Flow is the NodeJS based ABX Action will add extra tags besides the ones found at the Cloud Template, if you inspect your actual deployment, note that Event Topic and UserName, they were created by our NodeJS Script the other two tags came from the Cloud Template and left unmodified as we wanted.
    10. You can inspect the ABX Action Executions also at Activity, then Action Runs
    11. Let’s start with ABX Flow “Set VM Tags and Email Notifications”, you will notice that there is no FaaS provider since this is a launcher for the actuals Action in the flow, however you can get details about:
      • The Action Timeline ( the ABX called, the order and their Status )
      • Details ( the consolidated input and output data )
      • Trace ( the logic behind selecting ABX Engine )

 

 

If you select any of the executed ABX action you could also see

    1. Details  ( the input and output data handled by the ABX Action)
    2. Log ( the Script Output, include any specific data from the ABX Engine )
    3. Trace  ( the logic behind selecting ABX Engine )

 

At this point you can instance once again the Cloud Template, leave the default input, however make sure to check off Enable Extensibility ( this is will set ‘enable_ext’ == “false” ), then no ABX extensibility will be executed.

Conclusion

Extensibility by ABX or vRO enhances  vRealize Automation integration and customization capabilities, having the ability to create multi-Scripting ABX actions and vRO Workflows allows you to re-use existing scripts and/or to pick the right language for the specific job in complex deployment executions.

For more information feel free to check these blogs out:

Self-Service Hybrid Cloud – Part 2 – Using vRealize Automation ABX to make API calls to VMware Cloud on AWS

vRealize Automation Action Based Extensibility (ABX) now supports PowerShell

Leverage vRealize Automation’s Action Based eXtensibility (ABX), Event Broker Service (EBS) & APIs for Email customized notifications

HOW-TO: ABX/vRO Powershell actions which include additional Modules

Comments

Leave a Reply

Your email address will not be published.