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.
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>firstname.lastname@example.org</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@example.com</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.
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.
- 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.
- The name of the project.
- The location on the file system where you want to place it.
Having a fresh new project, we are now ready to code!
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.
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.
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.
2 comments have been added so far
Thank you for this! This is really exciting.