Merge pull request #4960 from rickard-von-essen/issue-4959
virtualbox: Don't add portforwarding if comm = none
This commit is contained in:
commit
0c116981ab
|
@ -41,10 +41,10 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ui.Say("Preparing to export machine...")
|
||||
|
||||
// Clear out the Packer-created forwarding rule
|
||||
if !s.SkipNatMapping {
|
||||
sshPort := state.Get("sshHostPort")
|
||||
if !s.SkipNatMapping && sshPort != 0 {
|
||||
ui.Message(fmt.Sprintf(
|
||||
"Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port %d)",
|
||||
state.Get("sshHostPort")))
|
||||
"Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port %d)", sshPort))
|
||||
command := []string{"modifyvm", vmName, "--natpf1", "delete", "packercomm"}
|
||||
if err := driver.VBoxManage(command...); err != nil {
|
||||
err := fmt.Errorf("Error deleting port forwarding rule: %s", err)
|
||||
|
|
|
@ -32,6 +32,12 @@ func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ui := state.Get("ui").(packer.Ui)
|
||||
vmName := state.Get("vmName").(string)
|
||||
|
||||
if s.CommConfig.Type == "none" {
|
||||
log.Printf("Not using a communicator, skipping setting up port forwarding...")
|
||||
state.Put("sshHostPort", 0)
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
guestPort := s.CommConfig.Port()
|
||||
sshHostPort := guestPort
|
||||
if !s.SkipNatMapping {
|
||||
|
|
Loading…
Reference in New Issue