Hi Alexandra,
I just tried to test this, and unfortunately, ovn-sbctl.c had
compilation errors when I attempted.
utilities/ovn-sbctl.c:417:6: error: extra brace group at end of initializer
417 | {&sbrec_chassis_col_name,
| ^
utilities/ovn-sbctl.c:428:6: error: extra brace group at end of initializer
428 | {NULL, NULL, NULL}
|
utilities/ovn-sbctl.c:432:44: error: extra brace group at end of initializer
432 | {NULL, NULL, NULL}},
|
I'm guessing that this patch needs to be re-rolled due to an intervening
update to the cmd_show_tables struct.
I have a couple of other notes in-line.
On 3/10/25 06:01, Alexandra Rukomoinikova wrote:
Add support for 'show' command filtering by chassis name, hostname,
and IP.
Based on "lib: Enhance the OVS cmd_show for options args" patch in
ovs.
Signed-off-by: Alexandra Rukomoinikova <arukomoinikova@k2.cloud>
---
tests/ovn-sbctl.at | 35 +++++++++++++++++++++++++++++++++++
utilities/ovn-ic-nbctl.c | 7 +++++--
utilities/ovn-sbctl.c | 18 +++++++++++++-----
3 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at
index 9bb3993f5..370835512 100644
--- a/tests/ovn-sbctl.at
+++ b/tests/ovn-sbctl.at
@@ -164,6 +164,41 @@ Chassis ch0
Port_Binding vif0
])
+AT_CHECK([ovn-sbctl chassis-add ch1 geneve 1.2.3.6])
+AT_CHECK([ovn-sbctl chassis-add ch2 geneve 1.2.3.7])
+AT_CHECK([ovn-sbctl chassis-add ch3 geneve 1.2.3.4])
+
+AT_CHECK([ovn-sbctl show | grep Chassis | sort], [0], [dnl
+Chassis ch0
+Chassis ch1
+Chassis ch2
+Chassis ch3
+])
+
+AT_CHECK([ovn-sbctl show 1.2.3.6 1.2.3.4 | grep Chassis | sort], [0], [dnl
+Chassis ch1
+Chassis ch3
+])
+
+AT_CHECK([ovn-sbctl show 1.2.3.4 ch1 ch2 | grep Chassis | sort], [0], [dnl
+Chassis ch1
+Chassis ch2
+Chassis ch3
+])
+
+AT_CHECK([ovn-sbctl show ch0 ch1 | grep Chassi | sort], [0], [dnl
+Chassis ch0
+Chassis ch1
+])
+
+ch1uuid=$(ovn-sbctl --columns=_uuid list Chassis ch1 | cut -d ':' -f2 | tr -d
' ')
This can be done using the fetch_column macro in ovn-macros.at
ch1uuid=$(fetch_column Chassis _uuid name=ch1)
+
+AT_CHECK([ovn-sbctl set Chassis $ch1uuid hostname=host1])
+AT_CHECK([ovn-sbctl show host1 ch2 | grep Chassis | sort], [0], [dnl
+Chassis ch1
+Chassis ch2
+])
+
uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d '
')
AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list
Port_Binding], [0], [dnl
logical_port : vif0
diff --git a/utilities/ovn-ic-nbctl.c b/utilities/ovn-ic-nbctl.c
index 5819192fe..854cd34c6 100644
--- a/utilities/ovn-ic-nbctl.c
+++ b/utilities/ovn-ic-nbctl.c
@@ -398,9 +398,12 @@ static struct cmd_show_table cmd_show_tables[] = {
{&icnbrec_table_transit_switch,
&icnbrec_transit_switch_col_name,
{NULL},
- {NULL, NULL, NULL}},
+ {NULL, NULL, NULL},
+ {NULL, NULL, NULL}
+ },
- {NULL, NULL, {NULL, NULL, NULL}, {NULL, NULL, NULL}},
+ {NULL, NULL, {NULL, NULL, NULL}, {NULL, NULL, NULL},
+ {NULL, NULL, NULL}},
};
static void
diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c
index b00b8cd04..bdb4e6ce2 100644
--- a/utilities/ovn-sbctl.c
+++ b/utilities/ovn-sbctl.c
@@ -91,7 +91,8 @@ sbctl_usage(void)
usage: %s [OPTIONS] COMMAND [ARG...]\n\
\n\
General commands:\n\
- show print overview of database contents\n\
+ show CHASSIS-NAME CHASSIS-HOSTNAME ENCAP-IP print overview of database\n\
+ contents\n\
CHASSIS-NAME, CHASSIS-HOSTNAME, and ENCAP-IP are all optional arguments,
so they should be enclosed in square brackets:
"show [CHASSIS-NAME] [CHASSIS-HOSTNAME] [ENCAP-IP] ..."
\n\
Chassis commands:\n\
chassis-add CHASSIS ENCAP-TYPE ENCAP-IP create a new chassis named\n\
@@ -412,16 +413,23 @@ static struct cmd_show_table cmd_show_tables[] = {
NULL},
{&sbrec_table_port_binding,
&sbrec_port_binding_col_logical_port,
- &sbrec_port_binding_col_chassis}},
+ &sbrec_port_binding_col_chassis},
+ {&sbrec_chassis_col_name,
+ &sbrec_chassis_col_hostname,
+ &sbrec_chassis_col_encaps}
+ },
{&sbrec_table_encap,
&sbrec_encap_col_type,
{&sbrec_encap_col_ip,
&sbrec_encap_col_options,
- NULL},
- {NULL, NULL, NULL}},
+ NULL, NULL},
+ {NULL, NULL, NULL},
+ {NULL, NULL, NULL}
+ },
- {NULL, NULL, {NULL, NULL, NULL}, {NULL, NULL, NULL}},
+ {NULL, NULL, {NULL, NULL, NULL, NULL}, {NULL, NULL, NULL},
+ {NULL, NULL, NULL}},
};
static void
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev