[ovs-dev] [PATCH ovn] nbctl: Add optional ha-chassis-group arg to ha-chassis-group-list

2023-10-17 Thread Evgenii Kovalev
This commit adds support for optional ha-chassis-group argument to
ha-chassis-group-list command to show one record.

Also add few tests to validate output from ha-chassis-group-list.

Signed-off-by: Evgenii Kovalev 
---
 tests/ovn-nbctl.at| 53 +
 utilities/ovn-nbctl.8.xml |  8 +++---
 utilities/ovn-nbctl.c | 55 +++
 3 files changed, 96 insertions(+), 20 deletions(-)

diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index fde3a28ee..7206d1fe5 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -2741,3 +2741,56 @@ cp $PKIDIR/$cert $cert
 OVS_WAIT_UNTIL([ovn-appctl -t ovn-nbctl run show])
 
 AT_CLEANUP
+
+dnl -
+
+AT_SETUP([ovn-nbctl - ha-chassis-group-list group])
+OVN_NBCTL_TEST_START daemon
+check ovn-nbctl ha-chassis-group-add chg1
+chg1uuid=$(fetch_column nb:HA_Chassis_Group _uuid name=chg1)
+check ovn-nbctl ha-chassis-group-add chg2
+chg2uuid=$(fetch_column nb:HA_Chassis_Group _uuid name=chg2)
+check ovn-nbctl ha-chassis-group-add-chassis chg1 hv1 1
+check ovn-nbctl ha-chassis-group-add-chassis chg1 hv2 2
+check ovn-nbctl ha-chassis-group-add-chassis chg2 hv3 3
+check ovn-nbctl ha-chassis-group-add-chassis chg2 hv4 4
+AT_CHECK([ovn-nbctl ha-chassis-group-list], [0], [ignore])
+
+AT_CHECK_UNQUOTED([ovn-nbctl ha-chassis-group-list $chg1uuid | grep chg1 | awk 
'{print $1}'], [0], [dnl
+$chg1uuid
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep chg], 
[0], [dnl
+(chg1)
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep -A1 
hv1], [0], [dnl
+(hv1)
+1
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep -A1 
hv2], [0], [dnl
+(hv2)
+2
+])
+
+AT_CHECK_UNQUOTED([ovn-nbctl ha-chassis-group-list $chg2uuid | grep chg2 | awk 
'{print $1}'], [0], [dnl
+$chg2uuid
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep chg], 
[0], [dnl
+(chg2)
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep -A1 
hv3], [0], [dnl
+(hv3)
+3
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep -A1 
hv4], [0], [dnl
+(hv4)
+4
+])
+
+AT_CHECK([ovn-nbctl ha-chassis-group-list negative], [1], [], [dnl
+ovn-nbctl: negative: ha_chassis_group name not found
+])
+AT_CHECK([ovn-nbctl ha-chassis-group-list 
----], [1], [], [dnl
+ovn-nbctl: ----: ha_chassis_group UUID not 
found
+])
+OVN_NBCTL_TEST_STOP "/terminating with signal 15/d"
+AT_CLEANUP
diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml
index b4af43185..6f74bd557 100644
--- a/utilities/ovn-nbctl.8.xml
+++ b/utilities/ovn-nbctl.8.xml
@@ -1466,10 +1466,12 @@
 group does not exist.
   
 
-  ha-chassis-group-list
+  ha-chassis-group-list [ha-chassis-group]
   
-Lists the HA chassis group group along with the
-HA chassis if any associated with it.
+Lists all HA chassis groups along with the HA chassis
+if any associated with it.
+If ha-chassis-group is also specified, then only the
+specified ha-chassis-group will be listed.
   
 
   ha-chassis-group-add-chassis group
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 444fbd2fe..9029e8133 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -464,9 +464,9 @@ Port group commands:\n\
   pg-set-ports PG PORTS   Set PORTS on port group PG\n\
   pg-del PG   Delete port group PG\n\
 HA chassis group commands:\n\
