Method: Vagrant::Action::VM::Network#find_matching_hostonly_network

Defined in:
lib/vagrant/action/vm/network.rb

#find_matching_hostonly_network(config) ⇒ Object

Finds a host only network that matches our configuration on VirtualBox. This will return nil if a matching network does not exist.



281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/vagrant/action/vm/network.rb', line 281

def find_matching_hostonly_network(config)
  this_netaddr = network_address(config[:ip], config[:netmask])

  @env[:vm].driver.read_host_only_interfaces.each do |interface|
    if config[:name] && config[:name] == interface[:name]
      return interface
    elsif this_netaddr == network_address(interface[:ip], interface[:netmask])
      return interface
    end
  end

  nil
end