Skip to content

Instantly share code, notes, and snippets.

View nickgarvey's full-sized avatar

Nick Garvey nickgarvey

View GitHub Profile
import libvirt
import xml.etree.ElementTree as ET
def findDomainWithMac(conn, addr):
domlist = map(conn.lookupByID, conn.listDomainsID())
for dom in domlist:
root = ET.fromstring(dom.XMLDesc(0))
searchString = "./devices/interface/mac[@address='{0}']".format(addr)
if (root.find(searchString) is not None):
return dom