From patchwork Thu Oct 14 16:41:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 1541022 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=fNu7ybBu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::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 4HVZtj1sNlz9sNH for ; Fri, 15 Oct 2021 03:42:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BD899405AC; Thu, 14 Oct 2021 16:42:02 +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 odwt-LN7poU2; Thu, 14 Oct 2021 16:42:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id D9E2140262; Thu, 14 Oct 2021 16:42:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B9354C0011; Thu, 14 Oct 2021 16:42:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4DA64C000D for ; Thu, 14 Oct 2021 16:41:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3C6EB6069B for ; Thu, 14 Oct 2021 16:41:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 4doE0mj6XIiz for ; Thu, 14 Oct 2021 16:41:58 +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 69636605FE for ; Thu, 14 Oct 2021 16:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634229717; 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=fNu7ybBuJVK7l1ixcH0lZ5XdM0DuPG55rNHusdV/vcGxn28SdXwgj/TASQMZNSZv3OTLSg WJ+tweFPsiWhzod07978RxgdEKOgJuVzihnMmSJYcLbpqhc3XgiUCMvlSRo1+H5oF/AmFr BIOxgvbqW4KN92DztfzOQRNxw3TFZS8= 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-300-vF0d-0ekOPGvRfBq5a2qTA-1; Thu, 14 Oct 2021 12:41:54 -0400 X-MC-Unique: vF0d-0ekOPGvRfBq5a2qTA-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 5EA751966322 for ; Thu, 14 Oct 2021 16:41:53 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23D3A2C175; Thu, 14 Oct 2021 16:41:51 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 14 Oct 2021 18:41:26 +0200 Message-Id: <20211014164130.606220-2-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 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 --- 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 14 16:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 1541027 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=d/BQJrkx; 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 4HVZv55CHFz9s0r for ; Fri, 15 Oct 2021 03:42:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id AAB788392B; Thu, 14 Oct 2021 16:42:23 +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 tJdzGZNAD4dk; Thu, 14 Oct 2021 16:42:21 +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 0568D835BA; Thu, 14 Oct 2021 16:42:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 897C1C001C; Thu, 14 Oct 2021 16:42:20 +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 1C716C0022 for ; Thu, 14 Oct 2021 16:42:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6376F403EC for ; Thu, 14 Oct 2021 16:42:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 4bRHMF73wY34 for ; Thu, 14 Oct 2021 16:42:10 +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 smtp2.osuosl.org (Postfix) with ESMTPS id 4636040585 for ; Thu, 14 Oct 2021 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634229729; 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=d/BQJrkxs1lT8LjvmDwwnXUnfUfKx7AEM13RDZYDeb8uCYK7pUTFrbTqWQvqNUgEqDpJmL HNNz+Lydk471nRkkARANkjYkHeRy3RWW4r6S8qCg6Vlxbj09JX2D3pQc+M4SmbeWxNaikq tvqyL8EBxTI0OOQ/Rea7kbe7AM3Oc9k= 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-375-GR8mG9vDMHiGukHxcXgUvg-1; Thu, 14 Oct 2021 12:41:57 -0400 X-MC-Unique: GR8mG9vDMHiGukHxcXgUvg-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 4F05256BFF for ; Thu, 14 Oct 2021 16:41:55 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD4F460657; Thu, 14 Oct 2021 16:41:53 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 14 Oct 2021 18:41:27 +0200 Message-Id: <20211014164130.606220-3-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 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 --- 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 14 16:41:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 1541025 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=Ve2xmlKQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::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 4HVZtp6Cfyz9s0r for ; Fri, 15 Oct 2021 03:42:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 011A940650; Thu, 14 Oct 2021 16:42:09 +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 67zF86POgFZB; Thu, 14 Oct 2021 16:42:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3B27B405C9; Thu, 14 Oct 2021 16:42:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 014F0C0011; Thu, 14 Oct 2021 16:42:07 +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 3C8B9C000D for ; Thu, 14 Oct 2021 16:42:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 289244054D for ; Thu, 14 Oct 2021 16:42:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 IFkcy9Ff_RjD for ; Thu, 14 Oct 2021 16:42:02 +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 smtp2.osuosl.org (Postfix) with ESMTPS id B67E8403E0 for ; Thu, 14 Oct 2021 16:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634229721; 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=U2HPKBKDpLboDtcaljm8Z4jUdsDJzm58KKc9x92K9i8=; b=Ve2xmlKQZn0AXRHKtbL6V6SDIOu0JVIccHZ3UDfxVugUVuuQaYht1l+tjF50YSVsEJF36+ S7cNEYTO0VMsKS6j1KqZlYniW1OBM4lKhAygYCk8kcUqTv3Yx+HURBvcoJYrmzPDInrehm Tkk/1+VCK2khP8RP3YBuiZvEHT20Uho= 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-501-XbA296iQMCm-2-KM-TbSEg-1; Thu, 14 Oct 2021 12:41:57 -0400 X-MC-Unique: XbA296iQMCm-2-KM-TbSEg-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 B4B8F80574F for ; Thu, 14 Oct 2021 16:41:56 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9148960583; Thu, 14 Oct 2021 16:41:55 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 14 Oct 2021 18:41:28 +0200 Message-Id: <20211014164130.606220-4-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 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-detrac.py and create a symlink with the old name for backwards compatibility. Signed-off-by: Adrian Moreno --- debian/ovn-common.install | 2 +- debian/ovn-common.postinst | 1 + debian/ovn-common.postrm | 1 + rhel/ovn-fedora.spec.in | 9 +++++++++ utilities/automake.mk | 14 ++++++++++++-- utilities/{ovn-detrace.in => ovn_detrace.py.in} | 0 6 files changed, 24 insertions(+), 3 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..fc0992263 100644 --- a/rhel/ovn-fedora.spec.in +++ b/rhel/ovn-fedora.spec.in @@ -264,6 +264,12 @@ if [ $1 -eq 1 ] ; then fi fi +%preun +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + rm %{_bindir}/ovn-detrace +fi + %preun central %if 0%{?systemd_preun:1} %systemd_preun ovn-northd.service @@ -318,6 +324,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 +470,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/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 14 16:41:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 1541023 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=A4sraEAv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::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 4HVZtm1Cblz9sNH for ; Fri, 15 Oct 2021 03:42:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 33D1140355; Thu, 14 Oct 2021 16:42:06 +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 oQzUz3YyeDn7; Thu, 14 Oct 2021 16:42:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7A23C40393; Thu, 14 Oct 2021 16:42:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 41D94C0022; Thu, 14 Oct 2021 16:42:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id BDACCC0011 for ; Thu, 14 Oct 2021 16:42:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9F3A060855 for ; Thu, 14 Oct 2021 16:42:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 U9vZmyNP6QMZ for ; Thu, 14 Oct 2021 16:42:03 +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 smtp3.osuosl.org (Postfix) with ESMTPS id 090D9605FE for ; Thu, 14 Oct 2021 16:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634229722; 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=A4sraEAvkDPCb6VWLYYfZCIhs3MbYpD5EFDLdOhjc4qnRmFlSDwXgD8zKYp0IXCCwQ2h0T /8eSu4DrdqyGSnHpo/5nh4LcwM9fC8+TYpDTwavekqBG082xc5r7AflR3ARskEJ0LoP4zA ypfnpEmtCRFmw7nhD4hBUxJE6ctlzek= 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-311-U1uI6tCMPm-9ATx4nL8qMA-1; Thu, 14 Oct 2021 12:41:59 -0400 X-MC-Unique: U1uI6tCMPm-9ATx4nL8qMA-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 7B9E4801AA7 for ; Thu, 14 Oct 2021 16:41:58 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 207581980E; Thu, 14 Oct 2021 16:41:56 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 14 Oct 2021 18:41:29 +0200 Message-Id: <20211014164130.606220-5-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 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 --- 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 14 16:41:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian 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)