-  ha-chassis-group-add GRP  Create an HA chassis group GRP\n\
-  ha-chassis-group-del GRP  Delete the HA chassis group GRP\n\
-  ha-chassis-group-list List the HA chassis groups\n\
+  ha-chassis-group-add GRPCreate an HA chassis group GRP\n\
+  ha-chassis-group-del GRPDelete the HA chassis group GRP\n\
+  ha-chassis-group-list [GRP] Print the supplied HA chassis group or all if 
none supplied\n\
   ha-chassis-group-add-chassis GRP CHASSIS PRIORITY Adds an HA\
 chassis with mandatory PRIORITY to the HA chassis group GRP\n\
   ha-chassis-group-remove-chassis GRP CHASSIS Removes the HA chassis\
@@ -7260,7 +7260,7 @@ ha_chassis_group_by_name_or_uuid(struct ctl_context *ctx, 
const char *id,
 }
 
 if (!ha_ch_grp && must_exist) {
-ctx->error = xasprintf("%s: ha_chassi_group %s not found",
+ctx->error = xasprintf("%s: ha_chassis_group %s not found",
id, is_uuid ? "UUID" : "name");
 }
 
@@ -7306,23 +7306,44 @@ pre_ha_ch_grp_list(struct ctl_context *ctx)
 }
 
 static void
