vRealize GETTING STARTED vRealize Orchestrator

Developing vRealize content with Visual Studio Code

The source code editor is a fundamental part of every software engineer’s life. Whether you are new to the field, or a black-belt ninja, you need the right one to do your magic. A good code editor makes you more efficient at writing code and assists you in examining and editing it. Also, it provides enough customization options to create a comfortable experience, which should not be underestimated as we often spend multiple hours every day working with code.

Dozens of options are available – from cultural picks like Vim and Emacs, to full-blown IDEs like IntelliJ IDEA and Eclipse. While they are all incredible editors, none of them are currently capable of working with vRealize content. On the other hand, we already have awesome visual editors of such content – vRealize Automation (vRA) and vRealize Orchestrator (vRO). However, as a friend of mine once said – developing infrastructure automation at scale is hard, and it requires diving into the world of software development while using different processes and tools.

In this post, I will showcase some features of the vRO extension for Visual Studio Code that we created to enable a more developer-friendly experience when creating vRO and vRA content.

Out of the box, Visual Studio Code already provides powerful JavaScript editing, navigation and refactoring features, built-in Git support and thousands of extensions to enrich your development workflow (some of my personal favorites are Beautify, GitLens, Settings Sync and Docker). In addition, the vRO extension adds vRO-aware autocomplete, support for moving content between your local machine and a vRA/vRO instance, automated project on-boarding and more.

Getting started

The first step is to configure an endpoint to your development environment in order to enable some features and to collect vRO Scripting API symbols and documentation (used to power the code intelligence features of the extension). The configuration is in the form of Maven profile specified in your global settings.xml file (usually located at ~/.m2/settings.xml). Note the passwords are specified in cleartext since the profile is on the local machine and is targeting a dedicated development environment. If hiding the passwords from snooping eyes is important, there is a way to encrypt the credentials.

<profile>
    <id>iac-demo</id>
    <properties>
        <!--vRO Connection-->
        <vro.host>10.27.120.27</vro.host>
        <vro.port>443</vro.port>
        <vro.username>[email protected]</vro.username>
        <vro.password>myPlainTextPass</vro.password>
        <vro.auth>basic</vro.auth>
        <!-- vRA Connection -->
        <vra.host>10.27.120.27</vra.host>
        <vra.port>443</vra.port>
        <vra.username>[email protected]</vra.username>
        <vra.password>myPlainTextPass</vra.password>
        <vra.tenant>vsphere.local</vra.tenant>
    </properties>
</profile>

Once created, the profile can be selected from the command palette in Visual Studio Code.

vro environment profile

The beginning of a solution…

A typical automation solution that we develop for our customers involves vRA infrastructure blueprints and forms on one hand, and the automation logic as functions and classes on the other hand. A thin layer of vRO workflows is usually used as a bridge between them. Boot strapping a new project with such content only takes a minute. All you need to specify is the following.

  1. The type of project you need. We have four types of projects, each with different use-case in mind.
    • The JS-based is great for reusing code between different solutions in the form of libraries.
    • The XML-based – for bundling workflows, configurations and resources.
    • The YAML-based – for your infrastructure blueprints, software components and other vRA content.
    • And the Mixed projects that combine the above three into one master solution project.
  2. The name of the project.
  3. The location on the file system where you want to place it.

vro project wizard

Having a fresh new project, we are now ready to code!

vRO-aware IntelliSense

IntelliSense is a term in Visual Studio Code that combines a set of code editin1vo lig features – code completion, parameter info and quick info. For JavaScript files, these features are enhanced with symbols and information from the vRO’s core scripting API, plug-in objects and actions. We can even go further and have a code completion on steroids by using a typed version of JavaScript – TypeScript. You can read more on that topic in the vRO development with TypeScript blog post.

vro autocomplete

vRA/vRO content flow

Once you are happy with your code, from the tasks palette, you can push it to the live vRO instance to test it out. Any workflows, configurations and resources created in the vRO client, or composite/XaaS blueprints, property groups and other vRA content, can also be pulled back to your local machine – in a form suitable for committing into source control.

vro push/pull

And if you want to quickly check out the code of an action that is not part of your solution project, you can fetch it from the live vRO environment using the Open Action command. Keep in mind that the action source is presented as read-only, as you can open any action from vRO and we do not want to make changes to code outside our solution. Instead, it is best practice to adjust such actions in their repository and go through the full review cycle.

open vro action source

Conclusion

When using vRA and vRO as a platform, having a code editor that understands our content and enhances our daily work flow contributes to a more productive and enjoyable development experience.

The vRO extension for Visual Studio Code is a component of a toolchain delivered as part of a service by VMware Professional Services Center of Excellence. If you are interested to know more please contact VMware Professional Services sales representative.