Hi All,
I'm trying to create a workflow that would take a snapshot and remove the snapshot (not all snapshots) after x amount of min, hours or days. So far I copy the "Create a Snapshot" workflow and add a Scriptable task for the wait time to remove the snapshot but I cannot figure it out how to remove only one snapshot instead of all. Scriptable task for the time works fine. In the create snapshot process you have to give name and description to snapshot so I'm wondering if removing snapshot can be bind with them.
Thank you,
Yes, you have to create a new action item. Here are the steps:
if (snapshot == null) {
throw "ReferenceError: snapshot cannot be null"
}
return snapshot.removeSnapshot_Task(false);
That's it. The new action is created and you should be able to use it in your workflow.
Hi,
'Create a snapshot' workflow has an output parameter snapshot (of type VC:VirtualMachineSnapshot) containing the created snapshot object. And the snapshot scripting type has a method removeSnapshot_Task() which you can use to remove the snapshot, using a code like:
snapshot.removeSnapshot_Task(false);
One small issue is that the output parameter snapshot cannot be accessed directly as an input in your scriptable task, but you can fix this by moving the snapshot output parameter as attribute.
I'm not sure where should I add the code? should a add another Scriptable task after the "Time to Wait" task?
Hi
Find the below ,more details related to snapshot workflow.it will easy to understand.
www.vmwarebits.com/content/vcenter-orchestrator-workflows-create-and-delete-snapshots-folder-vms
Thanks
Yes I saw this one too but this workflow removes all the snapshot on the virtual machine. I would like to remove the snapshot I take with the workflow. For example if I have snapshot1, and snapshot2 on the machine already and I'm running this workflow to create a new snapshot named snapshot3 and schedule to remove it in 48 hours. After 48 hours only snapshot3 should be deleted not all of them.
Thank you,
Yes, it could be another Scriptable task after the "Time to Wait" task. Or you can create a new action removeSnapshot, put the code inside it, and use it the same way as you do with the createSnapshot action.
Also note that snapshot.removeSnapshot_Task(false); call returns a VC:Task object so you may want to wait for it to complete the same way you wait for createSnapshot using vim3WaitTaskEnd action.
When I add an Action element and search "Remove", only remove actions related to snapshot is "removeallsnapshot" or "removeOldestSnapshot" I don't see just remove snapshot. Do I have to create a new action item? if so can you please walk me through the creation and what I need to be added in it.
Thank you,
Haluk
Yes, you have to create a new action item. Here are the steps:
if (snapshot == null) {
throw "ReferenceError: snapshot cannot be null"
}
return snapshot.removeSnapshot_Task(false);
That's it. The new action is created and you should be able to use it in your workflow.
Ilian, thank you for fast respond.
I create the action element and added to me workflow.
When I run the workflow it give me the error message below.
Here is removeSnapshot action element looks like in the workflow
Looks like I have to bind the Snapshot in to something but only option is NULL or Create parameter/attribute in workflow.
Hi,
You need to bind a snapshot parameter to the "remove snapshot" action. If you look in the existing workflow " Library / vCenter / Virtual Machine management / Snapshot / Create a snapshot", you would find the "vim3WaitTaskEnd" has an Output to an "Out parameter".
Transfert this "Out parameter" to an attribute and use it as an Input in your "removesnapshot" action.