vswitches/ovs: delete bridges on stop 55/54655/4
authorJulien Meunier <julien.meunier@6wind.com>
Thu, 12 Apr 2018 07:39:27 +0000 (09:39 +0200)
committerJulien Meunier <julien.meunier@6wind.com>
Thu, 19 Apr 2018 07:58:12 +0000 (09:58 +0200)
On stop, remove all created bridges in order to clean the working
environment.

Moreover, when an OVS bridge is deleted, remove also all attached ports.

By the way, as the context manager of OFBridge is never used by the
current test implementation and by any OVS vswitches in order to manage
their creation/deletion, let's remove this dead code.

JIRA: VSPERF-570

Change-Id: I7ce62d56a8a2fe7b45e693f3c2dd91e1b435567c
Signed-off-by: Julien Meunier <julien.meunier@6wind.com>
src/ovs/ofctl.py
vswitches/ovs.py

index b023e08..21da850 100644 (file)
@@ -156,21 +156,6 @@ class OFBridge(OFBase):
         self._ports = {}
         self._cache_file = None
 
-    # context manager
-
-    def __enter__(self):
-        """Create datapath
-
-        :returns: self
-        """
-        return self
-
-    def __exit__(self, type_, value, traceback):
-        """Remove datapath.
-        """
-        if not traceback:
-            self.destroy()
-
     # helpers
 
     def run_ofctl(self, args, check_error=False, timeout=None):
index 9e49b2e..6f65000 100644 (file)
@@ -128,6 +128,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
     def stop(self):
         """See IVswitch for general description
         """
+        for switch_name in list(self._bridges):
+            self.del_switch(switch_name)
         self._logger.info("Terminating vswitchd...")
         self.kill()
         self._bridges = {}
@@ -147,6 +149,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
         """See IVswitch for general description
         """
         bridge = self._bridges[switch_name]
+        for port in list(bridge.get_ports()):
+            bridge.del_port(port)
         self._bridges.pop(switch_name)
         bridge.destroy()