builder/virtualbox: remove floppy drive before exporting
This commit is contained in:
parent
3a420478f9
commit
dbad270d27
|
@ -85,7 +85,6 @@ func (s *stepAttachFloppy) Cleanup(state map[string]interface{}) {
|
|||
defer os.Remove(s.floppyPath)
|
||||
|
||||
driver := state["driver"].(Driver)
|
||||
ui := state["ui"].(packer.Ui)
|
||||
vmName := state["vmName"].(string)
|
||||
|
||||
command := []string{
|
||||
|
@ -97,7 +96,7 @@ func (s *stepAttachFloppy) Cleanup(state map[string]interface{}) {
|
|||
}
|
||||
|
||||
if err := driver.VBoxManage(command...); err != nil {
|
||||
ui.Error(fmt.Sprintf("Error unregistering floppy: %s", err))
|
||||
log.Printf("Error unregistering floppy: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ func (s *stepExport) Run(state map[string]interface{}) multistep.StepAction {
|
|||
vmName := state["vmName"].(string)
|
||||
|
||||
// Clear out the Packer-created forwarding rule
|
||||
ui.Say(fmt.Sprintf("Deleting forwarded port mapping for SSH (host port %d)", state["sshHostPort"]))
|
||||
ui.Say("Preparing to export machine...")
|
||||
ui.Message(fmt.Sprintf("Deleting forwarded port mapping for SSH (host port %d)", state["sshHostPort"]))
|
||||
command := []string{"modifyvm", vmName, "--natpf1", "delete", "packerssh"}
|
||||
if err := driver.VBoxManage(command...); err != nil {
|
||||
err := fmt.Errorf("Error deleting port forwarding rule: %s", err)
|
||||
|
@ -31,6 +32,23 @@ func (s *stepExport) Run(state map[string]interface{}) multistep.StepAction {
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
// Remove the attached floppy disk, if it exists
|
||||
if _, ok := state["floppy_path"]; ok {
|
||||
ui.Message("Removing floppy drive...")
|
||||
command := []string{
|
||||
"storageattach", vmName,
|
||||
"--storagectl", "Floppy Controller",
|
||||
"--port", "0",
|
||||
"--device", "0",
|
||||
"--medium", "none",
|
||||
}
|
||||
if err := driver.VBoxManage(command...); err != nil {
|
||||
state["error"] = fmt.Errorf("Error removing floppy: %s", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Export the VM to an OVF
|
||||
outputPath := filepath.Join(config.OutputDir, "packer.ovf")
|
||||
|
||||
|
|
Loading…
Reference in New Issue