From: Ondrej Lichtner <olichtne(a)redhat.com>
Instead of crashing with a traceback we just log a warning message
saying that the device wasn't found, for the set_unmapped_device_down
method.
For the regular set_device_down method we log an error message and
return False since this probably influences the results of the test.
This still won't stop the test from running but it should at least be
more visible.
Fixes #122
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NetTestSlave.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index d186757..efcdfdd 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -172,12 +172,19 @@ class SlaveMethods:
def set_device_down(self, if_id):
dev = self._if_manager.get_mapped_device(if_id)
- dev.down()
+ if dev is not None:
+ dev.down()
+ else:
+ logging.error("Device with id '%s' not found." % if_id)
+ return False
return True
def set_unmapped_device_down(self, hwaddr):
dev = self._if_manager.get_device_by_hwaddr(hwaddr)
- dev.down()
+ if dev is not None:
+ dev.down()
+ else:
+ logging.warning("Device with hwaddr '%s' not found." %
hwaddr)
return True
def configure_interface(self, if_id, config):
--
2.1.0