From 0fd8ecc019fa11255641cca9526c2982f0eb2b4a Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 17 Jul 2018 21:51:49 -0400 Subject: [PATCH] Correct working of getmemory function --- pvcd/NodeInstance.py | 2 +- pvcd/VMInstance.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pvcd/NodeInstance.py b/pvcd/NodeInstance.py index ce4a30c8..690cc437 100644 --- a/pvcd/NodeInstance.py +++ b/pvcd/NodeInstance.py @@ -231,7 +231,7 @@ class NodeInstance(): for domain, instance in self.s_domain.items(): if instance.inshutdown == False and domain in self.domain_list: # Add the allocated memory to our memalloc value - memalloc += instance.getmaxmemory() + memalloc += instance.getmemory() if instance.getstate() == 'start' and instance.gethypervisor() == self.name: if instance.getdom() != None: try: diff --git a/pvcd/VMInstance.py b/pvcd/VMInstance.py index 05f2d91f..21081420 100644 --- a/pvcd/VMInstance.py +++ b/pvcd/VMInstance.py @@ -45,11 +45,6 @@ class VMInstance: self.dom = self.lookupByUUID(self.domuuid) - try: - self.maxmemory = self.dom.maxMemory() - except: - self.maxmemory = 0 - # Watch for changes to the state field in Zookeeper @zk_conn.DataWatch('/domains/{}/state'.format(self.domuuid)) def watch_state(data, stat, event=""): @@ -70,8 +65,13 @@ class VMInstance: def getdom(self): return self.dom - def getmaxmemory(self): - return self.maxmemory + def getmemory(self): + try: + memory = self.dom.info()[2] / 1024 + except: + memory = 0 + + return memory # Manage local node domain_list def addDomainToList(self):