Aegis Automation Workflows in 5 Minutes - Detect and Notify on vCenter Orphaned Virtual Disks

Aegis Automation Workflows in 5 Minutes - Detect and Notify on vCenter Orphaned Virtual Disks

The "Aegis Automation Workflows in 5 Minutes" cool-tool blog series shows examples of Aegis workflows which deliver value in as little as 5 minutes development time - all using out of the box activities! Aegis workflows can be forever evolving, and while these workflows fulfill a purpose, you may for example want to extend a workflow from being a simple notification workflow to one which goes further to remediate a problem.

Orphaned Disks in VMWare vCenter are disk files on Datastores which are no longer associated with a Virtual Machine, therefore probably wasting disk space which over time can lead to disk space issues. However datastores may be being used to stored backups of disks, snapshot files or disks not currently connected, so automatically deleting all detected orphaned disks is not a good idea without a sanity check. This 5 minute workflow uses the vCenter Adapter for Aegis, first to find all Datastores in connected vCenter instances and then to find orphaned disk on each detected datastore. Finally the workflow sends the detected list to an administrator for action.

So this is what the workflow looks like...

workflow

 

I use the 'Find Objects' activity to find objects of type : VMWare/vCenter/Datacenter Folder/DataCenter/Datastore I didn't apply any filters to exclude particular datastores / vCenter instances etc. but you can add these in the activity filters. This activity outputs an array of, which we loop through with the 'For Each' activity so that each datastore can be handled individually.

The 'List VMDK Files' activity just takes the output of the 'For Each Loop', and specifies to only find orphaned disks. The output is the orphaned file list in the form of an array.

Next I convert the orphaned file result array into a string with a newline separator for nice easy visualization. This result is then appended to a Workitem Attribute (Variable) ... then work on the next VMDK file.

When the loop completes processing each orphaned file, Use the 'Send Email' activity to send the results to an administrator for analysis, and you are done ... hopefully in 5 minutes!

 

email

(actual results from our lab - its a pretty long mail!)

 

The workflow is attached if you want to compare results. There are two workitem attributes which need updating, the email_FromAddress and email_ToAddress which are used by the send mail activity, everything else is generic. The workflow requires Aegis 3.2 and the vCenter Adapter 1.1 for Aegis.

 

Next Steps - yes you've guessed it, there are loads of possibilities to extend this workflow! Here are some examples...


  1. A must - add some error handling and notification! If there are any failures (for example is vCenter is unreachable) the workflow will silently fail apart from an error in console.

  2. Add a scheduled trigger, so the workflow runs automatically on a schedule of your choosing.

  3. Add an input form - Have the administrator go to an input form so that they can select which files to delete - then use 'Delete Virtual Machine from Disk' activity to delete the selected files.

  4. Extend the input form - Add an option to permanently ignore an orphaned file so its no longer presented on the input form.

  5. Add extra logic - what if no orphaned files are found?



Think about how you'd extend the workflow!
Attachments

DISCLAIMER:

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 #:
1 of 1
Last update:
‎2014-08-26 00:35
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.