Make lookup_network_by_name the default for veryisolated networks

This commit is contained in:
Joe Julian 2015-07-20 13:01:34 -07:00
parent 9b7c9def3c
commit fc24db479f

View File

@ -133,27 +133,27 @@ module VagrantPlugins
# Set IP address of network (actually bridge). It will be used as # Set IP address of network (actually bridge). It will be used as
# gateway address for machines connected to this network. # gateway address for machines connected to this network.
net = IPAddr.new(net_address) net = IPAddr.new(net_address)
# Default to first address (after network name)
@interface_network[:ip_address] = @options[:host_ip].nil? ? \
net.to_range.begin.succ : \
IPAddr.new(@options[:host_ip])
end end
@interface_network[:network_address] = net_address @interface_network[:network_address] = net_address
# Default to first address (after network name) # if network is veryisolated, search by name
@interface_network[:ip_address] = @options[:host_ip].nil? ? \ if @options[:libvirt__forward_mode] == "veryisolated"
net.to_range.begin.succ : \ network = lookup_network_by_name(@options[:network_name])
IPAddr.new(@options[:host_ip]) elsif net_address
# otherwise, search by ip (if set)
# Is there an available network matching to configured ip network = lookup_network_by_ip(net_address)
# address? else
if net_address # leaving this here to mimic prior behavior. If we get
network = lookup_network_by_ip(net_address) # here, something's probably broken.
@interface_network = network if network
end
# if network is veryisolated, search by name instead
if !@interface_network and @options[:libvirt__forward_mode] == "veryisolated"
network = lookup_network_by_name(@options[:network_name]) network = lookup_network_by_name(@options[:network_name])
@interface_network = network if network
end end
@interface_network = network if network
if @interface_network[:created] if @interface_network[:created]
verify_dhcp verify_dhcp