def memory_usage(self):
ids = self.readonly.listDomainsID()
hostmem = self.readonly.getInfo()[1]
totalmax = 0
totalrunningmax = 0
for id in ids:
dom = self.readonly.lookupByID(id)
machinestate, maxmem, mem = dom.info()[0:3]
totalmax += maxmem / 1000
if machinestate == libvirt.VIR_DOMAIN_RUNNING:
totalrunningmax += maxmem / 1000
return (hostmem, totalmax, totalrunningmax)
评论列表
文章目录