Example #1
0
func (s *StepMountDvdDrive) Cleanup(state multistep.StateBag) {
	if s.path == "" {
		return
	}

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

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

	ui.Say("Unmounting dvd drive...")

	err := hyperv.UnmountDvdDrive(vmName)
	if err != nil {
		ui.Error(fmt.Sprintf(errorMsg, err))
	}
}
Example #2
0
func (s *StepUnmountDvdDrive) Run(state multistep.StateBag) multistep.StepAction {
	//driver := state.Get("driver").(Driver)
	ui := state.Get("ui").(packer.Ui)

	vmName := state.Get("vmName").(string)

	ui.Say("Unmounting dvd drive...")

	err := hyperv.UnmountDvdDrive(vmName)
	if err != nil {
		err := fmt.Errorf("Error unmounting dvd drive: %s", err)
		state.Put("error", err)
		ui.Error(err.Error())
		return multistep.ActionHalt
	}

	return multistep.ActionContinue
}