summaryrefslogtreecommitdiff
path: root/utilities/ovs-vsctl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-12-11 10:40:55 -0800
committerBen Pfaff <blp@nicira.com>2009-12-11 13:26:05 -0800
commit524555d18bda66f4f2c4bcb7bfb83b22bf50a942 (patch)
tree01b14cf4e52e09ec5eb799d795e5820c82d74780 /utilities/ovs-vsctl.c
parentbd1b03cd02b6afec15c1d717068cbcc58402ec7a (diff)
downloadopenvswitch-524555d18bda66f4f2c4bcb7bfb83b22bf50a942.tar.gz
ovs-vsctl: Initialize the database automatically.
Diffstat (limited to 'utilities/ovs-vsctl.c')
-rw-r--r--utilities/ovs-vsctl.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 8de6ae112..e86cb7cd9 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
vsctl_fatal("missing command name (use --help for help)");
}
- /* Now execut the commands. */
+ /* Now execute the commands. */
idl = ovsdb_idl_create(db, &ovsrec_idl_class);
seqno = ovsdb_idl_get_seqno(idl);
trials = 0;
@@ -624,6 +624,11 @@ ovs_delete_bridge(const struct ovsrec_open_vswitch *ovs,
}
static void
+cmd_init(struct vsctl_context *ctx UNUSED)
+{
+}
+
+static void
cmd_add_br(struct vsctl_context *ctx)
{
const char *br_name = ctx->argv[1];
@@ -1186,15 +1191,14 @@ do_vsctl(int argc, char *argv[], struct ovsdb_idl *idl)
int n_output;
int i, start;
+ txn = ovsdb_idl_txn_create(idl);
+
ovs = ovsrec_open_vswitch_first(idl);
if (!ovs) {
- /* XXX it would be more user-friendly to create a record ourselves
- * (while verifying that the table is empty before doing so). */
- vsctl_fatal("%s: database does not contain any Open vSwitch "
- "configuration", db);
+ /* XXX add verification that table is empty */
+ ovs = ovsrec_open_vswitch_insert(txn);
}
- txn = ovsdb_idl_txn_create(idl);
output = xmalloc(argc * sizeof *output);
n_output = 0;
for (start = i = 0; i <= argc; i++) {
@@ -1273,6 +1277,9 @@ static vsctl_handler_func *
get_vsctl_handler(int argc, char *argv[], struct vsctl_context *ctx)
{
static const struct vsctl_command all_commands[] = {
+ /* Open vSwitch commands. */
+ {"init", 0, 0, cmd_init, ""},
+
/* Bridge commands. */
{"add-br", 1, 3, cmd_add_br, ""},
{"del-br", 1, 1, cmd_del_br, "--if-exists"},