Make this work better and stop bad VMs
This commit is contained in:
@ -114,24 +114,34 @@ class VMInstance:
|
||||
except:
|
||||
running = libvirt.VIR_DOMAIN_NOSTATE
|
||||
|
||||
# VM should be stopped
|
||||
if running == libvirt.VIR_DOMAIN_RUNNING and self.state == "stop" and self.hypervisor == self.thishypervisor.name:
|
||||
self.stop_vm()
|
||||
|
||||
if running == libvirt.VIR_DOMAIN_RUNNING and self.state == "shutdown" and self.hypervisor == self.thishypervisor.name:
|
||||
# VM should not be running on this hypervisor
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor != self.thishypervisor.name:
|
||||
self.stop_vm()
|
||||
|
||||
# VM should be shut down
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "shutdown" and self.hypervisor == self.thishypervisor.name:
|
||||
self.shutdown_vm()
|
||||
|
||||
# VM should be migrated to this hypervisor
|
||||
elif running != libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor == self.thishypervisor.name:
|
||||
self.receive_migrate()
|
||||
|
||||
|
||||
# VM should be migrated away from this hypervisor
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name:
|
||||
self.migrate_vm()
|
||||
|
||||
# VM should be started
|
||||
elif running != libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name:
|
||||
# Grab the domain information from Zookeeper
|
||||
domxml, domxmlstat = self.zk.get(self.zkey + '/xml')
|
||||
domxml = str(domxml.decode('ascii'))
|
||||
self.dom = self.start_vm(conn, domxml)
|
||||
|
||||
# VM is already running and should be
|
||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "start" and self.hypervisor == self.thishypervisor.name:
|
||||
if not self.domuuid in self.thishypervisor.domain_list:
|
||||
self.thishypervisor.domain_list.append(self.domuuid)
|
||||
|
Reference in New Issue
Block a user