Merge pull request #5207 from mwrock/switch_name

select a Hyper-V switch based on a network_name
This commit is contained in:
Seth Vargo 2015-05-30 11:45:09 -07:00
commit 39a1a5c7ba
1 changed files with 31 additions and 15 deletions

View File

@ -55,7 +55,20 @@ module VagrantPlugins
switches = env[:machine].provider.driver.execute("get_switches.ps1", {})
raise Errors::NoSwitches if switches.empty?
switch = switches[0]["Name"]
switch = nil
env[:machine].config.vm.networks.each do |type, opts|
next if type != :public_network && type != :private_network
switchToFind = opts[:bridge]
if switchToFind
puts "Looking for switch with name: #{switchToFind}"
switch = switches.find { |s| s["Name"].downcase == switchToFind.downcase }["Name"]
puts "Found switch: #{switch}"
end
end
if switch.nil?
if switches.length > 1
env[:ui].detail(I18n.t("vagrant_hyperv.choose_switch") + "\n ")
switches.each_index do |i|
@ -72,6 +85,9 @@ module VagrantPlugins
switch = nil if switch < 0 || switch >= switches.length
end
switch = switches[switch]["Name"]
else
switch = switches[0]["Name"]
end
end
env[:ui].detail("Cloning virtual hard drive...")