diff --git a/builder/parallels/common/step_remove_devices.go b/builder/parallels/common/step_remove_devices.go deleted file mode 100644 index 0bcbc6eb3..000000000 --- a/builder/parallels/common/step_remove_devices.go +++ /dev/null @@ -1,67 +0,0 @@ -package common - -import ( - "fmt" - "github.com/mitchellh/multistep" - "github.com/mitchellh/packer/packer" -) - -// This step removes any devices (floppy disks, ISOs, etc.) from the -// machine that we may have added. -// -// Uses: -// driver Driver -// ui packer.Ui -// vmName string -// -// Produces: -type StepRemoveDevices struct{} - -func (s *StepRemoveDevices) Run(state multistep.StateBag) multistep.StepAction { - driver := state.Get("driver").(Driver) - ui := state.Get("ui").(packer.Ui) - vmName := state.Get("vmName").(string) - - // Remove the attached floppy disk, if it exists - if _, ok := state.GetOk("floppy_path"); ok { - ui.Message("Removing floppy drive...") - command := []string{"set", vmName, "--device-del", "fdd0"} - if err := driver.Prlctl(command...); err != nil { - err := fmt.Errorf("Error removing floppy: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } - } - - if _, ok := state.GetOk("attachedIso"); ok { - command := []string{ - "set", vmName, - "--device-set", "cdrom0", - "--device", "Default CD/DVD-ROM", - } - - if err := driver.Prlctl(command...); err != nil { - err := fmt.Errorf("Error detaching ISO: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } - } - - if _, ok := state.GetOk("attachedToolsIso"); ok { - command := []string{"set", vmName, "--device-del", "cdrom1"} - - if err := driver.Prlctl(command...); err != nil { - err := fmt.Errorf("Error detaching ISO: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } - } - - return multistep.ActionContinue -} - -func (s *StepRemoveDevices) Cleanup(state multistep.StateBag) { -} diff --git a/builder/parallels/common/step_remove_devices_test.go b/builder/parallels/common/step_remove_devices_test.go deleted file mode 100644 index 983b6faad..000000000 --- a/builder/parallels/common/step_remove_devices_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package common - -import ( - "github.com/mitchellh/multistep" - "testing" -) - -func TestStepRemoveDevices_impl(t *testing.T) { - var _ multistep.Step = new(StepRemoveDevices) -} - -func TestStepRemoveDevices(t *testing.T) { - state := testState(t) - step := new(StepRemoveDevices) - - state.Put("vmName", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test that ISO was removed - if len(driver.PrlctlCalls) != 0 { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } -} - -func TestStepRemoveDevices_attachedIso(t *testing.T) { - state := testState(t) - step := new(StepRemoveDevices) - - state.Put("attachedIso", true) - state.Put("vmName", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test that ISO was detached - if len(driver.PrlctlCalls) != 1 { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } - if driver.PrlctlCalls[0][2] != "--device-set" { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } - if driver.PrlctlCalls[0][3] != "cdrom0" { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } - if driver.PrlctlCalls[0][5] != "Default CD/DVD-ROM" { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } -} - -func TestStepRemoveDevices_floppyPath(t *testing.T) { - state := testState(t) - step := new(StepRemoveDevices) - - state.Put("floppy_path", "foo") - state.Put("vmName", "foo") - - driver := state.Get("driver").(*DriverMock) - - // Test the run - if action := step.Run(state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - if _, ok := state.GetOk("error"); ok { - t.Fatal("should NOT have error") - } - - // Test that both were removed - if len(driver.PrlctlCalls) != 1 { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } - if driver.PrlctlCalls[0][2] != "--device-del" { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } - if driver.PrlctlCalls[0][3] != "fdd0" { - t.Fatalf("bad: %#v", driver.PrlctlCalls) - } -} diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index b177bb27d..5b4c628a1 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -294,7 +294,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Command: b.config.ShutdownCommand, Timeout: b.config.ShutdownTimeout, }, - new(parallelscommon.StepRemoveDevices), } // Setup the state bag diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 83ac73b12..037641619 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -99,7 +99,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Command: b.config.ShutdownCommand, Timeout: b.config.ShutdownTimeout, }, - new(parallelscommon.StepRemoveDevices), } // Run the steps.