Permalink
Browse files

Merge pull request #628 from bdellegrazie/windows-port-forwarding-fix

Windows port forwarding fix
  • Loading branch information...
jedi4ever committed Apr 2, 2013
2 parents a809ded + 617c1cb commit 9fbb67e03341f990f786102ef87309c53bdf74cf
@@ -27,7 +27,11 @@ def add_ssh_nat_mapping
unless definition.nil?
unless definition.skip_nat_mapping == true
#Map SSH Ports
command="#{@vboxcmd} modifyvm \"#{name}\" --natpf#{self.natinterface} \"guestssh,tcp,,#{definition.ssh_host_port},,#{definition.ssh_guest_port}\""
if self.running?
command="#{@vboxcmd} controlvm \"#{name}\" natpf#{self.natinterface} \"guestssh,tcp,,#{definition.ssh_host_port},,#{definition.ssh_guest_port}\""
else
command="#{@vboxcmd} modifyvm \"#{name}\" --natpf#{self.natinterface} \"guestssh,tcp,,#{definition.ssh_host_port},,#{definition.ssh_guest_port}\""
end
shell_exec("#{command}")
end
end
@@ -38,7 +42,11 @@ def add_winrm_nat_mapping
unless definition.nil?
#Map SSH Ports
unless definition.skip_nat_mapping == true
command="#{@vboxcmd} modifyvm \"#{name}\" --natpf1 'guestwinrm,tcp,,#{definition.winrm_host_port},,#{definition.winrm_guest_port}'"
if self.running?
command="#{@vboxcmd} controlvm \"#{name}\" natpf#{self.natinterface} \"guestwinrm,tcp,,#{definition.winrm_host_port},,#{definition.winrm_guest_port}\""
else
command="#{@vboxcmd} modifyvm \"#{name}\" --natpf#{self.natinterface} \"guestwinrm,tcp,,#{definition.winrm_host_port},,#{definition.winrm_guest_port}\""
end
shell_exec("#{command}")
end
end
@@ -28,7 +28,11 @@ def forwarding(name)
def delete_forwarding(name)
forward=self.forwarding(name)
command="#{@vboxcmd} controlvm \"#{self.name}\" natpf#{self.natinterface} delete #{name}"
if self.running?
command="#{@vboxcmd} controlvm \"#{self.name}\" natpf#{self.natinterface} delete \"#{name}\""
else
command="#{@vboxcmd} modifyvm \"#{self.name}\" --natpf#{self.natinterface} delete \"#{name}\""
end
shell_results=shell_exec("#{command}")
end
@@ -20,10 +20,10 @@ def up(options={})
definition.winrm_host_port=guessed_port.to_s
unless forward.nil?
if guessed_port!=forward[:guest_port]
if guessed_port!=forward[:host_port]
# Remove the existing one
self.delete_forwarding("guestwinrm")
env.ui.warn "Changing winrm port on UP from #{forward[:guest_port]} to #{guessed_port}"
env.ui.warn "Changing winrm port on UP from #{forward[:host_port]} to #{guessed_port}"
self.add_winrm_nat_mapping
end
else
@@ -38,10 +38,10 @@ def up(options={})
definition.ssh_host_port=guessed_port.to_s
unless forward.nil?
if guessed_port!=forward[:guest_port]
if guessed_port!=forward[:host_port]
# Remove the existing one
self.delete_forwarding("guestssh")
env.ui.warn "Changing ssh port from #{forward[:guest_port]} to #{guessed_port}"
env.ui.warn "Changing ssh port from #{forward[:host_port]} to #{guessed_port}"
self.add_ssh_nat_mapping
end
else

0 comments on commit 9fbb67e

Please sign in to comment.