From patchwork Fri Nov 8 11:15:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1191823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="bAFBwwmU"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 478d6T6fYhz9sNH for ; Fri, 8 Nov 2019 22:17:53 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6982513E8; Fri, 8 Nov 2019 11:15:25 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E56A613E0 for ; Fri, 8 Nov 2019 11:15:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 829B4EC for ; Fri, 8 Nov 2019 11:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573211722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2OHRt6vJWPt7Iojx/0VHw59X43MdKDW8nrh5e2lbUi0=; b=bAFBwwmUHbcx6ZbOwc+vtVNpEZS8yyFGMLsU4BrW/ooJXLQfwe3mT/iCl418zqOYIPW7Zl GJebaPydpU6ue8qe781bkddPx/X/hXtDvZmLad3GrM7f5p0MzEyXjCwEAF3NB7wu7sFeID kfd3AQSKoGJRr3tpzjXFdDq70tsHdM8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-BH_VUhF9PeqSv7JHU13gbA-1; Fri, 08 Nov 2019 06:15:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F268107ACC4; Fri, 8 Nov 2019 11:15:18 +0000 (UTC) Received: from dceara.remote.csb (ovpn-117-112.ams2.redhat.com [10.36.117.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF7765D6B7; Fri, 8 Nov 2019 11:15:17 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 8 Nov 2019 12:15:15 +0100 Message-Id: <20191108111511.10100.37826.stgit@dceara.remote.csb> In-Reply-To: <20191108111457.10100.28180.stgit@dceara.remote.csb> References: <20191108111457.10100.28180.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: BH_VUhF9PeqSv7JHU13gbA-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH ovn 1/3] ovn-detrace: Fix rundir. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org After the separation of OVS and OVN rundirs, the ovn-detrace script hasn't been updated to use the OVN rundir instead of the OVS one. Signed-off-by: Dumitru Ceara --- utilities/ovn-detrace.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in index c842adc..9471e37 100755 --- a/utilities/ovn-detrace.in +++ b/utilities/ovn-detrace.in @@ -169,16 +169,16 @@ def main(): "(use --help for help)\n" % argv0) sys.exit(1) - ovs_rundir = os.getenv('OVS_RUNDIR', '@RUNDIR@') + ovn_rundir = os.getenv('OVN_RUNDIR', '@OVN_RUNDIR@') if not ovnsb_db: ovnsb_db = os.getenv('OVN_SB_DB') if not ovnsb_db: - ovnsb_db = 'unix:%s/ovnsb_db.sock' % ovs_rundir + ovnsb_db = 'unix:%s/ovnsb_db.sock' % ovn_rundir if not ovnnb_db: ovnnb_db = os.getenv('OVN_NB_DB') if not ovnnb_db: - ovnnb_db = 'unix:%s/ovnnb_db.sock' % ovs_rundir + ovnnb_db = 'unix:%s/ovnnb_db.sock' % ovn_rundir ovsdb_ovnsb = OVSDB(ovnsb_db, 'OVN_Southbound') ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound') From patchwork Fri Nov 8 11:15:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1191824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="XahYceT6"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 478d716T6Vz9sNH for ; Fri, 8 Nov 2019 22:18:21 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 04BF213EE; Fri, 8 Nov 2019 11:15:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E218F13EC for ; Fri, 8 Nov 2019 11:15:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id B9507EC for ; Fri, 8 Nov 2019 11:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573211735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KWERE+vDy86o9TXSzuJT8sl4iDhb2jUSE6LuyWPNUsE=; b=XahYceT60FFKiL3rQices5ldqW7nfF5LVzqE38NEEW4AsYmWoQP6gbTCltN13oh5w1thsK gfUfplGL7KyvM7568mFyQetAZJB1WOcxfWhjCvWZ3YuaJUszaM41XMS9F6+aFds+/yFLht yzXqFQQDQG7lrNIsz8j8OkmIpvuGQ4A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-7xDhvjV0N9uxtKcxuuwf2g-1; Fri, 08 Nov 2019 06:15:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 514441800D7B; Fri, 8 Nov 2019 11:15:32 +0000 (UTC) Received: from dceara.remote.csb (ovpn-117-112.ams2.redhat.com [10.36.117.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A30060C18; Fri, 8 Nov 2019 11:15:31 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 8 Nov 2019 12:15:28 +0100 Message-Id: <20191108111523.10100.58145.stgit@dceara.remote.csb> In-Reply-To: <20191108111457.10100.28180.stgit@dceara.remote.csb> References: <20191108111457.10100.28180.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 7xDhvjV0N9uxtKcxuuwf2g-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH ovn 2/3] ovn-detrace: Fix line parsing. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- utilities/ovn-detrace.in | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) 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__": From patchwork Fri Nov 8 11:15:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1191825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="esudp6qh"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 478d7c0NtMz9sNH for ; Fri, 8 Nov 2019 22:18:52 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9789813EF; Fri, 8 Nov 2019 11:15:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 519CE13EF for ; Fri, 8 Nov 2019 11:15:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 938B7EC for ; Fri, 8 Nov 2019 11:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573211751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hK1EeA2d0bqfbOJ2oLT82+557z7d2C1682sou1a5Kvo=; b=esudp6qhOLWvx02HneiImWUqdRE6fCPxdpQJVipCPTc9SaMfRkwEP10sEMWBdgMgbYNOaB T2cmHKAGua/vu6w2RSF9J/ThxclNw7g/46BeI4QeM0RIYYGOQNYi4zzM3ji/VJv5L4/yen C5pzc2G7WIPUONO8iN8VF9RGPhlNjFo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-pLkVpWoKP42majSQnob0vw-1; Fri, 08 Nov 2019 06:15:48 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F1B78017DE; Fri, 8 Nov 2019 11:15:47 +0000 (UTC) Received: from dceara.remote.csb (ovpn-117-112.ams2.redhat.com [10.36.117.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id B908560C18; Fri, 8 Nov 2019 11:15:46 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 8 Nov 2019 12:15:41 +0100 Message-Id: <20191108111537.10100.38432.stgit@dceara.remote.csb> In-Reply-To: <20191108111457.10100.28180.stgit@dceara.remote.csb> References: <20191108111457.10100.28180.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: pLkVpWoKP42majSQnob0vw-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH ovn 3/3] ovn-detrace: Add support for other types of SB cookies. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Commit eb25a7da639e ("Improve debuggability of OVN to OpenFlow translations.") added cookies for Port_Binding, Mac_Binding, Multicast_Group, Chassis records to the OpenfFlow entries they generate. Add support for parsing such cookies in ovn-detrace too. Also, refactor ovn-detrace to allow a more generic way of defining cookie handlers. Signed-off-by: Dumitru Ceara --- utilities/ovn-detrace.in | 166 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 117 insertions(+), 49 deletions(-) diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in index 34b6b0e..79c6d3b 100755 --- a/utilities/ovn-detrace.in +++ b/utilities/ovn-detrace.in @@ -98,48 +98,112 @@ class OVSDB(object): def find_row_by_partial_uuid(self, table_name, value): return self._find_row(table_name, lambda row: value in str(row.uuid)) - -def get_lflow_from_cookie(ovnsb_db, cookie): - return ovnsb_db.find_row_by_partial_uuid('Logical_Flow', cookie) - - -def print_lflow(lflow, prefix): - ldp_uuid = lflow.logical_datapath.uuid - ldp_name = str(lflow.logical_datapath.external_ids.get('name')) - - print '%sLogical datapath: "%s" (%s) [%s]' % (prefix, - ldp_name, - ldp_uuid, - lflow.pipeline) - print "%sLogical flow: table=%s (%s), priority=%s, " \ - "match=(%s), actions=(%s)" % (prefix, - lflow.table_id, - lflow.external_ids.get('stage-name'), - lflow.priority, - str(lflow.match).strip('"'), - str(lflow.actions).strip('"')) - - -def print_lflow_nb_hint(lflow, prefix, ovnnb_db): - external_ids = lflow.external_ids - if external_ids.get('stage-name') in ['ls_in_acl', - 'ls_out_acl']: - acl_hint = external_ids.get('stage-hint') - if not acl_hint: - return - acl = ovnnb_db.find_row_by_partial_uuid('ACL', acl_hint) - if not acl: +class CookieHandler(object): + def __init__(self, db, table): + self._db = db + self._table = table + + def get_record(self, cookie): + return self._db.find_row_by_partial_uuid(self._table, cookie) + + def print_record(self, record, prefix): + pass + + def print_hint(self, record, prefix, db): + pass + +def datapath_str(datapath): + return '"%s" (%s)' % (str(datapath.external_ids.get('name')), + datapath.uuid) + +def chassis_str(chassis): + if len(chassis) == 0: + return '' + ch = chassis[0] + return 'chassis-name "%s", chassis-str "%s"' % (ch.name, ch.hostname) + +class LogicalFlowHandler(CookieHandler): + def __init__(self, ovnsb_db): + super(LogicalFlowHandler, self).__init__(ovnsb_db, 'Logical_Flow') + + def print_record(self, lflow, prefix): + print('%sLogical datapath: %s [%s]' % + (prefix, datapath_str(lflow.logical_datapath), lflow.pipeline)) + print('%sLogical flow: table=%s (%s), priority=%s, ' + 'match=(%s), actions=(%s)' % + (prefix, lflow.table_id, lflow.external_ids.get('stage-name'), + lflow.priority, + str(lflow.match).strip('"'), + str(lflow.actions).strip('"'))) + + def print_hint(self, lflow, prefix, ovnnb_db): + external_ids = lflow.external_ids + if external_ids.get('stage-name') in ['ls_in_acl', + 'ls_out_acl']: + acl_hint = external_ids.get('stage-hint') + if not acl_hint: + return + acl = ovnnb_db.find_row_by_partial_uuid('ACL', acl_hint) + if not acl: + return + output = '%sACL: %s, priority=%s, ' \ + 'match=(%s), %s' % (prefix, + acl.direction, + acl.priority, + acl.match.strip('"'), + acl.action) + if acl.log: + output += ' (log)' + print(output) + +class PortBindingHandler(CookieHandler): + def __init__(self, ovnsb_db): + super(PortBindingHandler, self).__init__(ovnsb_db, 'Port_Binding') + + def print_record(self, pb, prefix): + ldp_uuid = pb.datapath.uuid + ldp_name = str(pb.datapath.external_ids.get('name')) + + print('%sLogical datapath: %s' % (prefix, datapath_str(pb.datapath))) + print('%sPort Binding: logical_port "%s", tunnel_key %ld, %s' % + (prefix, pb.logical_port, pb.tunnel_key, + chassis_str(pb.chassis))) + +class MacBindingHandler(CookieHandler): + def __init__(self, ovnsb_db): + super(MacBindingHandler, self).__init__(ovnsb_db, 'MAC_Binding') + + def print_record(self, mb, prefix): + print('%sLogical datapath: %s' % (prefix, datapath_str(mb.datapath))) + print('%sMAC Binding: ip "%s", logical_port "%s", mac "%s"' % + (prefix, mb.ip, mb.logical_port, mb.mac)) + +class MulticastGroupHandler(CookieHandler): + def __init__(self, ovnsb_db): + super(MulticastGroupHandler, self).__init__(ovnsb_db, + 'Multicast_Group') + + def print_record(self, mc, prefix): + mc_ports = ', '.join([pb.logical_port for pb in mc.ports]) + + print('%sLogical datapath: %s' % (prefix, datapath_str(mc.datapath))) + print('%sMulticast Group: name "%s", tunnel_key %ld ports: (%s)' % + (prefix, mc.name, mc.tunnel_key, mc_ports)) + +class ChassisHandler(CookieHandler): + def __init__(self, ovnsb_db): + super(ChassisHandler, self).__init__(ovnsb_db, 'Chassis') + + def print_record(self, chassis, prefix): + print('%sChassis: %s' % (prefix, chassis_str([chassis]))) + +def print_sb_record_from_cookie(ovnnb_db, ovnsb_db, cookie_handlers, cookie): + for handler in cookie_handlers: + sb_record = handler.get_record(cookie) + if sb_record: + handler.print_record(sb_record, " * ") + handler.print_hint(sb_record, " * ", ovnnb_db) return - output = "%sACL: %s, priority=%s, " \ - "match=(%s), %s" % (prefix, - acl.direction, - acl.priority, - acl.match.strip('"'), - acl.action) - if acl.log: - output += ' (log)' - print output - def main(): try: @@ -183,6 +247,14 @@ def main(): ovsdb_ovnsb = OVSDB(ovnsb_db, 'OVN_Southbound') ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound') + cookie_handlers = [ + LogicalFlowHandler(ovsdb_ovnsb), + PortBindingHandler(ovsdb_ovnsb), + MacBindingHandler(ovsdb_ovnsb), + MulticastGroupHandler(ovsdb_ovnsb), + ChassisHandler(ovsdb_ovnsb) + ] + regex_cookie = re.compile(r'^.*cookie 0x([0-9a-fA-F]+)') regex_table_id = re.compile(r'^[0-9]+\.') cookie = None @@ -194,14 +266,10 @@ def main(): line = line.strip() - if cookie: - # print lflow info when the current flow block ends - if regex_table_id.match(line): - lflow = get_lflow_from_cookie(ovsdb_ovnsb, cookie) - if lflow: - print_lflow(lflow, " * ") - print_lflow_nb_hint(lflow, " * ", ovsdb_ovnnb) - cookie = None + # Print SB record info when the current flow block ends. + if cookie and regex_table_id.match(line): + print_sb_record_from_cookie(ovsdb_ovnnb, ovsdb_ovnsb, + cookie_handlers, cookie) print line