From patchwork Thu Nov 16 10:41:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Meng X-Patchwork-Id: 1864679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=Is70KYFS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SWGmv3wXVz1yRR for ; Thu, 16 Nov 2023 21:41:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 74321831D6; Thu, 16 Nov 2023 10:41:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 74321831D6 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Is70KYFS 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 fgxu4wwkln3D; Thu, 16 Nov 2023 10:41:48 +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 67EC6831B0; Thu, 16 Nov 2023 10:41:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 67EC6831B0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 425FBC0071; Thu, 16 Nov 2023 10:41:47 +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 60596C0032 for ; Thu, 16 Nov 2023 10:41:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 37718404F1 for ; Thu, 16 Nov 2023 10:41:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 37718404F1 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Is70KYFS 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 xUCawvDNz3H2 for ; Thu, 16 Nov 2023 10:41:43 +0000 (UTC) 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 A126F40558 for ; Thu, 16 Nov 2023 10:41:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A126F40558 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700131302; 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; bh=i/QtmUKcT0XfQYMgv7WuStJSjfLlH5yFevKrfFN6StA=; b=Is70KYFSzAzJtjpYZQBdh4HxH6GFLkkicKi7ex/Ijke0gEq7/gs3EofWZUHBug8nIzStkK bQU8u0G1+hgVuRFGRAZ+1DiYYWV6uZfiJjSzZGZQQoFDLUkJC56JCXRvQceqKdL5tJOHUR Lf3X0/8EKscxPmE1rG70/9831OX7Cj0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180--kYSz0xPPz-3VtqiNiSCZw-1; Thu, 16 Nov 2023 05:41:41 -0500 X-MC-Unique: -kYSz0xPPz-3VtqiNiSCZw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4084e4ce543so3654845e9.3 for ; Thu, 16 Nov 2023 02:41:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700131300; x=1700736100; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=i/QtmUKcT0XfQYMgv7WuStJSjfLlH5yFevKrfFN6StA=; b=oxXkgZg8eDwalBPkYKm+2EB6mxBzhHBVoLLhR4Z65ltjREqkIESLkmjRL0br4UY4Vn QPLCo6O2N6ebsSRtMt/8Y6L7KABAhbLMxP8tpxvrL1V8Cyf7hhUxHXozEhUs1GmgH1ym FRncUJEenOg+deOFUCU3JvFvo1aD9yoi/RwknHc/zT9Mckeqlh9y3vVQa8ikvXwYHljN a8+nkOTF3Ci7OAdVcX+b7gKfv6DKk+mLsWjZ1eYewyGr2t0bprJbE5WDA3WaBz5BIxAW X19WE/CSsM9bn6gKCOYOZ5AeFp4+NU3wm419hYGd5D/SJ/651sbwiAGo8XWSJf+lv9mp vVHw== X-Gm-Message-State: AOJu0YxR9WB0hiL7bweyUM/8eV20c2Snbmyx03dbSpLAG3VBXybjbCum Jx+i+5gtgK2PTUJzAFmU/TbUjz7qeZJtrZaG6AsMWgv/noM7UPDM1VZx9yR51vkxW38yVP1qGEb k2Ern+ick9vgzSUaQnuahihkhfw6ThZ1jon8EIk5wFCwM9Xim1gkIOCsU9XI5bJskeR4= X-Received: by 2002:a05:600c:3b9f:b0:408:3c8f:afd9 with SMTP id n31-20020a05600c3b9f00b004083c8fafd9mr11792035wms.3.1700131300180; Thu, 16 Nov 2023 02:41:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlGxgcLM9i6yA0VkhTM3ZKweBtAXCromeV5iRM9Filk+rk+mCASod8RUmRtJA+NvjVvHQwbg== X-Received: by 2002:a05:600c:3b9f:b0:408:3c8f:afd9 with SMTP id n31-20020a05600c3b9f00b004083c8fafd9mr11792012wms.3.1700131299727; Thu, 16 Nov 2023 02:41:39 -0800 (PST) Received: from positronik4lide.redhat.com ([87.122.56.153]) by smtp.gmail.com with ESMTPSA id n10-20020a05600c304a00b004080f0376a0sm2937210wmh.42.2023.11.16.02.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:41:39 -0800 (PST) From: jmeng@redhat.com To: dev@openvswitch.org, i.maximets@ovn.org, echaudro@redhat.com, ktraynor@redhat.com, aconole@redhat.com, rjarry@redhat.com Date: Thu, 16 Nov 2023 11:41:14 +0100 Message-Id: <20231116104120.25676-1-jmeng@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v4 0/6] Add global option to output JSON from ovs-appctl cmds. 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" From: Jakob Meng This patch series builds upon [0] and brings the following changes: * Last patch in series shows how output format and other args could be passed via JSON-RPC API without the indirection introduced in the first patch (at the cost of inferiour error handling) * By default, the JSON output will not be prettyfied nor sorted * Added global option '--pretty' to ovs-appctl for prettyfy and sort the JSON output * Added missing check for supported output formats to server.py * Commented @enum.verify(enum.NAMED_FLAGS) because its available in Python 3.11+ only * Renamed 'fmt' to 'output_fmts' in Python code to highlight that multiple values are possible at the same time * Added NEWS entries for '--format' and '--pretty' options * Fixed flake8 errors * Replaced TODO with FIXME * Dropped option '--format' from ovs-dpctl * No longer mention OVS-DPDK in commit msgs * Adopted comments to style guide. What has not been changed from previous series is the function type unixctl_cb_func in lib/unixctl.h: The output format continues to be passed via new arg 'enum ovs_output_fmt fmt'. We discussed whether this should be moved to 'struct unixctl_conn' or a new struct [1] but did not come to a conclusion yet. [0] https://patchwork.ozlabs.org/project/openvswitch/list/?series=379267&state=%2A&archive=both [1] https://patchwork.ozlabs.org/comment/3208683/ In particular, I would like to ask for your opinion on the last patch in the series: What do you think about both JSON-RPC API approaches? Thanks! Jakob Meng (6): Add global option for JSON output to ovs-appctl. python: Add global option for JSON output to Python tools. Migrate commands to extended unixctl API. ofproto: Add JSON output for 'dpif/show' command. appctl: Add option '--pretty' for pretty-printing JSON output. unixctl: Pass output format as command args via JSON-RPC API. NEWS | 7 ++ lib/bfd.c | 16 ++- lib/cfm.c | 13 ++- lib/command-line.c | 36 ++++++ lib/command-line.h | 10 ++ lib/coverage.c | 11 +- lib/dpctl.c | 129 +++++++++++++-------- lib/dpctl.h | 4 + lib/dpdk.c | 15 ++- lib/dpif-netdev-perf.c | 1 + lib/dpif-netdev-perf.h | 1 + lib/dpif-netdev.c | 84 ++++++++------ lib/dpif-netlink.c | 6 +- lib/lacp.c | 7 +- lib/memory.c | 5 +- lib/netdev-dpdk.c | 16 ++- lib/netdev-dummy.c | 30 +++-- lib/netdev-native-tnl.c | 4 +- lib/netdev-native-tnl.h | 4 +- lib/netdev-vport.c | 1 + lib/odp-execute.c | 10 +- lib/ovs-lldp.c | 16 ++- lib/ovs-router.c | 26 +++-- lib/rstp.c | 22 ++-- lib/stopwatch.c | 10 +- lib/stp.c | 20 ++-- lib/timeval.c | 13 ++- lib/tnl-neigh-cache.c | 35 +++--- lib/tnl-ports.c | 6 +- lib/unixctl.c | 206 ++++++++++++++++++++++++--------- lib/unixctl.h | 11 +- lib/vlog.c | 46 +++++--- ofproto/bond.c | 32 +++-- ofproto/ofproto-dpif-trace.c | 10 +- ofproto/ofproto-dpif-upcall.c | 81 +++++++++---- ofproto/ofproto-dpif.c | 187 +++++++++++++++++++++++++----- ofproto/ofproto.c | 10 +- ofproto/tunnel.c | 4 +- ovsdb/file.c | 4 +- ovsdb/ovsdb-client.c | 40 ++++--- ovsdb/ovsdb-server.c | 122 ++++++++++++++----- ovsdb/ovsdb.c | 4 +- ovsdb/raft.c | 28 +++-- python/ovs/unixctl/__init__.py | 19 +-- python/ovs/unixctl/client.py | 9 +- python/ovs/unixctl/server.py | 75 +++++++----- python/ovs/util.py | 8 ++ python/ovs/vlog.py | 12 +- tests/appctl.py | 7 +- tests/pmd.at | 33 ++++++ tests/test-netflow.c | 4 +- tests/test-sflow.c | 4 +- tests/test-unixctl.c | 33 ++++-- tests/test-unixctl.py | 25 ++-- tests/unixctl-py.at | 7 ++ utilities/ovs-appctl.c | 82 ++++++++++--- utilities/ovs-dpctl.c | 1 + utilities/ovs-ofctl.c | 43 ++++--- vswitchd/bridge.c | 25 ++-- vswitchd/ovs-vswitchd.c | 5 +- 60 files changed, 1250 insertions(+), 485 deletions(-) --- 2.39.2