If there is only one bridgable interface, just use that [GH-655]

This commit is contained in:
Mitchell Hashimoto 2012-01-19 21:09:51 -08:00
parent f022e9ee36
commit 4ead6e3f82
2 changed files with 29 additions and 16 deletions

View File

@ -13,6 +13,8 @@
the behavior seems different/wrong. the behavior seems different/wrong.
- Give a nice error if `:vagrant` is used as a JSON key, since Vagrant - Give a nice error if `:vagrant` is used as a JSON key, since Vagrant
uses this. [GH-661] uses this. [GH-661]
- If there is only one bridgable interface, use that without asking
the user. [GH-655]
## 0.9.1 (January 18, 2012) ## 0.9.1 (January 18, 2012)

View File

@ -314,7 +314,13 @@ module Vagrant
def bridged_adapter(config) def bridged_adapter(config)
bridgedifs = @env[:vm].driver.read_bridged_interfaces bridgedifs = @env[:vm].driver.read_bridged_interfaces
# Output all the interfaces that are available as choices chosen_bridge = nil
if bridgedifs.length == 1
# One bridgable interface? Just use it.
chosen_bridge = bridgedifs[0][:name]
else
# More than one bridgable interface requires a user decision, so
# show options to choose from.
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available", @env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
:prefix => false) :prefix => false)
bridgedifs.each_index do |index| bridgedifs.each_index do |index|
@ -332,11 +338,16 @@ module Vagrant
choice = choice.to_i choice = choice.to_i
end end
chosen_bridge = bridgedifs[choice - 1][:name]
end
@logger.info("Bridging adapter #{config[:adapter]} to #{bridge}")
# Given the choice we can now define the adapter we're using # Given the choice we can now define the adapter we're using
return { return {
:adapter => config[:adapter], :adapter => config[:adapter],
:type => :bridged, :type => :bridged,
:bridge => bridgedifs[choice - 1][:name], :bridge => chosen_bridge,
:mac_address => config[:mac] :mac_address => config[:mac]
} }
end end