commit 7986a213bc2a20dde3ccd30caab575442966f352
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu May 7 13:31:48 2015 +0200
NetTestSlave: don't crash when deconfiguration fails
Trying to deconfigure a device that wasn't configured causes lnst-slave
to get into an inconsistent state. This patch fixes the issue by
skipping the deconfiguration and logging an error message.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Slave/InterfaceManager.py | 2 +-
lnst/Slave/NetTestSlave.py | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index b2bb92e..5727646 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -132,7 +132,7 @@ class InterfaceManager(object):
elif if_id in self._tmp_mapping:
return self._tmp_mapping[if_id]
else:
- raise IfMgrError("No device with id %s mapped." % if_id)
+ return None
def get_mapped_devices(self):
ret = {}
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 8eb1f99..ec6de85 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -253,7 +253,10 @@ class SlaveMethods:
def deconfigure_interface(self, if_id):
device = self._if_manager.get_mapped_device(if_id)
- device.clear_configuration()
+ if device is not None:
+ device.clear_configuration()
+ else:
+ logging.error("No device with id '%s' to deconfigure." %
if_id)
return True
def start_packet_capture(self, filt):
Show replies by thread