Re: [ovs-dev] [PATCH v8] ovsdb-idl: Add the support to specify the uuid for row insert.

2022-11-30 Thread Ilya Maximets
On 11/29/22 01:32, Terry Wilson wrote:
> On Sun, Nov 27, 2022 at 9:56 PM mailto:num...@ovn.org>> 
> wrote:
> 
> From: Numan Siddique mailto:num...@ovn.org>>
> 
> ovsdb-server allows the OVSDB clients to specify the uuid for
> the row inserts [1].  Both the C IDL client library and Python
> IDL are missing this feature.  This patch adds this support.
> 
> In C IDL, for each schema table, a new function is generated -
> insert_persistent_uuid(txn, uuid) which can
> be used the clients to persist the uuid.
> 
> ovs-vsctl and other derivatives of ctl now supports the same
> in the generic 'create' command with the option "--id=".
> 
> In Python IDL, the uuid to persist can be specified in
> the Transaction.insert() function.
> 
> [1] - a529e3cd1f("ovsdb-server: Allow OVSDB clients to specify the UUID 
> for inserted rows.:)
> 
> Signed-off-by: Numan Siddique mailto:num...@ovn.org>>
> Acked-by: Adrian Moreno mailto:amore...@redhat.com>>
> Acked-by: Han Zhou mailto:hz...@ovn.org>>
> CC: twil...@redhat.com 
> CC: i.maxim...@ovn.org 
>
> Looks good to me, I'll work on adding some code to ovsdbapp that uses this as 
> well. Thanks!
> 
> Acked-by: Terry Wilson mailto:twil...@redhat.com>> 

Applied.  Thanks!

Best regards, Ilya Maximets.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v8] ovsdb-idl: Add the support to specify the uuid for row insert.

2022-11-28 Thread Terry Wilson
On Sun, Nov 27, 2022 at 9:56 PM  wrote:

