Commit d89fd906 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #1504 from sneal/always-remove-vmx-floppy-entries

Clean VMX step should always remove floppy.
parents 72aea045 5fd96519
...@@ -32,7 +32,6 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { ...@@ -32,7 +32,6 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
if _, ok := state.GetOk("floppy_path"); ok {
// Delete the floppy0 entries so the floppy is no longer mounted // Delete the floppy0 entries so the floppy is no longer mounted
ui.Message("Unmounting floppy from VMX...") ui.Message("Unmounting floppy from VMX...")
for k, _ := range vmxData { for k, _ := range vmxData {
...@@ -42,28 +41,18 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { ...@@ -42,28 +41,18 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction {
} }
} }
vmxData["floppy0.present"] = "FALSE" vmxData["floppy0.present"] = "FALSE"
}
if isoPathRaw, ok := state.GetOk("iso_path"); ok {
isoPath := isoPathRaw.(string)
ui.Message("Detaching ISO from CD-ROM device...")
devRe := regexp.MustCompile(`^ide\d:\d\.`) devRe := regexp.MustCompile(`^ide\d:\d\.`)
for k, _ := range vmxData { for k, v := range vmxData {
match := devRe.FindString(k) ide := devRe.FindString(k)
if match == "" { if ide == "" || v != "cdrom-image" {
continue continue
} }
filenameKey := match + "filename" ui.Message("Detaching ISO from CD-ROM device...")
if filename, ok := vmxData[filenameKey]; ok {
if filename == isoPath { vmxData[ide+"devicetype"] = "cdrom-raw"
// Change the CD-ROM device back to auto-detect to eject vmxData[ide+"filename"] = "auto detect"
vmxData[filenameKey] = "auto detect"
vmxData[match+"devicetype"] = "cdrom-raw"
}
}
}
} }
// Rewrite the VMX // Rewrite the VMX
......
...@@ -39,7 +39,6 @@ func TestStepCleanVMX_floppyPath(t *testing.T) { ...@@ -39,7 +39,6 @@ func TestStepCleanVMX_floppyPath(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
state.Put("floppy_path", "foo")
state.Put("vmx_path", vmxPath) state.Put("vmx_path", vmxPath)
// Test the run // Test the run
...@@ -89,7 +88,6 @@ func TestStepCleanVMX_isoPath(t *testing.T) { ...@@ -89,7 +88,6 @@ func TestStepCleanVMX_isoPath(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
state.Put("iso_path", "foo")
state.Put("vmx_path", vmxPath) state.Put("vmx_path", vmxPath)
// Test the run // Test the run
...@@ -136,6 +134,7 @@ floppy0.filetype = "file" ...@@ -136,6 +134,7 @@ floppy0.filetype = "file"
` `
const testVMXISOPath = ` const testVMXISOPath = `
ide0:0.devicetype = "cdrom-image"
ide0:0.filename = "foo" ide0:0.filename = "foo"
ide0:1.filename = "bar" ide0:1.filename = "bar"
foo = "bar" foo = "bar"
......
...@@ -137,10 +137,14 @@ LockWaitLoop: ...@@ -137,10 +137,14 @@ LockWaitLoop:
} }
} }
if runtime.GOOS == "windows" && !s.Testing { if runtime.GOOS != "darwin" && !s.Testing {
// Windows takes a while to yield control of the files when the // Windows takes a while to yield control of the files when the
// process is exiting. We just sleep here. In the future, it'd be // process is exiting. Ubuntu will yield control of the files but
// nice to find a better solution to this. // VMWare may overwrite the VMX cleanup steps that run after this,
// so we wait to ensure VMWare has exited and flushed the VMX.
// We just sleep here. In the future, it'd be nice to find a better
// solution to this.
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
} }
......
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