From 152cba5e192a6fed0e597635bf8b73cff5f4ec3c Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sat, 2 Jun 2018 15:39:17 -0400 Subject: [PATCH] Fix this to handle errors --- VMInstance.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/VMInstance.py b/VMInstance.py index ac4cc949..5eab9246 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -70,14 +70,20 @@ class VMInstance: print(self.zkey) self.zk.set(self.zkey + '/state', 'migrate'.encode('ascii')) - dest_conn = libvirt.open('qemu+ssh://%s/system' % self.hypervisor) - if dest_conn == None: + try: + dest_conn = libvirt.open('qemu+ssh://%s/system' % self.hypervisor) + if dest_conn == None: + raise + except: self.zk.set(self.zkey + '/state', 'start'.encode('ascii')) print('Failed to open connection to qemu+ssh://%s/system' % target) return - target_dom = self.dom.migrate(dest_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0) - if target_dom == None: + try: + target_dom = self.dom.migrate(dest_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0) + if target_dom == None: + raise + except: print('Could not migrate to the new domain') self.stop_vm()