Cleanup some public network MAC code.

This commit is contained in:
Jose A. Rivera
2017-02-06 15:12:22 +01:00
parent 9cc0ff906c
commit da87d06bfb

View File

@@ -122,20 +122,17 @@ module VagrantPlugins
end end
# Re-read the network configuration and grab the MAC address # Re-read the network configuration and grab the MAC address
next if @mac if iface_configuration[:iface_type] == :public_network and not @mac
xml = Nokogiri::XML(domain.xml_desc) xml = Nokogiri::XML(domain.xml_desc)
if iface_configuration[:iface_type] == :public_network source = "@network='#{@network_name}'"
if @type == 'direct' if @type == 'direct'
@mac = xml.xpath("/domain/devices/interface[source[@dev='#{@device}']]/mac/@address") source = "@dev='#{@device}'"
elsif !@portgroup.nil? elsif @portgroup.nil?
@mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address") source = "@bridge='#{@device}'"
else
@mac = xml.xpath("/domain/devices/interface[source[@bridge='#{@device}']]/mac/@address")
end end
else @mac = xml.xpath("/domain/devices/interface[source[#{source}]]/mac/@address")
@mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address") iface_configuration[:mac] = @mac.to_s
end end
iface_configuration[:mac] = @mac.to_s
end end
# Continue the middleware chain. # Continue the middleware chain.