VMware Cloud Community
filosmith
Enthusiast
Enthusiast
Jump to solution

How to get resource action request information

I'm trying to get any useful information from the payload sent by a Change Lease operation, so I can also adjust the destruction time. My workflow is receiving the payload and several __asd_* inputs, but none of them seem to refer to anything I can use to look up the vm or deployment.

None of these actually refer to a catalog item, catalog item request, or resource action request, as far as I can tell. They all throw 404 errors when I try to look them up with another workflow:

payload.requestId

payload.deploymentId

__asd_catalogRequestId

__asd_correlationId

__asd_requestInstanceId

__asd_targetResourceId

I can go through vRO's browser to find requests and items, and then paste those IDs in to my workflows, and that works.

Any nudge in the right direction would be most appreciated. Thanks in advance!

Reply
0 Kudos
1 Solution

Accepted Solutions
bulatkaz
Contributor
Contributor
Jump to solution

Hi, filosmith

I managed to get deployment using the following code:

var items = vCACCAFEEntitiesFinder.getCatalogResources(vcacCafeHost); //vcacCafeHost - vCACCAFE:VCACHost, need to be specified as attribute

for each(item in items){

  if(item.providerBinding.bindingId == deploymentId){ //depoment ID which comes as input

       System.log("Deployment name: " + item.name);

       System.log("Deployment lease: " + item.lease.getEnd());

  }

}

Hope this will help you.

View solution in original post

7 Replies
bulatkaz
Contributor
Contributor
Jump to solution

Hi, filosmith

I managed to get deployment using the following code:

var items = vCACCAFEEntitiesFinder.getCatalogResources(vcacCafeHost); //vcacCafeHost - vCACCAFE:VCACHost, need to be specified as attribute

for each(item in items){

  if(item.providerBinding.bindingId == deploymentId){ //depoment ID which comes as input

       System.log("Deployment name: " + item.name);

       System.log("Deployment lease: " + item.lease.getEnd());

  }

}

Hope this will help you.

filosmith
Enthusiast
Enthusiast
Jump to solution

Thank you very much, bulatkaz Smiley Happy

Reply
0 Kudos
filosmith
Enthusiast
Enthusiast
Jump to solution

Reply
0 Kudos
bulatkaz
Contributor
Contributor
Jump to solution

Hi filosmith,

Below is another one way, from vRA Plug-In official guide

var requestId = __asd_correlationId; //from payload

var service = vcacCafeHost.createCatalogClient().getCatalogConsumerResourceService();

var filter = new Array();

filter[0] = vCACCAFEFilterParam.equal("request", vCACCAFEFilterParam.string(requestId));

var query = vCACCAFEOdataQuery.query().addFilter(filter);

var items = service.getResourcesList(new vCACCAFEPageOdataRequest(query));

for each(var item in items) {

    if(item.resourceTypeRef.getLabel() == "Deployment") {

        var deployment = item;  //vCACCAFECatalogResource type

        break;

    }

}

Reply
0 Kudos
balawiz
Enthusiast
Enthusiast
Jump to solution

The above solution is working only for successful deployments. How do we get for failed catalog requests?

Reply
0 Kudos
balawiz
Enthusiast
Enthusiast
Jump to solution

Hi filosmithbulatkaz

In which way the below code has been modified to get the VMs above 100 by matching deploymentId?

  1. var items = vCACCAFEEntitiesFinder.getCatalogResources(vcacCafeHost); //vcacCafeHost - vCACCAFE:VCACHost, need to be specified as attribute 
  2. for each(item in items){ 
  3.   if(item.providerBinding.bindingId == deploymentId){ //depoment ID which comes as input 
  4.        System.log("Deployment name: " + item.name); 
  5.        System.log("Deployment lease: " + item.lease.getEnd()); 
  6.   } 
  7. }

Regards

Bala

Reply
0 Kudos
Lie_DW
Contributor
Contributor
Jump to solution

Hi bulatkaz,

I have the payload as input in my workflow. The first lines are

var machine = payload.get("machine");

var properties = machine.get("properties")

since I need some custom properties but adding your code in the script doesn't work.

The workflow gives this error: Get Catalog Resource / Scriptable task (item2)#7) Data Integrity validation error.

I see the __asd_correlationId in the variables after the workflow has run but it doesn't seem to use it in the workflow. When I use your code but set the correlationId as a manual input, everything works.

Hope you can help me find the missing piece to process the correclationId correctly.

ps: I'm on 7.5 HF1

Reply
0 Kudos