From f6057bf80ad63d28a0a41e981c7960129827223a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 14 Mar 2010 17:54:30 -0700 Subject: [PATCH] Port collision detection now checks every VirtualBox VM, not just the active list --- lib/vagrant/actions/vm/forward_ports.rb | 5 ++--- test/vagrant/actions/vm/forward_ports_test.rb | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/vagrant/actions/vm/forward_ports.rb b/lib/vagrant/actions/vm/forward_ports.rb index 95e2c6bf3..66da66232 100644 --- a/lib/vagrant/actions/vm/forward_ports.rb +++ b/lib/vagrant/actions/vm/forward_ports.rb @@ -3,8 +3,7 @@ module Vagrant module VM class ForwardPorts < Base def prepare - ActiveList.vms.each do |vagrant_vm| - vm = vagrant_vm.vm + VirtualBox::VM.all.each do |vm| next unless vm.running? vm.forwarded_ports.each do |fp| @@ -12,7 +11,7 @@ module Vagrant if fp.hostport.to_s == options[:hostport].to_s raise ActionException.new(<<-msg) Vagrant cannot forward the specified ports on this VM, since they -would collide with another Vagrant-managed virtual machine's forwarded +would collide with another VirtualBox virtual machine's forwarded ports! The "#{name}" forwarded port (#{fp.hostport}) is already in use on the host machine. diff --git a/test/vagrant/actions/vm/forward_ports_test.rb b/test/vagrant/actions/vm/forward_ports_test.rb index da290fac6..7fae1ff3d 100644 --- a/test/vagrant/actions/vm/forward_ports_test.rb +++ b/test/vagrant/actions/vm/forward_ports_test.rb @@ -15,10 +15,8 @@ class ForwardPortsActionTest < Test::Unit::TestCase @vm = mock("vm") @vm.stubs(:forwarded_ports).returns(@forwarded_ports) @vm.stubs(:running?).returns(true) - vagrant_vm = mock("vagrant_vm") - vagrant_vm.stubs(:vm).returns(@vm) - vms = [vagrant_vm] - Vagrant::ActiveList.stubs(:vms).returns(vms) + vms = [@vm] + VirtualBox::VM.stubs(:all).returns(vms) mock_config do |config| config.vm.forwarded_ports.clear