summaryrefslogtreecommitdiff
path: root/ovsdb/ovsdb-server.c
diff options
context:
space:
mode:
authorGurucharan Shetty <gshetty@nicira.com>2013-06-24 08:38:22 -0700
committerGurucharan Shetty <gshetty@nicira.com>2013-06-26 10:46:37 -0700
commitfb6de52cd7054053f745a880f09607628fc3b7cd (patch)
treeaabdd4418e01d499e6b8367eeac9d8c38f041468 /ovsdb/ovsdb-server.c
parenteeb36a52b4dbec1fb2ebdc13edf0f3d37fa216f4 (diff)
downloadopenvswitch-fb6de52cd7054053f745a880f09607628fc3b7cd.tar.gz
ovsdb-server: Make database name mandatory when specifying db paths.
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>
Diffstat (limited to 'ovsdb/ovsdb-server.c')
-rw-r--r--ovsdb/ovsdb-server.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index f992e5900..919575a57 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -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);