Properly handle forward port collision detection with auto-correct

[GH-1472]
This commit is contained in:
Mitchell Hashimoto 2013-03-21 16:33:06 -07:00
parent df23c2a8fa
commit a4745fb426
3 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,8 @@ BUG FIXES:
- Attempt to re-establish SSH connection on `Net::SSH::Disconnect`
- Allow any value that can convert to a string for `Vagrant.plugin`
- Chef solo `recipe_url` works properly again. [GH-1467]
- Port collision detection works properly in VirtualBox with
auto-corrected ports. [GH-1472]
## 1.1.2 (March 18, 2013)

View File

@ -32,7 +32,7 @@ module Vagrant
end
def call(env)
@logger.debug("Detecting any forwarded port collisions...")
@logger.info("Detecting any forwarded port collisions...")
# Get the extra ports we consider in use
extra_in_use = env[:port_collision_extra_in_use] || []
@ -43,6 +43,11 @@ module Vagrant
# Determine the handler we'll use if we have any port collisions
repair = !!env[:port_collision_repair]
# Log out some of our parameters
@logger.debug("Extra in use: #{extra_in_use.inspect}")
@logger.debug("Remap: #{remap.inspect}")
@logger.debug("Repair: #{repair.inspect}")
# Determine a list of usable ports for repair
usable_ports = Set.new(env[:machine].config.vm.usable_port_range)
usable_ports.subtract(extra_in_use)

View File

@ -21,7 +21,7 @@ module VagrantPlugins
# If the ID matches the name of the forwarded port, then
# remap.
if options[:id] == name
remap[name] = hostport
remap[options[:host]] = hostport
break
end
end