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.
- A snapshot can be removed only while the associated virtual machine is
powered off or suspended.
- The Server 1.0 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.
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
result = 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 = result(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 = result(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()
Copyright (C) 2007 VMware, Inc. All rights reserved.