[ovs-dev,v4,ovn,2/3] ovn-detrace: Fix line parsing.
diff mbox series

Message ID 20191113095210.10768.60140.stgit@dceara.remote.csb
State Accepted
Headers show
Series
  • Improve ovn-detrace support for parsing OpenFlow cookies.
Related show

Commit Message

Dumitru Ceara Nov. 13, 2019, 9:52 a.m. UTC
The script was not properly parsing rows containing flows from
tables 0-9 because ofproto/trace adds leading whitespace for
pretty printing flows.
Also, add a check to make sure that the cookie refers to a
Logical_Flow before trying to print the record.

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
 utilities/ovn-detrace.in |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in
index 9471e37..accbcd2 100755
--- a/utilities/ovn-detrace.in
+++ b/utilities/ovn-detrace.in
@@ -184,7 +184,7 @@  def main():
     ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound')
 
     regex_cookie = re.compile(r'^.*cookie 0x([0-9a-fA-F]+)')
-    regex_table_id = re.compile(r'^[0-9]+\.')
+    regex_table_id = re.compile(r'^ *[0-9]+\.')
     cookie = None
     while True:
         line = sys.stdin.readline()
@@ -192,8 +192,9 @@  def main():
             # print lflow info when the current flow block ends
             if regex_table_id.match(line) or line.strip() == '':
                 lflow = get_lflow_from_cookie(ovsdb_ovnsb, cookie)
-                print_lflow(lflow, "  * ")
-                print_lflow_nb_hint(lflow, "    * ", ovsdb_ovnnb)
+                if lflow:
+                    print_lflow(lflow, "  * ")
+                    print_lflow_nb_hint(lflow, "    * ", ovsdb_ovnnb)
                 cookie = None
 
         print line.strip()