Improve network interface detection to avoid crash [GH-1480]

This commit is contained in:
Mitchell Hashimoto 2013-03-22 10:51:07 -07:00
parent 230a3ca0bf
commit 43d85930ed
4 changed files with 22 additions and 0 deletions

View File

@ -21,6 +21,8 @@ BUG FIXES:
auto-corrected ports. [GH-1472]
- Fix obscure error when temp directory is world writable when
adding boxes.
- Improved error handling around network interface detection for
VirtualBox [GH-1480]
## 1.1.2 (March 18, 2013)

View File

@ -203,6 +203,10 @@ module Vagrant
error_key(:home_dir_not_accessible)
end
class ForwardPortAdapterNotFound < VagrantError
error_key(:forward_port_adapter_not_found)
end
class ForwardPortAutolistEmpty < VagrantError
error_key(:auto_empty, "vagrant.actions.vm.forward_ports")
end

View File

@ -50,6 +50,14 @@ module VagrantPlugins
@env[:ui].info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry",
message_attributes))
# Verify we have the network interface to attach to
if !interfaces[fp.adapter]
raise Vagrant::Errors::ForwardPortAdapterNotFound,
:adapter => fp.adapter.to_s,
:guest => fp.guest_port.to_s,
:host => fp.host_port.to_s
end
# Port forwarding requires the network interface to be a NAT interface,
# so verify that that is the case.
if interfaces[fp.adapter][:type] != :nat

View File

@ -130,6 +130,14 @@ en:
may run at any given time to avoid problems with VirtualBox inconsistencies
occurring. Please wait for the other instance of Vagrant to end and then
try again.
forward_port_adapter_not_found: |-
The adapter to attach a forwarded port to was not found. Please
verify that the given adapter is setup on the machine as a NAT
interface.
Host port: %{host}
Guest port: %{guest}
Adapter: %{adapter}
gem_command_in_bundler: |-
You cannot run the `vagrant plugin` command while in a bundler environment.
This should generally never happen unless Vagrant is installed outside