Error message is given if there are no auto ports available.
This commit is contained in:
parent
7fa0303925
commit
61bcc761bc
|
@ -46,6 +46,10 @@ module Vagrant
|
|||
range = runner.env.config.vm.auto_port_range.to_a
|
||||
range -= used_ports
|
||||
|
||||
if range.empty?
|
||||
raise ActionException.new(:vm_port_auto_empty, :vm_name => @runner.name, :name => name, :options => options)
|
||||
end
|
||||
|
||||
# Set the port up to be the first one and add that port to
|
||||
# the used list.
|
||||
options[:hostport] = range.shift
|
||||
|
|
|
@ -197,6 +197,13 @@
|
|||
The vagrant virtual environment you are trying to suspend must be running to be suspended.
|
||||
:vm_not_suspended: |-
|
||||
The vagrant virtual environment you are trying to resume is not in a suspended state.
|
||||
:vm_port_auto_empty: |-
|
||||
Vagrant found a port collision for the specified port and virtual machine.
|
||||
While this port was marked to be auto-corrected, the ports in the
|
||||
auto-correction range are all also used.
|
||||
|
||||
VM: <%= vm_name %>
|
||||
Forwarded port: <%= name %> (<%= options[:guestport] %> => <%= options[:hostport] %>)
|
||||
:vm_port_collision: |-
|
||||
Vagrant cannot forward the specified ports on this VM, since they
|
||||
would collide with another VirtualBox virtual machine's forwarded
|
||||
|
|
|
@ -101,6 +101,7 @@ class Test::Unit::TestCase
|
|||
action = action_klass.new(mock_vm, *args)
|
||||
stub_default_action_dependecies(action)
|
||||
|
||||
mock_vm.stubs(:name).returns("foo")
|
||||
mock_vm.stubs(:vm).returns(vm)
|
||||
mock_vm.stubs(:vm=)
|
||||
mock_vm.stubs(:invoke_callback)
|
||||
|
|
|
@ -72,7 +72,6 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|||
@used_ports = [1,2,3]
|
||||
|
||||
@runner.env.config.vm.auto_port_range = (1..5)
|
||||
@auto_port_range = @runner.env.config.vm.auto_port_range.to_a
|
||||
end
|
||||
|
||||
should "raise an exception if auto forwarding is disabled" do
|
||||
|
@ -94,6 +93,13 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|||
@action.handle_collision(@name, @options, @used_ports)
|
||||
assert @used_ports.include?(4)
|
||||
end
|
||||
|
||||
should "raise an exception if there are no auto ports available" do
|
||||
@runner.env.config.vm.auto_port_range = (1..3)
|
||||
assert_raises(Vagrant::Actions::ActionException) {
|
||||
@action.handle_collision(@name, @options, @used_ports)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "execution" do
|
||||
|
|
Loading…
Reference in New Issue