Auto configuration for tunnel interfaces

This commit is contained in:
Kirill Yudenok 2021-04-08 14:02:57 +03:00 committed by Darragh Bailey
parent ae1d0667df
commit c387864dd2
2 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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
@ -103,13 +112,17 @@ module VagrantPlugins
# use default values if not already set
options = {
iface_type: type,
netmask: '255.255.255.0',
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