From 0c7efde1031a80267093e74b1b815e5a0451a262 Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Fri, 19 Jul 2013 20:46:26 -0400 Subject: [PATCH] Remove ISO from ide1 in stepCleanVMX --- builder/vmware/step_clean_vmx.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/builder/vmware/step_clean_vmx.go b/builder/vmware/step_clean_vmx.go index 595b90e01..cc9841681 100644 --- a/builder/vmware/step_clean_vmx.go +++ b/builder/vmware/step_clean_vmx.go @@ -22,9 +22,6 @@ import ( type stepCleanVMX struct{} func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction { - if _, ok := state["floppy_path"]; !ok { - return multistep.ActionContinue - } ui := state["ui"].(packer.Ui) vmxPath := state["vmx_path"].(string) @@ -35,15 +32,22 @@ func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction { return multistep.ActionHalt } - // Delete the floppy0 entries so the floppy is no longer mounted - ui.Say("Unmounting floppy from VMX...") - for k, _ := range vmxData { - if strings.HasPrefix(k, "floppy0.") { - log.Printf("Deleting key: %s", k) - delete(vmxData, k) + if _, ok := state["floppy_path"]; ok { + // Delete the floppy0 entries so the floppy is no longer mounted + ui.Say("Unmounting floppy from VMX...") + for k, _ := range vmxData { + if strings.HasPrefix(k, "floppy0.") { + log.Printf("Deleting key: %s", k) + delete(vmxData, k) + } } + vmxData["floppy0.present"] = "FALSE" } - vmxData["floppy0.present"] = "FALSE" + + // Change the CD-ROM device back to auto-detect, ejecting the iso + ui.Say("Detatching ISO from CD-ROM device...") + vmxData["ide1:0.fileName"] = "auto detect" + vmxData["ide1:0.deviceType"] = "cdrom-raw" // Rewrite the VMX if err := WriteVMX(vmxPath, vmxData); err != nil {