Gracefully handle not being able to remove oruself from list

This commit is contained in:
2018-06-02 15:43:02 -04:00
parent 152cba5e19
commit a155eb5fab
2 changed files with 9 additions and 3 deletions

View File

@ -56,14 +56,20 @@ class VMInstance:
print("Forcibly stopping VM %s" % self.domuuid)
self.dom.destroy()
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
def shutdown_vm(self):
print("Stopping VM %s" % self.domuuid)
self.dom.shutdown()
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
def migrate_vm(self):