Provisioning Virtual Machines Using vRealize Automation REST API for Software Development

Provisioning Virtual Machines Using vRealize Automation REST API for Software Development

著者の連絡先情報

Moinul Islam

Moinul Islam

Introduction

VMware vRealize Automation (vRA), formerly called vCloud Automation Center, is automation software for virtual environments developed by VMware, Inc. vRealize provides a secure portal where users can request new IT services and manage specific cloud and IT resources. Using vRealize REST (representational state transfer) API, application developers can provision and automate virtual machines/physical machines in virtual, physical, and cloud environments.

This article is intended for software engineers and application developers who want to configure and manage vRealize Automation programmatically using the vRealize Automation REST API.

This article provides a step by step use of vRealize Automation REST APIs to provision a blueprint, including how to use the REST API services and resources, create HTTP bearer tokens for authentication and authorization, and construct REST API service calls. The steps demonstrated in this article are as follows:

  • Deploy a virtual machine from a blueprint.
  • Monitor the status of the request through the deployment.
  • Finally, return networking information about the provisioned virtual machine at the end of the process.

Intended Audience

This article is intended for application developers, software engineers who create client applications, web interfaces, web services that connect to the vAPI endpoint to use VMware vSphere Automation SDK for REST services, and anyone who wants to use vRA to manage their resources but wants the provisioning of a resource to fit in with their current processes.

Why vRealize Automation, Not vCloud Director (vCD)

VMware announced that vCloud Director will no longer be part of the license in the vCloud Suite 6.x generation. vCloud Director is at its end of life stage for enterprise customers. vCloud Director will continue to be available through the VMware Service Provider Program (VSPP) in the cloud bundle. vRealize Automation is the intended successor for those who currently use vCloud Director. vRealize Automation accelerates the deployment and management of applications and compute services.

Why REST API over SOAP

SOAP (simple object access protocol) and REST are both web service communications protocols. REST operates through a solitary, consistent interface to access named resources. It’s most commonly used when you’re exposing a public API over the internet. SOAP, on the other hand, exposes components of application logic as services rather than data.

  • REST allows a greater variety of data formats, whereas SOAP only allows XML.
  • Coupled with JSON (which typically works better with data and offers faster parsing), REST is generally considered easier to work with.
  • REST offers better support for browser clients because its output is in JSON format.
  • REST provides superior performance, particularly through caching for information that’s not altered and not dynamic.
  • It is the protocol used most often for major services such as Yahoo, eBay, Amazon, and even Google.
  • REST is generally faster and uses less bandwidth. It is also easier to integrate with existing websites with no need to refactor site infrastructure. This enables developers to work faster rather than spend time rewriting a site from scratch. Instead, they can simply add functionality.

Blueprints

A blueprint is the specification of a scenario that contains one or more physical, virtual, or cloud machines, including network configurations and the respective lifecycle information. In a typical software development process, users invoke REST API to provision a blueprint.

Figure 1. A typical simple blueprint.

vRealize Automation: REST API

The catalog service REST API is designed to be used by the consumers of the service catalog; for example, an end user who wants to request a catalog item would be a consumer of this API. When end users request catalog items, the catalog consumer REST API is called.

The techniques used under our development are intended for developers who want to manage vRealize Automation programmatically for provisioning VMs for software development. The procedures to request a catalog item using vRA REST API can be accomplished by the following five steps:

Step 1: Acquire an HTTP bearer token for authentication

  • URL: https://<vrafqdn>/identity/api/tokens
  • Type: Get
  • Type: Post
  • Headers: Content-type: application/json

Step 2: Get blueprint-id using blueprint name

  • URL: https://<vrafqdn>/catalog-service/api/consumer/entitledCatalogIt ems?$filter=name+eq+'name'
  • Type: Get
  • Headers:
    Content-type: application/json,
    Authorization: Bearer <token>,
    Accept: application/json

Step 3: Get the JSON template required to request the catalog item

  • URL: https://<vrafqdn>/catalog-service/api/consumer/entitledCatalogItems/{id}/requests/template
  • Type: Get
  • Headers:
    Content-type: application/json,
    Authorization: Bearer <token>,
    Accept: application/json

Step 4: Request catalog item

  • URL: https://<vrafqdn>/catalog-service/api/consumer entitledCatalogItems/{id}/requests
  • Type: Post
  • Body: json response received from request template (previous step)

Step 5: Check status of the request

  • URL: https://<vrafqdn/catalog-service/api/consumer/requests/{requestid}
  • Type: Get

Figure 2. Five steps to request and deploy a blue print.

REST Client Programs

Any client application that can send HTTPS requests is an appropriate tool for developing REST applications with the vRealize Automation API. Some of the open-source software commonly used is:

API References

The vRealize Automation API Reference lists all REST API service calls. It is provided as a Swagger document and is available in either of the following ways:

Cyber Range: A Real-Life Software of Analog Devices, Inc.

What Is Cyber Range?

The Analog Devices Cyber Range software provides customers with an extensible virtualized platform for cyber security training, modeling, simulation, and advanced analytics. We offer our solution to multiple customers, which include the U.S. Department of Defense, the Singapore Cyber Security Agency (CSA/SITSA), and the Kyushu University in Japan.

  • User clicks the Start button to provision a lab or challenge.
  • The Cyber Range software calls the corresponding vRA REST API.
  • REST API calls the corresponding vRA blueprint.
  • vRealize starts provisioning all the VMs that belong to the particular blueprint.
  • vRealize Orchestrator runs custom scripts (if any) during the life-cycle of the VMs.
  • REST API returns the status back to Cyber Range software.
  • If the status check is successful, it displays either a Windows or a Linux icon that enables a hyperlink to open the console.

Figure 3. Cyber Range interacts with vRA through the REST API.

Conclusion

vRealize acts as a repository for our exercise infrastructure in a more visual, user-friendly environment through the use of blueprints. This helps us to customize or add more content in a timely manner to satisfy user needs. Additionally, the vRealize Orchestrator integration into our solution leverages most of the code for provisioning by offering common automated tasks to be applied to the exercise virtual environment. Being oriented to JavaScript it helps us to manage any custom scripts inside the VMware solution and to be recycled for our different scenarios. Additionally, using vRA REST API to provision a blueprint, getting provisioning status, or destroying the blueprints reduces significant time during the software development process.