diff --git a/CHANGELOG.md b/CHANGELOG.md index 77bdabcbe..985a72818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.6.6 (unreleased) + - Fix port collision handling with greater than two VMs. [GH-185] - Fix potential infinite loop with root path if bad CWD is given to environment. ## 0.6.5 (October 8, 2010) diff --git a/lib/vagrant/action/vm/forward_ports.rb b/lib/vagrant/action/vm/forward_ports.rb index d8a59e472..4f6ba1d6b 100644 --- a/lib/vagrant/action/vm/forward_ports.rb +++ b/lib/vagrant/action/vm/forward_ports.rb @@ -34,7 +34,7 @@ module Vagrant def external_collision_check existing = used_ports @env.env.config.vm.forwarded_ports.each do |name, options| - if existing.include?(options[:hostport].to_s) + if existing.include?(options[:hostport].to_i) handle_collision(name, options, existing) end end diff --git a/lib/vagrant/action/vm/forward_ports_helpers.rb b/lib/vagrant/action/vm/forward_ports_helpers.rb index 5204237a0..495f21919 100644 --- a/lib/vagrant/action/vm/forward_ports_helpers.rb +++ b/lib/vagrant/action/vm/forward_ports_helpers.rb @@ -14,7 +14,7 @@ module Vagrant if vm.running? && vm.uuid != @env["vm"].uuid vm.network_adapters.collect do |na| na.nat_driver.forwarded_ports.collect do |fp| - fp.hostport.to_s + fp.hostport.to_i end end end diff --git a/test/vagrant/action/vm/forward_ports_helpers_test.rb b/test/vagrant/action/vm/forward_ports_helpers_test.rb index d4aefcabc..d234bcd2d 100644 --- a/test/vagrant/action/vm/forward_ports_helpers_test.rb +++ b/test/vagrant/action/vm/forward_ports_helpers_test.rb @@ -64,7 +64,7 @@ class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase na.stubs(:nat_driver).returns(ne) ne.stubs(:forwarded_ports).returns(fps) @vms << mock_vm(:network_adapters => [na]) - assert_equal %W[2222 80], @instance.used_ports + assert_equal [2222, 80], @instance.used_ports end end end diff --git a/test/vagrant/action/vm/forward_ports_test.rb b/test/vagrant/action/vm/forward_ports_test.rb index 31378443a..406bad6c6 100644 --- a/test/vagrant/action/vm/forward_ports_test.rb +++ b/test/vagrant/action/vm/forward_ports_test.rb @@ -53,12 +53,12 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase end should "not raise any errors if no forwarded ports collide" do - @used_ports << "80" + @used_ports << 80 assert_nothing_raised { @klass.new(@app, @env) } end should "handle collision if it happens" do - @used_ports << "2222" + @used_ports << 2222 @klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once assert_nothing_raised { @klass.new(@app, @env) } end