From 2b3411965aef1095fded20ea14151ced577a2d91 Mon Sep 17 00:00:00 2001 From: Joakim Bergman Date: Thu, 7 May 2015 18:07:08 +0200 Subject: [PATCH 1/2] virtualbox: handle a list of bridged nics This change allows you to specify multiple network interfaces to bridge to, picking the first found. ```ruby config.vm.network "public_network", bridge: ["en4: Thunderbolt Ethernet", "en6: Broadcom NetXtreme Gigabit Ethernet Controller", "en0: Wi-Fi (AirPort)"] ``` --- plugins/providers/virtualbox/action/network.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/providers/virtualbox/action/network.rb b/plugins/providers/virtualbox/action/network.rb index f1beff00b..df1146f35 100644 --- a/plugins/providers/virtualbox/action/network.rb +++ b/plugins/providers/virtualbox/action/network.rb @@ -157,14 +157,18 @@ module VagrantPlugins @logger.debug("Bridge was directly specified in config, searching for: #{config[:bridge]}") # Search for a matching bridged interface - bridge = config[:bridge] - bridge = bridge.downcase if bridge.respond_to?(:downcase) - bridgedifs.each do |interface| - if bridge === interface[:name].downcase - @logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.") - chosen_bridge = interface[:name] - break + bridges = config[:bridge] + bridges = [bridges] if not bridges.respond_to?(:each) + bridges.each do |bridge| + bridge = bridge.downcase if bridge.respond_to?(:downcase) + bridgedifs.each do |interface| + if bridge === interface[:name].downcase + @logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.") + chosen_bridge = interface[:name] + break + end end + break if chosen_bridge end # If one wasn't found, then we notify the user here. From 08f240668b71cfd5167f174491bb4dfce2c5e8cf Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sat, 30 May 2015 12:02:10 -0700 Subject: [PATCH 2/2] Minor cleanup --- plugins/providers/virtualbox/action/network.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/providers/virtualbox/action/network.rb b/plugins/providers/virtualbox/action/network.rb index df1146f35..a95b79857 100644 --- a/plugins/providers/virtualbox/action/network.rb +++ b/plugins/providers/virtualbox/action/network.rb @@ -157,9 +157,7 @@ module VagrantPlugins @logger.debug("Bridge was directly specified in config, searching for: #{config[:bridge]}") # Search for a matching bridged interface - bridges = config[:bridge] - bridges = [bridges] if not bridges.respond_to?(:each) - bridges.each do |bridge| + Array(config[:bridge]).each do |bridge| bridge = bridge.downcase if bridge.respond_to?(:downcase) bridgedifs.each do |interface| if bridge === interface[:name].downcase