ovsdb-server: Make database name mandatory when specifying db paths.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 24 Jun 2013 15:38:22 +0000 (08:38 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Wed, 26 Jun 2013 17:46:37 +0000 (10:46 -0700)
Currently, if we have just one database, we can optionally skip the
database name when providing the DB path for certain options (ex:
--remote=db:[db,]table,column). But in case we have multiple databases,
it is mandatory.

With this commit, we make the database name mandatory. This provides
increased flexibility for an upcoming commit that provides the ability
to add and remove databases during run time.

Feature #14595.
Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
NEWS
ovsdb/ovsdb-server.1.in
ovsdb/ovsdb-server.c
tests/ovsdb-server.at

diff --git a/NEWS b/NEWS
index 7b43447..b07a651 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ post-v1.11.0
     - New "check-oftest" Makefile target for running OFTest against Open
       vSwitch.  See README-OFTest for details.
     - The flow eviction threshold has been moved to the Open_vSwitch table.
+    - Database names are now mandatory when specifying ovsdb-server options
+      through database paths (e.g. Private key option with the database name
+      should look like "--private-key=db:Open_vSwitch,SSL,private_key").
 
 
 v1.11.0 - xx xxx xxxx
index 82dd9c6..ceefef5 100644 (file)
@@ -45,12 +45,10 @@ Adds \fIremote\fR as a connection method used by \fBovsdb\-server\fR.
 .so ovsdb/remote-passive.man
 .so ovsdb/remote-active.man
 .
-.IP "\fBdb:\fR[\fIdb\fB,\fR]\fItable\fB,\fIcolumn\fR"
+.IP "\fBdb:\fIdb\fB,\fItable\fB,\fIcolumn\fR"
 Reads additional connection methods from \fIcolumn\fR in all of the
-rows in \fItable\fR within \fIdb\fR.  (If \fBovsdb\-server\fR is
-providing access to only one database, then \fIdb\fR is optional.)  As
-the contents of \fIcolumn\fR changes, \fBovsdb\-server\fR also adds
-and drops connection methods accordingly.
+rows in \fItable\fR within \fIdb\fR.  As the contents of \fIcolumn\fR changes,
+\fBovsdb\-server\fR also adds and drops connection methods accordingly.
 .IP
 If \fIcolumn\fR's type is string or set of strings, then the
 connection methods are taken directly from the column.  The connection
@@ -98,9 +96,9 @@ configured remotes.
 The options described below for configuring the SSL public key
 infrastructure accept a special syntax for obtaining their
 configuration from the database.  If any of these options is given
-\fBdb:\fR[\fIdb\fB,\fR]\fItable\fB,\fIcolumn\fR as its argument, then the
+\fBdb:\fIdb\fB,\fItable\fB,\fIcolumn\fR as its argument, then the
 actual file name is read from the specified \fIcolumn\fR in \fItable\fR
-within the \fBovsdb\-server\fR database.  The \fIcolumn\fR must have type
+within the \fIdb\fR database.  The \fIcolumn\fR must have type
 string or set of strings.  The first nonempty string in the table is taken
 as the file name.  (This means that ordinarily there should be at most
 one row in \fItable\fR.)
@@ -140,9 +138,9 @@ with an error if \fIremote\fR is not configured as a remote.  This
 command only works with remotes that were named on \fB\-\-remote\fR or
 \fBovsdb\-server/add\-remote\fR, that is, it will not remove remotes
 added indirectly because they were read from the database by
-configuring a \fBdb:\fR[\fIdb\fB,\fR]\fItable\fB,\fIcolumn\fR remote.
+configuring a \fBdb:\fIdb\fB,\fItable\fB,\fIcolumn\fR remote.
 (You can remove a database source with \fBovsdb\-server/remove\-remote
-\fBdb:\fR[\fIdb\fB,\fR]\fItable\fB,\fIcolumn\fR, but not individual
+\fBdb:\fIdb\fB,\fItable\fB,\fIcolumn\fR, but not individual
 remotes found indirectly through the database.)
 .
 .IP "\fBovsdb\-server/list\-remotes"
@@ -150,7 +148,7 @@ Outputs a list of the currently configured remotes named on
 \fB\-\-remote\fR or \fBovsdb\-server/add\-remote\fR, that is, it does
 not list remotes added indirectly because they were read from the
 database by configuring a
-\fBdb:\fR[\fIdb\fB,\fR]\fItable\fB,\fIcolumn\fR remote.
+\fBdb:\fIdb\fB,\fItable\fB,\fIcolumn\fR remote.
 .
 .so lib/vlog-unixctl.man
 .so lib/memory-unixctl.man
index f992e59..919575a 100644 (file)
@@ -339,7 +339,7 @@ parse_db_column__(const struct shash *all_dbs,
                   const struct ovsdb_table **tablep,
                   const struct ovsdb_column **columnp)
 {
-    const char *table_name, *column_name;
+    const char *db_name, *table_name, *column_name;
     const struct ovsdb_column *column;
     const struct ovsdb_table *table;
     const char *tokens[3];
@@ -354,30 +354,17 @@ parse_db_column__(const struct shash *all_dbs,
     tokens[0] = strtok_r(NULL, ",", &save_ptr);
     tokens[1] = strtok_r(NULL, ",", &save_ptr);
     tokens[2] = strtok_r(NULL, ",", &save_ptr);
-    if (!tokens[0] || !tokens[1]) {
+    if (!tokens[0] || !tokens[1] || !tokens[2]) {
         return xasprintf("\"%s\": invalid syntax", name_);
     }
-    if (tokens[2]) {
-        const char *db_name = tokens[0];
-        table_name = tokens[1];
-        column_name = tokens[2];
-
-        db = find_db(all_dbs, tokens[0]);
-        if (!db) {
-            return xasprintf("\"%s\": no database named %s", name_, db_name);
-        }
-    } else {
-        struct shash_node *node;
-        if (shash_count(all_dbs) > 1) {
-            return xasprintf("\"%s\": database name must be specified "
-                             "(because multiple databases are configured)",
-                             name_);
-        }
 
-        table_name = tokens[0];
-        column_name = tokens[1];
-        node = shash_first(all_dbs);
-        db = (struct db *)node->data;
+    db_name = tokens[0];
+    table_name = tokens[1];
+    column_name = tokens[2];
+
+    db = find_db(all_dbs, tokens[0]);
+    if (!db) {
+        return xasprintf("\"%s\": no database named %s", name_, db_name);
     }
 
     table = ovsdb_get_table(db->db, table_name);
index acb5a44..2368cbc 100644 (file)
@@ -207,7 +207,7 @@ AT_CHECK(
         "uuid-name": "x",
         "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
 ON_EXIT([kill `cat ovsdb-server.pid`])
-AT_CHECK([ovsdb-server --enable-dummy --detach --no-chdir --pidfile --remote=db:Root,managers --remote=db:Root,manager_options --log-file db], [0], [ignore], [ignore])
+AT_CHECK([ovsdb-server --enable-dummy --detach --no-chdir --pidfile --remote=db:mydb,Root,managers --remote=db:mydb,Root,manager_options --log-file db], [0], [ignore], [ignore])
 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
 AT_CHECK(
   [[ovsdb-client transact unix:socket1 \
@@ -344,9 +344,9 @@ AT_CHECK(
 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
 AT_CHECK(
   [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
-        --private-key=db:SSL,private_key \
-        --certificate=db:SSL,certificate \
-        --ca-cert=db:SSL,ca_cert \
+        --private-key=db:mydb,SSL,private_key \
+        --certificate=db:mydb,SSL,certificate \
+        --ca-cert=db:mydb,SSL,ca_cert \
         --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
   [0], [ignore], [ignore])
 SSL_PORT=`parse_listening_port < ovsdb-server.log`