The new --filter option accepts comma-separated rules to display only matching chassis, ports or encapsulation types.
Includes test cases and man page updates. Signed-off-by: Alexandra Rukomoinikova <arukomoinikova@k2.cloud> --- NEWS | 3 +++ tests/ovn-sbctl.at | 48 +++++++++++++++++++++++++++++++++++++++ utilities/ovn-sbctl.8.xml | 12 +++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0cce1790d..6478e75fb 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,9 @@ Post v25.03.0 - Added support for running tests from the 'check-kernel' system test target under retis by setting OVS_TEST_WITH_RETIS=yes. See the 'Testing' section of the documentation for more details. + - ovn-sbctl: + * Added --filter option that allows filtering the command output based + on the specified filter. OVN v25.03.0 - 07 Mar 2025 -------------------------- diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index cb2fd2d0a..b024fae28 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -183,6 +183,54 @@ options : {vtep_logical_switch=l0, vtep_physical_switch=p0} dnl --------------------------------------------------------------------- +OVN_SBCTL_TEST([ovn_sbctl_show_filter_option], [ovn-sbctl show filter option], [ + +AT_CHECK([ovn-nbctl ls-add br-test]) +AT_CHECK([ovn-nbctl lsp-add br-test vif0]) +AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02]) +AT_CHECK([ovn-sbctl chassis-add ch0 geneve 1.2.3.1]) +AT_CHECK([ovn-nbctl --wait=sb sync]) +AT_CHECK([ovn-sbctl lsp-bind vif0 ch0]) + +AT_CHECK([ovn-sbctl show], [0], [dnl +Chassis ch0 + Encap geneve + ip: "1.2.3.1" + options: {csum="true} + Port_Binding vif0 +]) + +AT_CHECK([ovn-sbctl chassis-add ch2 geneve 1.2.3.2]) +AT_CHECK([ovn-sbctl chassis-add ch3 geneve 1.2.3.3]) +AT_CHECK([ovn-sbctl chassis-add ch4 vxlan 1.2.3.4]) + +AT_CHECK([ovn-sbctl --filter='ch2,ch3' show | grep Chassis | sort], [0], [dnl +Chassis ch2 +Chassis ch3 +]) + +AT_CHECK([ovn-sbctl --filter='1.2.3.4,1.2.3.3' show | grep Chassis | sort], [0], [dnl +Chassis ch3 +Chassis ch4 +]) + +AT_CHECK([ovn-sbctl --filter='Encap(vxlan)' show | grep -E '(Chassis|Encap)' | sort], [0], [dnl + Encap vxlan +Chassis ch0 +Chassis ch2 +Chassis ch3 +Chassis ch4 +]) + +AT_CHECK([ovn-sbctl --filter='Encap(vxlan),ch4' show | grep -E '(Chassis|Encap)' | sort], [0], [dnl + Encap vxlan +Chassis ch4 +]) + +]) + +dnl --------------------------------------------------------------------- + OVN_SBCTL_TEST([ovn_sbctl_connection], [ovn-sbctl - connection], [ AT_CHECK([ovn-sbctl --inactivity-probe=30000 set-connection ptcp:6641:127.0.0.1 punix:$OVS_RUNDIR/ovnsb_db.sock]) AT_CHECK([ovn-sbctl list connection | grep inactivity_probe], [0], [dnl diff --git a/utilities/ovn-sbctl.8.xml b/utilities/ovn-sbctl.8.xml index 69ae62115..3df335e36 100644 --- a/utilities/ovn-sbctl.8.xml +++ b/utilities/ovn-sbctl.8.xml @@ -279,9 +279,19 @@ been initialized, this command has no effect. </dd> - <dt><code>show</code></dt> + <dt> + [<code>--filter=<var>filter-rule</var>[,<var>filter-rule</var>...]</code>] + <code>show</code> + </dt> <dd> Prints a brief overview of the database contents. + If <code>--filter</code> is specified, output is filtered according to + the rules. Each <var>filter-rule</var> has the form + <code><var>table-name</var>(<var>filter</var>[|<var>filter</var>]...)</code>. + If <var>table-name</var> is omitted, filtering is applied to + the <code>Chassis</code> table by default. A row is shown only if its + printed representation (including all referenced rows) contains at + least one of the specified <var>filter</var> substrings. </dd> </dl> -- 2.48.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev