Continuing smooth migration to vRealize Automation 8, API control is next in line. In vRO 7, the vCAC and vCACCAFE plugins were used to manage vRA, in the 8th version, only the REST API was used. There is no package from VMware yet, but processes are needed right now. To save time at the start, I suggest starting with a small set of basic processes.
vRA 8.x REST API
vRA 8 is under active development, so not all necessary functions are implemented in the API, or the documentation does not keep pace with the changes.
- It is better to start acquaintance with the API with this guide: https://code.vmware.com/docs/12597/vrealize-automation-8-2-api-programming-guide ;
- A more complete description of the available requests can be found at https://developer.vmware.com and in your vRA’s built-in documentation: https://<your_vra8>/automation-ui/api-docs/.
When accessing REST API functions, vRealize Automation 8 requires an authentication token to be passed in the header of each request.
To get an authentication token, you first need to contact the Identity Service API to get an API token (refresh token). Then, using the API token and the IaaS API, you need to get an authentication token (access token). In vRA 8.0, the process for obtaining a token was slightly different from vRA in recent versions, so always refer to the documentation for your specific version.
- refresh token is valid for 90 days, it is better to update it on a schedule;
- The access token is valid for only 8 hours, it can also be updated on a schedule, or you can request a new token if necessary.
VRA Management Pack 8
v1.1.0
The first version of the package implements the basic processes for automating the creation of vRA projects and working with catalog items:
- setting up networks, creating IP ranges and network profiles;
- obtaining information about various vRA objects: zones, regions, projects;
- creating a new project;
- obtaining information about catalog items, deployments, resources;
- creating new deployments and calling actions on deployments and their resources.
Request execution process
The main process that makes all requests to the vRA8 API is called “Invoke a REST operation (vRA)”. All parameters for connecting to the server are stored in the vra-api configuration item . The process accepts the request parameters as input: param_0 .. param_3 , the request body, if necessary: content , and the name of the REST operation. The process itself locates the REST: RESTOperation object on the host by name, so you do not need to specify the operations to be invoked in each process.
When an error occurs, the return status and response headers are checked. If the error occurred due to the expiration of the authentication token (in the diagram, this is the “Token expired?” Element), then a new token is requested, and the request is repeated. This eliminates unnecessary token updates multiple times a day.
if (statusCode == 401) {
var headerWwwAuthenticate = headers.get("Www-Authenticate");
if (headerWwwAuthenticate.indexOf("Jwt expired") != -1)
return true;
}
return false;
Preparing the package for work
1. Install the package into vRealize Orchestrator:
- Download the vRO package ru.zabedu.vra.package ;
- Import the package into the orchestrator via the Packages tab;
- Check that all items have been successfully imported: processes, actions, configuration items.
2. Start the “Initialize (vRA)” process, this process performs all the necessary preparation of the package for work, namely:
- Registering a REST host – “ Add REST host (vRA) “ and saving a link to the host in the vra_api configuration element ;
- Launching the registration process of the used REST operations: “Add REST operations (vRA)”;
- Saving a user account (to receive a refresh token) in a configuration item;
- Receiving and saving the vRA refresh token: “Update refresh token”;
- Obtaining and saving the vRA access token: “Update access token”;
- Creating a schedule for refreshing the refresh token.
These processes will not be enough to automate the work with vRA (Automation of the Automation System). But on their basis it will be easier to develop the necessary processes, well, or write …, we’ll figure it out together.
Translated by Google Translate