Add Notes in vSphere Vm - Aria Automation

Intro

To add notes to the VM in vSphere by inserting them during the deployment request in Aria Automation, we can create an Aria Orchestrator Workflow that will allow us to modify the VM post-deploy.

This Workflow will then be activated using the Extensibility Subscriptions of Automation, triggered by Compute Post Provisioning.

Blueprint preparation

Let's proceed by modifying our Blueprint so it accepts input notes with a field of type String.

Here is an example of the code for the Notes section:

 1formatVersion: 1
 2inputs:
 3  Name:
 4    type: string
 5    title: Name
 6  Notes:
 7    type: string
 8    title: Notes
 9  Image:
10    type: string
11    title: Image
12    oneOf:
13      - title: WIN-2019-TEMPLATE
14        const: WIN-2019-TEMPLATE
15    default: WIN-2019-TEMPLATE
16resources:
17  Cloud_vSphere_Machine_1:
18    type: Cloud.vSphere.Machine
19    properties:
20      name: ${input.Name}
21      image: ${input.Image}
22      flavor: small
23      VMnotes: ${input.Notes}

In this way, the deployment will have the value VMnotes as CustomProperties.

Orchestrator Workflow

Let's now prepare the Workflow, which will primarily consist of 2 JavaScript scripts and a Workflow Element.

As variables, we have:

Variables

And as Input/Output, we have:

Inputs

Now let's move to the schema of the Workflow

Workflow Scheme

The code for the 'Get properties' script is as follows:

1var resourceName = inputProperties.get("resourceNames");
2var newnote = inputProperties.get('customProperties').get('VMnotes');
3
4System.log("VM Name: " + resourceName[0]);
5
6VMresourceName = resourceName[0];
7VMnewNote = newnote;

And this is the configuration of the script element:

Get Properties

The configuration of the Workflow Element "Get virtual machines by name" is as follows:

Get virtual machines by name

While this is the code and configuration for the 'Add Notes' script:

 1var vm = vmObject[0];
 2var newNotes = VMnewNote;
 3var task;
 4
 5try {
 6    var vmConfigSpec = new VcVirtualMachineConfigSpec();
 7    vmConfigSpec.annotation = newNotes;
 8    task = vm.reconfigVM_Task(vmConfigSpec);
 9}
10catch (ex) {
11    System.error("Error updating VM notes: " + ex);
12}

Add notes

This is everything needed for the Workflow! Now we should use an Extensibility Subscription to execute it every time a VM is deployed.

Extensibility Subscription

I won’t go into much detail about the Subscription, just keep in mind that the configuration will be similar to this

Subscription
Subscription

Execution post deploy

Let's see the result of the Workflow execution triggered by our Subscription.

VRA Deploy Input Mask
VRA Deploy

And this is the execution result!

Result

comments powered by Disqus