[sos-devel] [PATCH] [plugins/openvswitch] Add flow information from OVS bridges

Stephen Ma sma102874 at gmail.com
Thu Dec 4 03:32:46 UTC 2014


Add ovs-ofctl dump-flows output to openvswitch plugin report.

Signed-off-by: Stephen Ma <stephen.ma at hp.com>
---
 sos/plugins/openvswitch.py | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/sos/plugins/openvswitch.py b/sos/plugins/openvswitch.py
index 3611671..e92d9f4 100644
--- a/sos/plugins/openvswitch.py
+++ b/sos/plugins/openvswitch.py
@@ -30,7 +30,30 @@ class OpenVSwitch(Plugin):
 
         # The '-t 5' adds an upper bound on how long to wait to connect
         # to the Open vSwitch server, avoiding hangs when running sosreport.
-        self.add_cmd_output("ovs-vsctl -t 5 show")
+        vsctl_file = self.get_cmd_output_now("ovs-vsctl -t 5 show")
+        self.get_bridge_flows(vsctl_file)
+
+    def get_bridge_flows(self, vsctl_file):
+        bridges = self.get_bridge_names(vsctl_file)
+        for bridge in bridges:
+            self.add_cmd_output("ovs-ofctl dump-flows " + bridge)
+
+    def get_bridge_names(self, vsctl_file):
+        """Return a list for which items are bridge name according to the
+        output of ovs-vsctl show stored in vsctl_file.
+        """
+        out = []
+        try:
+            vsctl_out = open(vsctl_file).read()
+        except Exception:
+            return out
+
+        for line in vsctl_out.splitlines():
+            tokens = line.split()
+            if len(tokens) == 2 and tokens[0] == "Bridge":
+                out.append(tokens[1])
+
+        return out
 
 
 class RedHatOpenVSwitch(OpenVSwitch, RedHatPlugin):
-- 
1.9.1




More information about the sos-devel mailing list