Aegis ‘Depot’ Activity – Hyper-V Integration Part 2 - Snapshots!

Aegis ‘Depot’ Activity – Hyper-V Integration Part 2 - Snapshots!

Welcome to Part 2 of Hyper-V Integration Activities for NetIQ Aegis.   This is a 4 part cool tool Activity Library which will introduce and extend the functionality with new activities in each part bringing the power of Aegis Automation to Hyper-V environments.

In Part 1 (here) I provided Aegis Activities to Find, View Details and Modify the Power State of Hyper-V Virtual Machines.  Part 2 focuses on Virtual Machine Snapshots.


Take Snapshot

The first activity in the snapshots section is the simple 'Take Snapshot' activity.  All you need do is specify the connection information and the correct Virtual Machine using its Instance ID (see part 1), and the activity will (barring any errors) create a snapshot of the Virtual Machine.


At run-time there are 2 outputs - 'Result' which is a True/False success indicator and 'Failure Reason' is additional information if the operation fails for some reason like in the following example where a hostname was incorrectly specified at input:



What you may notice however is that the completed state of the activity is a success.  Which brings be to Hyper-V Activities Top Tip #1


Hyper-V Activities Top Tip #1 

When an Activity is designed, the designer has to decide what works best for a workflow when an error occurs.  There are two main options:

1. End the workflow in a failed state - This error can be handled by an error handling activity.

2. End the workflow in a success state - One output will indicate an error and another possibly more details on the error.

The Hyper-V activities use both.

Where there is a connection error to the Hyper-V server for any reason including host unreachable and bad credentials etc. an error is thrown which needs to be handled by an error handler. If however after the connection is made an operation error occurs where a Boolean Success/Fail output exists this will allow the activity to succeed but indicate an error.

For the workflow designer this can cut down on the number of error handling activities required, but also pushes the designer towards handling Failure situations which are often ignored or handled in a passive way, although its also possible of course to ignore the Success/Fail output.


Apply Snapshot

The apply snapshot Activity allows you to apply an existing snapshot of the Virtual Machine in order to revert the Virtual Machine to a previous point in time. The first option is to revert to the last snapshot taken (the default) - this is the easiest option from a workflow point of view but it might not always be what you want to do.  The second option is to select a previous snapshot for the virtual machine.  To do this first we need to find the snapshots associated with the Virtual Machine.


List Snapshots

The List Snapshots activity lists snapshots including some details on each snapshot for a Virtual Machine.  Its configured like most of the other activities, you only need specify the Virtual Instance ID of the VM plus the connection details to hyper-V.  At run-time the output is as follows:


The 'Result Array' produces a list of Element Names - the element name identifies a snapshot for the machine to be used as input to the apply and delete snapshot activities.  The snapshots are listed in date order, oldest first.

The 'Results Table' contains more information to help identify individual snapshots including full path of parent snapshot, snapshot creation time and any notes which were on the VM at time of snapshot.  The table is listed in the same order as the 'Result Array' output.

So now we can look again at the Apply Snapshot activity ...


Here I am now able to specify which snapshot I want to apply if I don't want to go with the default value.


Delete Snapshot

The Delete snapshot activity is configured exactly the same as the Apply snapshot - removing the last snapshot is the default action or you can specify which snapshot to delete.  Again the output is a Success/Failure boolean and an error message value if any.


Hyper-V Activity Use Cases:

From the activities we have from Parts 1 and 2, we can easily create a workflow to keep snapshots up to date and also to delete older snapshots older than a certain date for example.

a) Scheduled Snapshot and Auto-Maintenance

A simple workflow to achieve this could do the following:

1. Trigger workflow on a defined schedule

2. Find all machines in Hyper-V

3. Loop through the list of computers

4. For each machine, take a new snapshot.

5. For each machine, list snapshots.

6. For each machine, delete the oldest X snapshots or keep Y number of snapshots.

7. Send workflow report to Admin and end.


b) Detect Machines with too many snapshots and approve deletion

A simple workflow to achieve this could do the following:


1. Trigger workflow on a defined schedule

2. Find all machines in Hyper-V

3. Loop through the list of computers

4. For each machine check if number of snapshots exceeds maximum allowed.

5. For each machine exceeding limit request approval to delete excess snapshots.  This could be done with an input form displaying the table of snapshots with a b for each snapshot entry to delete or not.

6. Check the output of the input form and delete any snapshots which were approved for deletion.

7. Send workflow report to Admin and end.


This is what an input form to do this might look like at run-time:




So there you go – watch out for Part 3 where I’ll be adding on activities to work with Importing, Exporting, Renaming and Deleting Virtual Machines!


Activity Installation Instructions are here:

Please note this activity library extends the previous set from part 1 so you need to choose to overwrite the existing dlls and other files.
Labels (1)


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
10 of 10
Last update:
‎2020-01-09 16:44
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.