2015-06-21 07:36:07 -04:00
|
|
|
// Copyright (c) Microsoft Open Technologies, Inc.
|
|
|
|
// All Rights Reserved.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
// See License.txt in the project root for license information.
|
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
)
|
|
|
|
|
|
|
|
type StepUnmountFloppyDrive struct {
|
2015-07-14 02:51:03 -04:00
|
|
|
Generation uint
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction {
|
2015-10-30 04:23:30 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
2015-06-21 07:36:07 -04:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2015-07-14 02:51:03 -04:00
|
|
|
if s.Generation > 1 {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2015-06-21 07:36:07 -04:00
|
|
|
vmName := state.Get("vmName").(string)
|
2015-11-01 11:00:56 -05:00
|
|
|
ui.Say("Unmount/delete floppy drive (Run)...")
|
2015-10-30 13:19:25 -04:00
|
|
|
|
|
|
|
errorMsg := "Error Unmounting floppy drive: %s"
|
2015-06-21 07:36:07 -04:00
|
|
|
|
2015-10-30 04:23:30 -04:00
|
|
|
err := driver.UnmountFloppyDrive(vmName)
|
2015-06-21 07:36:07 -04:00
|
|
|
if err != nil {
|
|
|
|
err := fmt.Errorf(errorMsg, err)
|
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepUnmountFloppyDrive) Cleanup(state multistep.StateBag) {
|
|
|
|
// do nothing
|
|
|
|
}
|