lib/vagrant-windows/guest/cap/configure_networks.rb in vagrant-windows-1.3.0.pre.2 vs lib/vagrant-windows/guest/cap/configure_networks.rb in vagrant-windows-1.3.0.pre.3
- old
+ new
@@ -1,10 +1,11 @@
require 'log4r'
require_relative '../../communication/guestnetwork'
require_relative '../../communication/winrmshell'
require_relative '../../errors'
require_relative '../../helper'
+require_relative '../../windows_machine'
module VagrantWindows
module Guest
module Cap
class ConfigureNetworks
@@ -12,13 +13,14 @@
@@logger = Log4r::Logger.new("vagrant_windows::guest::cap::configure_networks")
def self.configure_networks(machine, networks)
@@logger.debug("networks: #{networks.inspect}")
- guest_network = ::VagrantWindows::Communication::GuestNetwork.new(machine.communicate.winrmshell)
- unless VagrantWindows::Helper.is_vmware(machine)
- vm_interface_map = create_vm_interface_map(machine, guest_network)
+ windows_machine = VagrantWindows::WindowsMachine.new(machine)
+ guest_network = VagrantWindows::Communication::GuestNetwork.new(windows_machine.winrmshell)
+ unless windows_machine.is_vmware?()
+ vm_interface_map = create_vm_interface_map(windows_machine, guest_network)
end
networks.each do |network|
interface = vm_interface_map[network[:interface]+1]
if interface.nil?
@@ -38,16 +40,16 @@
interface[:net_connection_id])
else
raise WindowsError, "#{network_type} network type is not supported, try static or dhcp"
end
end
- guest_network.set_all_networks_to_work() if machine.config.windows.set_work_network
+ guest_network.set_all_networks_to_work() if windows_machine.windows_config.set_work_network
end
#{1=>{:name=>"Local Area Connection", :mac_address=>"0800275FAC5B", :interface_index=>"11", :index=>"7"}}
- def self.create_vm_interface_map(machine, guest_network)
+ def self.create_vm_interface_map(windows_machine, guest_network)
vm_interface_map = {}
- driver_mac_address = machine.provider.driver.read_mac_addresses.invert
+ driver_mac_address = windows_machine.read_mac_addresses.invert
@@logger.debug("mac addresses: #{driver_mac_address.inspect}")
guest_network.network_adapters().each do |nic|
@@logger.debug("nic: #{nic.inspect}")
naked_mac = nic[:mac_address].gsub(':','')
if driver_mac_address[naked_mac]