Remove any updates of hypervisor domain_list from the VMInstance; this is all handled during node keepalive

This commit is contained in:
Joshua Boniface 2018-06-19 19:50:29 -04:00
parent d39f41980b
commit 79e6118411
1 changed files with 5 additions and 38 deletions

View File

@ -81,9 +81,6 @@ class VMInstance:
# Grab the domain information from Zookeeper
xmlconfig = self.zk_conn.get('/domains/{}/xml'.format(self.domuuid))[0].decode('ascii')
dom = lv_conn.createXML(xmlconfig, 0)
if not self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.append(self.domuuid)
ansiiprint.echo('Successfully started VM', '{}:'.format(self.domuuid), 'o')
self.dom = dom
except libvirt.libvirtError as e:
@ -126,11 +123,6 @@ class VMInstance:
self.dom.destroy()
except AttributeError:
ansiiprint.echo('Failed to terminate VM', '{}:'.format(self.domuuid), 'e')
if self.domuuid in self.thishypervisor.domain_list:
try:
self.thishypervisor.domain_list.remove(self.domuuid)
except ValueError:
pass
ansiiprint.echo('Successfully terminated VM', '{}:'.format(self.domuuid), 'o')
self.dom = None
self.instop = False
@ -143,11 +135,6 @@ class VMInstance:
self.dom.destroy()
except AttributeError:
ansiiprint.echo('Failed to stop VM', '{}:'.format(self.domuuid), 'e')
if self.domuuid in self.thishypervisor.domain_list:
try:
self.thishypervisor.domain_list.remove(self.domuuid)
except ValueError:
pass
if self.inrestart == False:
self.zk_conn.set('/domains/{}/state'.format(self.domuuid), 'stop'.encode('ascii'))
@ -175,12 +162,6 @@ class VMInstance:
except:
pass
if self.domuuid in self.thishypervisor.domain_list:
try:
self.thishypervisor.domain_list.remove(self.domuuid)
except ValueError:
pass
if self.inrestart == False:
self.zk_conn.set('/domains/{}/state'.format(self.domuuid), 'stop'.encode('ascii'))
@ -219,12 +200,6 @@ class VMInstance:
ansiiprint.echo('Could not live migrate VM; shutting down to migrate instead', '{}:'.format(self.domuuid), 'e')
self.shutdown_vm()
time.sleep(1)
else:
try:
self.thishypervisor.domain_list.remove(self.domuuid)
except ValueError:
pass
time.sleep(1)
self.zk_conn.set('/domains/{}/state'.format(self.domuuid), 'start'.encode('ascii'))
self.inmigrate = False
@ -256,8 +231,6 @@ class VMInstance:
dom_state = None
if dom_state == libvirt.VIR_DOMAIN_RUNNING:
if not self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.append(self.domuuid)
ansiiprint.echo('Successfully received migrated VM', '{}:'.format(self.domuuid), 'o')
else:
ansiiprint.echo('Failed to receive migrated VM', '{}:'.format(self.domuuid), 'e')
@ -309,13 +282,10 @@ class VMInstance:
if running == libvirt.VIR_DOMAIN_RUNNING:
# VM is already running and should be
if self.state == "start":
if not self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.append(self.domuuid)
pass
# VM is already running and should be but stuck in migrate state
elif self.state == "migrate":
self.zk_conn.set('/domains/{}/state'.format(self.domuuid), 'start'.encode('ascii'))
if not self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.append(self.domuuid)
# VM should be restarted
elif self.state == "restart":
self.restart_vm()
@ -335,15 +305,12 @@ class VMInstance:
# VM should be restarted (i.e. started since it isn't running)
if self.state == "restart":
self.zk_conn.set('/domains/{}/state'.format(self.domuuid), 'start'.encode('ascii'))
# VM should be shut down; ensure it's gone from this node's domain_list
# VM should be shut down
elif self.state == "shutdown":
if self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.remove(self.domuuid)
# VM should be stoped; ensure it's gone from this node's domain_list
pass
# VM should be stoped
elif self.state == "stop":
if self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.remove(self.domuuid)
pass
else:
# Conditional pass three - Is this VM currently running on this hypervisor
if running == libvirt.VIR_DOMAIN_RUNNING: