kvmクエリー(python)
#!/usr/bin/python
import libvirt
conn=libvirt.open('qemu:///system')
print "Freememory: %s"%(conn.getFreeMemory())
print "Hostname: %s"%(conn.getHostname())
print "Info: %s"%(conn.getInfo())
print "Type: %s"%(conn.getType())
print "Url: %s"%(conn.getURI())
print "Version: %s"%(conn.getVersion())
print "isAlive: %s"%(conn.isAlive())
print "Num0defineDomains: %s"%(conn.numOfDefinedDomains())
for id in conn.listDefinedDomains():
print "ID: %s"%id
for po in conn.listStoragePools():
print "Pools: %s"%po
print "num of domain is %d"%(conn.numOfDomains())
for i in conn.listDomainsID():
dom=conn.lookupByID(i)
print "ID:%d"%(dom.ID())
print "OSType:%s"%(dom.OSType())
for id in conn.listDomainsID():
dom=conn.lookupByID(id)
print "Dom %s:State %s,OS_type %s,maxMem %d MB,maxVCPU %d"%(dom.name(),dom.info()[0],dom.OSType(),dom.maxMemory()/1024,dom.maxVcpus())
本文は“muzinanの技術のブログ”のブログから出て、転載をお断りします!