From 778eff2d7d1872f30b8339eecd27d4ccc3d255e7 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 17 Jul 2018 12:17:22 -0400 Subject: [PATCH] Ensure running VMs are in domain_list Addresses #7 --- pvcd/NodeInstance.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pvcd/NodeInstance.py b/pvcd/NodeInstance.py index 9de91d95..3ee0453e 100644 --- a/pvcd/NodeInstance.py +++ b/pvcd/NodeInstance.py @@ -223,6 +223,13 @@ class NodeInstance(): # Toggle a state "change" 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 self.name = lv_conn.getHostname() self.memused = int(psutil.virtual_memory().used / 1024 / 1024)