From 155e48ce9496712784fbf50278fcb236e7da50cb Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 6 Jun 2018 21:47:06 -0400 Subject: [PATCH] Add terminate option instead of using stop (which screws with ZK state) --- VMInstance.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/VMInstance.py b/VMInstance.py index bfbeb3fa..7947c62f 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -92,6 +92,20 @@ class VMInstance: self.dom = dom self.instart = False + # Stop the VM forcibly without updating state + def terminate_vm(self): + print(">>> %s - Terminating VM" % self.domuuid) + self.instop = True + try: + self.dom.destroy() + except AttributeError: + pass + if self.domuuid in self.thishypervisor.domain_list: + try: + self.thishypervisor.domain_list.remove(self.domuuid) + except ValueError: + pass + # Stop the VM forcibly def stop_vm(self): print(">>> %s - Forcibly stopping VM" % self.domuuid) @@ -229,7 +243,7 @@ class VMInstance: # VM should be running but not on this hypervisor elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor != self.thishypervisor.name: - self.stop_vm() + self.terminate_vm() # VM is already running and should be elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name: