From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds cleanup to some places that it makes sense and it
wasn't done previously. Mainly when there are errors during
configuration the already configured parts will be cleaned up.
Another case that didn't work properly was when lnst was interrupted
by Ctrl-C during configuration.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestController.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 910b40e..fe92b16 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -418,7 +418,14 @@ class NetTestController:
return {"passed": True}
def config_only_recipe(self):
- self._prepare_network()
+ try:
+ self._prepare_network()
+ except (KeyboardInterrupt, Exception) as exc:
+ msg = "Exception raised during configuration."
+ logging.error(msg)
+ self._cleanup_slaves()
+ raise
+
self._cleanup_slaves(deconfigure=False)
return {"passed": True}
@@ -426,9 +433,10 @@ class NetTestController:
try:
self._prepare_network()
self._prepare_tasks()
- except Exception as exc:
+ except (KeyboardInterrupt, Exception) as exc:
msg = "Exception raised during configuration."
logging.error(msg)
+ self._cleanup_slaves()
raise
if packet_capture:
--
1.8.3.1