From: Ondrej Lichtner <olichtne(a)redhat.com>
VirtualDevices are created by the Controller so they should also be
cleaned up by the Controller.
Also added exception handling to the Controller machine cleanup method -
the exception must be logged and should be reported as recipe failure
but shouldn't stop the cleanup of the other slave machines.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Controller.py | 17 +++++++++++++----
lnst/Controller/Machine.py | 5 -----
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lnst/Controller/Controller.py b/lnst/Controller/Controller.py
index d1ccf61..cdce799 100644
--- a/lnst/Controller/Controller.py
+++ b/lnst/Controller/Controller.py
@@ -183,10 +183,19 @@ class Controller(object):
return
for m_id, machine in self._machines.iteritems():
- machine.cleanup()
- #clean-up slave logger
- self._log_ctl.remove_slave(m_id)
- machine.set_mapped(False)
+ try:
+ machine.cleanup()
+ except:
+ #TODO report errors during deconfiguration as FAIL!!
+ log_exc_traceback()
+ finally:
+ for dev in machine._device_database.values():
+ if isinstance(dev, VirtualDevice):
+ dev._destroy()
+
+ #clean-up slave logger
+ self._log_ctl.remove_slave(m_id)
+ machine.set_mapped(False)
self._machines.clear()
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 042d8e2..a604ede 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -295,11 +295,6 @@ class Machine(object):
self.rpc_call("destroy_devices", netns=netns)
self.rpc_call("destroy_devices")
- for dev in self._device_database.values():
- if isinstance(dev, VirtualDevice):
- dev._destroy()
- self._device_database = {}
-
def cleanup(self):
""" Clean the machine up
--
2.19.0