From 530122de30a3af82af1f6a7778ac4768381af7db Mon Sep 17 00:00:00 2001 From: Carl Caum Date: Fri, 3 Aug 2012 12:30:50 -0700 Subject: [PATCH] Add source for getting instance mac address Previous to this commit, the only source to obtain the mac address for the primary interface on an instance was through libvirt directly. If libvirt was unable to retrieve the mac address, it would be nil. This commit adds the ability to dump the XML using the virsh command and attempting to retrieve the mac address from that. --- lib/fog/libvirt/models/compute/server.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fog/libvirt/models/compute/server.rb b/lib/fog/libvirt/models/compute/server.rb index 8eb48243e..14529fbf4 100644 --- a/lib/fog/libvirt/models/compute/server.rb +++ b/lib/fog/libvirt/models/compute/server.rb @@ -240,8 +240,10 @@ module Fog # It returns an array of public and private ip addresses # Currently only one ip address is returned, but in the future this could be multiple # if the server has multiple network interface - def addresses(connection, options={}) - mac=self.mac + def addresses(connection=connection, options={}) + unless mac = self.mac + mac = Nokogiri::XML(`virsh dumpxml #{self.name}`).xpath('//domain/devices/interface/mac').first.attribute('address').content + end # Aug 24 17:34:41 juno arpwatch: new station 10.247.4.137 52:54:00:88:5a:0a eth0.4 # Aug 24 17:37:19 juno arpwatch: changed ethernet address 10.247.4.137 52:54:00:27:33:00 (52:54:00:88:5a:0a) eth0.4