mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Merge pull request #730 from jarrpa/patch-1
Use slot number to report MAC address
This commit is contained in:
commit
5ed93bd908
@ -64,6 +64,7 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Create each interface as new domain device.
|
# Create each interface as new domain device.
|
||||||
|
@macs_per_network = Hash.new(0)
|
||||||
adapters.each_with_index do |iface_configuration, slot_number|
|
adapters.each_with_index do |iface_configuration, slot_number|
|
||||||
@iface_number = slot_number
|
@iface_number = slot_number
|
||||||
@network_name = iface_configuration[:network_name]
|
@network_name = iface_configuration[:network_name]
|
||||||
@ -138,20 +139,21 @@ 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
|
|
||||||
xml = Nokogiri::XML(domain.xml_desc)
|
|
||||||
if iface_configuration[:iface_type] == :public_network
|
if iface_configuration[:iface_type] == :public_network
|
||||||
|
xml = Nokogiri::XML(domain.xml_desc)
|
||||||
|
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
|
if not @mac
|
||||||
@mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address")
|
macs = xml.xpath("/domain/devices/interface[source[#{source}]]/mac/@address")
|
||||||
|
@mac = macs[@macs_per_network[source]]
|
||||||
|
iface_configuration[:mac] = @mac.to_s
|
||||||
|
end
|
||||||
|
@macs_per_network[source] += 1
|
||||||
end
|
end
|
||||||
iface_configuration[:mac] = @mac.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Continue the middleware chain.
|
# Continue the middleware chain.
|
||||||
|
Loading…
Reference in New Issue
Block a user