From patchwork Thu Apr 11 14:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakob Meng X-Patchwork-Id: 1922610 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=N0UOvkyY; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VFjGj1TDSz1yYB for ; Fri, 12 Apr 2024 00:47:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D7678612CA; Thu, 11 Apr 2024 14:47:38 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id SvKJUZGLYvea; Thu, 11 Apr 2024 14:47:37 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CAC2D612C3 Authentication-Results: smtp3.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=N0UOvkyY Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id CAC2D612C3; Thu, 11 Apr 2024 14:47:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 99319C0077; Thu, 11 Apr 2024 14:47:37 +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 5CC02C0037 for ; Thu, 11 Apr 2024 14:47:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5031341EE8 for ; Thu, 11 Apr 2024 14:47:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id A5TqfhixjOoV for ; Thu, 11 Apr 2024 14:47:35 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=jmeng@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org C98C341EDB Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C98C341EDB Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N0UOvkyY 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 C98C341EDB for ; Thu, 11 Apr 2024 14:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712846853; 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=iWwTFrcTqVfmV/Wr9ruxFdUMJG41gLwOZvl/JBowEcg=; b=N0UOvkyYoMdNFXJ0+FvpD4uZQSdprWgD9cuwTEKIV5CMus0QBcSYpEH62yihfgNZC7Rxlc K3uiUPRPwFT4pgoIRDSbDD1j2UNbHZgHXzXkuQzp6GmOBJWAoaW4t0GwXnztOiUIesDu1n wQm9bV5gPdzem5+SKErHKUHOvsTJNnQ= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-6X6k3uVcMESk-yVFy1GCnw-1; Thu, 11 Apr 2024 10:47:31 -0400 X-MC-Unique: 6X6k3uVcMESk-yVFy1GCnw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a51c76700adso123476966b.0 for ; Thu, 11 Apr 2024 07:47:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712846850; x=1713451650; 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=iWwTFrcTqVfmV/Wr9ruxFdUMJG41gLwOZvl/JBowEcg=; b=WnbVspK4vxwS+lbsz7s97M24pGXRu8EiH999QtLdR+s5t18vCjj6hyxjxdLPKJy9Pb CHOkIeqv72SJascjehUD8pwdWO4tdpIW1nDqkBsB//ozKRZxfNeRyvRuVbjay/mk3prB uZICIpmshKyXiy9vLN56sYcwNCSsziex1lJOEdRLhItcdL+cUQuGGjhpt383vu3huTDK jpLdTOzHjAi7WT2G72canTm7PBfORqPOLuF9tDRJdx/h2m2Mk718QwbgZdiGp5MZB3tq zk6hfbCQ/k7OFTevZGYRIb4lC+8PjG6pIsqERlPsRJrncdia2EaIAJaD1UpVjwZvmhA9 KCtA== X-Gm-Message-State: AOJu0Yz72iJYKL4EJXj8bUqwMJB4kpEQ8sHQR4g37nbHaNI27COT+8N0 6hzcs7ZpiouTKptNayiu5L89tLhoSa2WoHZGIUDRFmZqw0+mTrgmoPPDPaxEvDBiQLKY8XW475Y +IwsRV39Auw+9sTnIj8eNFyRial6likspzfp+NOVYBmMBvNhIYqi4LmuaFOOQaH9iXjBu2QXFy+ deW9GyD2HuCc7yNmd9kW8FrkHYl5BM X-Received: by 2002:a17:907:7d8c:b0:a52:2238:abd7 with SMTP id oz12-20020a1709077d8c00b00a522238abd7mr1933576ejc.32.1712846850349; Thu, 11 Apr 2024 07:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXQkPyLupgYiMfaR3WXjJBrUc6XQ7VwqYTxpx1uEkUS5uCvMZleunxnDWpzdBLTp3dEzYP9A== X-Received: by 2002:a17:907:7d8c:b0:a52:2238:abd7 with SMTP id oz12-20020a1709077d8c00b00a522238abd7mr1933548ejc.32.1712846849909; Thu, 11 Apr 2024 07:47:29 -0700 (PDT) Received: from positronik4lide.. ([87.122.56.49]) by smtp.gmail.com with ESMTPSA id lo17-20020a170906fa1100b00a466af74ef2sm816835ejb.2.2024.04.11.07.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:47:29 -0700 (PDT) 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, 11 Apr 2024 16:47:12 +0200 Message-Id: <20240411144718.1921869-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 v8 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 is based on v7 [0] but applies three fundamental changes: * When JSON output is requested but a command has not implemented JSON printing yet, the plain-text output will be wrapped in a JSON object anyway. The main reason is that commands, which have already been executed, should not fail later at the printing/reply stage due to an unsupported output format. * The output format is stored in struct unixctl_conn and can be queried within commands with unixctl_command_get_output_format(). * Commands no longer need to register what output format they support. Thus, a huge amount of code changes from the previous patch series could be eliminated. Other changes from v7 [0]: * Additional tests for (wrapped) JSON. * '--pretty' option now also implemented in appctl.py (previously for ovs-appctl only). * 'list-commands' gained JSON output (because smaller/easier change than 'dpif/show' command). * 'dpif/show' test uses pretty-printing to avoid test failures due to unsorted keys. What has not been changed is the code for JSON output in 'dpif/show'. Mostly, because rearranging it does not make it more readable?! Thanks again, in particular to Ilya Maximets and Eelco Chaudron, for your good suggestions and helpful feedback! ☺️ [0] https://patchwork.ozlabs.org/project/openvswitch/list/?series=391066&state=%2A&archive=both Jakob Meng (6): Add global option for JSON output to ovs-appctl. python: Add global option for JSON output to Python tools. appctl: Add option '--pretty' for pretty-printing JSON output. python: Add option '--pretty' for pretty-printing JSON output. vswitchd: Add JSON output for 'list-commands' command. ofproto: Add JSON output for 'dpif/show' command. NEWS | 13 +++ lib/command-line.c | 36 +++++++ lib/command-line.h | 10 ++ lib/unixctl.c | 204 ++++++++++++++++++++++++++--------- lib/unixctl.h | 11 ++ ofproto/ofproto-dpif.c | 124 +++++++++++++++++++-- python/ovs/unixctl/client.py | 14 ++- python/ovs/unixctl/server.py | 45 +++++++- python/ovs/util.py | 8 ++ tests/appctl.py | 31 +++++- tests/ovs-vswitchd.at | 27 +++++ tests/pmd.at | 28 +++++ tests/unixctl-py.at | 8 ++ utilities/ovs-appctl.c | 122 ++++++++++++++++++--- 14 files changed, 599 insertions(+), 82 deletions(-)