Gracefully handle not being able to remove oruself from list
This commit is contained in:
		@@ -99,7 +99,7 @@ class NodeInstance(threading.Thread):
 | 
				
			|||||||
            for domain, instance in self.s_domain.items():
 | 
					            for domain, instance in self.s_domain.items():
 | 
				
			||||||
                instance.manage_vm_state()
 | 
					                instance.manage_vm_state()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Remove non-running VMs from our list
 | 
					            # Remove any non-running VMs from our list
 | 
				
			||||||
            for domain in self.domain_list:
 | 
					            for domain in self.domain_list:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    buuid = uuid.UUID(domain).bytes
 | 
					                    buuid = uuid.UUID(domain).bytes
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,14 +56,20 @@ class VMInstance:
 | 
				
			|||||||
        print("Forcibly stopping VM %s" % self.domuuid)
 | 
					        print("Forcibly stopping VM %s" % self.domuuid)
 | 
				
			||||||
        self.dom.destroy()
 | 
					        self.dom.destroy()
 | 
				
			||||||
        if self.domuuid in self.thishypervisor.domain_list:
 | 
					        if self.domuuid in self.thishypervisor.domain_list:
 | 
				
			||||||
            self.thishypervisor.domain_list.remove(self.domuuid)
 | 
					            try:
 | 
				
			||||||
 | 
					                self.thishypervisor.domain_list.remove(self.domuuid)
 | 
				
			||||||
 | 
					            except ValueError:
 | 
				
			||||||
 | 
					                pass
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    # Shutdown the VM gracefully
 | 
					    # Shutdown the VM gracefully
 | 
				
			||||||
    def shutdown_vm(self):
 | 
					    def shutdown_vm(self):
 | 
				
			||||||
        print("Stopping VM %s" % self.domuuid)
 | 
					        print("Stopping VM %s" % self.domuuid)
 | 
				
			||||||
        self.dom.shutdown()
 | 
					        self.dom.shutdown()
 | 
				
			||||||
        if self.domuuid in self.thishypervisor.domain_list:
 | 
					        if self.domuuid in self.thishypervisor.domain_list:
 | 
				
			||||||
            self.thishypervisor.domain_list.remove(self.domuuid)
 | 
					            try:
 | 
				
			||||||
 | 
					                self.thishypervisor.domain_list.remove(self.domuuid)
 | 
				
			||||||
 | 
					            except ValueError:
 | 
				
			||||||
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Migrate the VM to a target host
 | 
					    # Migrate the VM to a target host
 | 
				
			||||||
    def migrate_vm(self):
 | 
					    def migrate_vm(self):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user