2015-06-21 12:36:07 +01:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 15:32:33 -08:00
|
|
|
"context"
|
2015-06-21 12:36:07 +01:00
|
|
|
"fmt"
|
2018-01-22 15:32:33 -08:00
|
|
|
|
2018-01-19 16:18:44 -08:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 13:39:01 -07:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2015-06-21 12:36:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepUnmountFloppyDrive struct {
|
2015-07-14 07:51:03 +01:00
|
|
|
Generation uint
|
2015-06-21 12:36:07 +01:00
|
|
|
}
|
|
|
|
|
2019-03-29 16:50:02 +01:00
|
|
|
func (s *StepUnmountFloppyDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2015-10-30 08:23:30 +00:00
|
|
|
driver := state.Get("driver").(Driver)
|
2015-06-21 12:36:07 +01:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2015-07-14 07:51:03 +01:00
|
|
|
if s.Generation > 1 {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2015-06-21 12:36:07 +01:00
|
|
|
vmName := state.Get("vmName").(string)
|
2015-11-01 16:00:56 +00:00
|
|
|
ui.Say("Unmount/delete floppy drive (Run)...")
|
2016-11-06 16:02:00 +00:00
|
|
|
|
2015-10-30 17:19:25 +00:00
|
|
|
errorMsg := "Error Unmounting floppy drive: %s"
|
2015-06-21 12:36:07 +01:00
|
|
|
|
2015-10-30 08:23:30 +00:00
|
|
|
err := driver.UnmountFloppyDrive(vmName)
|
2015-06-21 12:36:07 +01: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
|
|
|
|
}
|