Merge pull request #1398 from rickard-von-essen/issue_1338
parallels-iso: ISO not removed from VM after install [GH-1338]
This commit is contained in:
commit
391dffd848
|
@ -44,7 +44,7 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
|
|||
}
|
||||
ui.Say("Attaching floppy disk...")
|
||||
|
||||
// Create the floppy disk controller
|
||||
// Attaching the floppy disk
|
||||
add_command := []string{
|
||||
"set", vmName,
|
||||
"--device-add", "fdd",
|
||||
|
@ -62,4 +62,18 @@ func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
|
|||
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
|
|||
}
|
||||
|
||||
// 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{
|
||||
"set", vmName,
|
||||
"--device-add", "cdrom",
|
||||
|
@ -53,4 +53,23 @@ func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepA
|
|||
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 (
|
|||
"github.com/mitchellh/multistep"
|
||||
parallelscommon "github.com/mitchellh/packer/builder/parallels/common"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"log"
|
||||
)
|
||||
|
||||
// This step attaches the ISO to the virtual machine.
|
||||
|
@ -23,6 +24,7 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
|
|||
vmName := state.Get("vmName").(string)
|
||||
|
||||
// Attach the disk to the controller
|
||||
ui.Say("Attaching ISO onto IDE controller...")
|
||||
command := []string{
|
||||
"set", vmName,
|
||||
"--device-set", "cdrom0",
|
||||
|
@ -42,4 +44,21 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
|
|||
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...)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue