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.
Either you can use the admin account or Service Account which has admin rights
Once we create action lets jump to custom form and Map the above created action .
In default value section I have given one of the cluster name and Value source I have set as External Source. Since we have chosen string of array in vro and drop down in custom form , when you search for action name you will see it will reflect there
Note: com.vmwarecode/ is my Package name where I have saved all my actions, It will be different for you.
Now next task is chosen the Network Port Group based on Cluster name.
Lets have a look how does network portgroup looks like in Custom form
As you see in above screenshot , for NetworkPortGroup field the drop down is coming and those values are based on Cluster which we chose in last above step.