Call Aria Lifecycle Manager from Aria Automation Orchestrator

In this blog post I show you how you can make an REST call to LCM via Aria Automation Orchestrator.

Prerequisites

  • Aria Lifecycle Manager added as REST Host to Aria Automation Orchestrator

Create an Action as shown below with the following Inputs and Return Type

  • restMethod (type string)
  • operationUrl (type string)
  • returnCode (type string)
  • body (type string)
  • Return type string
var restClient = System.getModule("com.vmware.pso.util").getConfigElementAttributeValue("PSO/vRA", "Global Config", "lcmRESTHost");

if(restClient)
{
    operationUrl = encodeURI(operationUrl)
    System.log("SWITCH TO DEBUG LOG TO SEE ALL LOGs")
    System.debug("++++++++++++++++++ STARTING LCM REST Call +++++++++++++++++++++++++")
    System.debug("Requested URL: " + operationUrl)
    if (body != null && body != "") {
        var myContent = passwordInBody(body)
            System.debug("Payload for REST Call: " + JSON.stringify(myContent, null, 2))
        var request = restClient.createRequest(restMethod.toUpperCase(), operationUrl, body);
    } else {
        var request = restClient.createRequest(restMethod.toUpperCase(), operationUrl);
    }
    System.debug("Requested URL: " + request.fullUrl)
    request.setHeader("Content-type","application/json");
    request.setHeader("Accept","application/json")
    var response = request.execute();
    if(response.statusCode != 200) throw "REST request failed with staus code "+response.statusCode+"\r\nResponse is: "+response.contentAsString;
    
    System.debug("LCM REST Call Response: " + JSON.stringify(JSON.parse(response.contentAsString), null, 4));
    var json = JSON.parse(response.contentAsString);
    System.debug("++++++++++++++++++ END LCM REST Call +++++++++++++++++++++++++")
    return JSON.stringify(json, null, 4)
}

function passwordInBody(body){
    myBody = JSON.parse(body)
    var keys = Object.keys(myBody)
    for each ( key in keys){
        if(key.toLowerCase().indexOf("password") != -1){
            myBody[key] = "************"
        }
    }
    return myBody
}








CREATE / SAVE the Action.

Run and test the Action.

Similar Posts

Leave a Reply

Your email address will not be published.

WC Captcha − 1 = 2