From patchwork Thu Oct 14 16:41:30 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: 1541026 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=aYaX2m9D; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4HVZts540Dz9s0r for ; Fri, 15 Oct 2021 03:42:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 96C7D405C3; Thu, 14 Oct 2021 16:42:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dWLE5-b8vFuv; Thu, 14 Oct 2021 16:42:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 81BD54065D; Thu, 14 Oct 2021 16:42:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 21F9BC0026; Thu, 14 Oct 2021 16:42:08 +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 C499DC0011 for ; Thu, 14 Oct 2021 16:42:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B4F6B8364B for ; Thu, 14 Oct 2021 16:42:06 +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 XKke6Ha6RN70 for ; Thu, 14 Oct 2021 16:42:06 +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 [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0F32C83626 for ; Thu, 14 Oct 2021 16:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634229725; 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=aYaX2m9DmC6lDlHo/w60+8hiW8UYp1mY16oTlOqILTAyBVWbDg0dACPRPfu0l3IdwQxmwL Qa3tMonad2qHblydhNbib5MskBGQIhq0qrQEnYaQz12H1x8azS96rPtvEBEp8xXy8PCgt1 luh7a7vN3mEN5tWZevp5wA9oypVeaxM= 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-110-hptb0aOtM-y8MUAGRFKidQ-1; Thu, 14 Oct 2021 12:42:00 -0400 X-MC-Unique: hptb0aOtM-y8MUAGRFKidQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D5711966320 for ; Thu, 14 Oct 2021 16:42:00 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1DB860657; Thu, 14 Oct 2021 16:41:58 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 14 Oct 2021 18:41:30 +0200 Message-Id: <20211014164130.606220-6-amorenoz@redhat.com> In-Reply-To: <20211014164130.606220-1-amorenoz@redhat.com> References: <20211014164130.606220-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: dceara@redhat.com Subject: [ovs-dev] [RFC ovn 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 --- 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)