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

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

Commit Message

Dumitru Ceara Nov. 12, 2019, 4:15 p.m. UTC
The script was never parsing the first cookie in the input. 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 |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

Patch
diff mbox series

diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in
index 9471e37..34b6b0e 100755
--- a/utilities/ovn-detrace.in
+++ b/utilities/ovn-detrace.in
@@ -188,22 +188,26 @@  def main():
     cookie = None
     while True:
         line = sys.stdin.readline()
+
+        if line == '':
+            break
+
+        line = line.strip()
+
         if cookie:
             # print lflow info when the current flow block ends
-            if regex_table_id.match(line) or line.strip() == '':
+            if regex_table_id.match(line):
                 lflow = get_lflow_from_cookie(ovsdb_ovnsb, cookie)
-                print_lflow(lflow, "  * ")
-                print_lflow_nb_hint(lflow, "    * ", ovsdb_ovnnb)
-                cookie = None
+                if lflow:
+                    print_lflow(lflow, "  * ")
+                    print_lflow_nb_hint(lflow, "    * ", ovsdb_ovnnb)
+                    cookie = None
 
-        print line.strip()
-        if line == "":
-            break
+        print line
 
         m = regex_cookie.match(line)
-        if not m:
-            continue
-        cookie = m.group(1)
+        if m:
+            cookie = m.group(1)
 
 
 if __name__ == "__main__":