Hi All,
I have been trying to learn developingworkflows using vRO.
to start with i thought of creating workflow of taking snapshot of vm using vRO.
i have duplicated the default workflow of creating snapshot and wants to add another decision element "if there is already a snapshot workflow should end ".
what needs to be edited in decision element so that i meet the requirement of stopping workflow if there is already a snapshot?
any help is highly appriciated.
Hi,
Add the following scripting code in your custom decision element:
var snapshots = System.getModule("com.vmware.library.vc.vm.snapshot").getAllSnapshotsOfVM(vm) ;
if (snapshots == null || snapshots.length == 0) {
// No snapshots found; proceed with creating a new one
return true;
} else {
// Found at least one snapshot; end the workflow
return false;
}
So, if there are no snapshots found for this VM, the code will return true, and the workflow execution will continue with green arrow path, thus creating a new snapshot.
Otherwise, if there are snapshots found for this VM, the code will return false, and the workflow execution will continue with red arrow path, thus ending the execution.
Hi,
Add the following scripting code in your custom decision element:
var snapshots = System.getModule("com.vmware.library.vc.vm.snapshot").getAllSnapshotsOfVM(vm) ;
if (snapshots == null || snapshots.length == 0) {
// No snapshots found; proceed with creating a new one
return true;
} else {
// Found at least one snapshot; end the workflow
return false;
}
So, if there are no snapshots found for this VM, the code will return true, and the workflow execution will continue with green arrow path, thus creating a new snapshot.
Otherwise, if there are snapshots found for this VM, the code will return false, and the workflow execution will continue with red arrow path, thus ending the execution.
Thank you very much Ilian that worked.