select a switch ased on a network_name
This commit is contained in:
parent
21736aa5d4
commit
0b6e65380a
|
@ -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[:network_name]
|
||||
|
||||
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...")
|
||||
|
|
Loading…
Reference in New Issue