-
-
Save nickgarvey/8229208 to your computer and use it in GitHub Desktop.
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 | |
conn = libvirt.openReadOnly('qemu:///system') | |
domain = findDomainWithMac(conn, '52:54:00:b6:53:32') | |
print domain.name() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment