Catch exceptions to avoid crashing the cleanup
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Mon, 21 May 2018 08:12:18 +0000 (10:12 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Mon, 21 May 2018 08:12:18 +0000 (10:12 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/nitsi/test.py

index 42d7f16..c46d7df 100755 (executable)
@@ -114,9 +114,18 @@ class test():
 
     def virtual_environ_stop(self):
         for name in self.virtual_environ.machine_names:
-            self.virtual_machines[name].shutdown()
-            self.virtual_machines[name].revert_snapshot()
-            self.virtual_machines[name].undefine()
+            # We just catch exception here to avoid
+            # that we stop the cleanup process if only  one command fails
+            try:
+                self.virtual_machines[name].shutdown()
+                self.virtual_machines[name].revert_snapshot()
+                self.virtual_machines[name].undefine()
+            except BaseException as e:
+                self.log.exception(e)
 
         for name in self.virtual_environ.network_names:
-            self.virtual_networks[name].undefine()
+            try:
+                self.virtual_networks[name].undefine()
+            except BaseException as e:
+                 self.log.exception(e)
+