VMware Cloud Community

vRealize Automation 7.0.1 (vRA) - Accessing Compute Resource info?


I've been given the task to create a vRO Workflow that creates a Business Group, Entitlement, and Reservation in vRA.

In the reservation part, i want the user to input the Compute resource he wants the resources to reside in, and how much Memory and Storage he needs.

In the workflow, i want to check against the selected Compute Resource if the memory and storage that the user has inserted won't cause overprovision on the selected Compute Resource.

However, i can't find a place in which to select the current provisioned resources from a Compute Resource from.

In the vRA GUI, under Compute Resources, There are the fields "Memory Reserved (%) " and "Storage Reserved (%)", which is exactly what i need, but i cant seem to get them from anywhere else to use them in the workflow.

in vRO, there doesnt seem to be a "Compute Resource" object that i can work with.

from the vRA REST API, there also doesnt seem to be a compute resource service or any http GET that will get me the compute resources.

I've gotten as far as searching inside the vRA Appliance PostgreSQL and the MSSQL IaaS DB, but i couldn't find the table that saves this information either.

I also tried getting this information from the reservation objects, but its problematic as i stated in this post: vRA 7.0.1 REST API Reservation Service - Getting computeResourceReservedMemory problem

Anyone did anything like that and could help me?


0 Kudos
4 Replies

Have you looked into using CloudClient 4.1? It has some commands in there like:

1. vra businessgroup add

2. vra entitlement add

3. vra reservation policy add

In the documentation that VMware provides there is an example called "CreateVSphereReservation.sh" in the Samples section. It shows you how to create generate the JSON template it's looking for and create the reservation.

I'm more of an API guy when it comes to doing stuff like this (and I'm pretty sure that's what the program is leveraging), but it seems like what you're doing here might be a good use case for CloudClient.

0 Kudos

I've used CloudClient originally but the problem with CloudClient was that i cannot create a script out of CloudClient commands... so i've moved to vRO. also i dont think there is any access to Compute Resource through CloudClient either if i remmember correctly.

I've managed to make all of this stuff in vRO already (the business group, entitlement and reservation creation), the only thing im missing is the overprovision check against the Compute Resource.

0 Kudos

There are a few ways to setup automatic login so that you can run CloudClient through something like PowerShell or bash. To your point however, I just checked to see if there was an OOTB command to get useful information from a compute resource but it appears you can only list them out.

Maybe another way to go about this is to try playing with the VcPlugin scripting object in vRO. That object has an allComputeResources attribute that returns an array of  VcComputeResource. It also has a getAllComputeResources method that allows you to get a filtered array of VcComputeResource. I ran this script in vRO 7.0.1 workflow that's pointing to a vRA 7 lab environment :

var computeResources = VcPlugin.allComputeResources;

for(var resource in computeResources){

  System.log("Resource Name: " + computeResources[resource].name);

  System.log("Number of Hosts: " + computeResources[resource].summary.numHosts);

  System.log("Number of CPU Cores: " + computeResources[resource].summary.numCpuCores);

  System.log("Effective CPU in MHz: " + computeResources[resource].summary.effectiveCpu);

  System.log("Effective Memory in MB: " + computeResources[resource].summary.effectiveMemory);



From the API documentation there are linkages to datastores, hosts, and resource pools. To check a host, I added this in my loop to pull out the overall cpu usage regarding the first listed host in my resource:

System.log("Current CPU Utilization: " + computeResources[resource].host[0].summary.quickStats.overallCpuUsage);

Good luck!

0 Kudos

Looks like you and I are trying pretty much same things. Not sure if you found the solution or not but here is my way of getting those to create the reservation by code:

1. Get the token:

postOp.method = "POST";
postOp.urlTemplate = '/identity/api/tokens';
postOp.defaultContentType = "application/json";

var content = '{"username":"' + username + '","password":"' + password + '","tenant":"vsphere.local"}';
var inParamtersValues = [];

var request = operation.createRequest(inParamtersValues, content);
request.contentType = "application/json";
request.setHeader("Accept", "application/json");
var response = request.execute();
var jsonResponse = JSON.parse(response.contentAsString);
token = jsonResponse.id;

2. Gets Compute resource:

restOp.method = "POST";
restOp.urlTemplate = '/reservation-service/api/data-service/schema/' + schemaClassId + uriExtension;
restOp.defaultContentType = "application/json";

var restContent = '{"text":"","dependencyValues":{"entries":[{"key":"computeResource","value":{"type":"entityRef","componentId":null,"classId":"ComputeResource","id":"' + comResId + '"}}]}}';
var inParamtersValues = [];

var addRESTOperation = restHost.addOperation(restOp);
var req = addRESTOperation.createRequest(inParamtersValues, restContent);
req.contentType = "application/json";

// Add Bearer token for authentication
var authorizationToken = "Bearer " + token
req.setHeader("Accept", "application/json");
req.setHeader("Authorization", authorizationToken);

Note: schemaClassId is from the getReservationType

3. Gets the memory, storage, network resource and fill in the JSON for create reservation:

Here is the URL for those:

Memory: '/default/reservationMemory/values'

Networks: '/default/reservationNetworks/values'

Storage: '/default/reservationStorages/values'

Resource Pool: '/default/resourcePool/values'

Hope that helps!

0 Kudos