From: Ben Pfaff Date: Tue, 26 Jul 2011 16:53:49 +0000 (-0700) Subject: ovsdb-server: Make database command-line argument optional. X-Git-Tag: v1.2.0~37 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=2970119462bf163a21ed0bc14f0268b0a54df508;p=sliver-openvswitch.git 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. --- diff --git a/INSTALL.Linux b/INSTALL.Linux index c7e4ed97d..6442fcc9b 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 6100c4d5b..9e2d79aae 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 5477e8680..9c01c4e4a 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