vRealize Orchestrator, VMs that Need Consolidation

I was creating a workflow that could find VM's that need consolidation and the consolidate them.

I did not find any actions or workflow for this so i created one, with this script:

System.log("Removing Consolidated Needed snapshots");

for each (var vcenter in vcenters) {
	var vms = vcenter.getAllVirtualMachines();
	for each (var vm in vms) {
		if(vm.runtime.connectionState.value=="connected" && !vm.config.template) {
			if(vm.runtime.ConsolidationNeeded) {
				System.log("Consolidate VM Name: " + vm.name);
				var task = vm.consolidateVMDisks_Task(true);
				var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task);
			}
		}
	}
}

This is just a sample workflow, you can modify for your own usage, test before using it.

Download: Finds-VM-that-Needs-Consolidation-and-Consolidate-them.zip

 

 

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.