Browse code

In worlddump, execute ovs-ofctl for an only existing bridge

When devstack fails, some or all bridges may not exist.
This change allows an only existing bridge to executes ovs-ofctl command.
And fix duplicate ofp version specified in protocol option of ovs-ofctl.

Change-Id: Ied01de727ca9b867ce87db358f72ae44838b63af
(cherry picked from commit 578459f8088474f8b1d1d29e4ca6f3aa3a5f42c5)

fumihiko kakuma authored on 2016/04/07 08:15:45
Showing 1 changed files
... ...
@@ -76,6 +76,12 @@ def _header(name):
76 76
     print
77 77
 
78 78
 
79
+def _bridge_list():
80
+    process = subprocess.Popen(['ovs-vsctl', 'list-br'], stdout=subprocess.PIPE)
81
+    stdout, _ = process.communicate()
82
+    return stdout.split()
83
+
84
+
79 85
 # This method gets a max openflow version supported by openvswitch.
80 86
 # For example 'ovs-ofctl --version' displays the following:
81 87
 #
... ...
@@ -157,14 +163,11 @@ def ovs_dump():
157 157
     if not _find_cmd('ovs-vsctl'):
158 158
         return
159 159
 
160
-    # NOTE(ihrachys): worlddump is used outside of devstack context (f.e. in
161
-    # grenade), so there is no single place to determine the bridge names from.
162
-    # Hardcode for now.
163
-    bridges = ('br-int', 'br-tun', 'br-ex')
160
+    bridges = _bridge_list()
164 161
     ofctl_cmds = ('show', 'dump-ports-desc', 'dump-ports', 'dump-flows')
165 162
     ofp_max = _get_ofp_version()
166 163
     vers = 'OpenFlow10'
167
-    for i in range(ofp_max + 1):
164
+    for i in range(1, ofp_max + 1):
168 165
         vers += ',OpenFlow1' + str(i)
169 166
     _dump_cmd("sudo ovs-vsctl show")
170 167
     for ofctl_cmd in ofctl_cmds: