diff --git a/builder/virtualbox/common/step_export.go b/builder/virtualbox/common/step_export.go index 0a3cd816c..56b013d9f 100644 --- a/builder/virtualbox/common/step_export.go +++ b/builder/virtualbox/common/step_export.go @@ -31,12 +31,10 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { // Wait a second to ensure VM is really shutdown. log.Println("1 second timeout to ensure VM is really shutdown") time.Sleep(1 * time.Second) + ui.Say("Preparing to export machine...") // Clear out the Packer-created forwarding rule - ui.Say("Preparing to export machine...") - var command []string - - if s.SkipNatMapping == false { + if !s.SkipNatMapping { ui.Message(fmt.Sprintf( "Deleting forwarded port mapping for SSH (host port %d)", state.Get("sshHostPort"))) @@ -52,13 +50,12 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { // Export the VM to an OVF outputPath := filepath.Join(s.OutputDir, vmName+"."+s.Format) - command = []string{ + command := []string{ "export", vmName, "--output", outputPath, } - command = append(command, s.ExportOpts...) ui.Say("Exporting virtual machine...") diff --git a/builder/virtualbox/common/step_forward_ssh.go b/builder/virtualbox/common/step_forward_ssh.go index d6d604e00..fe6004281 100644 --- a/builder/virtualbox/common/step_forward_ssh.go +++ b/builder/virtualbox/common/step_forward_ssh.go @@ -30,11 +30,8 @@ func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) - var sshHostPort uint - if s.SkipNatMapping { - sshHostPort = s.GuestPort - log.Printf("Skipping SSH NAT mapping and using SSH port %d", sshHostPort) - } else { + sshHostPort := s.GuestPort + if !s.SkipNatMapping { log.Printf("Looking for available SSH port between %d and %d", s.HostPortMin, s.HostPortMax) var offset uint = 0