diff options
author | Ben Pfaff <blp@nicira.com> | 2011-07-26 09:53:49 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-07-26 16:50:08 -0700 |
commit | 2970119462bf163a21ed0bc14f0268b0a54df508 (patch) | |
tree | 78f4422a4ee8328757f94a5d216c6176c00b2583 /ovsdb | |
parent | 2fad9ebd12e03a4be9d6f0227b32242287a8bec2 (diff) |
ovsdb-server: Make database command-line argument optional.
In practice the default location is the only one used, so we might as well
make it easier.
Diffstat (limited to 'ovsdb')
-rw-r--r-- | ovsdb/ovsdb-server.1.in | 9 | ||||
-rw-r--r-- | ovsdb/ovsdb-server.c | 17 |
2 files changed, 17 insertions, 9 deletions
diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in index 6100c4d5..9e2d79aa 100644 --- a/ovsdb/ovsdb-server.1.in +++ b/ovsdb/ovsdb-server.1.in @@ -10,7 +10,7 @@ ovsdb\-server \- Open vSwitch database server . .SH SYNOPSIS \fBovsdb\-server\fR -\fIdatabase\fR +[\fIdatabase\fR] [\fB\-\-remote=\fIremote\fR]\&... [\fB\-\-run=\fIcommand\fR] .so lib/daemon-syn.man @@ -25,9 +25,10 @@ The \fBovsdb\-server\fR program provides RPC interfaces to an Open vSwitch database (OVSDB). It supports JSON-RPC client connections over active or passive TCP/IP or Unix domain sockets. .PP -The name of the OVSDB file must be specified on the command line as -\fIdatabase\fR, which must already have been created and initialized -using, for example, \fBovsdb\-tool create\fR. +The OVSDB file may be specified on the command line as \fIdatabase\fR. +The default is \fB@sysconfdir@/openvswitch/conf.db\fR. The database +file must already have been created and initialized using, for +example, \fBovsdb\-tool create\fR. . .SH OPTIONS . diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 5477e868..9c01c4e4 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -25,6 +25,7 @@ #include "column.h" #include "command-line.h" #include "daemon.h" +#include "dirs.h" #include "file.h" #include "json.h" #include "jsonrpc.h" @@ -105,6 +106,7 @@ main(int argc, char *argv[]) if (error) { ovs_fatal(0, "%s", ovsdb_error_to_string(error)); } + free(file_name); jsonrpc = ovsdb_jsonrpc_server_create(db); reconfigure_from_db(jsonrpc, db, &remotes); @@ -738,14 +740,19 @@ parse_options(int argc, char *argv[], char **file_namep, argc -= optind; argv += optind; - if (argc > 1) { + switch (argc) { + case 0: + *file_namep = xasprintf("%s/openvswitch/conf.db", ovs_sysconfdir()); + break; + + case 1: + *file_namep = xstrdup(argv[0]); + break; + + default: ovs_fatal(0, "database file is only non-option argument; " "use --help for usage"); - } else if (argc < 1) { - ovs_fatal(0, "missing database file argument; use --help for usage"); } - - *file_namep = argv[0]; } static void |