Every row in the database has a UUID, generated by the database server. Rows in most tables also have a user-assigned name (e.g. a bridge or port or interface name). The ovs-vsctl database commands (e.g. "set", "get", "list", ...) accept both UUIDs and names, but until now if a command's argument had the form of a UUID, then it had to be the database-assigned UUID for a row; that is, ovs-vsctl did not check whether it was the name of a row. This commit changes that: a UUID argument to a database command is now first checked against database UUIDs then, if it is not a database UUID, it is checked as the name of a row.
This is prompted by Windows integration with OpenStack, which uses UUIDs as port names. CC: Nithin Raju <[email protected]> Requested-by: Gurucharan Shetty <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> --- tests/ovs-vsctl.at | 18 ++++++++++++++++++ utilities/ovs-vsctl.c | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 2f83566..fe65aed 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -1285,3 +1285,21 @@ AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])]) OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([naming in db commands]) +OVS_VSCTL_SETUP + +dnl First check that the database commands can refer to row by database UUID. +AT_CHECK([RUN_OVS_VSCTL([add-br br0])]) +uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)` +AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0" +]) + +dnl Next check that, if a database row is given a name that has the same form +dnl as the database UUIDs, the name can still be used to refer to rows. +AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])]) +AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal +]) + +OVS_VSCTL_CLEANUP +AT_CLEANUP diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 270d9bf..8ac6d10 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -2744,9 +2744,11 @@ get_row (struct vsctl_context *ctx, const struct ovsdb_idl_row *row; struct uuid uuid; + row = NULL; if (uuid_from_string(&uuid, record_id)) { row = ovsdb_idl_get_row_for_uuid(ctx->idl, table->class, &uuid); - } else { + } + if (!row) { int i; for (i = 0; i < ARRAY_SIZE(table->row_ids); i++) { -- 1.7.10.4 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
