[ovs-dev] [debian 4/9] Make the location of the database separately configurable.
Ansis Atteka
aatteka at nicira.com
Tue Jul 31 21:35:21 UTC 2012
On Mon, Jul 30, 2012 at 3:18 PM, Ben Pfaff <blp at nicira.com> wrote:
> The default is unchanged, /etc/openvswitch/conf.db.
>
> This makes it possible to transition each Open vSwitch packaging from
> /etc/openvswitch/conf.db to /var/lib/openvswitch/conf.db independently.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
> Makefile.am | 1 +
> configure.ac | 1 +
> lib/automake.mk | 2 ++
> lib/dirs.c.in | 9 ++++++++-
> lib/dirs.h | 3 ++-
> m4/openvswitch.m4 | 10 ++++++++++
> ovsdb/ovsdb-server.1.in | 2 +-
> ovsdb/ovsdb-server.c | 2 +-
> ovsdb/ovsdb-tool.1.in | 2 +-
> ovsdb/ovsdb-tool.c | 2 +-
> python/automake.mk | 1 +
> python/ovs/dirs.py | 1 +
> tests/ofproto-macros.at | 3 ++-
> tests/ovs-monitor-ipsec.at | 1 +
> tests/ovs-xapi-sync.at | 1 +
> tests/unixctl-py.at | 2 ++
> tests/vlog.at | 4 ++++
> utilities/bugtool/ovs-bugtool.in | 4 ++--
> .../bugtool/plugins/system-logs/openvswitch.xml | 3 ++-
> utilities/ovs-ctl.8 | 3 ++-
> utilities/ovs-ctl.in | 7 ++++---
> utilities/ovs-lib.in | 2 ++
> 22 files changed, 52 insertions(+), 14 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 9cad47b..1b14871 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -108,6 +108,7 @@ SUFFIXES += .in
> sed \
> -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
> -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
> + -e 's,[@]DBDIR[@],$(DBDIR),g' \
> -e 's,[@]PERL[@],$(PERL),g' \
> -e 's,[@]PYTHON[@],$(PYTHON),g' \
> -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
> diff --git a/configure.ac b/configure.ac
> index b18b259..9bdffea 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -62,6 +62,7 @@ AC_CHECK_HEADERS([mntent.h sys/statvfs.h linux/types.h])
>
> OVS_CHECK_PKIDIR
> OVS_CHECK_RUNDIR
> +OVS_CHECK_DBDIR
> OVS_CHECK_BACKTRACE
> OVS_CHECK_MALLOC_HOOKS
> OVS_CHECK_VALGRIND
> diff --git a/lib/automake.mk b/lib/automake.mk
> index 5223423..0a7302d 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -311,6 +311,7 @@ lib/dirs.c: lib/dirs.c.in Makefile
> -e 's,[@]srcdir[@],$(srcdir),g' \
> -e 's,[@]LOGDIR[@],"$(LOGDIR)",g' \
> -e 's,[@]RUNDIR[@],"$(RUNDIR)",g' \
> + -e 's,[@]DBDIR[@],"$(DBDIR)",g' \
> -e 's,[@]bindir[@],"$(bindir)",g' \
> -e 's,[@]sysconfdir[@],"$(sysconfdir)",g' \
> -e 's,[@]pkgdatadir[@],"$(pkgdatadir)",g') \
> @@ -329,6 +330,7 @@ lib-install-data-local:
> $(MKDIR_P) $(DESTDIR)$(RUNDIR)
> $(MKDIR_P) $(DESTDIR)$(PKIDIR)
> $(MKDIR_P) $(DESTDIR)$(LOGDIR)
> + $(MKDIR_P) $(DESTDIR)$(DBDIR)
>
> if !USE_LINKER_SECTIONS
> # All distributed sources, with names adjust properly for referencing
> diff --git a/lib/dirs.c.in b/lib/dirs.c.in
> index a5d9f31..2b998b9 100644
> --- a/lib/dirs.c.in
> +++ b/lib/dirs.c.in
> @@ -1,6 +1,6 @@
> #line 2 "@srcdir@/lib/dirs.c.in"
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -66,6 +66,13 @@ ovs_logdir(void)
> }
>
> const char *
> +ovs_dbdir(void)
> +{
> + static struct directory d = { NULL, @DBDIR@, "OVS_DBDIR" };
> + return get_dir(&d);
> +}
> +
> +const char *
> ovs_bindir(void)
> {
> static struct directory d = { NULL, @bindir@, "OVS_BINDIR" };
> diff --git a/lib/dirs.h b/lib/dirs.h
> index 6b4d1ce..811a51f 100644
> --- a/lib/dirs.h
> +++ b/lib/dirs.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -21,6 +21,7 @@ const char *ovs_sysconfdir(void); /* /usr/local/etc */
> const char *ovs_pkgdatadir(void); /* /usr/local/share/openvswitch */
> const char *ovs_rundir(void); /* /usr/local/var/run/openvswitch */
> const char *ovs_logdir(void); /* /usr/local/var/log/openvswitch */
> +const char *ovs_dbdir(void); /* /usr/local/etc/openvswitch */
> const char *ovs_bindir(void); /* /usr/local/bin */
>
> #endif /* dirs.h */
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index eca6010..7adce56 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -132,6 +132,16 @@ AC_DEFUN([OVS_CHECK_LOGDIR],
> [LOGDIR='${localstatedir}/log/${PACKAGE}'])
> AC_SUBST([LOGDIR])])
>
> +dnl Checks for the directory in which to store the Open vSwitch database.
> +AC_DEFUN([OVS_CHECK_DBDIR],
> + [AC_ARG_WITH(
> + [dbdir],
> + AC_HELP_STRING([--with-dbdir=DIR],
> + [directory used for conf.db [[SYSCONFDIR/PACKAGE]]]),
> + [DBDIR=$withval],
> + [DBDIR='${sysconfdir}/${PACKAGE}'])
> + AC_SUBST([DBDIR])])
> +
> dnl Defines HAVE_BACKTRACE if backtrace() is declared in <execinfo.h>
> dnl and exists in libc.
> AC_DEFUN([OVS_CHECK_BACKTRACE],
> diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in
> index 4236f8f..1f5be03 100644
> --- a/ovsdb/ovsdb-server.1.in
> +++ b/ovsdb/ovsdb-server.1.in
> @@ -26,7 +26,7 @@ vSwitch database (OVSDB). It supports JSON-RPC client
> connections
> over active or passive TCP/IP or Unix domain sockets.
> .PP
> 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
> +The default is \fB at DBDIR@/conf.db\fR. The database
> file must already have been created and initialized using, for
> example, \fBovsdb\-tool create\fR.
> .
> diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
> index 139acc6..6c68e50 100644
> --- a/ovsdb/ovsdb-server.c
> +++ b/ovsdb/ovsdb-server.c
> @@ -808,7 +808,7 @@ parse_options(int argc, char *argv[], char
> **file_namep,
>
> switch (argc) {
> case 0:
> - *file_namep = xasprintf("%s/openvswitch/conf.db",
> ovs_sysconfdir());
> + *file_namep = xasprintf("%s/conf.db", ovs_dbdir());
> break;
>
> case 1:
> diff --git a/ovsdb/ovsdb-tool.1.in b/ovsdb/ovsdb-tool.1.in
> index c440e0d..9d32844 100644
> --- a/ovsdb/ovsdb-tool.1.in
> +++ b/ovsdb/ovsdb-tool.1.in
> @@ -148,7 +148,7 @@ record.
> .SS "Other Options"
> .so lib/common.man
> .SH "FILES"
> -The default \fIdb\fR is \fB at sysconfdir@/openvswitch/conf.db\fR. The
> +The default \fIdb\fR is \fB at DBDIR@/conf.db\fR. The
> default \fIschema\fR is \fB at pkgdatadir@/vswitch.ovsschema\fR. The
> \fBhelp\fR command also displays these defaults.
> .SH "SEE ALSO"
> diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
> index f5412f3..4959478 100644
> --- a/ovsdb/ovsdb-tool.c
> +++ b/ovsdb/ovsdb-tool.c
> @@ -140,7 +140,7 @@ default_db(void)
> {
> static char *db;
> if (!db) {
> - db = xasprintf("%s/conf.db", ovs_sysconfdir());
> + db = xasprintf("%s/conf.db", ovs_dbdir());
> }
> return db;
> }
> diff --git a/python/automake.mk b/python/automake.mk
> index b656f08..3cd6e1e 100644
> --- a/python/automake.mk
> +++ b/python/automake.mk
> @@ -47,6 +47,7 @@ ovs-install-data-local:
> echo 'PKGDATADIR = os.environ.get("OVS_PKGDATADIR",
> """$(pkgdatadir)""")' && \
> echo 'RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")' && \
> echo 'LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")' && \
> + echo 'DBDIR = os.environ.get("OVS_DBDIR", """@DBDIR@""")' && \
> echo 'BINDIR = os.environ.get("OVS_BINDIR", """$(bindir)""")') \
> > python/ovs/dirs.py.tmp
> $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/python/ovs
> diff --git a/python/ovs/dirs.py b/python/ovs/dirs.py
> index 5b006cc..a5717fc 100644
> --- a/python/ovs/dirs.py
> +++ b/python/ovs/dirs.py
> @@ -5,4 +5,5 @@ import os
> PKGDATADIR = os.environ.get("OVS_PKGDATADIR",
> "/usr/local/share/openvswitch")
> RUNDIR = os.environ.get("OVS_RUNDIR", "/var/run")
> LOGDIR = os.environ.get("OVS_LOGDIR", "/usr/local/var/log")
> +LOGDIR = os.environ.get("OVS_DBDIR", "/usr/local/etc/openvswitch")
> BINDIR = os.environ.get("OVS_BINDIR", "/usr/local/bin")
> diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
> index e7d6da4..5625a50 100644
> --- a/tests/ofproto-macros.at
> +++ b/tests/ofproto-macros.at
> @@ -31,13 +31,14 @@ m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m'])
> m4_define([OVS_VSWITCHD_START],
> [OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> + OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat ovsdb-server.pid ovs-vswitchd.pid`' 0
>
> dnl Create database.
> mkdir openvswitch
> touch openvswitch/.conf.db.~lock~
> - AT_CHECK([ovsdb-tool create openvswitch/conf.db
> $abs_top_srcdir/vswitchd/vswitch.ovsschema])
> + AT_CHECK([ovsdb-tool create conf.db
> $abs_top_srcdir/vswitchd/vswitch.ovsschema])
>
> dnl Start ovsdb-server.
> AT_CHECK([ovsdb-server --detach --pidfile --log-file
> --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
> diff --git a/tests/ovs-monitor-ipsec.at b/tests/ovs-monitor-ipsec.at
> index e9d6389..1a83161 100644
> --- a/tests/ovs-monitor-ipsec.at
> +++ b/tests/ovs-monitor-ipsec.at
> @@ -4,6 +4,7 @@ AT_SETUP([ovs-monitor-ipsec])
> AT_SKIP_IF([test $HAVE_PYTHON = no])
>
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_PKGDATADIR=`pwd`; export OVS_PKGDATADIR
> cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
>
> diff --git a/tests/ovs-xapi-sync.at b/tests/ovs-xapi-sync.at
> index 5fa61ec..25acc74 100644
> --- a/tests/ovs-xapi-sync.at
> +++ b/tests/ovs-xapi-sync.at
> @@ -9,6 +9,7 @@ PYTHONPATH=`pwd`:$PYTHONPATH
> export PYTHONPATH
>
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_PKGDATADIR=`pwd`; export OVS_PKGDATADIR
> cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
>
> diff --git a/tests/unixctl-py.at b/tests/unixctl-py.at
> index 0374602..15fd86b 100644
> --- a/tests/unixctl-py.at
> +++ b/tests/unixctl-py.at
> @@ -73,6 +73,7 @@ AT_CLEANUP
>
> AT_SETUP([unixctl bad target - Python])
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> AT_SKIP_IF([test $HAVE_PYTHON = no])
>
> AT_CHECK([PYAPPCTL -t bogus doit], [1], [], [stderr])
> @@ -91,6 +92,7 @@ AT_SETUP([unixctl server - Python])
> AT_SKIP_IF([test $HAVE_PYTHON = no])
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat test-unixctl.py.pid`' 0
> AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
> diff --git a/tests/vlog.at b/tests/vlog.at
> index 2bc7b5c..a8a947c 100644
> --- a/tests/vlog.at
> +++ b/tests/vlog.at
> @@ -107,6 +107,7 @@ AT_SETUP([vlog - vlog/reopen - Python])
> AT_SKIP_IF([test $HAVE_PYTHON = no])
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat test-unixctl.py.pid`' 0
>
> @@ -136,6 +137,7 @@ AT_SETUP([vlog - vlog/reopen without log file -
> Python])
> AT_SKIP_IF([test $HAVE_PYTHON = no])
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat test-unixctl.py.pid`' 0
>
> @@ -158,6 +160,7 @@ AT_SKIP_IF([echo > /dev/full])
>
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat test-unixctl.py.pid`' 0
>
> @@ -184,6 +187,7 @@ AT_SETUP([vlog - vlog/set and vlog/list - Python])
> AT_SKIP_IF([test $HAVE_PYTHON = no])
> OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +OVS_DBDIR=`pwd`; export OVS_DBDIR
> OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> trap 'kill `cat test-unixctl.py.pid`' 0
>
> diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/
> ovs-bugtool.in
> index 7018665..2074e23 100755
> --- a/utilities/bugtool/ovs-bugtool.in
> +++ b/utilities/bugtool/ovs-bugtool.in
> @@ -14,7 +14,7 @@
> # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> #
> # Copyright (c) 2005, 2007 XenSource Ltd.
> -# Copyright (c) 2010, 2011 Nicira, Inc.
> +# Copyright (c) 2010, 2011, 2012 Nicira, Inc.
>
> #
> # To add new entries to the bugtool, you need to:
> @@ -115,7 +115,7 @@ OPENVSWITCH_LOG_DIR = '@LOGDIR@/'
> OPENVSWITCH_DEFAULT_SWITCH = '/etc/default/openvswitch-switch' # Debian
> OPENVSWITCH_SYSCONFIG_SWITCH = '/etc/sysconfig/openvswitch' # RHEL
> OPENVSWITCH_DEFAULT_CONTROLLER = '/etc/default/openvswitch-controller'
> -OPENVSWITCH_CONF_DB = '@sysconfdir@/openvswitch/conf.db'
> +OPENVSWITCH_CONF_DB = '@DBDIR@/conf.db'
> OPENVSWITCH_VSWITCHD_PID = '@RUNDIR@/ovs-vswitchd.pid'
> COLLECTD_LOGS_DIR = '/var/lib/collectd/rrd'
> VAR_LOG_DIR = '/var/log/'
> diff --git a/utilities/bugtool/plugins/system-logs/openvswitch.xml
> b/utilities/bugtool/plugins/system-logs/openvswitch.xml
> index 8493361..354af34 100644
> --- a/utilities/bugtool/plugins/system-logs/openvswitch.xml
> +++ b/utilities/bugtool/plugins/system-logs/openvswitch.xml
> @@ -13,9 +13,10 @@
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA.
>
> - Copyright (C) 2011 Nicira, Inc.
> + Copyright (C) 2011, 2012 Nicira, Inc.
> -->
>
> <collect>
> <directory label="ovsdb-backups" filters="ovs"
> pattern=".*/conf.db.backup[0-9][^/]*$">/etc/openvswitch</directory>
> + <directory label="ovsdb-backups2" filters="ovs"
> pattern=".*/conf.db.backup[0-9][^/]*$">/var/lib/openvswitch</directory>
> </collect>
> diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
> index 1a9ee2a..c730778 100644
> --- a/utilities/ovs-ctl.8
> +++ b/utilities/ovs-ctl.8
> @@ -395,6 +395,7 @@ that it runs. \fBovs\-ctl\fR will add the
> \fIsbindir\fR and
> .
> .IP "\fBOVS_LOGDIR\fR"
> .IQ "\fBOVS_RUNDIR\fR"
> +.IQ "\fBOVS_DBDIR\fR"
> .IQ "\fBOVS_SYSCONFDIR\fR"
> .IQ "\fBOVS_PKGDATADIR\fR"
> .IQ "\fBOVS_BINDIR\fR"
> @@ -422,7 +423,7 @@ process ID.
> The OVS database schema used to initialize the database (use
> \fB\-\-db\-schema to override this location).
> .
> -.IP "\fIsysconfdir\fB/openvswitch/conf.db\fR"
> +.IP "\fIdbdir\fB/conf.db\fR"
> The OVS database (use \fB\-\-db\-file\fR to override this location).
> .
> .IP "\fIrundir\fB/openvswitch/db.sock\fR"
> diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
> index 59c2a31..c79c2e6 100755
> --- a/utilities/ovs-ctl.in
> +++ b/utilities/ovs-ctl.in
> @@ -387,7 +387,7 @@ set_defaults () {
> OVS_VSWITCHD_WRAPPER=
> OVS_BRCOMPATD_WRAPPER=
>
> - DB_FILE=$etcdir/conf.db
> + DB_FILE=$dbdir/conf.db
> DB_SOCK=$rundir/db.sock
> DB_SCHEMA=$datadir/vswitch.ovsschema
>
> @@ -475,8 +475,9 @@ Other options:
> -V, --version display version information
>
> Default directories with "configure" option and environment variable
> override:
> - logs: @LOGDIR@ (--log-dir, OVS_LOGDIR)
> - pidfiles and sockets: @RUNDIR@ (--run-dir, OVS_RUNDIR)
> + logs: @LOGDIR@ (--with-logdir, OVS_LOGDIR)
> + pidfiles and sockets: @RUNDIR@ (--with-rundir, OVS_RUNDIR)
> + conf.db: @DBDIR@ (--with-dbdir, OVS_DBDIR)
> system configuration: @sysconfdir@ (--sysconfdir, OVS_SYSCONFDIR)
> data files: @pkgdatadir@ (--pkgdatadir, OVS_PKGDATADIR)
> user binaries: @bindir@ (--bindir, OVS_BINDIR)
> diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
> index 3905a84..893e8d1 100644
> --- a/utilities/ovs-lib.in
> +++ b/utilities/ovs-lib.in
> @@ -22,6 +22,8 @@
> # All of these should be substituted by the Makefile at build time.
> logdir=${OVS_LOGDIR-'@LOGDIR@'} # /var/log/openvswitch
> rundir=${OVS_RUNDIR-'@RUNDIR@'} # /var/run/openvswitch
> +dbdir=${OVS_DBDIR-'@DBDIR@'} # /etc/openvswitch
> + # or /var/lib/openvswitch
> sysconfdir=${OVS_SYSCONFDIR-'@sysconfdir@'} # /etc
> etcdir=$sysconfdir/openvswitch # /etc/openvswitch
> datadir=${OVS_PKGDATADIR-'@pkgdatadir@'} # /usr/share/openvswitch
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
Looks good to me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20120731/a472c277/attachment-0003.html>
More information about the dev
mailing list