jvm2016
Hot Shot
Hot Shot

creating snapshot of vm using vRO.

Jump to solution

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 ".

pastedImage_0.png

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.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

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.

View solution in original post

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

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.

View solution in original post

0 Kudos
jvm2016
Hot Shot
Hot Shot

Thank you very much Ilian  that worked.

0 Kudos