func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction {
	//driver := state.Get("driver").(Driver)
	ui := state.Get("ui").(packer.Ui)

	if s.Generation > 1 {
		return multistep.ActionContinue
	}

	errorMsg := "Error Unmounting floppy drive: %s"
	vmName := state.Get("vmName").(string)

	ui.Say("Unmounting floppy drive (Run)...")

	err := hyperv.UnmountFloppyDrive(vmName)
	if err != nil {
		err := fmt.Errorf(errorMsg, err)
		state.Put("error", err)
		ui.Error(err.Error())
	}

	return multistep.ActionContinue
}
Example #2
0
func (s *StepMountFloppydrive) Cleanup(state multistep.StateBag) {
	if s.floppyPath == "" {
		return
	}

	errorMsg := "Error unmounting floppy drive: %s"

	vmName := state.Get("vmName").(string)
	ui := state.Get("ui").(packer.Ui)

	ui.Say("Unmounting floppy drive (cleanup)...")

	err := hyperv.UnmountFloppyDrive(vmName)
	if err != nil {
		ui.Error(fmt.Sprintf(errorMsg, err))
	}

	err = os.Remove(s.floppyPath)

	if err != nil {
		ui.Error(fmt.Sprintf(errorMsg, err))
	}
}