-cmd_ha_ch_grp_list(struct ctl_context *ctx)
+ha_ch_grp_info_print(struct ctl_context *ctx, const struct 
nbrec_ha_chassis_group *ha_ch_grp)
+{
+ds_put_format(&ctx->output, UUID_FMT " (%s)\n",
+  UUID_ARGS(&ha_ch_grp->header_.uuid), ha_ch_grp->name);
+const struct nbrec_h

Re: [ovs-dev] [PATCH ovn] nbctl: Add optional ha-chassis-group arg to ha-chassis-group-list

2023-11-03 Thread Numan Siddique
On Tue, Oct 17, 2023 at 12:25 PM Evgenii Kovalev  wrote:
>
> This commit adds support for optional ha-chassis-group argument to
> ha-chassis-group-list command to show one record.
>
> Also add few tests to validate output from ha-chassis-group-list.
>
> Signed-off-by: Evgenii Kovalev 

Thanks for the patch and for the contribution.  I added your name to
AUTHORS list and applied the patch to the main.

Numan

> ---
>  tests/ovn-nbctl.at| 53 +
>  utilities/ovn-nbctl.8.xml |  8 +++---
>  utilities/ovn-nbctl.c | 55 +++
>  3 files changed, 96 insertions(+), 20 deletions(-)
>
> diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
> index fde3a28ee..7206d1fe5 100644
> --- a/tests/ovn-nbctl.at
> +++ b/tests/ovn-nbctl.at
> @@ -2741,3 +2741,56 @@ cp $PKIDIR/$cert $cert
>  OVS_WAIT_UNTIL([ovn-appctl -t ovn-nbctl run show])
>
>  AT_CLEANUP
> +
> +dnl -
> +
> +AT_SETUP([ovn-nbctl - ha-chassis-group-list group])
> +OVN_NBCTL_TEST_START daemon
> +check ovn-nbctl ha-chassis-group-add chg1
> +chg1uuid=$(fetch_column nb:HA_Chassis_Group _uuid name=chg1)
> +check ovn-nbctl ha-chassis-group-add chg2
> +chg2uuid=$(fetch_column nb:HA_Chassis_Group _uuid name=chg2)
> +check ovn-nbctl ha-chassis-group-add-chassis chg1 hv1 1
> +check ovn-nbctl ha-chassis-group-add-chassis chg1 hv2 2
> +check ovn-nbctl ha-chassis-group-add-chassis chg2 hv3 3
> +check ovn-nbctl ha-chassis-group-add-chassis chg2 hv4 4
> +AT_CHECK([ovn-nbctl ha-chassis-group-list], [0], [ignore])
> +
> +AT_CHECK_UNQUOTED([ovn-nbctl ha-chassis-group-list $chg1uuid | grep chg1 | 
> awk '{print $1}'], [0], [dnl
> +$chg1uuid
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep 
> chg], [0], [dnl
> +(chg1)
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep -A1 
> hv1], [0], [dnl
> +(hv1)
> +1
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg1 | awk '{print $2}' | grep -A1 
> hv2], [0], [dnl
> +(hv2)
> +2
> +])
> +
> +AT_CHECK_UNQUOTED([ovn-nbctl ha-chassis-group-list $chg2uuid | grep chg2 | 
> awk '{print $1}'], [0], [dnl
> +$chg2uuid
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep 
> chg], [0], [dnl
> +(chg2)
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep -A1 
> hv3], [0], [dnl
> +(hv3)
> +3
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list chg2 | awk '{print $2}' | grep -A1 
> hv4], [0], [dnl
> +(hv4)
> +4
> +])
> +
> +AT_CHECK([ovn-nbctl ha-chassis-group-list negative], [1], [], [dnl
> +ovn-nbctl: negative: ha_chassis_group name not found
> +])
> +AT_CHECK([ovn-nbctl ha-chassis-group-list 
> ----], [1], [], [dnl
> +ovn-nbctl: ----: ha_chassis_group UUID not 
> found
> +])
> +OVN_NBCTL_TEST_STOP "/terminating with signal 15/d"
> +AT_CLEANUP
> diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml
> index b4af43185..6f74bd557 100644
> --- a/utilities/ovn-nbctl.8.xml
> +++ b/utilities/ovn-nbctl.8.xml
> @@ -1466,10 +1466,12 @@
>  group does not exist.
>
>
> -  ha-chassis-group-list
> +  ha-chassis-group-list 
> [ha-chassis-group]
>
> -Lists the HA chassis group group along with the
> -HA chassis if any associated with it.
> +Lists all HA chassis groups along with the HA chassis
> +if any associated with it.
> +If ha-chassis-group is also specified, then only the
> +specified ha-chassis-group will be listed.
>
>
>ha-chassis-group-add-chassis group
> diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
> index 444fbd2fe..9029e8133 100644
> --- a/utilities/ovn-nbctl.c
> +++ b/utilities/ovn-nbctl.c
> @@ -464,9 +464,9 @@ Port group commands:\n\
>pg-set-ports PG PORTS   Set PORTS on port group PG\n\
>pg-del PG   Delete port group PG\n\
>  HA chassis group commands:\n\
> -  ha-chassis-group-add GRP  Create an HA chassis group GRP\n\
> -  ha-chassis-group-del GRP  Delete the HA chassis group GRP\n\
> -  ha-chassis-group-list List the HA chassis groups\n\
> +  ha-chassis-group-add GRPCreate an HA chassis group GRP\n\
> +  ha-chassis-group-del GRPDelete the HA chassis group GRP\n\
> +  ha-chassis-group-list [GRP] Print the supplied HA chassis group or all if 
> none supplied\n\
>ha-chassis-group-add-chassis GRP CHASSIS PRIORITY Adds an HA\
>  chassis with mandatory PRIORITY to the HA chassis group GRP\n\
>ha-chassis-group-remove-chassis GRP CHASSIS Removes the HA chassis\
> @@ -7260,7 +7260,7 @@ ha_chassis_group_by_name_or_uuid(struct ctl_context 
> *ctx, const char *id,
>  }
>
>  if (!ha_ch_grp && must_exist) {
> -ctx->error = xasprintf("%s: ha_chassi_group %s not found",
> +ctx->error = xasprintf("%s: ha_chassis_group %s not found",
> 

Re: [ovs-dev] [PATCH ovn] nbctl: Add optional ha-chassis-group arg to ha-chassis-group-list

2023-10-17 Thread 0-day Robot
Bleep bloop.  Greetings Evgenii Kovalev, I am a robot and I have tried out your 
patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line lacks whitespace around operator
#110 FILE: utilities/ovn-nbctl.c:467:
  ha-chassis-group-add GRPCreate an HA chassis group GRP\n\

WARNING: Line lacks whitespace around operator
#111 FILE: utilities/ovn-nbctl.c:468:
  ha-chassis-group-del GRPDelete the HA chassis group GRP\n\

WARNING: Line is 92 characters long (recommended limit is 79)
WARNING: Line lacks whitespace around operator
#112 FILE: utilities/ovn-nbctl.c:469:
  ha-chassis-group-list [GRP] Print the supplied HA chassis group or all if 
none supplied\n\

WARNING: Line is 93 characters long (recommended limit is 79)
#130 FILE: utilities/ovn-nbctl.c:7309:
ha_ch_grp_info_print(struct ctl_context *ctx, const struct 
nbrec_ha_chassis_group *ha_ch_grp)

Lines checked: 194, Warnings: 5, Errors: 0


Please check this out.  If you feel there has been an error, please email 
acon...@redhat.com

Thanks,
0-day Robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev