Fix: Make vim-emu ready for the upcoming Containernet release 36/7736/1
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 2 Jul 2019 11:01:36 +0000 (13:01 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 2 Jul 2019 11:01:36 +0000 (13:01 +0200)
Change-Id: Ia501fbf723d8ea508be05c0adeaf6d2b0dbc8c9e
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
src/emuvim/dcemulator/net.py

index 6258543..8b2c445 100755 (executable)
@@ -385,6 +385,18 @@ class DCNetwork(Containernet):
             switch_node = self.getNodeByName(src_sw)
             self._set_vlan_tag(switch_node, src_sw_inport_name, vlan)
 
+    def getNodeByName(self, name):
+        """
+        Wraps Containernet's getNodeByName method to avoid
+        key not found exceptions.
+        """
+        try:
+            return super(DCNetwork, self).getNodeByName(name)
+        except BaseException as ex:
+            LOG.warning("Node not found: {}".format(name))
+            LOG.debug("Node not found: {}".format(ex))
+        return None
+
     def _addMonitorFlow(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None,
                         tag=None, **kwargs):
         """