Vagrant now asks what adapter to bridge to
This commit is contained in:
parent
567c09df21
commit
22d042cb94
|
@ -68,12 +68,31 @@ module Vagrant
|
|||
def determine_bridged_interface(networks)
|
||||
bridgedifs = @env[:vm].driver.read_bridged_interfaces
|
||||
|
||||
# Output all the interfaces that are available for choices
|
||||
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
|
||||
:prefix => false)
|
||||
|
||||
bridgedifs.each_index do |index|
|
||||
interface = bridgedifs[index]
|
||||
|
||||
@env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
|
||||
end
|
||||
|
||||
valid = Range.new(1, bridgedifs.length)
|
||||
|
||||
results = []
|
||||
networks.each do |network|
|
||||
# TODO: Allow choosing the bridged interface. For now, we just use the
|
||||
# first one blindly.
|
||||
option = nil
|
||||
while !valid.include?(option)
|
||||
option = @env[:ui].ask("What network should adapter #{network[:adapter]} bridge to? ")
|
||||
|
||||
# We need the numeric value since it will be an index
|
||||
option = option.to_i
|
||||
end
|
||||
|
||||
# Duplicate the options so that we return a new dictionary
|
||||
options = network.dup
|
||||
options[:bridge] = bridgedifs[0][:name]
|
||||
options[:bridge] = bridgedifs[option - 1][:name]
|
||||
@logger.info("Bridging #{options[:adapter]} => #{options[:bridge]}")
|
||||
|
||||
results << options
|
||||
|
|
|
@ -17,7 +17,7 @@ module Vagrant
|
|||
@resource = resource
|
||||
end
|
||||
|
||||
[:warn, :error, :info, :success].each do |method|
|
||||
[:ask, :warn, :error, :info, :success].each do |method|
|
||||
define_method(method) do |message, *opts|
|
||||
# Log normal console messages
|
||||
@logger.info { "#{method}: #{message}" }
|
||||
|
@ -48,6 +48,21 @@ module Vagrant
|
|||
CODE
|
||||
end
|
||||
|
||||
def ask(message, opts=nil)
|
||||
super(message)
|
||||
|
||||
# Setup the options so that the new line is suppressed
|
||||
opts ||= {}
|
||||
opts[:new_line] = false if !opts.has_key?(:new_line)
|
||||
opts[:prefix] = false if !opts.has_key?(:prefix)
|
||||
|
||||
# Output the data
|
||||
say(:info, message, opts)
|
||||
|
||||
# Get the results and chomp off the newline
|
||||
STDIN.gets.chomp
|
||||
end
|
||||
|
||||
# This is used to output progress reports to the UI.
|
||||
# Send this method progress/total and it will output it
|
||||
# to the UI. Send `clear_line` to clear the line to show
|
||||
|
|
|
@ -281,6 +281,8 @@ en:
|
|||
Failed to connect to VM via SSH. Please verify the VM successfully booted
|
||||
by looking at the VirtualBox GUI.
|
||||
bridged_networking:
|
||||
available: |-
|
||||
Available bridged network interfaces:
|
||||
bridging: |-
|
||||
Bridging adapter #%{adapter} to '%{bridge}'
|
||||
enabling: |-
|
||||
|
|
Loading…
Reference in New Issue