xenserver: Install /etc/sysconfig/vswitch by default.
authorBen Pfaff <blp@nicira.com>
Thu, 3 Sep 2009 21:28:44 +0000 (14:28 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 3 Sep 2009 21:28:44 +0000 (14:28 -0700)
Until now, the vswitch RPM has installed /etc/sysconfig/vswitch.example
and made the system administrator copy it to /etc/sysconfig/vswitch if he
desires.  This is slightly inconvenient, since it is slightly easier for
the admin if he can just edit /etc/sysconfig/vswitch directly.  This commit
changes to the latter behavior.

Bug #1810.

xenserver/README
xenserver/automake.mk
xenserver/etc_sysconfig_vswitch.example [deleted file]
xenserver/root_vswitch_scripts_sysconfig.template [new file with mode: 0644]
xenserver/vswitch-xen.spec

index b940e3f..276cd6c 100644 (file)
@@ -30,10 +30,6 @@ files are:
         vswitch-related shell functions for the administrator's
         convenience.
 
-    etc_sysconfig_vswitch.example
-
-        Example configuration options for vswitch.
-
     etc_xapi.d_plugins_vswitch-cfg-update
 
         xapi plugin script to update the cache of configuration items
@@ -54,6 +50,11 @@ files are:
         needed by the controller.  This is called by the "vif" script,
         which is run when virtual interfaces are added and removed.
 
+    root_vswitch_scripts_sysconfig.template
+
+        Template for vswitch's /etc/sysconfig/vswitch configuration
+        file.
+
     usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py
 
         xsconsole plugin to configure the pool-wide configuration keys
index ceebb9d..deb79bc 100644 (file)
@@ -11,10 +11,10 @@ EXTRA_DIST += \
        xenserver/etc_init.d_vswitch-xapi-update \
        xenserver/etc_logrotate.d_vswitch \
        xenserver/etc_profile.d_vswitch.sh \
-       xenserver/etc_sysconfig_vswitch.example \
        xenserver/etc_xapi.d_plugins_vswitch-cfg-update \
        xenserver/etc_xensource_scripts_vif \
        xenserver/opt_xensource_libexec_interface-reconfigure \
+       xenserver/root_vswitch_scripts_sysconfig.template \
        xenserver/root_vswitch_scripts_dump-vif-details \
        xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
        xenserver/usr_sbin_brctl \
diff --git a/xenserver/etc_sysconfig_vswitch.example b/xenserver/etc_sysconfig_vswitch.example
deleted file mode 100644 (file)
index 4bc4b19..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-### Configuration options for vswitch
-
-# Copyright (C) 2009 Nicira Networks, Inc.
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.  This file is offered as-is,
-# without warranty of any kind.
-
-# VSWITCH_BASE: Root directory where vswitch binaries are installed
-# VSWITCH_BASE=/root/vswitch/openvswitch/build
-
-# ENABLE_BRCOMPAT: If 'y' than emulate linux bridging interfaces
-#    using the brcompat kernel module and ovs-brcompatd daemon
-# ENABLE_BRCOMPAT=y
-
-# ENABLE_FAKE_PROC_NET: If 'y' then emulate linux bonding and vlan
-#    files in /proc as if the bonding and vlan demultiplexing done in
-#    ovs-vswitchd were being implemented using existing Linux mechanisms.
-#    This is useful in some cases when replacing existing solutions.
-# ENABLE_FAKE_PROC_NET=y
-
-# FORCE_COREFILES: If 'y' then core files will be enabled.
-# FORCE_COREFILES=y
-
-# COREFILE_PATTERN: Pattern used to determine path and filename for
-#     core files when FORCE_COREFILES is 'y'.  This is Linux specific.
-#     See the manpage for "core".
-# COREFILE_PATTERN="/var/log/%e-%t"
-
-# VSWITCHD_CONF: File in which ovs-vswitchd stores its configuration.
-# VSWITCHD_CONF=/etc/ovs-vswitchd.conf
-
-# VSWITCHD_PIDFILE: File in which to store the pid of the running
-#     ovs-vswitchd.
-# VSWITCHD_PIDFILE=/var/run/ovs-vswitchd.pid
-
-# VSWITCHD_RUN_DIR: Set the directory in which ovs-vswitchd should be
-#     run.  This mainly affects where core files will be placed.
-# VSWITCHD_RUN_DIR=/var/xen/vswitch
-
-# VSWITCHD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related
-#     processes.
-# VSWITCHD_PRIORITY=-5
-
-# VSWITCHD_NETBACK_PRIORITY: "nice" priority at which to run netback.
-#     It is a good idea to run ovs-vswitchd at a higher priority than
-#     netback to ensure that it gets enough CPU time to set up flows
-#     (bug #1656).  Set this to 'default' to avoid changing netback's
-#     priority.
-# VSWITCHD_NETBACK_PRIORITY=0
-
-# VSWITCHD_LOGFILE: File to send the FILE_LOGLEVEL log messages to.
-# VSWITCHD_LOGFILE=/var/log/ovs-vswitchd.log
-
-# VSWITCHD_MEMLEAK_LOGFILE: File for logging memory leak data.
-#     Enabling this option will slow ovs-vswitchd significantly.  Do not
-#     enable it except to debug a suspected memory leak.  Use the
-#     ovs-parse-leaks utility included with Open vSwitch to parse the
-#     log file.  For best results, you also need debug symbols.
-# VSWITCHD_MEMLEAK_LOGFILE=""
-
-# VSWITCHD_FILE_LOGLEVEL: Log level at which to log into the
-#     VSWITCHD_LOG file.  If this is null or not set the logfile will
-#     not be created and nothing will be sent to it.  This is the
-#     default.  The available options are: EMER, WARN, INFO and DBG.
-# VSWITCHD_FILE_LOGLEVEL=""
-
-# VSWITCHD_SYSLOG_LOGLEVEL: Log level at which to log into syslog.  If
-#     this is null or not set the default is to log to syslog
-#     emergency and warning level messages only.
-# VSWITCHD_SYSLOG_LOGLEVEL="WARN"
-
-# VSWITCHD_STRACE_LOG: File for logging strace output.
-#     If this is set to a nonempty string, then ovs-vswitchd will run
-#     under strace, whose output will be logged to the specified file.
-#     Enabling this option will slow ovs-vswitchd significantly.
-#     VSWITCHD_STRACE_LOG and VSWITCHD_VALGRIND_LOG are mutually exclusive.
-# VSWITCHD_STRACE_LOG=""
-
-# VSWITCHD_STRACE_OPT: Options to pass to strace.
-#     This option's value is honored only when VSWITCHD_STRACE_LOG is
-#     set to a nonempty string.
-# VSWITCHD_STRACE_OPT=""
-
-# VSWITCHD_VALGRIND_LOG: File for logging valgrind output.
-#     If this is set to a nonempty string, then ovs-vswitchd will run
-#     under valgrind, whose output will be logged to the specified file.
-#     Enabling this option will slow ovs-vswitchd by 100X or more.
-#     valgrind is not installed by default on XenServer systems; you must
-#     install it by hand to usefully enable this option.
-#     VSWITCHD_STRACE_LOG and VSWITCHD_VALGRIND_LOG are mutually exclusive.
-# VSWITCHD_VALGRIND_LOG=""
-
-# VSWITCHD_VALGRIND_OPT: Options to pass to valgrind.
-#     This option's value is honored only when VSWITCHD_VALGRIND_LOG is
-#     set to a nonempty string.
-# VSWITCHD_VALGRIND_OPT=""
-
-# BRCOMPATD_PIDFILE: File in which to store the pid of the running
-#     ovs-brcompatd (the Linux bridge compatibility daemon for ovs-vswitchd).
-#     If this is the empty string, ovs-brcompatd will not be started and
-#     the brcompat_mod kernel module will not be inserted.  Note that
-#     the default is to use brcompat!
-# BRCOMPATD_PIDFILE=/var/run/ovs-brcompatd.pid
-
-# BRCOMPATD_RUN_DIR: Set the directory in which ovs-brcompatd should be
-#     run.  This mainly affects where core files will be placed.
-# BRCOMPATD_RUN_DIR=/var/xen/vswitch
-
-# BRCOMPATD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related
-#     processes.
-# BRCOMPATD_PRIORITY=-5
-
-# BRCOMPATD_LOGFILE: File to send the FILE_LOGLEVEL log messages to.
-# BRCOMPATD_LOGFILE=/var/log/ovs-brcompatd.log
-
-# BRCOMPATD_FILE_LOGLEVEL: Log level at which to log into the
-#     BRCOMPATD_LOG file.  If this is null or not set the logfile will
-#     not be created and nothing will be sent to it.  This is the
-#     default.  The available options are: EMER, WARN, INFO and DBG.
-# BRCOMPATD_FILE_LOGLEVEL=""
-
-# BRCOMPATD_SYSLOG_LOGLEVEL: Log level at which to log into syslog.  If
-#     this is null or not set the default is to log to syslog
-#     emergency and warning level messages only.
-# BRCOMPATD_SYSLOG_LOGLEVEL="WARN"
-
-# BRCOMPATD_MEMLEAK_LOGFILE: File for logging memory leak data.
-#     Enabling this option will slow ovs-brcompatd significantly.  Do not
-#     enable it except to debug a suspected memory leak.  Use the
-#     ovs-parse-leaks utility included with Open vSwitch to parse the
-#     log file.  For best results, you also need debug symbols.
-# BRCOMPATD_MEMLEAK_LOGFILE=""
-
-# BRCOMPATD_STRACE_LOG: File for logging strace output.
-#     If this is set to a nonempty string, then ovs-brcompatd will run
-#     under strace, whose output will be logged to the specified file.
-#     Enabling this option will slow brcompatd significantly.
-#     BRCOMPATD_STRACE_LOG and BRCOMPATD_VALGRIND_LOG are mutually exclusive.
-# BRCOMPATD_STRACE_LOG=""
-
-# BRCOMPATD_STRACE_OPT: Options to pass to strace.
-#     This option's value is honored only when BRCOMPATD_STRACE_LOG is
-#     set to a nonempty string.
-# BRCOMPATD_STRACE_OPT=""
-
-# BRCOMPATD_VALGRIND_LOG: File for logging valgrind output.
-#     If this is set to a nonempty string, then ovs-brcompatd will run
-#     under valgrind, whose output will be logged to the specified file.
-#     Enabling this option will slow brcompatd by 100X or more.
-#     valgrind is not installed by default on XenServer systems; you must
-#     install it by hand to usefully enable this option.
-#     BRCOMPATD_STRACE_LOG and BRCOMPATD_VALGRIND_LOG are mutually exclusive.
-# BRCOMPATD_VALGRIND_LOG=""
-
-# BRCOMPATD_VALGRIND_OPT: Options to pass to valgrind.
-#     This option's value is honored only when BRCOMPATD_VALGRIND_LOG is
-#     set to a nonempty string.
-# BRCOMPATD_VALGRIND_OPT=""
diff --git a/xenserver/root_vswitch_scripts_sysconfig.template b/xenserver/root_vswitch_scripts_sysconfig.template
new file mode 100644 (file)
index 0000000..4bc4b19
--- /dev/null
@@ -0,0 +1,160 @@
+### Configuration options for vswitch
+
+# Copyright (C) 2009 Nicira Networks, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without warranty of any kind.
+
+# VSWITCH_BASE: Root directory where vswitch binaries are installed
+# VSWITCH_BASE=/root/vswitch/openvswitch/build
+
+# ENABLE_BRCOMPAT: If 'y' than emulate linux bridging interfaces
+#    using the brcompat kernel module and ovs-brcompatd daemon
+# ENABLE_BRCOMPAT=y
+
+# ENABLE_FAKE_PROC_NET: If 'y' then emulate linux bonding and vlan
+#    files in /proc as if the bonding and vlan demultiplexing done in
+#    ovs-vswitchd were being implemented using existing Linux mechanisms.
+#    This is useful in some cases when replacing existing solutions.
+# ENABLE_FAKE_PROC_NET=y
+
+# FORCE_COREFILES: If 'y' then core files will be enabled.
+# FORCE_COREFILES=y
+
+# COREFILE_PATTERN: Pattern used to determine path and filename for
+#     core files when FORCE_COREFILES is 'y'.  This is Linux specific.
+#     See the manpage for "core".
+# COREFILE_PATTERN="/var/log/%e-%t"
+
+# VSWITCHD_CONF: File in which ovs-vswitchd stores its configuration.
+# VSWITCHD_CONF=/etc/ovs-vswitchd.conf
+
+# VSWITCHD_PIDFILE: File in which to store the pid of the running
+#     ovs-vswitchd.
+# VSWITCHD_PIDFILE=/var/run/ovs-vswitchd.pid
+
+# VSWITCHD_RUN_DIR: Set the directory in which ovs-vswitchd should be
+#     run.  This mainly affects where core files will be placed.
+# VSWITCHD_RUN_DIR=/var/xen/vswitch
+
+# VSWITCHD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related
+#     processes.
+# VSWITCHD_PRIORITY=-5
+
+# VSWITCHD_NETBACK_PRIORITY: "nice" priority at which to run netback.
+#     It is a good idea to run ovs-vswitchd at a higher priority than
+#     netback to ensure that it gets enough CPU time to set up flows
+#     (bug #1656).  Set this to 'default' to avoid changing netback's
+#     priority.
+# VSWITCHD_NETBACK_PRIORITY=0
+
+# VSWITCHD_LOGFILE: File to send the FILE_LOGLEVEL log messages to.
+# VSWITCHD_LOGFILE=/var/log/ovs-vswitchd.log
+
+# VSWITCHD_MEMLEAK_LOGFILE: File for logging memory leak data.
+#     Enabling this option will slow ovs-vswitchd significantly.  Do not
+#     enable it except to debug a suspected memory leak.  Use the
+#     ovs-parse-leaks utility included with Open vSwitch to parse the
+#     log file.  For best results, you also need debug symbols.
+# VSWITCHD_MEMLEAK_LOGFILE=""
+
+# VSWITCHD_FILE_LOGLEVEL: Log level at which to log into the
+#     VSWITCHD_LOG file.  If this is null or not set the logfile will
+#     not be created and nothing will be sent to it.  This is the
+#     default.  The available options are: EMER, WARN, INFO and DBG.
+# VSWITCHD_FILE_LOGLEVEL=""
+
+# VSWITCHD_SYSLOG_LOGLEVEL: Log level at which to log into syslog.  If
+#     this is null or not set the default is to log to syslog
+#     emergency and warning level messages only.
+# VSWITCHD_SYSLOG_LOGLEVEL="WARN"
+
+# VSWITCHD_STRACE_LOG: File for logging strace output.
+#     If this is set to a nonempty string, then ovs-vswitchd will run
+#     under strace, whose output will be logged to the specified file.
+#     Enabling this option will slow ovs-vswitchd significantly.
+#     VSWITCHD_STRACE_LOG and VSWITCHD_VALGRIND_LOG are mutually exclusive.
+# VSWITCHD_STRACE_LOG=""
+
+# VSWITCHD_STRACE_OPT: Options to pass to strace.
+#     This option's value is honored only when VSWITCHD_STRACE_LOG is
+#     set to a nonempty string.
+# VSWITCHD_STRACE_OPT=""
+
+# VSWITCHD_VALGRIND_LOG: File for logging valgrind output.
+#     If this is set to a nonempty string, then ovs-vswitchd will run
+#     under valgrind, whose output will be logged to the specified file.
+#     Enabling this option will slow ovs-vswitchd by 100X or more.
+#     valgrind is not installed by default on XenServer systems; you must
+#     install it by hand to usefully enable this option.
+#     VSWITCHD_STRACE_LOG and VSWITCHD_VALGRIND_LOG are mutually exclusive.
+# VSWITCHD_VALGRIND_LOG=""
+
+# VSWITCHD_VALGRIND_OPT: Options to pass to valgrind.
+#     This option's value is honored only when VSWITCHD_VALGRIND_LOG is
+#     set to a nonempty string.
+# VSWITCHD_VALGRIND_OPT=""
+
+# BRCOMPATD_PIDFILE: File in which to store the pid of the running
+#     ovs-brcompatd (the Linux bridge compatibility daemon for ovs-vswitchd).
+#     If this is the empty string, ovs-brcompatd will not be started and
+#     the brcompat_mod kernel module will not be inserted.  Note that
+#     the default is to use brcompat!
+# BRCOMPATD_PIDFILE=/var/run/ovs-brcompatd.pid
+
+# BRCOMPATD_RUN_DIR: Set the directory in which ovs-brcompatd should be
+#     run.  This mainly affects where core files will be placed.
+# BRCOMPATD_RUN_DIR=/var/xen/vswitch
+
+# BRCOMPATD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related
+#     processes.
+# BRCOMPATD_PRIORITY=-5
+
+# BRCOMPATD_LOGFILE: File to send the FILE_LOGLEVEL log messages to.
+# BRCOMPATD_LOGFILE=/var/log/ovs-brcompatd.log
+
+# BRCOMPATD_FILE_LOGLEVEL: Log level at which to log into the
+#     BRCOMPATD_LOG file.  If this is null or not set the logfile will
+#     not be created and nothing will be sent to it.  This is the
+#     default.  The available options are: EMER, WARN, INFO and DBG.
+# BRCOMPATD_FILE_LOGLEVEL=""
+
+# BRCOMPATD_SYSLOG_LOGLEVEL: Log level at which to log into syslog.  If
+#     this is null or not set the default is to log to syslog
+#     emergency and warning level messages only.
+# BRCOMPATD_SYSLOG_LOGLEVEL="WARN"
+
+# BRCOMPATD_MEMLEAK_LOGFILE: File for logging memory leak data.
+#     Enabling this option will slow ovs-brcompatd significantly.  Do not
+#     enable it except to debug a suspected memory leak.  Use the
+#     ovs-parse-leaks utility included with Open vSwitch to parse the
+#     log file.  For best results, you also need debug symbols.
+# BRCOMPATD_MEMLEAK_LOGFILE=""
+
+# BRCOMPATD_STRACE_LOG: File for logging strace output.
+#     If this is set to a nonempty string, then ovs-brcompatd will run
+#     under strace, whose output will be logged to the specified file.
+#     Enabling this option will slow brcompatd significantly.
+#     BRCOMPATD_STRACE_LOG and BRCOMPATD_VALGRIND_LOG are mutually exclusive.
+# BRCOMPATD_STRACE_LOG=""
+
+# BRCOMPATD_STRACE_OPT: Options to pass to strace.
+#     This option's value is honored only when BRCOMPATD_STRACE_LOG is
+#     set to a nonempty string.
+# BRCOMPATD_STRACE_OPT=""
+
+# BRCOMPATD_VALGRIND_LOG: File for logging valgrind output.
+#     If this is set to a nonempty string, then ovs-brcompatd will run
+#     under valgrind, whose output will be logged to the specified file.
+#     Enabling this option will slow brcompatd by 100X or more.
+#     valgrind is not installed by default on XenServer systems; you must
+#     install it by hand to usefully enable this option.
+#     BRCOMPATD_STRACE_LOG and BRCOMPATD_VALGRIND_LOG are mutually exclusive.
+# BRCOMPATD_VALGRIND_LOG=""
+
+# BRCOMPATD_VALGRIND_OPT: Options to pass to valgrind.
+#     This option's value is honored only when BRCOMPATD_VALGRIND_LOG is
+#     set to a nonempty string.
+# BRCOMPATD_VALGRIND_OPT=""
index fda211a..a9c3402 100644 (file)
@@ -51,8 +51,6 @@ install -m 755 xenserver/etc_init.d_vswitch \
 install -m 755 xenserver/etc_init.d_vswitch-xapi-update \
          $RPM_BUILD_ROOT/etc/init.d/vswitch-xapi-update
 install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
-install -m 755 xenserver/etc_sysconfig_vswitch.example \
-         $RPM_BUILD_ROOT/etc/sysconfig/vswitch.example
 install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
 install -m 755 xenserver/etc_logrotate.d_vswitch \
          $RPM_BUILD_ROOT/etc/logrotate.d/vswitch
@@ -73,6 +71,8 @@ install -m 755 xenserver/usr_sbin_xen-bugtool \
              $RPM_BUILD_ROOT%{_prefix}/scripts/xen-bugtool
 install -m 755 xenserver/usr_sbin_brctl \
              $RPM_BUILD_ROOT%{_prefix}/scripts/brctl
+install -m 755 xenserver/root_vswitch_scripts_sysconfig.template \
+         $RPM_BUILD_ROOT/root/vswitch/scripts/sysconfig.template
 install -m 644 \
         xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
                $RPM_BUILD_ROOT%{_prefix}/scripts/XSFeatureVSwitch.py
@@ -207,6 +207,21 @@ fi
 # Ensure ovs-vswitchd.conf exists
 touch /etc/ovs-vswitchd.conf
 
+# Create default or update existing /etc/sysconfig/vswitch.
+SYSCONFIG=/etc/sysconfig/vswitch
+TEMPLATE=/root/vswitch/scripts/sysconfig.template
+if [ ! -e $SYSCONFIG ]; then
+    cp $TEMPLATE $SYSCONFIG
+else
+    for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
+    do
+        if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
+            echo >> $SYSCONFIG
+            sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
+        fi
+    done
+fi
+
 # Replace XenServer files by our versions.
 mkdir -p %{_prefix}/xs-original \
     || printf "Could not create script backup directory.\n"
@@ -307,7 +322,6 @@ fi
 /etc/init.d/vswitch
 /etc/init.d/vswitch-xapi-update
 /etc/xapi.d/plugins/vswitch-cfg-update
-/etc/sysconfig/vswitch.example
 /etc/logrotate.d/vswitch
 /etc/profile.d/vswitch.sh
 /root/vswitch/kernel_modules/brcompat_mod.ko
@@ -319,6 +333,7 @@ fi
 /root/vswitch/scripts/xen-bugtool
 /root/vswitch/scripts/XSFeatureVSwitch.py
 /root/vswitch/scripts/brctl
+/root/vswitch/scripts/sysconfig.template
 # Following two files are generated automatically by rpm.  We don't
 # really need them and they won't be used on the XenServer, but there
 # isn't an obvious place to get rid of them since they are generated