diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index eb585e4..f0a0594 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -194,7 +194,7 @@ module VagrantPlugins # It's used for provisioning and it has to be available during provisioning, # ifdown command is not acceptable here. next if slot_number.zero? - next if options[:auto_config] === false + next if !options[:auto_config] @logger.debug "Configuring interface slot_number #{slot_number} options #{options}" network = { @@ -214,9 +214,6 @@ module VagrantPlugins network[:type] = :dhcp end - # do not run configure_networks for tcp tunnel interfaces - next if options.fetch(:tunnel_type, nil) - networks_to_configure << network end diff --git a/lib/vagrant-libvirt/util/network_util.rb b/lib/vagrant-libvirt/util/network_util.rb index a682827..796cf4f 100644 --- a/lib/vagrant-libvirt/util/network_util.rb +++ b/lib/vagrant-libvirt/util/network_util.rb @@ -1,6 +1,15 @@ +require 'ipaddr' require 'nokogiri' require 'vagrant/util/network_ip' +class IPAddr + def get_mask + if @addr + _to_string(@mask_addr) + end + end +end + module VagrantPlugins module ProviderLibvirt module Util @@ -102,14 +111,18 @@ module VagrantPlugins # store type in options # use default values if not already set options = { - iface_type: type, - netmask: '255.255.255.0', + iface_type: type, + netmask: options[:network_address] ? + IPAddr.new(options[:network_address]).get_mask : + '255.255.255.0', dhcp_enabled: true, forward_mode: 'nat' }.merge(options) if options[:type].to_s == 'dhcp' && options[:ip].nil? - options[:network_name] = 'vagrant-private-dhcp' + options[:network_name] = options[:network_name] ? + options[:network_name] : + 'vagrant-private-dhcp' end # add to list of networks to check