parent
20b53f5ca3
commit
31b93a3026
|
@ -41,10 +41,10 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
ui.Say("Preparing to export machine...")
|
ui.Say("Preparing to export machine...")
|
||||||
|
|
||||||
// Clear out the Packer-created forwarding rule
|
// Clear out the Packer-created forwarding rule
|
||||||
if !s.SkipNatMapping {
|
sshPort := state.Get("sshHostPort")
|
||||||
|
if !s.SkipNatMapping && sshPort != 0 {
|
||||||
ui.Message(fmt.Sprintf(
|
ui.Message(fmt.Sprintf(
|
||||||
"Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port %d)",
|
"Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port %d)", sshPort))
|
||||||
state.Get("sshHostPort")))
|
|
||||||
command := []string{"modifyvm", vmName, "--natpf1", "delete", "packercomm"}
|
command := []string{"modifyvm", vmName, "--natpf1", "delete", "packercomm"}
|
||||||
if err := driver.VBoxManage(command...); err != nil {
|
if err := driver.VBoxManage(command...); err != nil {
|
||||||
err := fmt.Errorf("Error deleting port forwarding rule: %s", err)
|
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)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vmName := state.Get("vmName").(string)
|
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()
|
guestPort := s.CommConfig.Port()
|
||||||
sshHostPort := guestPort
|
sshHostPort := guestPort
|
||||||
if !s.SkipNatMapping {
|
if !s.SkipNatMapping {
|
||||||
|
|
Loading…
Reference in New Issue