Get Aria Automation Deployment Lease Time by remaining days

In this post I show you how you can get the the remaining Lease days by a given number of days. This can be used to send an email to the Owner of the Deployment before the Deployment Lease will be expired.


  • callvRA Orchestrator Action (see here)

Create an Aria Automation Orchestrator Action with following Inputs and Return Type (see post here how create an Action)

  • diffDays
  • Return type Properties

Add the following Script to the Action Script Canvas:

var deployments = System.getModule("com.vmware.pso.vRA").callVra("GET", "/deployment/api/deployments", "200", null)
deployments = JSON.parse(deployments)
var p = new Properties()
for ( var d in deployments.content){
    var deployment = deployments.content[d]
        var leaseExpireDate = deployment.leaseExpireAt
        var currentDate = convertIsoDateShort (new Date().toISOString())    
        for ( var o in diffDays){          
            var cDate = convertIsoDateShort(leaseExpireDate)
            var diffDay = diffDays[o]
            if(cDate.getTime() == currentDate.getTime()){             
                if(p != null && p.get(diffDay) != null){
                    p.put(diffDay, addItemIfNotExists(p.get(diffDay), deployment))
                    var depl = []
                    p.put(diffDay, depl)
if(p != null && p.keys !=0){
    var keys = p.keys
    for ( var k in keys){
        var key = keys[k]
        p.put(key, JSON.stringify(p.get(key), null, 4))
    return p
return null

function convertIsoDateShort(isoDate){
    var myDate = isoDate.slice(0,-1)
        var [dateStr, timeStr] = myDate.split("T")
        var [year, month, day] = dateStr.split("-")
        var [hours, minutes, seconds] = timeStr.split(":")
        return new Date(year, month - 1, day)

function addItemIfNotExists(arr, item){
    var exists = false
    for ( var i in arr){
        var ele = arr[i]
        if( =={
            exists = true
    if(!exists) arr.push(item)
    return arr


Similar Posts

Leave a Reply

Your email address will not be published.

WC Captcha 5 + 2 =