Clean up some handling of restarting dead VMs
This commit is contained in:
parent
dd2560c2f8
commit
a87bf4bc4a
|
@ -200,28 +200,17 @@ class NodeInstance():
|
||||||
else:
|
else:
|
||||||
self.daemon_state = 'start'
|
self.daemon_state = 'start'
|
||||||
|
|
||||||
# Toggle state management of dead VMs
|
# Toggle state management of dead VMs to restart them
|
||||||
for domain, instance in self.s_domain.items():
|
for domain, instance in self.s_domain.items():
|
||||||
if instance.inshutdown == False and domain in self.domain_list:
|
if instance.inshutdown == False and domain in self.domain_list:
|
||||||
if instance.getstate() == 'start' and instance.gethypervisor() == self.name and instance.dom == None:
|
if instance.getstate() == 'start' and instance.gethypervisor() == self.name:
|
||||||
instance.manage_vm_state()
|
if instance.getdom() != None:
|
||||||
|
|
||||||
if instance.dom == None:
|
|
||||||
try:
|
|
||||||
self.domain_list.remove(domain)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
state = instance.dom.state()[0]
|
|
||||||
except:
|
|
||||||
state = libvirt.VIR_DOMAIN_NOSTATE
|
|
||||||
|
|
||||||
if state != libvirt.VIR_DOMAIN_RUNNING:
|
|
||||||
try:
|
try:
|
||||||
self.domain_list.remove(domain)
|
if instance.getdom().state()[0] != libvirt.VIR_DOMAIN_RUNNING:
|
||||||
except:
|
raise
|
||||||
pass
|
except Exception as e:
|
||||||
|
# Toggle a state "change"
|
||||||
|
self.zk.set('/domains/{}/state'.format(domain), instance.getstate().encode('ascii'))
|
||||||
|
|
||||||
# Set our information in zookeeper
|
# Set our information in zookeeper
|
||||||
self.name = conn.getHostname()
|
self.name = conn.getHostname()
|
||||||
|
|
|
@ -54,6 +54,9 @@ class VMInstance:
|
||||||
def gethypervisor(self):
|
def gethypervisor(self):
|
||||||
return self.hypervisor
|
return self.hypervisor
|
||||||
|
|
||||||
|
def getdom(self):
|
||||||
|
return self.dom
|
||||||
|
|
||||||
# Start up the VM
|
# Start up the VM
|
||||||
def start_vm(self, xmlconfig):
|
def start_vm(self, xmlconfig):
|
||||||
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')
|
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')
|
||||||
|
|
Loading…
Reference in New Issue