[ovs-dev] [ovsdb-locks 04/11] ovsdb-server: Make database command-line argument optional.
Ben Pfaff
blp at nicira.com
Thu Jul 14 21:27:25 UTC 2011
In practice the default location is the only one used, so we might as well
make it easy.
---
INSTALL.Linux | 13 ++++++-------
ovsdb/ovsdb-server.1.in | 9 +++++----
ovsdb/ovsdb-server.c | 16 +++++++++++-----
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/INSTALL.Linux b/INSTALL.Linux
index c7e4ed9..6442fcc 100644
--- a/INSTALL.Linux
+++ b/INSTALL.Linux
@@ -268,13 +268,12 @@ installation, above, to listen on a Unix domain socket, to connect to
any managers specified in the database itself, and to use the SSL
configuration in the database:
- % ovsdb-server /usr/local/etc/openvswitch/conf.db \
- --remote=punix:/usr/local/var/run/openvswitch/db.sock \
- --remote=db:Open_vSwitch,manager_options \
- --private-key=db:SSL,private_key \
- --certificate=db:SSL,certificate \
- --bootstrap-ca-cert=db:SSL,ca_cert \
- --pidfile --detach
+ % ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
+ --remote=db:Open_vSwitch,manager_options \
+ --private-key=db:SSL,private_key \
+ --certificate=db:SSL,certificate \
+ --bootstrap-ca-cert=db:SSL,ca_cert \
+ --pidfile --detach
(If you built Open vSwitch without SSL support, then omit
--private-key, --certificate, and --bootstrap-ca-cert.)
diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in
index 6100c4d..9e2d79a 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 at 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 5477e86..4202b30 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"
@@ -738,14 +739,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 = 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
--
1.7.4.4
More information about the dev
mailing list