Correct working of getmemory function

This commit is contained in:
Joshua Boniface 2018-07-17 21:51:49 -04:00
parent 329aa93d81
commit 0fd8ecc019
2 changed files with 8 additions and 8 deletions

View File

@ -231,7 +231,7 @@ class NodeInstance():
for domain, instance in self.s_domain.items(): for domain, instance in self.s_domain.items():
if instance.inshutdown == False and domain in self.domain_list: if instance.inshutdown == False and domain in self.domain_list:
# Add the allocated memory to our memalloc value # 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.getstate() == 'start' and instance.gethypervisor() == self.name:
if instance.getdom() != None: if instance.getdom() != None:
try: try:

View File

@ -45,11 +45,6 @@ class VMInstance:
self.dom = self.lookupByUUID(self.domuuid) 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 # Watch for changes to the state field in Zookeeper
@zk_conn.DataWatch('/domains/{}/state'.format(self.domuuid)) @zk_conn.DataWatch('/domains/{}/state'.format(self.domuuid))
def watch_state(data, stat, event=""): def watch_state(data, stat, event=""):
@ -70,8 +65,13 @@ class VMInstance:
def getdom(self): def getdom(self):
return self.dom return self.dom
def getmaxmemory(self): def getmemory(self):
return self.maxmemory try:
memory = self.dom.info()[2] / 1024
except:
memory = 0
return memory
# Manage local node domain_list # Manage local node domain_list
def addDomainToList(self): def addDomainToList(self):