mbox series

[ovs-dev,v8,0/6] Add global option to output JSON from ovs-appctl cmds.

Message ID 20240411144718.1921869-1-jmeng@redhat.com
Headers show
Series Add global option to output JSON from ovs-appctl cmds. | expand

Message

Jakob Meng April 11, 2024, 2:47 p.m. UTC
From: Jakob Meng <code@jakobmeng.de>

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(-)