Ensure running VMs are in domain_list

Addresses #7
This commit is contained in:
Joshua Boniface 2018-07-17 12:17:22 -04:00
parent fa46bd47d6
commit 778eff2d7d
1 changed files with 7 additions and 0 deletions

View File

@ -223,6 +223,13 @@ class NodeInstance():
# Toggle a state "change" # Toggle a state "change"
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(domain): instance.getstate() }) zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(domain): instance.getstate() })
# Ensure that any running VMs are readded to the domain_list
running_domains = lv_conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE)
for domain in running_domains:
domain_uuid = domain.UUIDString()
if domain_uuid not in self.domain_list:
self.domain_list.append(domain_uuid)
# Set our information in zookeeper # Set our information in zookeeper
self.name = lv_conn.getHostname() self.name = lv_conn.getHostname()
self.memused = int(psutil.virtual_memory().used / 1024 / 1024) self.memused = int(psutil.virtual_memory().used / 1024 / 1024)