From patchwork Thu Oct 21 09:10:03 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: 1544222 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=GlBPDBgr; 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 4HZhY660ffz9sRR for ; Thu, 21 Oct 2021 20:11:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 491CD407EC; Thu, 21 Oct 2021 09:11:04 +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 fbYw0PS62KNm; Thu, 21 Oct 2021 09:11:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6CDB9407BA; Thu, 21 Oct 2021 09:11:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A28FBC0038; Thu, 21 Oct 2021 09:11:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id ED4C6C0036 for ; Thu, 21 Oct 2021 09:10:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B6E77404D2 for ; Thu, 21 Oct 2021 09:10:59 +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 g1VmIOB48ROT for ; Thu, 21 Oct 2021 09:10:59 +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.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id F405C40491 for ; Thu, 21 Oct 2021 09:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807457; 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=zgrpFMFgfpcgKi/GaE/SYY1hjS2iaOBEnImQa7WRj1Y=; b=GlBPDBgrxKowditcqteB8bWxaVg64FEwb9SaNGca44aL/nAYKY0dwrq0kiBLOCpfHs+MrN hVveO7woXC0hHsZowisVv2tJ3MjRCoHpMGzMmiWkG54e/07NaNdVlLbycIRmlqGfbVZgSI Fbn2kHGf7YwqAvNuKVrhA2EHsBFUpPI= 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-17-uW2D9LXsPmuAawOPTGk9qg-1; Thu, 21 Oct 2021 05:10:54 -0400 X-MC-Unique: uW2D9LXsPmuAawOPTGk9qg-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 CDC3357227; Thu, 21 Oct 2021 09:10:53 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31F5417A7E; Thu, 21 Oct 2021 09:10:51 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 21 Oct 2021 11:10:03 +0200 Message-Id: <20211021091007.460641-2-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 1/5] manpages.mk: fix dependencies path 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" Currently, if "make" is run after the project is built, the root manpage (ovn-detrace.1) is rebuilt unnecessarily. The reason is that its dependencies are wrong: files such as lib/common.man or lib/ovs.tmac do not exist in the project's root path so "make" will constantly rebuild the manpage target. Instead, those dependencies live in $ovs_src. Modify sodepends.py to generate a makefile that contains the variable names that point the right paths. Signed-off-by: Adrian Moreno Acked-by: Numan Siddique Acked-by: Dumitru Ceara --- Makefile.am | 2 +- build-aux/sodepends.py | 45 ++++++++++++++++++++++++++++++++++++++---- manpages.mk | 12 +++++------ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0169c96ef..3b0df8393 100644 --- a/Makefile.am +++ b/Makefile.am @@ -425,7 +425,7 @@ CLEANFILES += flake8-check include $(srcdir)/manpages.mk $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py $(OVS_SRCDIR)/python/build/soutil.py - @PYTHONPATH=$(OVS_SRCDIR)/python$(psep)$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) -I$(OVS_MANDIR) $(MAN_ROOTS) >$(@F).tmp + @PYTHONPATH=$(OVS_SRCDIR)/python$(psep)$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -Isrcdir,$(srcdir) -IOVS_MANDIR,$(OVS_MANDIR) $(MAN_ROOTS) >$(@F).tmp @if cmp -s $(@F).tmp $@; then \ touch $@; \ rm -f $(@F).tmp; \ diff --git a/build-aux/sodepends.py b/build-aux/sodepends.py index 45812bcbd..343fda1af 100755 --- a/build-aux/sodepends.py +++ b/build-aux/sodepends.py @@ -16,9 +16,44 @@ from build import soutil import sys +import getopt +import os -def sodepends(include_dirs, filenames, dst): +def parse_include_dirs(): + include_dirs = [] + options, args = getopt.gnu_getopt(sys.argv[1:], 'I:', ['include=']) + for key, value in options: + if key in ['-I', '--include']: + include_dirs.append(value.split(',')) + else: + assert False + + include_dirs.append(['.']) + return include_dirs, args + + +def find_include_file(include_info, name): + for info in include_info: + if len(info) == 2: + dir = info[1] + var = "$(%s)/" % info[0] + else: + dir = info[0] + var = "" + + file = "%s/%s" % (dir, name) + try: + os.stat(file) + return var + name + except OSError: + pass + sys.stderr.write("%s not found in: %s\n" % + (name, ' '.join(str(include_info)))) + return None + + +def sodepends(include_info, filenames, dst): ok = True print("# Generated automatically -- do not modify! " "-*- buffer-read-only: t -*-") @@ -28,6 +63,7 @@ def sodepends(include_dirs, filenames, dst): continue # Open file. + include_dirs = [info[0] for info in include_info] fn = soutil.find_file(include_dirs, toplevel) if not fn: ok = False @@ -47,8 +83,9 @@ def sodepends(include_dirs, filenames, dst): name = soutil.extract_include_directive(line) if name: - if soutil.find_file(include_dirs, name): - dependencies.append(name) + include_file = find_include_file(include_info, name) + if include_file: + dependencies.append(include_file) else: ok = False @@ -62,6 +99,6 @@ def sodepends(include_dirs, filenames, dst): if __name__ == '__main__': - include_dirs, args = soutil.parse_include_dirs() + include_dirs, args = parse_include_dirs() error = not sodepends(include_dirs, args, sys.stdout) sys.exit(1 if error else 0) diff --git a/manpages.mk b/manpages.mk index 9f7a0ced3..9e3e75fe2 100644 --- a/manpages.mk +++ b/manpages.mk @@ -2,10 +2,10 @@ utilities/ovn-detrace.1: \ utilities/ovn-detrace.1.in \ - lib/common-syn.man \ - lib/common.man \ - lib/ovs.tmac + $(OVS_MANDIR)/lib/common-syn.man \ + $(OVS_MANDIR)/lib/common.man \ + $(OVS_MANDIR)/lib/ovs.tmac utilities/ovn-detrace.1.in: -lib/common-syn.man: -lib/common.man: -lib/ovs.tmac: +$(OVS_MANDIR)/lib/common-syn.man: +$(OVS_MANDIR)/lib/common.man: +$(OVS_MANDIR)/lib/ovs.tmac: From patchwork Thu Oct 21 09:10:04 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: 1544226 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=Tn02ryyk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::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 4HZhYK0Kbrz9sRR for ; Thu, 21 Oct 2021 20:11:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 39B9140636; Thu, 21 Oct 2021 09:11:12 +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 9XXlfO_7rYij; Thu, 21 Oct 2021 09:11:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1AA66405F9; Thu, 21 Oct 2021 09:11:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 44B21C0039; Thu, 21 Oct 2021 09:11:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01F55C001C for ; Thu, 21 Oct 2021 09:11:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E403B4060C for ; Thu, 21 Oct 2021 09:11:06 +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 H65zfzpGnQyt for ; Thu, 21 Oct 2021 09:11:05 +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 smtp2.osuosl.org (Postfix) with ESMTPS id B93D340590 for ; Thu, 21 Oct 2021 09:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807463; 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=wkuLeJuP07SOlVP8pgIMX5/feH/2sw7nIAjmvDedYqo=; b=Tn02ryykuPeUf+lb/cAO4S40eE2rWzO8Sn237cu1aP4wx0PRFBkYTbtP3KjKgU6i1etPtx 8WkblEFx+P5+0bHGN2Mz96y0q4twaS0qlv8KbC93ol3GX5VB9B+wFHLjwa+VrdA4VtlguI klIwsk8MlbR2hQXiGeXrOx2ZVZG9z0k= 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-214-J3ofW_bHNfuynlG_sn44-g-1; Thu, 21 Oct 2021 05:10:57 -0400 X-MC-Unique: J3ofW_bHNfuynlG_sn44-g-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 5AA72102C60F; Thu, 21 Oct 2021 09:10:56 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 487521948C; Thu, 21 Oct 2021 09:10:54 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 21 Oct 2021 11:10:04 +0200 Message-Id: <20211021091007.460641-3-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 2/5] ovn-detrace: use configurable printer object 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" Intead of declaring global printing functions, use a configurable printer object that has to declare print_p and print_h. That way external programs that may want to use ovn-detrace can obtain the information provided by ovn-detrace by just re-implementing the printer object Signed-off-by: Adrian Moreno Acked-by: Dumitru Ceara --- utilities/ovn-detrace.in | 177 +++++++++++++++++++++------------------ 1 file changed, 95 insertions(+), 82 deletions(-) diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in index 1e4f76dd7..d26efbd16 100755 --- a/utilities/ovn-detrace.in +++ b/utilities/ovn-detrace.in @@ -56,8 +56,15 @@ The following options are also available: """ % {'argv0': argv0}) sys.exit(0) -print_p = functools.partial(print, ' * ') -print_h = functools.partial(print, ' * ') +class Printer(object): + def __init__(self): + pass + + def print_p(self, string): + print(' * ' + string) + + def print_h(self, string): + print(' * ' + string) def datapath_str(datapath): return '"%s" (%s)' % (str(datapath.external_ids.get('name')), @@ -134,12 +141,16 @@ class OVSDB(object): return next(iter(table_rows)) class CookieHandler(object): - def __init__(self, db, table): + def __init__(self, db, table, printer): self._db = db self._table = table + self._printer = printer or Printer() - def print(self, msg): - print_h(msg) + def print_h(self, msg): + self._printer.print_h(msg) + + def print_p(self, msg): + self._printer.print_p(msg) def get_records(self, cookie): return [] @@ -151,8 +162,8 @@ class CookieHandler(object): pass class CookieHandlerByUUUID(CookieHandler): - def __init__(self, db, table): - super(CookieHandlerByUUUID, self).__init__(db, table) + def __init__(self, db, table, printer): + super(CookieHandlerByUUUID, self).__init__(db, table, printer) def get_records(self, cookie): # Adjust cookie to include leading zeroes if needed. @@ -160,8 +171,8 @@ class CookieHandlerByUUUID(CookieHandler): return self._db.find_rows_by_partial_uuid(self._table, cookie) class ACLHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(ACLHintHandler, self).__init__(ovnnb_db, 'ACL') + def __init__(self, ovnnb_db, printer): + super(ACLHintHandler, self).__init__(ovnnb_db, 'ACL', printer) def print_record(self, acl): output = 'ACL: %s, priority=%s, ' \ @@ -171,112 +182,112 @@ class ACLHintHandler(CookieHandlerByUUUID): acl.action) if acl.log: output += ' (log)' - print_h(output) + self.print_h(output) class DHCPOptionsHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(DHCPOptionsHintHandler, self).__init__(ovnnb_db, 'DHCP_Options') + def __init__(self, ovnnb_db, printer): + super(DHCPOptionsHintHandler, self).__init__(ovnnb_db, 'DHCP_Options', printer) def print_record(self, dhcp_opt): - print_h('DHCP Options: cidr %s options (%s)' % ( + self.print_h('DHCP Options: cidr %s options (%s)' % ( dhcp_opt.cidr, dhcp_opt.options)) class ForwardingGroupHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): + def __init__(self, ovnnb_db, printer): super(ForwardingGroupHintHandler, self).__init__(ovnnb_db, - 'Forwarding_Group') + 'Forwarding_Group', printer) def print_record(self, fwd_group): - print_h('Forwarding Group: name %s vip %s vmac %s liveness %s child ports (%s)' % ( + self.print_h('Forwarding Group: name %s vip %s vmac %s liveness %s child ports (%s)' % ( fwd_group.name, fwd_group.vip, fwd_group.vmac, fwd_group.liveness, fwd_group.child_port)) class LSPHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(LSPHintHandler, self).__init__(ovnnb_db, 'Logical_Switch_Port') + def __init__(self, ovnnb_db, printer): + super(LSPHintHandler, self).__init__(ovnnb_db, 'Logical_Switch_Port', printer) def print_record(self, lsp): - print_h('Logical Switch Port: %s type %s (addresses %s, dynamic addresses %s, security %s' % ( + self.print_h('Logical Switch Port: %s type %s (addresses %s, dynamic addresses %s, security %s' % ( lsp.name, lsp.type, lsp.addresses, lsp.dynamic_addresses, lsp.port_security)) class LRPHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(LRPHintHandler, self).__init__(ovnnb_db, 'Logical_Router_Port') + def __init__(self, ovnnb_db, printer): + super(LRPHintHandler, self).__init__(ovnnb_db, 'Logical_Router_Port', printer) def print_record(self, lrp): - print_h('Logical Router Port: %s mac %s networks %s ipv6_ra_configs %s' % ( + self.print_h('Logical Router Port: %s mac %s networks %s ipv6_ra_configs %s' % ( lrp.name, lrp.mac, lrp.networks, lrp.ipv6_ra_configs)) class LRPolicyHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(LRPolicyHandler, self).__init__(ovnnb_db, 'Logical_Router_Policy') + def __init__(self, ovnnb_db, printer): + super(LRPolicyHandler, self).__init__(ovnnb_db, 'Logical_Router_Policy', printer) def print_record(self, policy): - print_h('Logical Router Policy: priority %s match %s action %s nexthop %s' % ( + self.print_h('Logical Router Policy: priority %s match %s action %s nexthop %s' % ( policy.priority, policy.match, policy.action, policy.nexthop)) class LoadBalancerHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(LoadBalancerHintHandler, self).__init__(ovnnb_db, 'Load_Balancer') + def __init__(self, ovnnb_db, printer): + super(LoadBalancerHintHandler, self).__init__(ovnnb_db, 'Load_Balancer', printer) def print_record(self, lb): - print_h('Load Balancer: %s protocol %s vips %s ip_port_mappings %s' % ( + self.print_h('Load Balancer: %s protocol %s vips %s ip_port_mappings %s' % ( lb.name, lb.protocol, lb.vips, lb.ip_port_mappings)) class NATHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(NATHintHandler, self).__init__(ovnnb_db, 'NAT') + def __init__(self, ovnnb_db, printer): + super(NATHintHandler, self).__init__(ovnnb_db, 'NAT', printer) def print_record(self, nat): - print_h('NAT: external IP %s external_mac %s logical_ip %s logical_port %s type %s' % ( + self.print_h('NAT: external IP %s external_mac %s logical_ip %s logical_port %s type %s' % ( nat.external_ip, nat.external_mac, nat.logical_ip, nat.logical_port, nat.type)) class StaticRouteHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): + def __init__(self, ovnnb_db, printer): super(StaticRouteHintHandler, self).__init__(ovnnb_db, - 'Logical_Router_Static_Route') + 'Logical_Router_Static_Route', printer) def print_record(self, route): - print_h('Route: %s via %s (port %s), policy=%s' % ( + self.print_h('Route: %s via %s (port %s), policy=%s' % ( route.ip_prefix, route.nexthop, route.output_port, route.policy)) class QoSHintHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db): - super(QoSHintHandler, self).__init__(ovnnb_db, 'QoS') + def __init__(self, ovnnb_db, printer): + super(QoSHintHandler, self).__init__(ovnnb_db, 'QoS', printer) def print_record(self, qos): - print_h('QoS: priority %s direction %s match %s action %s bandwidth %s' % ( + self.print_h('QoS: priority %s direction %s match %s action %s bandwidth %s' % ( qos.priority, qos.direction, qos.match, qos.action, qos.bandwidth)) class LogicalFlowHandler(CookieHandlerByUUUID): - def __init__(self, ovnnb_db, ovnsb_db): - super(LogicalFlowHandler, self).__init__(ovnsb_db, 'Logical_Flow') + def __init__(self, ovnnb_db, ovnsb_db, printer): + super(LogicalFlowHandler, self).__init__(ovnsb_db, 'Logical_Flow', printer) self._hint_handlers = [ - ACLHintHandler(ovnnb_db), - DHCPOptionsHintHandler(ovnnb_db), - ForwardingGroupHintHandler(ovnnb_db), - LSPHintHandler(ovnnb_db), - LRPHintHandler(ovnnb_db), - LRPolicyHandler(ovnnb_db), - LoadBalancerHintHandler(ovnnb_db), - NATHintHandler(ovnnb_db), - StaticRouteHintHandler(ovnnb_db), - QoSHintHandler(ovnnb_db), + ACLHintHandler(ovnnb_db, printer), + DHCPOptionsHintHandler(ovnnb_db, printer), + ForwardingGroupHintHandler(ovnnb_db, printer), + LSPHintHandler(ovnnb_db, printer), + LRPHintHandler(ovnnb_db, printer), + LRPolicyHandler(ovnnb_db, printer), + LoadBalancerHintHandler(ovnnb_db, printer), + NATHintHandler(ovnnb_db, printer), + StaticRouteHintHandler(ovnnb_db, printer), + QoSHintHandler(ovnnb_db, printer), ] def print_record(self, lflow): - print_p('Logical datapaths:') + self.print_p('Logical datapaths:') datapaths = lflow.logical_datapath if lflow.logical_dp_group: datapaths.extend(lflow.logical_dp_group[0].datapaths) for datapath in datapaths: - print_p(' %s [%s]' % (datapath_str(datapath), lflow.pipeline)) - print_p('Logical flow: table=%s (%s), priority=%s, ' + self.print_p(' %s [%s]' % (datapath_str(datapath), lflow.pipeline)) + self.print_p('Logical flow: table=%s (%s), priority=%s, ' 'match=(%s), actions=(%s)' % (lflow.table_id, lflow.external_ids.get('stage-name'), lflow.priority, @@ -291,58 +302,58 @@ class LogicalFlowHandler(CookieHandlerByUUUID): for handler in self._hint_handlers: for i, record in enumerate(handler.get_records(hint)): if i > 0: - print_h('[Duplicate uuid hint]') + self.print_h('[Duplicate uuid hint]') handler.print_record(record) class PortBindingHandler(CookieHandlerByUUUID): - def __init__(self, ovnsb_db): - super(PortBindingHandler, self).__init__(ovnsb_db, 'Port_Binding') + def __init__(self, ovnsb_db, printer): + super(PortBindingHandler, self).__init__(ovnsb_db, 'Port_Binding', printer) def print_record(self, pb): - print_p('Logical datapath: %s' % (datapath_str(pb.datapath))) - print_p('Port Binding: logical_port "%s", tunnel_key %ld, %s' % + self.print_p('Logical datapath: %s' % (datapath_str(pb.datapath))) + self.print_p('Port Binding: logical_port "%s", tunnel_key %ld, %s' % (pb.logical_port, pb.tunnel_key, chassis_str(pb.chassis))) class MacBindingHandler(CookieHandlerByUUUID): - def __init__(self, ovnsb_db): - super(MacBindingHandler, self).__init__(ovnsb_db, 'MAC_Binding') + def __init__(self, ovnsb_db, printer): + super(MacBindingHandler, self).__init__(ovnsb_db, 'MAC_Binding', printer) def print_record(self, mb): - print_p('Logical datapath: %s' % (datapath_str(mb.datapath))) - print_p('MAC Binding: ip "%s", logical_port "%s", mac "%s"' % + self.print_p('Logical datapath: %s' % (datapath_str(mb.datapath))) + self.print_p('MAC Binding: ip "%s", logical_port "%s", mac "%s"' % (mb.ip, mb.logical_port, mb.mac)) class MulticastGroupHandler(CookieHandlerByUUUID): - def __init__(self, ovnsb_db): + def __init__(self, ovnsb_db, printer): super(MulticastGroupHandler, self).__init__(ovnsb_db, - 'Multicast_Group') + 'Multicast_Group', printer) def print_record(self, mc): mc_ports = ', '.join([pb.logical_port for pb in mc.ports]) - print_p('Logical datapath: %s' % (datapath_str(mc.datapath))) - print_p('Multicast Group: name "%s", tunnel_key %ld ports: (%s)' % + self.print_p('Logical datapath: %s' % (datapath_str(mc.datapath))) + self.print_p('Multicast Group: name "%s", tunnel_key %ld ports: (%s)' % (mc.name, mc.tunnel_key, mc_ports)) class ChassisHandler(CookieHandlerByUUUID): - def __init__(self, ovnsb_db): - super(ChassisHandler, self).__init__(ovnsb_db, 'Chassis') + def __init__(self, ovnsb_db, printer): + super(ChassisHandler, self).__init__(ovnsb_db, 'Chassis', printer) def print_record(self, chassis): - print_p('Chassis: %s' % (chassis_str([chassis]))) + self.print_p('Chassis: %s' % (chassis_str([chassis]))) class SBLoadBalancerHandler(CookieHandlerByUUUID): - def __init__(self, ovnsb_db): - super(SBLoadBalancerHandler, self).__init__(ovnsb_db, 'Load_Balancer') + def __init__(self, ovnsb_db, printer): + super(SBLoadBalancerHandler, self).__init__(ovnsb_db, 'Load_Balancer', printer) def print_record(self, lb): - print_p('Load Balancer: %s protocol %s vips %s' % ( + self.print_p('Load Balancer: %s protocol %s vips %s' % ( lb.name, lb.protocol, lb.vips)) class OvsInterfaceHandler(CookieHandler): - def __init__(self, ovs_db): - super(OvsInterfaceHandler, self).__init__(ovs_db, 'Interface') + def __init__(self, ovs_db, printer): + super(OvsInterfaceHandler, self).__init__(ovs_db, 'Interface', printer) # Store the interfaces connected to the integration bridge in a dict # indexed by ofport. @@ -365,7 +376,7 @@ class OvsInterfaceHandler(CookieHandler): return [intf] if intf else [] def print_record(self, intf): - print_p('OVS Interface: %s (%s)' % + self.print_p('OVS Interface: %s (%s)' % (intf.name, intf.external_ids.get('iface-id'))) def print_record_from_cookie(ovnnb_db, cookie_handlers, cookie): @@ -373,7 +384,7 @@ def print_record_from_cookie(ovnnb_db, cookie_handlers, cookie): records = list(handler.get_records(cookie)) for i, record in enumerate(records): if i > 0: - handler.print('[Duplicate uuid cookie]') + handler.print_h('[Duplicate uuid cookie]') handler.print_record(record) handler.print_hint(record, ovnnb_db) @@ -459,13 +470,15 @@ def main(): ovsdb_ovnsb = OVSDB(ovnsb_db, 'OVN_Southbound') ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound') + printer = Printer() + cookie_handlers = [ - LogicalFlowHandler(ovsdb_ovnnb, ovsdb_ovnsb), - PortBindingHandler(ovsdb_ovnsb), - MacBindingHandler(ovsdb_ovnsb), - MulticastGroupHandler(ovsdb_ovnsb), - ChassisHandler(ovsdb_ovnsb), - SBLoadBalancerHandler(ovsdb_ovnsb) + 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) ] regex_cookie = re.compile(r'^.*cookie 0x([0-9a-fA-F]+)') @@ -478,7 +491,7 @@ def main(): regex_inport = re.compile(r'^ *[0-9]+\. *in_port=([0-9])+') regex_outport = re.compile(r'^ *output:([0-9]+)') ofport_handlers = [ - OvsInterfaceHandler(ovsdb_ovs) + OvsInterfaceHandler(ovsdb_ovs, printer) ] regex_handlers += [ (regex_outport, ofport_handlers), From patchwork Thu Oct 21 09:10:05 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: 1544225 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=IqpKt7p+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4HZhYF5jRcz9sRR for ; Thu, 21 Oct 2021 20:11:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6F88583BE4; Thu, 21 Oct 2021 09:11:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 UZuEBLxQfxVL; Thu, 21 Oct 2021 09:11:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id B30D083BB2; Thu, 21 Oct 2021 09:11:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8356CC0034; Thu, 21 Oct 2021 09:11:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B39CC0037 for ; Thu, 21 Oct 2021 09:11:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4859B83B8C for ; Thu, 21 Oct 2021 09:11:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 A9nepoTI7eIQ for ; Thu, 21 Oct 2021 09:11:05 +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 AAF7F83AC3 for ; Thu, 21 Oct 2021 09:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807463; 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=HGRblJjEigq9iIjP73z2o5tdJRN5Jk1bS8py3A0DkUc=; b=IqpKt7p+EipXW3jMkgCj3k44oF+3Gt61hbjSUH5vLZHsrs8qsDiGvoZvxFmHla5gpZLfGU 6BofL2Si5h1NtynMajz1r4Nc03iGJd/+ByMF7tuvm5gTAB4khvw/6bwknEPWL5DBoNyvr6 bcwd6V0Gr0K23T+pM1hBMC+Qqoojn5U= 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-382-K8LPZRc5Nn2i4uCMNPH52g-1; Thu, 21 Oct 2021 05:10:59 -0400 X-MC-Unique: K8LPZRc5Nn2i4uCMNPH52g-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 7734F79EEF; Thu, 21 Oct 2021 09:10:58 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id AED3BE14A; Thu, 21 Oct 2021 09:10:56 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 21 Oct 2021 11:10:05 +0200 Message-Id: <20211021091007.460641-4-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 3/5] ovn-detrace: rename ovn-detrace to ovn_detrace.py 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" For external python programs to be able to load ovn-detrace as a python module easily, it should end in .py and should have underscores. Move ovn-detrace to ovn_detrace.py and create a symlink with the old name for backwards compatibility. Signed-off-by: Adrian Moreno Acked-by: Dumitru Ceara --- debian/ovn-common.install | 2 +- debian/ovn-common.postinst | 1 + debian/ovn-common.postrm | 1 + rhel/ovn-fedora.spec.in | 3 +++ utilities/.gitignore | 2 +- utilities/automake.mk | 14 ++++++++++++-- utilities/{ovn-detrace.in => ovn_detrace.py.in} | 0 7 files changed, 19 insertions(+), 4 deletions(-) rename utilities/{ovn-detrace.in => ovn_detrace.py.in} (100%) diff --git a/debian/ovn-common.install b/debian/ovn-common.install index 8e5915724..050d1c63a 100644 --- a/debian/ovn-common.install +++ b/debian/ovn-common.install @@ -4,7 +4,7 @@ usr/bin/ovn-sbctl usr/bin/ovn-ic-nbctl usr/bin/ovn-ic-sbctl usr/bin/ovn-trace -usr/bin/ovn-detrace +usr/bin/ovn_detrace.py usr/share/ovn/scripts/ovn-ctl usr/share/ovn/scripts/ovndb-servers.ocf usr/share/ovn/scripts/ovn-lib diff --git a/debian/ovn-common.postinst b/debian/ovn-common.postinst index 15f3c7577..dfddb1f08 100644 --- a/debian/ovn-common.postinst +++ b/debian/ovn-common.postinst @@ -9,6 +9,7 @@ case "$1" in configure) mkdir -p /usr/lib/ocf/resource.d/ovn ln -sf /usr/share/ovn/scripts/ovndb-servers.ocf /usr/lib/ocf/resource.d/ovn/ovndb-servers + ln -sf /usr/bin/ovn_detrace.py /usr/bin/ovn-detrace ;; abort-upgrade|abort-remove|abort-deconfigure) ;; diff --git a/debian/ovn-common.postrm b/debian/ovn-common.postrm index 9face726b..d607a66d5 100644 --- a/debian/ovn-common.postrm +++ b/debian/ovn-common.postrm @@ -8,6 +8,7 @@ set -e case "$1" in purge|remove) rm -rf /usr/lib/ocf/resource.d/ovn + rm -f /usr/bin/ovn-detrace ;; upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; diff --git a/rhel/ovn-fedora.spec.in b/rhel/ovn-fedora.spec.in index 9c8647b5a..3fb854a37 100644 --- a/rhel/ovn-fedora.spec.in +++ b/rhel/ovn-fedora.spec.in @@ -318,6 +318,8 @@ fi %endif %post +ln -sf ovn_detrace.py %{_bindir}/ovn-detrace + %if %{with libcapng} if [ $1 -eq 1 ]; then sed -i 's:^#OVN_USER_ID=:OVN_USER_ID=:' %{_sysconfdir}/sysconfig/ovn @@ -462,6 +464,7 @@ fi %{_bindir}/ovn-nbctl %{_bindir}/ovn-sbctl %{_bindir}/ovn-trace +%{_bindir}/ovn_detrace.py %{_bindir}/ovn-detrace %{_bindir}/ovn-appctl %{_bindir}/ovn-ic-nbctl diff --git a/utilities/.gitignore b/utilities/.gitignore index 763f760ee..da237563b 100644 --- a/utilities/.gitignore +++ b/utilities/.gitignore @@ -11,7 +11,7 @@ /ovn-appctl.8 /ovn-trace /ovn-trace.8 -/ovn-detrace +/ovn_detrace.py /ovn-detrace.1 /ovn-docker-overlay-driver /ovn-docker-underlay-driver diff --git a/utilities/automake.mk b/utilities/automake.mk index a03892f20..67b04cbff 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -20,7 +20,7 @@ MAN_ROOTS += \ bin_SCRIPTS += \ utilities/ovn-docker-overlay-driver \ utilities/ovn-docker-underlay-driver \ - utilities/ovn-detrace + utilities/ovn_detrace.py EXTRA_DIST += \ utilities/ovn-ctl \ @@ -34,7 +34,7 @@ EXTRA_DIST += \ utilities/ovn-ic-sbctl.8.xml \ utilities/ovn-appctl.8.xml \ utilities/ovn-trace.8.xml \ - utilities/ovn-detrace.in \ + utilities/ovn_detrace.py.in \ utilities/ovndb-servers.ocf \ utilities/checkpatch.py \ utilities/docker/Makefile \ @@ -60,6 +60,7 @@ CLEANFILES += \ utilities/ovn-trace.8 \ utilities/ovn-detrace.1 \ utilities/ovn-detrace \ + utilities/ovn_detrace.py \ utilities/ovn-appctl.8 \ utilities/ovn-appctl \ utilities/ovn-sim @@ -105,4 +106,13 @@ bin_PROGRAMS += utilities/ovn-appctl utilities_ovn_appctl_SOURCES = utilities/ovn-appctl.c utilities_ovn_appctl_LDADD = lib/libovn.la $(OVSDB_LIBDIR)/libovsdb.la $(OVS_LIBDIR)/libopenvswitch.la +# ovn-detrace +INSTALL_DATA_LOCAL += ovn-detrace-install +ovn-detrace-install: + ln -sf ovn_detrace.py $(DESTDIR)$(bindir)/ovn-detrace + +UNINSTALL_LOCAL += ovn-detrace-uninstall +ovn-detrace-uninstall: + rm -f $(DESTDIR)$(bindir)/ovn-detrace + include utilities/bugtool/automake.mk diff --git a/utilities/ovn-detrace.in b/utilities/ovn_detrace.py.in similarity index 100% rename from utilities/ovn-detrace.in rename to utilities/ovn_detrace.py.in From patchwork Thu Oct 21 09:10:06 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: 1544224 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=cq5Ssaci; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4HZhYD6JRXz9sRR for ; Thu, 21 Oct 2021 20:11:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B443160ED2; Thu, 21 Oct 2021 09:11:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2bRlyrmmSWva; Thu, 21 Oct 2021 09:11:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id D0F6E60EBB; Thu, 21 Oct 2021 09:11:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AE31AC001C; Thu, 21 Oct 2021 09:11:05 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 16C3EC0011 for ; Thu, 21 Oct 2021 09:11:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F073160EC3 for ; Thu, 21 Oct 2021 09:11:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Y1lpD36QYU0 for ; Thu, 21 Oct 2021 09:11:04 +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 smtp3.osuosl.org (Postfix) with ESMTPS id 452F460EC1 for ; Thu, 21 Oct 2021 09:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807463; 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=x3LwMQ3EG8p6Lu8/ppzMktiuaX+GXCNkwQi34Icss3w=; b=cq5SsaciJYDRtnyV//2ISl3+gKCkpjtaPBlTcOrqmaSc/DNHEcPWk3h0ogL7rq3A07DZJ2 yOdhKT+vPXCccl46AfB1NVrzXYfc7grEmcNS9eUusVyASQPbNxSXbjwLEy/5PgiCBEn3fj jAQUBN3sZe6/quOCkVbi8/nHEStYrvM= 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-292-mqFW8H2GO-uSMeagBMN0SA-1; Thu, 21 Oct 2021 05:11:02 -0400 X-MC-Unique: mqFW8H2GO-uSMeagBMN0SA-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 8A3E01006AA9; Thu, 21 Oct 2021 09:11:00 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD054E2C9; Thu, 21 Oct 2021 09:10:58 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 21 Oct 2021 11:10:06 +0200 Message-Id: <20211021091007.460641-5-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 4/5] ovn-detrace: expose version as global variable 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 importers can check it to determine whether a particular feature exists or not. Signed-off-by: Adrian Moreno Acked-by: Dumitru Ceara --- utilities/ovn_detrace.py.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities/ovn_detrace.py.in b/utilities/ovn_detrace.py.in index d26efbd16..570119d5a 100755 --- a/utilities/ovn_detrace.py.in +++ b/utilities/ovn_detrace.py.in @@ -36,7 +36,7 @@ except Exception: argv0 = sys.argv[0] - +version = "@VERSION@" def usage(): print("""\ @@ -415,7 +415,7 @@ def main(): if key in ['-h', '--help']: usage() elif key in ['-V', '--version']: - print("%s (OVN) @VERSION@" % argv0) + print("%s (OVN) %s" % (argv0, version)) elif key in ['--ovnsb']: ovnsb_db = value elif key in ['--ovnnb']: 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)