Error if no available network adapters are found

This commit is contained in:
Mitchell Hashimoto 2012-01-03 08:01:26 -08:00
parent ccd688593f
commit 20edb5d05a
3 changed files with 17 additions and 2 deletions

View File

@ -90,6 +90,11 @@ module Vagrant
adapters.each do |adapter| adapters.each do |adapter|
# Ignore the adapters that already have been assigned # Ignore the adapters that already have been assigned
if !adapter[:adapter] if !adapter[:adapter]
# If we have no available adapters, then that is an exceptional
# event.
raise Errors::NetworkNoAdapters if available.empty?
# Otherwise, assign as the adapter the next available item
adapter[:adapter] = available.shift adapter[:adapter] = available.shift
end end
end end

View File

@ -208,6 +208,11 @@ module Vagrant
error_key(:collides, "vagrant.actions.vm.host_only_network") error_key(:collides, "vagrant.actions.vm.host_only_network")
end end
class NetworkNoAdapters < VagrantError
status_code(64)
error_key(:no_adapters, "vagrant.actions.vm.network")
end
class NetworkNotFound < VagrantError class NetworkNotFound < VagrantError
status_code(30) status_code(30)
error_key(:not_found, "vagrant.actions.vm.host_only_network") error_key(:not_found, "vagrant.actions.vm.host_only_network")

View File

@ -395,10 +395,15 @@ en:
MAC address is typically up to the box and box maintiner. Please contact MAC address is typically up to the box and box maintiner. Please contact
the relevant person to solve this issue. the relevant person to solve this issue.
network: network:
preparing: |-
Preparing network interfaces based on configuration...
configuring: |- configuring: |-
Configuring and enabling network interfaces... Configuring and enabling network interfaces...
no_adapters: |-
No available adapters on the virtual machine were found to accomodate
for all configured networks. VirtualBox virtual machines have 8
network interfaces available usually, so please lower the number of
networks to below 8.
preparing: |-
Preparing network interfaces based on configuration...
host_only_network: host_only_network:
collides: |- collides: |-
The specified host network collides with a non-hostonly network! The specified host network collides with a non-hostonly network!