Provisioning Virtual Machines Using vRealize Automation REST API for Software Development

October 29, 2018

Story

Provisioning Virtual Machines Using vRealize Automation REST API for Software Development

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.

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 and 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 also provides step-by-step instructions 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.

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 typical simple blueprint.

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.

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:

Five steps to request and deploy a blueprint.

Step 1: Acquire an HTTP bearer token for authentication

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

Step 2: Get blueprint-id using blueprint name

  • URL: https:///catalog-service/api/consumer/entitledCatalogItems?$filter=name+eq+'name'
  • Type: Get
  • Headers:

Content-type: application/json,

Authorization: Bearer ,

Accept: application/json

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

  • URL: https:///catalog-service/api/consumer/entitledCatalogItems/{id}/requests/template
  • Type: Get
  • Headers:

Content-type: application/json,

Authorization: Bearer ,

Accept: application/json

Step 4: Request catalog item

  • URL: https:///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://
  • Type: Get
Cyber Range interacts with vRA through the REST API.

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:

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.

About the Author

Moinul Islam is a software engineer at the Trusted Security Solutions (TSS) Group of Analog Devices in Tampa, Florida. He has 20 years of experience in software engineering, design, and development. He received his M.S. in computer and information science (MCIS) from Cleveland State University, Ohio in 1997. As part of the Trusted Security Solutions Group in Tampa, he focuses on the design and development of a unique software solution with convenient and continuous access to realistic, hands-on cyber security training scenarios coupled with foundational training. He can be reached at [email protected].

Categories
Software & OS