.IP "\fBlist \fItable \fR[\fIrecord\fR]..."
List the values of all columns of each specified \fIrecord\fR. If no
records are specified, lists all the records in \fItable\fR.
+.IP
+The UUIDs shown for rows created in the same \fBovs\-vsctl\fR
+invocation will be wrong.
.
.IP "\fBget \fItable record column\fR[\fB:\fIkey\fR]..."
Prints the value of each specified \fIcolumn\fR in the given
.IP "\fB\-\-force create \fItable column\fR[\fB:\fIkey\fR]\fB=\fIvalue\fR..."
Creates a new record in \fItable\fR and sets the initial values of
each \fIcolumn\fR. Columns not explicitly set will receive their
-default values.
+default values. Outputs the UUID of the new row.
.IP
This command requires the \fB\-\-force\fR option.
.
ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(&row->uuid));
}
+/* This function may be used as the 'postprocess' function for commands that
+ * insert new rows into the database. It expects that the command's 'run'
+ * function prints the UUID reported by ovsdb_idl_txn_insert() as the command's
+ * sole output. It replaces that output by the row's permanent UUID assigned
+ * by the database server and appends a new-line.
+ *
+ * Currently we use this only for "create", because the higher-level commands
+ * are supposed to be independent of the actual structure of the vswitch
+ * configuration. */
+static void
+post_create(struct vsctl_context *ctx)
+{
+ const struct uuid *real;
+ struct uuid dummy;
+
+ uuid_from_string(&dummy, ds_cstr(&ctx->output));
+ real = ovsdb_idl_txn_get_insert_uuid(ctx->txn, &dummy);
+ if (real) {
+ ds_clear(&ctx->output);
+ ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(real));
+ }
+ ds_put_char(&ctx->output, '\n');
+}
+
static void
cmd_destroy(struct vsctl_context *ctx)
{
{"add", 4, INT_MAX, cmd_add, NULL, "--force"},
{"remove", 4, INT_MAX, cmd_remove, NULL, "--force"},
{"clear", 3, INT_MAX, cmd_clear, NULL, "--force"},
- {"create", 2, INT_MAX, cmd_create, NULL, "--force"},
+ {"create", 2, INT_MAX, cmd_create, post_create, "--force"},
{"destroy", 1, INT_MAX, cmd_destroy, NULL, "--force,--if-exists"},
{NULL, 0, 0, NULL, NULL, NULL},