Add terminate option instead of using stop (which screws with ZK state)

This commit is contained in:
Joshua Boniface 2018-06-06 21:47:06 -04:00
parent 3f25f89324
commit 155e48ce94
1 changed files with 15 additions and 1 deletions

View File

@ -92,6 +92,20 @@ class VMInstance:
self.dom = dom self.dom = dom
self.instart = False 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 # Stop the VM forcibly
def stop_vm(self): def stop_vm(self):
print(">>> %s - Forcibly stopping VM" % self.domuuid) print(">>> %s - Forcibly stopping VM" % self.domuuid)
@ -229,7 +243,7 @@ class VMInstance:
# VM should be running but not on this hypervisor # 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: 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 # VM is already running and should be
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name: elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name: