Commit fe37d9b6 authored by Rickard von Essen's avatar Rickard von Essen

parallels-iso: ISO not removed from VM after install [GH-1338]

Also remove floppy and prl-tools ISO if applicable.
parent 104bd9d6
...@@ -44,7 +44,7 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction { ...@@ -44,7 +44,7 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
} }
ui.Say("Attaching floppy disk...") ui.Say("Attaching floppy disk...")
// Create the floppy disk controller // Attaching the floppy disk
add_command := []string{ add_command := []string{
"set", vmName, "set", vmName,
"--device-add", "fdd", "--device-add", "fdd",
...@@ -62,4 +62,18 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction { ...@@ -62,4 +62,18 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionContinue return multistep.ActionContinue
} }
func (s *StepAttachFloppy) Cleanup(state multistep.StateBag) {} func (s *StepAttachFloppy) Cleanup(state multistep.StateBag) {
driver := state.Get("driver").(Driver)
vmName := state.Get("vmName").(string)
if s.floppyPath == "" {
return
}
log.Println("Detaching floppy disk...")
command := []string{
"set", vmName,
"--device-del", "fdd0",
}
driver.Prlctl(command...)
}
...@@ -34,7 +34,7 @@ func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepA ...@@ -34,7 +34,7 @@ func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepA
} }
// Attach the guest additions to the computer // Attach the guest additions to the computer
log.Println("Attaching Parallels Tools ISO onto IDE controller...") ui.Say("Attaching Parallels Tools ISO onto IDE controller...")
command := []string{ command := []string{
"set", vmName, "set", vmName,
"--device-add", "cdrom", "--device-add", "cdrom",
...@@ -53,4 +53,23 @@ func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepA ...@@ -53,4 +53,23 @@ func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepA
return multistep.ActionContinue return multistep.ActionContinue
} }
func (s *StepAttachParallelsTools) Cleanup(state multistep.StateBag) {} func (s *StepAttachParallelsTools) Cleanup(state multistep.StateBag) {
if _, ok := state.GetOk("attachedToolsIso"); !ok {
return
}
driver := state.Get("driver").(Driver)
vmName := state.Get("vmName").(string)
log.Println("Detaching Parallels Tools ISO...")
cdDevice := "cdrom0"
if _, ok := state.GetOk("attachedIso"); ok {
cdDevice = "cdrom1"
}
command := []string{
"set", vmName,
"--device-del", cdDevice,
}
driver.Prlctl(command...)
}
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
parallelscommon "github.com/mitchellh/packer/builder/parallels/common" parallelscommon "github.com/mitchellh/packer/builder/parallels/common"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
) )
// This step attaches the ISO to the virtual machine. // This step attaches the ISO to the virtual machine.
...@@ -23,6 +24,7 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction { ...@@ -23,6 +24,7 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
vmName := state.Get("vmName").(string) vmName := state.Get("vmName").(string)
// Attach the disk to the controller // Attach the disk to the controller
ui.Say("Attaching ISO onto IDE controller...")
command := []string{ command := []string{
"set", vmName, "set", vmName,
"--device-set", "cdrom0", "--device-set", "cdrom0",
...@@ -42,4 +44,21 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction { ...@@ -42,4 +44,21 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionContinue return multistep.ActionContinue
} }
func (s *stepAttachISO) Cleanup(state multistep.StateBag) {} func (s *stepAttachISO) Cleanup(state multistep.StateBag) {
if _, ok := state.GetOk("attachedIso"); !ok {
return
}
driver := state.Get("driver").(parallelscommon.Driver)
vmName := state.Get("vmName").(string)
command := []string{
"set", vmName,
"--device-set", "cdrom0",
"--enable", "--disconnect",
}
// Remove the ISO, ignore errors
log.Println("Detaching ISO...")
driver.Prlctl(command...)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment