Port collision detection now checks every VirtualBox VM, not just the active list
This commit is contained in:
parent
98d5454936
commit
f6057bf80a
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue