How to use Compute allocation & Network configure subscription to change the IP address and Rename of VM in VRA 8

As we talk about the automation in VM provisioning , One of the crucial step is to get the IP address from external source.

Recently I was working on used case where we want to provide the IP addresses at the time of submitting the provisioning.

There are multiple ways to do it in VRA and VRO . I am using VRA ABX Python action to achieve it.

Used Case: I want to submit more than one machine at time and provide the IP addresses at same time. For my example I am using 2 Machines here.

Subscription Used:

  • Compute Allocation
  • Network Configure

First Lets take a look at Blueprint’s Yaml where we define all custom properties.

formatVersion: 1
inputs:
  firstVM:
    type: string
    title: NewVMName1
  SecondVM:
    type: string
    title: NewVMName2
  VM1IP:
    type: string
    title: VM-1-IP
  VM2IP:
    title: VM-2-IP
    type: string
resources:
  vSphere_Machine:
    type: Cloud.Machine
    properties:
      firstVM: '${input.firstVM}'
      SecondVM: '${input.SecondVM}'
      VM1IP: '${input.VM1IP}'
      VM2IP: '${input.VM2IP}'
      abxaction: 'yes'
      count: 2
      image: VMwareCode-CentOS
      flavor: VMwareCode-small
      networks:
        - network: '${resource.vSphere_Network.id}'
          assignment: static
  vSphere_Network:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
      constraints:
        - tag: 'vsphere:network'

  • As we see above , I am using 4 Inputs as 2 VM names and 2 IP addresses in line 19-22
  • Line 23 we will use for condition in subscription
  • Also I am using static assignment in line 28-29
  • Line 35 is to Target the Network Profile where I have defined the Range

Once we are done with Blueprint, that is how it will look like when we click on Deploy

Since I am changing the name of VM and assigning the IP , I would need 2 ABX action
Below is the action is to change the VM Name as per Input


Below is the action Code in Python
def handler(context, inputs):
    firstVM = inputs['customProperties']['firstVM']
    secondVM = inputs['customProperties']['SecondVM']
    returnobj = inputs
    returnobj['resourceNames'][0] = firstVM
    returnobj['resourceNames'][1] = secondVM
    return returnobj

Here is the action for Assigning the IP addresses to correspond VMs.

Below is the python code for same
def handler(context, inputs):
    firstVMIP = inputs['customProperties']['VM1IP']
    SecondVMIP = inputs['customProperties']['VM2IP']
    outputs = {}
    addresses = [[]]
    outputs["addresses"] = addresses
    outputs["addresses"][0]=[str(firstVMIP)]
    outputs["addresses"].append([SecondVMIP])
    return outputs

If you have followed the article without missing any step, means you are done Python and Yaml code stuff.
Now all is left is Creation of the subscription If already not exist and Map to above created ABX python action.

To create the new Subscription follow below
Click on Cloud Assembly => Click Extensibility => Subscription = > Click New Subscription


Provide Name, enable Subscription and on Event Topic Choose Compute Allocation

If you noticed in YAML line number 23 I have specified the condition abxaction: yes

      abxaction: 'yes'

In subscription we are using that as condition to run and in action/workflow choose abx and above created action.


Click Save and we are done with Rename subscription.

Click New subscription once again and this time we will choose Network Configure subscription and network action , Rest all settings will be same.

so we have done all the coding and configuration , Now it is time to submit the VM provisioning request .

Once we submit this , You can check the outcome in action result or once vm allocation is done.


As we see the name as we submitted during provisioning, lets check the IP of each .


Both VMs got renamed and static IP which we entered has been applied to VMs.

Disclaimer: Indexing issue for multi Dimensional array has been fixed in 8.4.1, which was getting interchanged in 8.3 and 8.4

How to automate vm snapshot creation using csv and schedule automatic deletion of the snapshot using VRO 8

Snapshot is one of the great feature which we have in vSphere and which can be used like backup whenever we want to perform any change in Virtual Machine.

There are multiple ways to take the snapshot for VM using multiple products/Language.
We can use vSphere GUI or Rest APIs or pyvmomi or PowerCli .

Also as precaution when take snapshot , it is recommended to delete the snapshot after x amount of times unless we will end up in datastore full or High space utilization by vmdk .

And this is our topic of discussion of today where we automate the creation of snapshot and deletion using vro.
As we know PowerCli is great language to automate the stuff in vSphere and in VRO 8 it has been added as addtional language followed by Python.

I have used PowerCli for this workflow.

Also I have used Mime attachment as Input of CSV and Datagrid custom form element to display the existing snapshot in table.

Lets see the demo when we choose single VM from drop down

As we see once create snapshot is completed ,It will create schedule for deletion of the snapshot

For Single VM I am not checking for existing Snapshot , If you need you can take reference from multiple VM input where we are checking existing

Lets look into demo of Multiple VM’s snapshot ,where we are using CSV file as input , To process the CSV I am using Mime attachment

As you see in logs , If you specify the VM in CSV which is not in vCenter it will throw error in logs but It will not stop for other vms , If you need you can put stop on that also .

Here is the link for Package , which includes all actions and workflow related to this.

We can follow this Instruction to Import the Package

Once we are done with Import Package , Just changed the Variable value in VRO and enter your vCenter Name , UserID and Password

Here is my CSV file Sample, You do not need to have PowerState, Only thing is required is It should have name in heading

Disclaimer: We can not use this workflow as XAAS as Mime attachment is currently not supported in Service Broker for VRA8.4 .