A snapshot is reproduction of the virtual machine just as it was when you took the snapshot. The snapshot includes the state of the data on all virtual machine disks and the virtual machine power state (on, off, or suspended). You can take a snapshot when a virtual machine is powered on, powered off, or suspended.
The VirtualMachine object has methods for creating snapshots, reverting to any snapshot in the tree, and removing snapshots.
Snapshot hierarchies can become fairly complex. For example, assume that, in the example in Virtual Machine Snapshots, you revert to
snapshot_a. You might then work with and make changes to the
snapshot_a virtual machine, and create a new snapshot, creating, in effect, a branching tree.
The VirtualMachine.CreateSnapshot_Task method creates a new snapshot of a virtual machine. As a side effect, the current snapshot becomes the parent of the new snapshot.
The VMSnapshot.java example calls this method as follows:
The method returns MOR to a Task object with which to monitor the operation. The
info.result property in the
Task contains the newly created
VirtualMachineSnapshot upon success.
When you revert to a snapshot, you restore a virtual machine to the state it was in when the snapshot was taken. The
VirtualMachine.RevertToSnapshot_Task allows you to specify a target host and whether the virtual machine should be powered on.
You can delete all snapshots by calling VirtualMachine.RemoveAllSnapshots or by calling the
VirtualMachineSnapshot.RemoveSnapshot_Task method. The
VirtualMachineSnapshot object was previously returned in the task returned by the
CreateSnapshot_Task method.