Name
RemoveSnapshot
Description
This function deletes all saved states for the specified snapshot.
Parameters
- snapshot
-
An ISnapshot object representing the snapshot to remove. A virtual machine's snapshots
can be accessed through VM::GetRootSnapshot()
- options
-
Flags to specify optional behavior. Any combination of the following
or 0:
- VIX_SNAPSHOT_REMOVE_CHILDREN - Remove snapshots that are children
of the given snapshot.
- jobDoneCallback
-
An ICallback instance that will be called when the
operation is complete.
- removeJob
-
Returns an IJob object that describes the state of this asynchronous operation.
Return Value
HRESULT
Remarks
- This function deletes all saved states for the specified snapshot. If the
snapshot was based on another snapshot, the base snapshot becomes the new
root snapshot.
- The VMware Server release of the VIX API can manage only a single snapshot for
each virtual machine. A virtual machine imported from another VMware product
can have more than one snapshot at the time it is imported. In that case,
you can delete only a snapshot subsequently added using the VIX API.
- Starting in VMware Workstation 6.5, snapshot operations are allowed on
virtual machines that are part of a team. Previously, this operation failed
with error code VIX_PROPERTY_VM_IN_VMTEAM. Team members snapshot independently
so they can have different and inconsistent snapshot states.
Side Effects
None.
Requirements
VixCOM.h, since VMware Workstation 6.0
Example
This example deletes every root snapshot belonging to a virtual machine.
Dim lib
Dim host
Dim vm
Dim job
Dim err
Dim results
results = Nothing
Set lib = CreateObject("VixCOM.VixLib")
Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, Empty, 0, Empty, Empty, 0, Nothing, Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
' Handle error...
End If
Set host = results(0)
Set job = host.OpenVM("c:\Virtual Machines\vm1\win2000.vmx", Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
' Handle error...
End If
Set vm = results(0)
Dim numSnapshots
err = vm.GetNumRootSnapshots(numSnapshots)
If lib.ErrorIndicatesFailure(err) Then
' Handle error...
End If
Dim snapshot
For i=0 to numSnapshots-1
err = vm.GetRootSnapshot(i, snapshot)
If lib.ErrorIndicatesFailure(err) Then
' Handle error...
End If
Set job = vm.RemoveSnapshot(snapshot, 0, Nothing)
err = job.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
' Handle error...
End If
Next
host.Disconnect()