Skip to content

Commit

Permalink
ovsdb-server: Make database command-line argument optional.
Browse files Browse the repository at this point in the history
In practice the default location is the only one used, so we might as well
make it easier.
  • Loading branch information
blp committed Jul 26, 2011
1 parent 2fad9eb commit 2970119
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
13 changes: 6 additions & 7 deletions INSTALL.Linux
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
9 changes: 5 additions & 4 deletions ovsdb/ovsdb-server.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
.
Expand Down
17 changes: 12 additions & 5 deletions ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2970119

Please sign in to comment.