/usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43/lib/vagrant-libvirt/action/read_mac_addresses.rb is in vagrant-libvirt 0.0.43-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | require 'log4r'
module VagrantPlugins
module ProviderLibvirt
module Action
class ReadMacAddresses
def initialize(app, _env)
@app = app
@logger = Log4r::Logger.new('vagrant_libvirt::action::read_mac_addresses')
end
def call(env)
env[:machine_mac_addresses] = read_mac_addresses(env[:machine].provider.driver.connection, env[:machine])
end
def read_mac_addresses(libvirt, machine)
return nil if machine.id.nil?
domain = libvirt.client.lookup_domain_by_uuid(machine.id)
if domain.nil?
@logger.info('Machine could not be found, assuming it got destroyed')
machine.id = nil
return nil
end
xml = Nokogiri::XML(domain.xml_desc)
mac = xml.xpath('/domain/devices/interface/mac/@address')
return {} if mac.empty?
Hash[mac.each_with_index.map do |x, i|
@logger.debug("interface[#{i}] = #{x.value}")
[i, x.value]
end]
end
end
end
end
end
|