Let me apologize in advance if this has been answered but a quick search didn't help me. Also understand I am very new to this with almost zero training so this is probably a newbie question but the community seems very helpful and friendly so I'm reaching out for guidance and advise.
We will be implementing snapshot as a service to our customers. We want to allow only one snapshot per VM. Therefore I need to check if a snapshot exists before allowing the customer to take a new one. I have a simple workflow now to take a single virtual machine and snap it. I am using the built in remove old snapshots to check if a snapshot exists. We use service now as our portal. The hostname comes across as a string and I convert it to a vc:virtualmachine. What I need some help on is in the remove old snapshots I'm reusing the getPropertiesForAllSnapshotTask action element. I want to pass the single vm name and have it get the properties of the snapshot if it exists. As it is an auto generated script I am not able to modify the scripting of the action. Does anyone have a better way or idea on how I can pass a single vm object and know if it has a snap or not? I hope I've explained this well enough to get a discussion started and thanks.
Hi,
Checking if a virtual machine has at least one snapshot is easy. Here is some sample code (the input parameter is the variable vm of type VC:VirtualMachine😞
if (vm.snapshot != null) {
System.log("This VM has at least one snapshot");
} else {
System.log("This VM has no snapshots");
}
Are you using ServiceNow to request from vRA in this case?
Hi,
Checking if a virtual machine has at least one snapshot is easy. Here is some sample code (the input parameter is the variable vm of type VC:VirtualMachine😞
if (vm.snapshot != null) {
System.log("This VM has at least one snapshot");
} else {
System.log("This VM has no snapshots");
}
yes that would be correct. It will come from SNOW to vRA.
Thank you very much. I have some other tasks at the moment but I'll be sure to give this a try. Appreciate the quick responses from everyone.
SO easy. Thank you very much. Really appreciate the assist. I'll mark your answer as correct.