1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

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.
This commit is contained in:
Carl Caum 2012-08-03 12:30:50 -07:00
parent 69fd1561ac
commit 530122de30

View file

@ -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