From patchwork Thu Oct 21 09:10:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1544227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JQnOZOhd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZhYM5Wzrz9sRR for ; Thu, 21 Oct 2021 20:11:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 49FD040707; Thu, 21 Oct 2021 09:11:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z9xYXamv6XcS; Thu, 21 Oct 2021 09:11:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id C1030405F3; Thu, 21 Oct 2021 09:11:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8FD4CC001C; Thu, 21 Oct 2021 09:11:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1115FC0038 for ; Thu, 21 Oct 2021 09:11:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5ADB583AE5 for ; Thu, 21 Oct 2021 09:11:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5APWAYeKmd0r for ; Thu, 21 Oct 2021 09:11:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id BEB12831F2 for ; Thu, 21 Oct 2021 09:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807466; 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=/iwTcplcfJmE23ePfADXR0ao7J8JoRllo3lxj8gl7wQ=; b=JQnOZOhdk98mdy8p0+TUVjC8mcF3UR9Y4JDCID+GXKOCfEdliFzM5Q4WjMpLzArALwugIB tWD2BztHI/kFn22uNKTzeTW+lB7V4T4qVgfj3wc2TPPZlKrJVEc/CMyevJIkA/gwNwOAML 2U6AmwHANrD6lKc84LHye6lYkEFBEuU= 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-335-n0sfgGnbNaGBcSltfwCYMQ-1; Thu, 21 Oct 2021 05:11:03 -0400 X-MC-Unique: n0sfgGnbNaGBcSltfwCYMQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F2F787300D; Thu, 21 Oct 2021 09:11:02 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB91017A7E; Thu, 21 Oct 2021 09:11:00 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 21 Oct 2021 11:10:07 +0200 Message-Id: <20211021091007.460641-6-amorenoz@redhat.com> In-Reply-To: <20211021091007.460641-1-amorenoz@redhat.com> References: <20211021091007.460641-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: blp@ovn.org, horms@debian.org, dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v1 5/5] ovn_detrace.py: add helper to create CookieHandlers X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" That way external programs can use such handlers to create all the supported handlers. Signed-off-by: Adrian Moreno Acked-by: Dumitru Ceara --- utilities/ovn_detrace.py.in | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/utilities/ovn_detrace.py.in b/utilities/ovn_detrace.py.in index 570119d5a..dac4a1cbf 100755 --- a/utilities/ovn_detrace.py.in +++ b/utilities/ovn_detrace.py.in @@ -379,6 +379,22 @@ class OvsInterfaceHandler(CookieHandler): self.print_p('OVS Interface: %s (%s)' % (intf.name, intf.external_ids.get('iface-id'))) + +def get_cookie_handlers(ovsdb_ovnnb, ovsdb_ovnsb, printer): + return [ + LogicalFlowHandler(ovsdb_ovnnb, ovsdb_ovnsb, printer), + PortBindingHandler(ovsdb_ovnsb, printer), + MacBindingHandler(ovsdb_ovnsb, printer), + MulticastGroupHandler(ovsdb_ovnsb, printer), + ChassisHandler(ovsdb_ovnsb, printer), + SBLoadBalancerHandler(ovsdb_ovnsb, printer) + ] + +def get_ofport_handlers(ovsdb_ovs, printer): + return [ + OvsInterfaceHandler(ovsdb_ovs, printer) + ] + def print_record_from_cookie(ovnnb_db, cookie_handlers, cookie): for handler in cookie_handlers: records = list(handler.get_records(cookie)) @@ -471,15 +487,7 @@ def main(): ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound') printer = Printer() - - cookie_handlers = [ - LogicalFlowHandler(ovsdb_ovnnb, ovsdb_ovnsb, printer), - PortBindingHandler(ovsdb_ovnsb, printer), - MacBindingHandler(ovsdb_ovnsb, printer), - MulticastGroupHandler(ovsdb_ovnsb, printer), - ChassisHandler(ovsdb_ovnsb, printer), - SBLoadBalancerHandler(ovsdb_ovnsb, printer) - ] + cookie_handlers = get_cookie_handlers(ovsdb_ovnnb, ovsdb_ovnsb, printer) regex_cookie = re.compile(r'^.*cookie 0x([0-9a-fA-F]+)') regex_handlers = [ @@ -490,9 +498,8 @@ def main(): ovsdb_ovs = OVSDB(ovs_db, 'Open_vSwitch') regex_inport = re.compile(r'^ *[0-9]+\. *in_port=([0-9])+') regex_outport = re.compile(r'^ *output:([0-9]+)') - ofport_handlers = [ - OvsInterfaceHandler(ovsdb_ovs, printer) - ] + ofport_handlers = get_ofport_handlers(ovsdb_ovs, printer) + regex_handlers += [ (regex_outport, ofport_handlers), (regex_inport, ofport_handlers)