diff --git a/builder/parallels/common/step_attach_floppy.go b/builder/parallels/common/step_attach_floppy.go index 83814f17c..efc4088fb 100644 --- a/builder/parallels/common/step_attach_floppy.go +++ b/builder/parallels/common/step_attach_floppy.go @@ -33,15 +33,25 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) + ui.Say("Deleting any current floppy disk...") + // Delete the floppy disk controller + del_command := []string{ + "set", vmName, + "--device-del", "fdd0", + } + if err := driver.Prlctl(del_command...); err != nil { + state.Put("error", fmt.Errorf("Error deleting floppy: %s", err)) + } ui.Say("Attaching floppy disk...") // Create the floppy disk controller - command := []string{ + add_command := []string{ "set", vmName, "--device-add", "fdd", "--image", floppyPath, + "--connect", } - if err := driver.Prlctl(command...); err != nil { + if err := driver.Prlctl(add_command...); err != nil { state.Put("error", fmt.Errorf("Error adding floppy: %s", err)) return multistep.ActionHalt } diff --git a/builder/parallels/common/step_attach_floppy_test.go b/builder/parallels/common/step_attach_floppy_test.go index ab78025df..790eadc1b 100644 --- a/builder/parallels/common/step_attach_floppy_test.go +++ b/builder/parallels/common/step_attach_floppy_test.go @@ -36,17 +36,30 @@ func TestStepAttachFloppy(t *testing.T) { t.Fatal("should NOT have error") } - if len(driver.PrlctlCalls) != 1 { + if len(driver.PrlctlCalls) != 2 { t.Fatal("not enough calls to prlctl") } if driver.PrlctlCalls[0][0] != "set" { t.Fatal("bad call") } - if driver.PrlctlCalls[0][2] != "--device-add" { + if driver.PrlctlCalls[0][2] != "--device-del" { t.Fatal("bad call") } - if driver.PrlctlCalls[0][3] != "fdd" { + if driver.PrlctlCalls[0][3] != "fdd0" { + t.Fatal("bad call") + } + + if driver.PrlctlCalls[1][0] != "set" { + t.Fatal("bad call") + } + if driver.PrlctlCalls[1][2] != "--device-add" { + t.Fatal("bad call") + } + if driver.PrlctlCalls[1][3] != "fdd" { + t.Fatal("bad call") + } + if driver.PrlctlCalls[1][6] != "--connect" { t.Fatal("bad call") } }