VMware Cloud Community
jakubjs
Contributor
Contributor

Getting total resources of a request

Hi

I would like to build a VRO workflow to be used as part of working out if there is sufficient resources available to approve a request. So I need to be able to look at all currently approved requests and work out the total cpu and memory requested. I've been able to get current requests but am not sure how to easily obtain the total required. It appears to me that the request data of the catalog request only has information that is different then the blueprint (which is easily obtained as a JSON structure). The issue is I'm not sure how to convert the request data into a JSON format. Alternatively is there another way?

I figure that VRA must somehow work this out for its costing.

Any help would be greatly appreciated.

cheers,

Jakub

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

To convert request data into JSON format, you can first get the request data from the request as a plain string, and then parse the string into a JSON object. Try something like the following:

var jsonData = vCACCAFERequestsHelper.getProvisioningRequestData(request);

var json = JSON.parse(jsonData);

0 Kudos
jakubjs
Contributor
Contributor

Hi Ilian

Thanks for the reply. The issue is that my request at the time is a vCACCAFECatalogItemRequest and not a provisioning request. The getRequestData method returns a vCACCAFELiteralMap. Can I apply this to the provisioning request somehow and convert it?

cheers,

Jakub

0 Kudos
bulatkaz
Contributor
Contributor

Hi jakubjs,

You can try to use REST calls, the following way:

var catalogClient = vcacCafeHost.createCatalogClient();

var urlVariables = [catalogItemRequest.id]; // catalogItemRequest - VCACCAFECatalogItemRequest

  //, which you already have

var req= catalogClient.getWithVariables("consumer/requests/{requestId}", urlVariables);

json = req.getBodyAsJson();

I hope this will help.

0 Kudos