Month: March 2017

Using createRestClient() in vRealize Orchestrator to create vRealize Automation REST calls.

There is a createRestClient() method available in the vRealize Automation 7.x plugin in vRealize Orchestrator that you can use to create REST calls. The difference with using this method over using a REST host created in vRealize Orchestrator is that you do not need to get a Bearer token as the createRestClient()  method uses the vCACCAFEHost object configured and therefore you use the authentication configured within the host object you have created.

Once you have set up a vCACCAFEHost object using the ‘Add a vRA host’ workflow, you can use REST calls very similarly to native REST but there are some slight nuances. However, understanding these nuances helps understand how to interact with the API in my opinion.

Here is a screen shot of the scripting class and the method I am referring to.

Screen Shot 2017-03-22 at 11.49.33

You can see the return type is a the vCACCAFERestClient object. Once you have created an instance of the vCACCAFERestClient object, you can start interacting with the API by using some of the methods shown below.

Screen Shot 2017-03-22 at 11.48.54

However, you need to add which API service you want to connect to when creating the clientRestHost() method as that method requires an input string.

To determine what endpoint you need to use, you canlook at the API docs for the vCACCAFE plugin and search for the vCACCAFEServicesEnum scripting class. Here is a screen shot of what endpoints are available:

Screen Shot 2017-07-07 at 08.46.42

Or, as the above doesn;t work :), you can find your endpoint by searching this REST query:

https:{fqdn}/component-registry/endpoints?limit=500&orderby="url"&$filter endpointType/protocal eq "REST"

Here you can see the endpoint I am using for the catalog service is

Here is the Orchestrator code that you can use now:

var endpoint = '';
var restClient = host.createRestClient(endpoint);
var catItemsUrl = "consumer/resources";

Notice that I am passing in an additional consumer/resources URL. This is because once I have connected to the vRA API endpoint, I can then chose what URI to use depending what I am trying to query form the vRA API Endpoint. The URI is apended to the base URL determined from the vRA REST endpoint. This information is available in the online docs.

The other thing to note is that the return type from the REST call returns a vCACCAFEServiceResponse object. Have a look at that object in the API browser to see available methods and attributes.

So now I have my full URL, I can then make a REST call as follows:

var catItems = restClient.get(catItemsUrl);
var res = catItems.getBodyAsString();

TIP: I noticed that if I parsed the string output to a JSON object, it would fail as the vRA Host reference looks to be escaped. Therefore, before converting to a JSON object, you need to strip out any ‘\’ (forwardslashes) before parsing the string.

json = JSON.parse(res.replace(/\\/g, ''));

This now turns the REST response into a JSON ojbect that you can iterate through.

However, what happens if you have many catalog resources? You may hit a page size limit or the info you are bring back may take a long time to return. This is where you can use ODATA filters and pagesize parameters in your URL.

For example:

var catItemsUrl = "consumer/resources?limit=10$filter=catalogItem/name eq 'vRA IaaS'";

This dramatically cuts down the response time and saves resources.

Check the /var/log/vcac/access_log.txt for more info and look here at a snippet [ +0000][51 ms] "GET /catalog-service/api/consumer/resources?
$filter=catalogItem/name%20eq%20'vRA%20IaaS' [ +0000][406 ms] "GET /catalog-service/api/consumer/resources'

So nearly 800% faster and I only have a hand ful or catalog resources available in my lab. If you have 000’s, make sure you use filters. For more info on ODATA filters for the catalog-service, see this URL https://{vra-fqdn}/component-registry/services/docs

How to get vRealize Automation Install Wizard values

The vRealize Automation installation wizards is one of the best new features in version 7 but I was recently asked how to get the install wizard values post installation for vRealize Automation. This is useful to just help understand what values were entered in case you need to troubleshoot the install or double check the config.

I found one way of doing this which may or may not be the best way.

You can pass in a parameter to the vcac-config utility to get page data specified during the install.

Each installation wizard page has an ID value. You can find these by running this command:

cat /opt/vmware/share/htdocs/service/wizard/wizard.xml
| grep -i '<wizardPage' -A1 | grep -i -w ' id\b'

This will list all the page IDs in the install wizard.


Now you have the wizard page IDs, you can get the parameters you have entered on the install wizard by running this command:

 /usr/sbin/vcac-config install-wizard --page iaas.servers.dem --params-get

This will output something similar to this:


You can run this command and enter the page ID to get any of the install wizard data you entered, just in case you aren’t sure what was configured.