> From: Numan Siddique 
>
> ovsdb-server allows the OVSDB clients to specify the uuid for
> the row inserts [1].  Both the C IDL client library and Python
> IDL are missing this feature.  This patch adds this support.
>
> In C IDL, for each schema table, a new function is generated -
> insert_persistent_uuid(txn, uuid) which can
> be used the clients to persist the uuid.
>
> ovs-vsctl and other derivatives of ctl now supports the same
> in the generic 'create' command with the option "--id=".
>
> In Python IDL, the uuid to persist can be specified in
> the Transaction.insert() function.
>
> [1] - a529e3cd1f("ovsdb-server: Allow OVSDB clients to specify the UUID
> for inserted rows.:)
>
> Signed-off-by: Numan Siddique 
> Acked-by: Adrian Moreno 
> Acked-by: Han Zhou 
> CC: twil...@redhat.com
> CC: i.maxim...@ovn.org
>
> ---
> v7 -> v8
> ---
>   * Addressed the review comments from Ilya.
>   - Added the same support in Python IDL.
>   - Reworked the test cases to make them
> generic - for both C and Python.
>
> v6 -> v7
> ---
>   * Rebased to resolve conflicts.
>
> v5 -> v6
> ---
>   * Rebased to resolve conflicts.
>
> v4 -> v5
> ---
>   * Addressed review comments from Ilya.
>  - Added NEWS item entry.
>
> v3 -> v4
> ---
>   * Added an entry in python/TODO.rst.
>
> v2 -> v3
> 
>   * Addressed review comments from Han
>   - Added test case for --id ctl option
>
> v1 -> v2
> -
>   * Addressed review comments from Adrian Moreno
>   * Added the support in generic 'create' command to specify the uuid in
> --id option.
>
>
>  NEWS |  3 ++
>  lib/db-ctl-base.c| 38 --
>  lib/db-ctl-base.man  |  5 ++-
>  lib/db-ctl-base.xml  |  6 ++-
>  lib/ovsdb-idl-provider.h |  1 +
>  lib/ovsdb-idl.c  | 85 +---
>  lib/ovsdb-idl.h  |  3 ++
>  ovsdb/ovsdb-idlc.in  | 15 +++
>  python/ovs/db/idl.py | 26 
>  tests/ovs-vsctl.at   | 25 
>  tests/ovsdb-idl.at   | 58 +++
>  tests/test-ovsdb.c   | 28 +++--
>  tests/test-ovsdb.py  | 20 +-
>  13 files changed, 263 insertions(+), 50 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index ff77ee404..b827a64ab 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -24,6 +24,9 @@ Post-v3.0.0
> If a user wishes to benefit from these fixes it is recommended to
> use
> DPDK 21.11.2.
>
> +   - OVSDB-IDL:
> + * Add the support to specify the persistent uuid for row insert in
> both
> +   C and Python IDLs.
>
>  v3.0.0 - 15 Aug 2022
>  
> diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
> index bc85e9921..856832a04 100644
> --- a/lib/db-ctl-base.c
> +++ b/lib/db-ctl-base.c
> @@ -1731,29 +1731,43 @@ cmd_create(struct ctl_context *ctx)
>  const struct ovsdb_idl_table_class *table;
>  const struct ovsdb_idl_row *row;
>  const struct uuid *uuid = NULL;
> +bool persist_uuid = false;
> +struct uuid uuid_;
>  int i;
>
>  ctx->error = get_table(table_name, &table);
>  if (ctx->error) {
>  return;
>  }
> +
>  if (id) {
> -struct ovsdb_symbol *symbol = NULL;
> +if (uuid_from_string(&uuid_, id)) {
> +uuid = &uuid_;
> +persist_uuid = true;
> +} else {
> +struct ovsdb_symbol *symbol = NULL;
>
> -ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
> -if (ctx->error) {
> -return;
> -}
> -if (table->is_root) {
> -/* This table is in the root set, meaning that rows created
> in it
> - * won't disappear even if they are unreferenced, so disable
> - * warnings about that by pretending that there is a
> reference. */
> -symbol->strong_ref = true;
> +ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
> +if (ctx->error) {
> +return;
> +}
> +if (table->is_root) {
> +/* This table is in the root set, meaning that rows
> created in
> + * it won't disappear even if they are unreferenced, so
> disable
> + * warnings about that by pretending that there is a
> + * reference. */
> +symbol->strong_ref = true;
> +}
> +uuid = &symbol->uuid;
>  }
> -uuid = &symbol->uuid;
>  }
>
> -row = ovsdb_idl_txn_insert(ctx->txn, table, uuid);
> +if (persist_uuid) {
> +row = ovsdb_idl_txn_insert_persist_uuid(ctx->txn, table, uuid);
> +} else {
> +row = ovsdb_idl_txn_insert(ctx->txn, table, uuid);
> +}
> +
>  for (i = 2; i < ctx->argc; i++) {
>  ctx->error = set_column(table, row, ctx->argv[i], ctx->symtab);
>  if (ctx->error) {
> diff --git a/lib/db-ctl-base.man b/lib/db-ctl-base.man
> index a529d8b4d..c8111c

Re: [ovs-dev] [PATCH v8] ovsdb-idl: Add the support to specify the uuid for row insert.

2022-11-27 Thread 0-day Robot
Bleep bloop.  Greetings Numan Siddique, 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 is 108 characters long (recommended limit is 79)
#126 FILE: lib/db-ctl-base.man:206:
.IP "[\fB\-\-id=(@\fIname\fR | \fIuuid\fR] \fBcreate\fR \fItable 
column\fR[\fB:\fIkey\fR]\fB=\fIvalue\fR..."

WARNING: Line is 174 characters long (recommended limit is 79)
#149 FILE: lib/db-ctl-base.xml:313:
[--id=(@name|uuid)] 
create table 
column[:key]=value...

Lines checked: 628, Warnings: 2, 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


[ovs-dev] [PATCH v8] ovsdb-idl: Add the support to specify the uuid for row insert.

2022-11-27 Thread numans
From: Numan Siddique 

ovsdb-server allows the OVSDB clients to specify the uuid for
the row inserts [1].  Both the C IDL client library and Python
IDL are missing this feature.  This patch adds this support.

In C IDL, for each schema table, a new function is generated -
insert_persistent_uuid(txn, uuid) which can
be used the clients to persist the uuid.

ovs-vsctl and other derivatives of ctl now supports the same
in the generic 'create' command with the option "--id=".

In Python IDL, the uuid to persist can be specified in
the Transaction.insert() function.

[1] - a529e3cd1f("ovsdb-server: Allow OVSDB clients to specify the UUID for 
inserted rows.:)

Signed-off-by: Numan Siddique 
Acked-by: Adrian Moreno 
Acked-by: Han Zhou 
CC: twil...@redhat.com
CC: i.maxim...@ovn.org

---
v7 -> v8
---
  * Addressed the review comments from Ilya.
  - Added the same support in Python IDL.
  - Reworked the test cases to make them
generic - for both C and Python.

v6 -> v7
---
  * Rebased to resolve conflicts.

v5 -> v6
---
  * Rebased to resolve conflicts.

v4 -> v5
---
  * Addressed review comments from Ilya.
 - Added NEWS item entry.

v3 -> v4
---
  * Added an entry in python/TODO.rst.

v2 -> v3

  * Addressed review comments from Han
  - Added test case for --id ctl option

v1 -> v2
-
  * Addressed review comments from Adrian Moreno
  * Added the support in generic 'create' command to specify the uuid in
--id option.


 NEWS |  3 ++
 lib/db-ctl-base.c| 38 --
 lib/db-ctl-base.man  |  5 ++-
 lib/db-ctl-base.xml  |  6 ++-
 lib/ovsdb-idl-provider.h |  1 +
 lib/ovsdb-idl.c  | 85 +---
 lib/ovsdb-idl.h  |  3 ++
 ovsdb/ovsdb-idlc.in  | 15 +++
 python/ovs/db/idl.py | 26 
 tests/ovs-vsctl.at   | 25 
 tests/ovsdb-idl.at   | 58 +++
 tests/test-ovsdb.c   | 28 +++--
 tests/test-ovsdb.py  | 20 +-
 13 files changed, 263 insertions(+), 50 deletions(-)

diff --git a/NEWS b/NEWS
index ff77ee404..b827a64ab 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,9 @@ Post-v3.0.0
If a user wishes to benefit from these fixes it is recommended to use
DPDK 21.11.2.
 
+   - OVSDB-IDL:
+ * Add the support to specify the persistent uuid for row insert in both
+   C and Python IDLs.
 
 v3.0.0 - 15 Aug 2022
 
diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index bc85e9921..856832a04 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -1731,29 +1731,43 @@ cmd_create(struct ctl_context *ctx)
 const struct ovsdb_idl_table_class *table;
 const struct ovsdb_idl_row *row;
 const struct uuid *uuid = NULL;
+bool persist_uuid = false;
+struct uuid uuid_;
 int i;
 
 ctx->error = get_table(table_name, &table);
 if (ctx->error) {
 return;
 }
+
 if (id) {
-struct ovsdb_symbol *symbol = NULL;
+if (uuid_from_string(&uuid_, id)) {
+uuid = &uuid_;
+persist_uuid = true;
+} else {
+struct ovsdb_symbol *symbol = NULL;
 
-ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
-if (ctx->error) {
-return;
-}
-if (table->is_root) {
-/* This table is in the root set, meaning that rows created in it
- * won't disappear even if they are unreferenced, so disable
- * warnings about that by pretending that there is a reference. */
-symbol->strong_ref = true;
+ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
+if (ctx->error) {
+return;
+}
+if (table->is_root) {
+/* This table is in the root set, meaning that rows created in
+ * it won't disappear even if they are unreferenced, so disable
+ * warnings about that by pretending that there is a
+ * reference. */
+symbol->strong_ref = true;
+}
+uuid = &symbol->uuid;
 }
-uuid = &symbol->uuid;
 }
 
-row = ovsdb_idl_txn_insert(ctx->txn, table, uuid);
+if (persist_uuid) {
+row = ovsdb_idl_txn_insert_persist_uuid(ctx->txn, table, uuid);
+} else {
+row = ovsdb_idl_txn_insert(ctx->txn, table, uuid);
+}
+
 for (i = 2; i < ctx->argc; i++) {
 ctx->error = set_column(table, row, ctx->argv[i], ctx->symtab);
 if (ctx->error) {
diff --git a/lib/db-ctl-base.man b/lib/db-ctl-base.man
index a529d8b4d..c8111c9ef 100644
--- a/lib/db-ctl-base.man
+++ b/lib/db-ctl-base.man
@@ -203,7 +203,7 @@ Without \fB\-\-if-exists\fR, it is an error if \fIrecord\fR 
does not
 exist.  With \fB\-\-if-exists\fR, this command does nothing if
 \fIrecord\fR does not exist.
 .
-.IP "[\fB\-\-id=@\fIname\fR] \fBcreate\fR \fItable 
column\fR[\fB:\fIkey\fR]\fB=\