From 79e61184117ceb81c5b37a68b99f33a5dc395302 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 19 Jun 2018 19:50:29 -0400 Subject: [PATCH] Remove any updates of hypervisor domain_list from the VMInstance; this is all handled during node keepalive --- pvcd/VMInstance.py | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/pvcd/VMInstance.py b/pvcd/VMInstance.py index f0d0f17c..ae7161fb 100644 --- a/pvcd/VMInstance.py +++ b/pvcd/VMInstance.py @@ -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: