Fix 8904 (#9435)
This commit is contained in:
parent
ca067475fd
commit
88c94cc987
|
@ -325,7 +325,7 @@ func (d *VBox42Driver) LoadSnapshots(vmName string) (*VBoxSnapshot, error) {
|
|||
var rootNode *VBoxSnapshot
|
||||
stdoutString, err := d.VBoxManageWithOutput("snapshot", vmName, "list", "--machinereadable")
|
||||
if stdoutString == "This machine does not have any snapshots" {
|
||||
return rootNode, fmt.Errorf("VM %s does not have any snapshots.", vmName)
|
||||
return rootNode, nil
|
||||
}
|
||||
if nil != err {
|
||||
return nil, err
|
||||
|
|
|
@ -40,18 +40,22 @@ func (s *StepCreateSnapshot) Run(_ context.Context, state multistep.StateBag) mu
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
currentSnapshot := snapshotTree.GetCurrentSnapshot()
|
||||
targetSnapshot := currentSnapshot.GetChildWithName(s.TargetSnapshot)
|
||||
if nil != targetSnapshot {
|
||||
log.Printf("Deleting existing target snapshot %s", s.TargetSnapshot)
|
||||
err = driver.DeleteSnapshot(s.Name, targetSnapshot)
|
||||
if nil != err {
|
||||
err = fmt.Errorf("Unable to delete snapshot %s from VM %s: %s", s.TargetSnapshot, s.Name, err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
// Remove any snapshot with the target's name, if present.
|
||||
if snapshotTree != nil {
|
||||
currentSnapshot := snapshotTree.GetCurrentSnapshot()
|
||||
targetSnapshot := currentSnapshot.GetChildWithName(s.TargetSnapshot)
|
||||
if nil != targetSnapshot {
|
||||
log.Printf("Deleting existing target snapshot %s", s.TargetSnapshot)
|
||||
err = driver.DeleteSnapshot(s.Name, targetSnapshot)
|
||||
if nil != err {
|
||||
err = fmt.Errorf("Unable to delete snapshot %s from VM %s: %s", s.TargetSnapshot, s.Name, err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = driver.CreateSnapshot(s.Name, s.TargetSnapshot)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error creating snaphot VM: %s", err)
|
||||
|
|
Loading…
Reference in New Issue