VMware Cloud Community
chandu4955
Contributor
Contributor

VRA:VRO Expire workflow : Unable to set ArchiveDays for Expired VMs

In VRA6.2 I have used below module to update Archive Days. But in 7.2 the same is not working. Any idea on how to do it?

ironPropretiesValue = new Properties();

ironPropretiesValue.put("ExpireDays", a_IronArchivedays);

actionResult = System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,ironPropretiesValue,links,headers) ;

Untitled.png

All I need is a solution to set "Destroy On" date to user requested date and get the VM deleted on that day.

0 Kudos
2 Replies
parmarr
VMware Employee
VMware Employee

You can try to configure and run an event broker subscription which automatically sets lease days and archive days on the deployment / VMs based on the current date + the lease time required.

Sincerely, Rahul Parmar VMware Support Moderator
0 Kudos
kumar6384
Enthusiast
Enthusiast

Hi, check whether below code helps,

System.log("\n================================");

System.log("\n START: Lease Day Configuration.");

System.log("\n================================");

// vmName as string example "VM001"

var numberOfDaysToAdd = 10;

var myResources = Server.findAllForType("VCACCAFE:CatalogResource", vmName);

for each (resource in myResources){

if (resource.getName() == vmName){

catalogResourceName = vCACCAFEEntitiesFinder.getCatalogResource(cafeHost,resource.getId());

catalogResourceMachine = catalogResourceName = vCACCAFEEntitiesFinder.getCatalogResource(cafeHost, catalogResourceName.parentResourceRef.getId());

System.log("catalogResourceMachine = " +catalogResourceMachine);

}

}

var operations = catalogResourceMachine.getOperations();

for each (op in operations){

System.log(op.getName());

if (String(op.getName()) == "Change Lease"){

System.log(op.getName());

operation = op;

System.log("operation = " +operation);

}

}

//System.log (operation.getName() + " for machine resource " + catalogResourceMachine.getName() + " was selected.");

var newLeaseDate = new Date();

newLeaseDate.setDate(newLeaseDate.getDate() + numberOfDaysToAdd);

System.log("Setting new lease date to " + newLeaseDate);

var myvCACCAFEDateTimeLiteral = new vCACCAFEDateTimeLiteral(newLeaseDate);

var inputs = new Properties();

inputs.put("provider-ExpirationDate", myvCACCAFEDateTimeLiteral);

//var result = System.getModule("vra.nus.action").requestResourceAction(operation,inputs);

var result = System.getModule("com.vmware.library.vcaccafe.request").requestResourceAction(operation,inputs);

System.log("result =" +result);

System.log("\n==============================");

System.log("\n END: Lease Day Configuration.");

System.log("\n==============================");

0 Kudos