github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/builder/hyperv/common/step_unmount_floppydrive.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 ) 8 9 type StepUnmountFloppyDrive struct { 10 Generation uint 11 } 12 13 func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction { 14 driver := state.Get("driver").(Driver) 15 ui := state.Get("ui").(packer.Ui) 16 17 if s.Generation > 1 { 18 return multistep.ActionContinue 19 } 20 21 vmName := state.Get("vmName").(string) 22 ui.Say("Unmount/delete floppy drive (Run)...") 23 24 errorMsg := "Error Unmounting floppy drive: %s" 25 26 err := driver.UnmountFloppyDrive(vmName) 27 if err != nil { 28 err := fmt.Errorf(errorMsg, err) 29 state.Put("error", err) 30 ui.Error(err.Error()) 31 } 32 33 return multistep.ActionContinue 34 } 35 36 func (s *StepUnmountFloppyDrive) Cleanup(state multistep.StateBag) { 37 // do nothing 38 }