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 <nithin@vmware.com>
Requested-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
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
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++) {