2015-06-21 07:36:07 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2015-06-21 07:36:07 -04:00
|
|
|
"fmt"
|
2018-01-22 18:32:33 -05:00
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2015-06-21 07:36:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepUnmountFloppyDrive struct {
|
2015-07-14 02:51:03 -04:00
|
|
|
Generation uint
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (s *StepUnmountFloppyDrive) Run(ctx context.Context, 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)...")
|
2016-11-06 11:02:00 -05:00
|
|
|
|
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
|
|
|
|
}
|