This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |