From: Ondrej Lichtner <olichtne(a)redhat.com>
The unmap_if method now checks if the if_id is present in _id_mapping or
_tmp_mapping.
Even though this method should only be called in the cleanup phase of a
test run when every interface should have been moved to _id_mapping this
patch should prevent exceptions being thrown in unexpected scenarios.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/InterfaceManager.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index a557322..de2042d 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -52,7 +52,12 @@ class InterfaceManager(object):
return
def unmap_if(self, if_id):
- del self._id_mapping[if_id]
+ if if_id in self._id_mapping:
+ del self._id_mapping[if_id]
+ elif if_id in self._tmp_mapping:
+ del self._tmp_mapping[if_id]
+ else:
+ pass
def clear_if_mapping(self):
self._id_mapping = {}
--
1.9.3