mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ovsdb-idl: Add the support to specify the uuid for row insert.
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 - <schema_table>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=<UUID>". 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.:) Acked-by: Adrian Moreno <amorenoz@redhat.com> Acked-by: Han Zhou <hzhou@ovn.org> Acked-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Numan Siddique <numans@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
committed by
Ilya Maximets
parent
954ae38a12
commit
55b9507e68
@@ -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;
|
||||
|
||||
ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
|
||||
if (ctx->error) {
|
||||
return;
|
||||
if (id) {
|
||||
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;
|
||||
}
|
||||
uuid = &symbol->uuid;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user