From: Justin Pettit Date: Fri, 26 Mar 2010 05:38:13 +0000 (-0700) Subject: Cleanup default file locations and XenServer packaging X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc39196;p=openvswitch Cleanup default file locations and XenServer packaging This commit cleans up the locations of a number of files and directories used. These include: - Config file lives in /etc/openvswitch/conf.db - Logs go into /var/log/openvswitch - ovsdb-server socket is /var/run/openvswitch/db.sock - Schema goes into /usr/share/openvswitch/vswitch.ovsschema - PID files go in /var/run/openvswitch For XenServer, these additional changes are made: - Cores go in /var/xen/openvswitch - OVS binaries run in /var/xen/openvswitch In addition, it attempts to cleanup the XenServer packaging. This includes referring to the project as "openvswitch" as opposed to the somewhat presumptuous "vswitch". Note: Changes to the Debian packaging will be forthcoming. --- diff --git a/INSTALL.Linux b/INSTALL.Linux index 263e2618..177a9cd1 100644 --- a/INSTALL.Linux +++ b/INSTALL.Linux @@ -167,7 +167,7 @@ configuration database, ovsdb-server. Configure it to use the database you created during step 7 of installation, above, and to listen on a Unix domain socket, e.g.: - % ovsdb-server /usr/local/etc/ovs-vswitchd.conf.db --remote=punix:/usr/local/var/run/ovsdb-server + % ovsdb-server /usr/local/etc/ovs-vswitchd.conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock Then initialize the database with "ovs-vsctl init". This is only necessary the first time after you create the database with @@ -178,7 +178,7 @@ ovsdb-tool (but running it at any time is harmless): Then start the main Open vSwitch daemon, telling it to connect to the same Unix domain socket: - % ovs-vswitchd unix:/usr/local/var/run/ovsdb-server + % ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock Now you may use ovs-vsctl to set up bridges and other Open vSwitch features. For example, to create a bridge named br0 and add ports diff --git a/INSTALL.SSL b/INSTALL.SSL index 4ba09254..3b625fbd 100644 --- a/INSTALL.SSL +++ b/INSTALL.SSL @@ -290,7 +290,7 @@ cacert.pem: Once you have these files, configure ovs-vswitchd to use them using the ovs-vsctl "set-ssl" command, e.g.: - ovs-vsctl set-ssl /etc/vswitch/sc-privkey.pem /etc/vswitch/sc-cert.pem /etc/vswitch/cacert.pem + ovs-vsctl set-ssl /etc/openvswitch/sc-privkey.pem /etc/openvswitch/sc-cert.pem /etc/openvswitch/cacert.pem Substitute the correct file names, of course, if they differ from the ones used above. You should use absolute file names (ones that begin @@ -301,7 +301,7 @@ If you are using self-signed certificates (see "SSL Concepts for OpenFlow") and you did not copy controllerca/cacert.pem from the PKI machine to the Open vSwitch, then add the --bootstrap option, e.g.: - ovs-vsctl -- --bootstrap set-ssl /etc/vswitch/sc-privkey.pem /etc/vswitch/sc-cert.pem /etc/vswitch/cacert.pem + ovs-vsctl -- --bootstrap set-ssl /etc/openvswitch/sc-privkey.pem /etc/openvswitch/sc-cert.pem /etc/openvswitch/cacert.pem After you have added all of these configuration keys, you may specify "ssl:" connection methods elsewhere in the configuration database. diff --git a/INSTALL.XenServer b/INSTALL.XenServer index 54766332..2f41d8f5 100644 --- a/INSTALL.XenServer +++ b/INSTALL.XenServer @@ -28,9 +28,9 @@ Once you have a distribution tarball, copy it into cd /tmp tar xfz /usr/src/redhat/SOURCES/openvswitch-$VERSION.tar.gz rpmbuild \ - -D "vswitch_version $VERSION" \ + -D "openvswitch_version $VERSION" \ -D "xen_version $XENKERNEL" \ - -bb openvswitch-$VERSION/xenserver/vswitch-xen.spec + -bb openvswitch-$VERSION/xenserver/openvswitch-xen.spec where: @@ -43,26 +43,26 @@ where: It always ends in "xen". Two RPMs will be output into /usr/src/redhat/RPMS, whose names begin -with "vswitch" and "vswitch-debuginfo". +with "openvswitch" and "openvswitch-debuginfo". Installing Open vSwitch for XenServer ------------------------------------- To install Open vSwitch on a XenServer host, or to upgrade to a newer -version, copy the "vswitch" RPM to that host with "scp", then install +version, copy the "openvswitch" RPM to that host with "scp", then install it with "rpm -U", e.g.: - scp vswitch-$VERSION-1.i386.rpm root@: + scp openvswitch-$VERSION-1.i386.rpm root@: (At this point you will have to enter 's root password.) ssh root@ (At this point you will have to enter 's root password again.) - rpm -U vswitch-$VERSION-1.i386.rpm + rpm -U openvswitch-$VERSION-1.i386.rpm To uninstall Open vSwitch from a XenServer host, remove the package: ssh root@ (At this point you will have to enter 's root password again.) - rpm -e vswitch + rpm -e openvswitch After installing or uninstalling Open vSwitch, the XenServer should be rebooted as soon as possible. diff --git a/INSTALL.bridge b/INSTALL.bridge index fc04a87e..8e65021b 100644 --- a/INSTALL.bridge +++ b/INSTALL.bridge @@ -41,7 +41,7 @@ kernel bridge module. 3. Start ovs-brcompatd: % ovs-brcompatd --pidfile --detach -vANY:console:EMER \ - unix:/usr/local/var/run/ovsdb-server + unix:/usr/local/var/run/openvswitch/db.sock (ovsdb-server and ovs-vswitchd should already have been loaded.) diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index 3db7ace7..08f961ad 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -205,7 +205,7 @@ case "$1" in fi # Create an empty configuration database if it doesn't exist. - if test ! -e /etc/openvswitch-switch/conf; then + if test ! -e /etc/openvswitch/conf.db; then # Create configuration database. ovsdb-tool -vANY:console:emer \ create /etc/openvswitch-switch/conf \ diff --git a/lib/dirs.h b/lib/dirs.h index 5e261059..ea5e3b5d 100644 --- a/lib/dirs.h +++ b/lib/dirs.h @@ -18,8 +18,8 @@ #define DIRS_H 1 extern const char ovs_pkgdatadir[]; /* /usr/local/share/openvswitch */ -extern const char ovs_rundir[]; /* /usr/local/var/run */ -extern const char ovs_logdir[]; /* /usr/local/var/log */ +extern const char ovs_rundir[]; /* /usr/local/var/run/openvswitch */ +extern const char ovs_logdir[]; /* /usr/local/var/log/openvswitch */ extern const char ovs_bindir[]; /* /usr/local/bin */ #endif /* dirs.h */ diff --git a/lib/unixctl.c b/lib/unixctl.c index 88fe6035..b52d3d1e 100644 --- a/lib/unixctl.c +++ b/lib/unixctl.c @@ -443,7 +443,7 @@ unixctl_server_destroy(struct unixctl_server *server) /* Connects to a Vlog server socket. 'path' should be the name of a Vlog * server socket. If it does not start with '/', it will be prefixed with - * ovs_rundir (e.g. /var/run). + * ovs_rundir (e.g. /var/run/openvswitch). * * Returns 0 if successful, otherwise a positive errno value. If successful, * sets '*clientp' to the new unixctl_client, otherwise to NULL. */ diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4 index ccb3a014..58e4b64e 100644 --- a/m4/openvswitch.m4 +++ b/m4/openvswitch.m4 @@ -113,9 +113,10 @@ AC_DEFUN([OVS_CHECK_RUNDIR], [AC_ARG_WITH( [rundir], AC_HELP_STRING([--with-rundir=DIR], - [directory used for pidfiles [[LOCALSTATEDIR/run]]]), + [directory used for pidfiles + [[LOCALSTATEDIR/run/openvswitch]]]), [RUNDIR=$withval], - [RUNDIR='${localstatedir}/run']) + [RUNDIR='${localstatedir}/run/openvswitch']) AC_SUBST([RUNDIR])]) dnl Checks for the directory in which to store logs. diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 19ef5584..ee1eadf3 100644 --- a/utilities/ovs-vsctl.8.in +++ b/utilities/ovs-vsctl.8.in @@ -79,7 +79,7 @@ the global options by \fB\-\-\fR. .IP "\fB\-\-db=\fIserver\fR" Sets \fIserver\fR as the database server that \fBovs\-vsctl\fR contacts to query or modify configuration. The default is -\fBunix:@RUNDIR@/ovsdb\-server\fR. \fIserver\fR must take one of the +\fBunix:@RUNDIR@/db.sock\fR. \fIserver\fR must take one of the following forms: .RS .so ovsdb/remote-active.man diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 4ca737ed..0bf87c2b 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -449,7 +449,7 @@ default_db(void) { static char *def; if (!def) { - def = xasprintf("unix:%s/ovsdb-server", ovs_rundir); + def = xasprintf("unix:%s/db.sock", ovs_rundir); } return def; } diff --git a/xenserver/README b/xenserver/README index 6dafdb40..255e5e60 100644 --- a/xenserver/README +++ b/xenserver/README @@ -1,4 +1,4 @@ -This directory contains files for seamless integration of vswitch on +This directory contains files for seamless integration of Open vSwitch on Citrix XenServer hosts managed by the Citrix management tools. Some of these files are modifications of Citrix's proprietary code. @@ -11,55 +11,60 @@ Most of the files in this directory is installed on a XenServer system under the same name, if underscores are replaced by slashes. The files are: - etc_init.d_vswitch + etc_init.d_openvswitch - Initializes the vswitch at boot and shuts it down at shutdown. + Initializes Open vSwitch at boot and shuts it down at shutdown. - etc_init.d_vswitch-xapi-update + etc_init.d_openvswitch-xapi-update - Init script to ensure vswitch-cfg-update is called for the + Init script to ensure openvswitch-cfg-update is called for the current host at boot. - etc_logrotate.d_vswitch + etc_logrotate.d_openvswitch - Ensures that /var/log/ovs-vswitchd.log is rotated periodically - and that ovs-vswitchd reopens its log file at that point. + Ensures that logs in /var/log/openvswitch are rotated + periodically and that appropriate daemons reopen their log + files at that point. - etc_profile.d_vswitch.sh + etc_profile.d_openvswitch.sh - vswitch-related shell functions for the administrator's + Open vSwitch-related shell functions for the administrator's convenience. - etc_xapi.d_plugins_vswitch-cfg-update + etc_xapi.d_plugins_openvswitch-cfg-update xapi plugin script to update the cache of configuration items - in the ovs-vswitchd configuration file that are managed in the + in the ovs-vswitchd configuration that are managed in the xapi database when integrated with Citrix management tools. etc_xensource_scripts_vif - vswitch-aware replacement for Citrix script of the same name. + Open vSwitch-aware replacement for Citrix script of the same name. + + openvswitch-xen.spec + + spec file for building RPMs to install on a XenServer host. opt_xensource_libexec_interface-reconfigure - vswitch-aware replacement for Citrix script of the same name. + Open vSwitch-aware replacement for Citrix script of the same name. - usr_share_vswitch_scripts_refresh-network-uuids + usr_share_openvswitch_scripts_refresh-network-uuids Script to refresh bridge..network-uuids keys, which can get out-of-sync following a pool join. Running this script is an alternative to rebooting the host. - root_vswitch_scripts_sysconfig.template + usr_share_openvswitch_scripts_sysconfig.template - Template for vswitch's /etc/sysconfig/vswitch configuration - file. + Template for Open vSwitch's /etc/sysconfig/openvswitch + configuration file. usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py xsconsole plugin to configure the pool-wide configuration keys - used to control vswitch when integrated with Citrix management - tools. + used to control Open vSwitch when integrated with Citrix + management tools. usr_sbin_brctl @@ -68,25 +73,21 @@ files are: usr_sbin_xen-bugtool - vswitch-aware replacement for Citrix script of the same name. - - vswitch-xen.spec - - spec file for building RPMs to install on a XenServer host. + Open vSwitch-aware replacement for Citrix script of the same name. -To install, build the vswitch RPM with a command like this: +To install, build the Open vSwitch RPM with a command like this: - rpmbuild -D "vswitch_version $full_version" \ + rpmbuild -D "openvswitch_version $full_version" \ -D "xen_version $XENKERNEL" \ -D "build_number --with-build-number=$buildnr" \ - -bb vswitch-xen.spec + -bb openvswitch-xen.spec -Then, "rpm -U" the resulting vswitch package on the XenServer hosts in -question and reboot them. (The vswitch-dbg package that is also +Then, "rpm -U" the resulting Open vSwitch package on the XenServer hosts in +question and reboot them. (The openvswitch-dbg package that is also produced need not be installed, but it is harmless to do so.) ---------------------------------------------------------------------- -Copyright (C) 2009 Nicira Networks, Inc. +Copyright (C) 2009, 2010 Nicira Networks, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/xenserver/automake.mk b/xenserver/automake.mk index dde4105e..b451bbb8 100644 --- a/xenserver/automake.mk +++ b/xenserver/automake.mk @@ -9,12 +9,13 @@ EXTRA_DIST += \ xenserver/LICENSE \ xenserver/README \ xenserver/automake.mk \ - xenserver/etc_init.d_vswitch \ - xenserver/etc_init.d_vswitch-xapi-update \ - xenserver/etc_logrotate.d_vswitch \ - xenserver/etc_profile.d_vswitch.sh \ - xenserver/etc_xapi.d_plugins_vswitch-cfg-update \ + xenserver/etc_init.d_openvswitch \ + xenserver/etc_init.d_openvswitch-xapi-update \ + xenserver/etc_logrotate.d_openvswitch \ + xenserver/etc_profile.d_openvswitch.sh \ + xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \ xenserver/etc_xensource_scripts_vif \ + xenserver/openvswitch-xen.spec \ xenserver/opt_xensource_libexec_InterfaceReconfigure.py \ xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \ xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \ @@ -22,6 +23,5 @@ EXTRA_DIST += \ xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \ xenserver/usr_sbin_brctl \ xenserver/usr_sbin_xen-bugtool \ - xenserver/usr_share_vswitch_scripts_refresh-network-uuids \ - xenserver/usr_share_vswitch_scripts_sysconfig.template \ - xenserver/vswitch-xen.spec + xenserver/usr_share_openvswitch_scripts_refresh-network-uuids \ + xenserver/usr_share_openvswitch_scripts_sysconfig.template diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch new file mode 100755 index 00000000..f531d45c --- /dev/null +++ b/xenserver/etc_init.d_openvswitch @@ -0,0 +1,440 @@ +#!/bin/bash +# +# openvswitch +# +# chkconfig: 2345 09 91 +# description: Manage Open vSwitch kernel modules and user-space daemons + +# Copyright (C) 2009, 2010 Nicira Networks, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +. /etc/init.d/functions + +test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch + +# General config variables in /etc/sysconfig/openvswitch +: ${ENABLE_BRCOMPAT:=y} +: ${ENABLE_FAKE_PROC_NET:=y} +: ${ENABLE_MONITOR:=y} +: ${FORCE_COREFILES:=y} + +# Config variables specific to ovsdb-server +: ${OVSDB_SERVER_REMOTES:=punix:/var/run/openvswitch/db.sock db:Open_vSwitch,managers} +: ${OVSDB_SERVER_DB:=/etc/openvswitch/conf.db} +: ${OVSDB_SERVER_PIDFILE:=/var/run/openvswitch/ovsdb-server.pid} +: ${OVSDB_SERVER_RUN_DIR:=/var/xen/openvswitch} +: ${OVSDB_SERVER_PRIORITY:=-10} +: ${OVSDB_SERVER_LOGFILE:=/var/log/openvswitch/ovsdb-server.log} +: ${OVSDB_SERVER_FILE_LOGLEVEL:=INFO} +: ${OVSDB_SERVER_SYSLOG_LOGLEVEL:=ERR} +: ${OVSDB_SERVER_MEMLEAK_LOGFILE:=} +: ${OVSDB_SERVER_STRACE_LOG:=} +: ${OVSDB_SERVER_STRACE_OPT:=} +: ${OVSDB_SERVER_VALGRIND_LOG:=} +: ${OVSDB_SERVER_VALGRIND_OPT:=} + +# Config variables specific to ovs-vswitchd +: ${VSWITCHD_OVSDB_SERVER:=unix:/var/run/openvswitch/db.sock} +: ${VSWITCHD_OVSDB_SCHEMA:=/usr/share/openvswitch/vswitch.ovsschema} +: ${VSWITCHD_PIDFILE:=/var/run/openvswitch/ovs-vswitchd.pid} +: ${VSWITCHD_RUN_DIR:=/var/xen/openvswitch} +: ${VSWITCHD_PRIORITY:=-10} +: ${VSWITCHD_MLOCKALL:=yes} +: ${VSWITCHD_LOGFILE:=/var/log/openvswitch/ovs-vswitchd.log} +: ${VSWITCHD_FILE_LOGLEVEL:=INFO} +: ${VSWITCHD_SYSLOG_LOGLEVEL:=ERR} +: ${VSWITCHD_MEMLEAK_LOGFILE:=} +: ${VSWITCHD_STRACE_LOG:=} +: ${VSWITCHD_STRACE_OPT:=} +: ${VSWITCHD_VALGRIND_LOG:=} +: ${VSWITCHD_VALGRIND_OPT:=} + +# Config variables specific to ovs-brcompatd +: ${BRCOMPATD_PIDFILE:=/var/run/openvswitch/ovs-brcompatd.pid} +: ${BRCOMPATD_RUN_DIR:=/var/xen/openvswitch} +: ${BRCOMPATD_PRIORITY:=-10} +: ${BRCOMPATD_LOGFILE:=/var/log/openvswitch/ovs-brcompatd.log} +: ${BRCOMPATD_FILE_LOGLEVEL:=INFO} +: ${BRCOMPATD_SYSLOG_LOGLEVEL:=ERR} +: ${BRCOMPATD_MEMLEAK_LOGFILE:=} +: ${BRCOMPATD_STRACE_LOG:=} +: ${BRCOMPATD_STRACE_OPT:=} +: ${BRCOMPATD_VALGRIND_LOG:=} +: ${BRCOMPATD_VALGRIND_OPT:=} + +# Full paths to executables & modules +ovsdb_server="/usr/sbin/ovsdb-server" +ovsdb_tool="/usr/bin/ovsdb-tool" +vswitchd="/usr/sbin/ovs-vswitchd" +brcompatd="/usr/sbin/ovs-brcompatd" +dpctl="/usr/bin/ovs-dpctl" +appctl="/usr/bin/ovs-appctl" +ofctl="/usr/bin/ovs-ofctl" +vsctl="/usr/bin/ovs-vsctl" + +if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then + if [ "$ENABLE_BRCOMPAT" != "y" ]; then + warning "FAKE_PROC_NET required BRCOMPAT which was disabled. Force enabling." + ENABLE_BRCOMPAT="y" + fi +fi + +if test "$ENABLE_MONITOR" = "y"; then + monitor_opt="--monitor" +else + monitor_opt= +fi + +function dp_list { + "$dpctl" show | grep '^dp[0-9]\+:' | cut -d':' -f 1 +} + +function turn_on_corefiles { + ulimit -Sc 67108864 +} + +function remove_all_dp { + for dp in $(dp_list); do + action "Removing datapath: $dp" "$dpctl" del-dp "$dp" + done +} + +function insert_modules_if_required { + if ! lsmod | grep -q "openvswitch_mod"; then + action "Inserting llc module" modprobe llc + action "Inserting openvswitch module" modprobe openvswitch_mod + fi + if [ -n "$BRCOMPATD_PIDFILE" ] && ! lsmod | grep -q "brcompat_mod"; then + action "Inserting brcompat module" modprobe brcompat_mod + fi + if [ -f "/lib/modules/`uname -r`/kernel/net/openvswitch/ip_gre_mod.ko" ] && ! lsmod | grep -q "ip_gre_mod"; then + action "Inserting ip_gre module" modprobe ip_gre_mod + fi +} + +function remove_modules { + if lsmod | grep -q "brcompat_mod"; then + action "Removing brcompat module" rmmod brcompat_mod.ko + fi + if lsmod | grep -q "openvswitch_mod"; then + action "Removing openvswitch module" rmmod openvswitch_mod.ko + fi + if lsmod | grep -q "ip_gre_mod"; then + action "Removing ip_gre module" rmmod ip_gre_mod.ko + fi +} + +function start_ovsdb_server { + local syslog_opt="-vANY:SYSLOG:${OVSDB_SERVER_SYSLOG_LOGLEVEL}" + local logfile_file_opt="" + local logfile_level_opt="" + if [ ! -d "$OVSDB_SERVER_RUN_DIR" ]; then + install -d -m 755 -o root -g root "$OVSDB_SERVER_RUN_DIR" + fi + cd "$OVSDB_SERVER_RUN_DIR" + local remotes= + for remote in $OVSDB_SERVER_REMOTES; do + remotes="$remotes --remote=$remote" + done + + install -d -m 755 -o root -g root `dirname $OVSDB_SERVER_LOGFILE` + if [ -n "$OVSDB_SERVER_FILE_LOGLEVEL" ]; then + logfile_level_opt="-vANY:FILE:${OVSDB_SERVER_FILE_LOGLEVEL}" + logfile_file_opt="--log-file=$OVSDB_SERVER_LOGFILE" + fi + + local leak_opt="" + if [ -n "$OVSDB_SERVER_MEMLEAK_LOGFILE" ]; then + leak_opt="--check-leaks=$OVSDB_SERVER_MEMLEAK_LOGFILE" + if [ -e "$OVSDB_SERVER_MEMLEAK_LOGFILE" ]; then + mv "$OVSDB_SERVER_MEMLEAK_LOGFILE" "$OVSDB_SERVER_MEMLEAK_LOGFILE.prev" + fi + fi + local strace_opt="" + local daemonize="y" + if [ -n "$OVSDB_SERVER_STRACE_LOG" ] && [ -n "$OVSDB_SERVER_VALGRIND_LOG" ]; then + printf "Can not start with both VALGRIND and STRACE\n" + exit 1 + fi + if [ -n "$OVSDB_SERVER_STRACE_LOG" ]; then + strace_opt="strace -o $OVSDB_SERVER_STRACE_LOG $OVSDB_SERVER_STRACE_OPT" + daemonize="n" + fi + if [ -n "$OVSDB_SERVER_VALGRIND_LOG" ]; then + valgrind_opt="valgrind --log-file=$OVSDB_SERVER_VALGRIND_LOG $OVSDB_SERVER_VALGRIND_OPT" + daemonize="n" + fi + ssl_opts="--private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert" + install -d -m 755 -o root -g root `dirname $OVSDB_SERVER_PIDFILE` + if [ "$daemonize" != "y" ]; then + # Start in background and force a "success" message + action "Starting ovsdb_server ($strace_opt$valgrind_opt)" true + (nice -n "$OVSDB_SERVER_PRIORITY" $strace_opt $valgrind_opt "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes $ssl_opts) & + else + action "Starting ovsdb-server" nice -n "$OVSDB_SERVER_PRIORITY" "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes $ssl_opts + fi +} + +function start_vswitchd { + local syslog_opt="-vANY:SYSLOG:${VSWITCHD_SYSLOG_LOGLEVEL}" + local logfile_file_opt="" + local logfile_level_opt="" + if [ ! -d "$VSWITCHD_RUN_DIR" ]; then + install -d -m 755 -o root -g root "$VSWITCHD_RUN_DIR" + fi + cd "$VSWITCHD_RUN_DIR" + + install -d -m 755 -o root -g root `dirname $VSWITCHD_LOGFILE` + if [ -n "$VSWITCHD_FILE_LOGLEVEL" ]; then + logfile_level_opt="-vANY:FILE:${VSWITCHD_FILE_LOGLEVEL}" + logfile_file_opt="--log-file=$VSWITCHD_LOGFILE" + fi + + local leak_opt="" + if [ -n "$VSWITCHD_MEMLEAK_LOGFILE" ]; then + leak_opt="--check-leaks=$VSWITCHD_MEMLEAK_LOGFILE" + if [ -e "$VSWITCHD_MEMLEAK_LOGFILE" ]; then + mv "$VSWITCHD_MEMLEAK_LOGFILE" "$VSWITCHD_MEMLEAK_LOGFILE.prev" + fi + fi + local strace_opt="" + local daemonize="y" + if [ -n "$VSWITCHD_STRACE_LOG" ] && [ -n "$VSWITCHD_VALGRIND_LOG" ]; then + printf "Can not start with both VALGRIND and STRACE\n" + exit 1 + fi + if [ -n "$VSWITCHD_STRACE_LOG" ]; then + strace_opt="strace -o $VSWITCHD_STRACE_LOG $VSWITCHD_STRACE_OPT" + daemonize="n" + fi + if [ -n "$VSWITCHD_VALGRIND_LOG" ]; then + valgrind_opt="valgrind --log-file=$VSWITCHD_VALGRIND_LOG $VSWITCHD_VALGRIND_OPT" + daemonize="n" + fi + local fake_proc_net_opt="" + if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then + fake_proc_net_opt="--fake-proc-net" + fi + if [ "$VSWITCHD_MLOCKALL" != "no" ]; then + mlockall_opt="--mlockall" + fi + + install -d -m 755 -o root -g root `dirname $VSWITCHD_PIDFILE` + if [ "$daemonize" != "y" ]; then + # Start in background and force a "success" message + action "Starting ovs-vswitchd ($strace_opt$valgrind_opt)" true + (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $mlockall_opt "$VSWITCHD_OVSDB_SERVER") & + else + action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $mlockall_opt "$VSWITCHD_OVSDB_SERVER" + fi +} + +function start_brcompatd { + local syslog_opt="-vANY:SYSLOG:${BRCOMPATD_SYSLOG_LOGLEVEL}" + local logfile_file_opt="" + local logfile_level_opt="" + if [ -d "$BRCOMPATD_RUN_DIR" ]; then + install -d -m 755 -o root -g root "$BRCOMPATD_RUN_DIR" + fi + cd "$BRCOMPATD_RUN_DIR" + + install -d -m 755 -o root -g root `dirname $BRCOMPATD_LOGFILE` + if [ -n "$BRCOMPATD_FILE_LOGLEVEL" ]; then + logfile_level_opt="-vANY:FILE:${BRCOMPATD_FILE_LOGLEVEL}" + logfile_file_opt="--log-file=$BRCOMPATD_LOGFILE" + fi + + local leak_opt="" + if [ -n "$BRCOMPATD_MEMLEAK_LOGFILE" ]; then + leak_opt="--check-leaks=$BRCOMPATD_MEMLEAK_LOGFILE" + if [ -e "$BRCOMPATD_MEMLEAK_LOGFILE" ]; then + mv "$BRCOMPATD_MEMLEAK_LOGFILE" "$BRCOMPATD_MEMLEAK_LOGFILE.prev" + fi + fi + local strace_opt="" + local daemonize="y" + if [ -n "$BRCOMPATD_STRACE_LOG" ] && [ -n "$BRCOMPATD_VALGRIND_LOG" ]; then + printf "Can not start with both VALGRIND and STRACE\n" + exit 1 + fi + if [ -n "$BRCOMPATD_STRACE_LOG" ]; then + strace_opt="strace -o $BRCOMPATD_STRACE_LOG $BRCOMPATD_STRACE_OPT" + daemonize="n" + fi + if [ -n "$VALGRIND_LOG" ]; then + valgrind_opt="valgrind --log-file=$BRCOMPATD_VALGRIND_LOG $BRCOMPATD_VALGRIND_OPT" + daemonize="n" + fi + appctl_cmd="$appctl --target=/var/run/openvswitch/ovs-vswitchd.\`cat $VSWITCHD_PIDFILE\`.ctl %s" + + install -d -m 755 -o root -g root `dirname $BRCOMPATD_PIDFILE` + if [ "$daemonize" != "y" ]; then + # Start in background and force a "success" message + action "Starting ovs-brcompatd ($strace_opt$valgrind_opt)" true + (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd"--no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER") & + else + action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE --detach $monitor_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" + fi +} + +function stop_ovsdb_server { + if [ -f "$OVSDB_SERVER_PIDFILE" ]; then + local pid=$(cat "$OVSDB_SERVER_PIDFILE") + action "Killing ovsdb-server ($pid)" kill -TERM $pid + rm -f "$OVSDB_SERVER_PIDFILE" + fi +} + +function stop_vswitchd { + if [ -f "$VSWITCHD_PIDFILE" ]; then + local pid=$(cat "$VSWITCHD_PIDFILE") + action "Killing ovs-vswitchd ($pid)" kill -TERM $pid + rm -f "$VSWITCHD_PIDFILE" + fi +} + +function stop_brcompatd { + if [ -f "$BRCOMPATD_PIDFILE" ]; then + local pid=$(cat "$BRCOMPATD_PIDFILE") + action "Killing ovs-brcompatd ($pid)" kill -TERM $pid + rm -f "$BRCOMPATD_PIDFILE" + fi +} + +function restart_approval { + if test ! -t 0; then + # Don't prompt if invoked non-interactively. + return 0 + fi + cat </dev/null +} + +function start { + if [ ! -f /etc/xensource-inventory ]; then + printf "vswitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n" + exit 1 + fi + source /etc/xensource-inventory + action "Updating configuration" do_host_call +} + +case "$1" in + start) + start + ;; + stop) + # Nothing to do here. + ;; + restart) + start + ;; + help) + printf "vswitch-xapi-update [start|stop|restart]\n" + ;; + *) + printf "Unknown command: $1\n" + exit 1 + ;; +esac diff --git a/xenserver/etc_init.d_vswitch b/xenserver/etc_init.d_vswitch deleted file mode 100755 index 9b05879a..00000000 --- a/xenserver/etc_init.d_vswitch +++ /dev/null @@ -1,425 +0,0 @@ -#!/bin/bash -# -# vswitch -# -# chkconfig: 2345 09 91 -# description: Manage vswitch kernel modules and user-space daemon - -# Copyright (C) 2009, 2010 Nicira Networks, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -. /etc/init.d/functions - -test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch - -# General config variables in /etc/sysconfig/vswitch -: ${ENABLE_BRCOMPAT:=y} -: ${ENABLE_FAKE_PROC_NET:=y} -: ${ENABLE_MONITOR:=y} -: ${FORCE_COREFILES:=y} - -# Config variables specific to ovsdb-server -: ${OVSDB_SERVER_REMOTES:=punix:/var/run/ovsdb-server db:Open_vSwitch,managers} -: ${OVSDB_SERVER_DB:=/etc/ovs-vswitchd.conf.db} -: ${OVSDB_SERVER_PIDFILE:=/var/run/ovsdb-server.pid} -: ${OVSDB_SERVER_RUN_DIR:=/var/xen/vswitch} -: ${OVSDB_SERVER_PRIORITY:=-10} -: ${OVSDB_SERVER_LOGFILE:=/var/log/ovsdb-server.log} -: ${OVSDB_SERVER_FILE_LOGLEVEL:=INFO} -: ${OVSDB_SERVER_SYSLOG_LOGLEVEL:=ERR} -: ${OVSDB_SERVER_MEMLEAK_LOGFILE:=} -: ${OVSDB_SERVER_STRACE_LOG:=} -: ${OVSDB_SERVER_STRACE_OPT:=} -: ${OVSDB_SERVER_VALGRIND_LOG:=} -: ${OVSDB_SERVER_VALGRIND_OPT:=} - -# Config variables specific to ovs-vswitchd -: ${VSWITCHD_OVSDB_SERVER:=unix:/var/run/ovsdb-server} -: ${VSWITCHD_OVSDB_SCHEMA:=/usr/share/vswitch/vswitch.ovsschema} -: ${VSWITCHD_PIDFILE:=/var/run/ovs-vswitchd.pid} -: ${VSWITCHD_RUN_DIR:=/var/xen/vswitch} -: ${VSWITCHD_PRIORITY:=-10} -: ${VSWITCHD_MLOCKALL:=yes} -: ${VSWITCHD_LOGFILE:=/var/log/ovs-vswitchd.log} -: ${VSWITCHD_FILE_LOGLEVEL:=INFO} -: ${VSWITCHD_SYSLOG_LOGLEVEL:=ERR} -: ${VSWITCHD_MEMLEAK_LOGFILE:=} -: ${VSWITCHD_STRACE_LOG:=} -: ${VSWITCHD_STRACE_OPT:=} -: ${VSWITCHD_VALGRIND_LOG:=} -: ${VSWITCHD_VALGRIND_OPT:=} - -# Config variables specific to ovs-brcompatd -: ${BRCOMPATD_PIDFILE:=/var/run/ovs-brcompatd.pid} -: ${BRCOMPATD_RUN_DIR:=/var/xen/vswitch} -: ${BRCOMPATD_PRIORITY:=-10} -: ${BRCOMPATD_LOGFILE:=/var/log/ovs-brcompatd.log} -: ${BRCOMPATD_FILE_LOGLEVEL:=INFO} -: ${BRCOMPATD_SYSLOG_LOGLEVEL:=ERR} -: ${BRCOMPATD_MEMLEAK_LOGFILE:=} -: ${BRCOMPATD_STRACE_LOG:=} -: ${BRCOMPATD_STRACE_OPT:=} -: ${BRCOMPATD_VALGRIND_LOG:=} -: ${BRCOMPATD_VALGRIND_OPT:=} - -# Full paths to executables & modules -ovsdb_server="/usr/sbin/ovsdb-server" -ovsdb_tool="/usr/bin/ovsdb-tool" -vswitchd="/usr/sbin/ovs-vswitchd" -brcompatd="/usr/sbin/ovs-brcompatd" -dpctl="/usr/bin/ovs-dpctl" -appctl="/usr/bin/ovs-appctl" -ofctl="/usr/bin/ovs-ofctl" -vsctl="/usr/bin/ovs-vsctl" - -if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then - if [ "$ENABLE_BRCOMPAT" != "y" ]; then - warning "FAKE_PROC_NET required BRCOMPAT which was disabled. Force enabling." - ENABLE_BRCOMPAT="y" - fi -fi - -if test "$ENABLE_MONITOR" = "y"; then - monitor_opt="--monitor" -else - monitor_opt= -fi - -function dp_list { - "$dpctl" show | grep '^dp[0-9]\+:' | cut -d':' -f 1 -} - -function turn_on_corefiles { - ulimit -Sc 67108864 -} - -function remove_all_dp { - for dp in $(dp_list); do - action "Removing datapath: $dp" "$dpctl" del-dp "$dp" - done -} - -function insert_modules_if_required { - if ! lsmod | grep -q "openvswitch_mod"; then - action "Inserting llc module" modprobe llc - action "Inserting openvswitch module" modprobe openvswitch_mod - fi - if [ -n "$BRCOMPATD_PIDFILE" ] && ! lsmod | grep -q "brcompat_mod"; then - action "Inserting brcompat module" modprobe brcompat_mod - fi - if [ -f "/lib/modules/`uname -r`/kernel/net/vswitch/ip_gre_mod.ko" ] && ! lsmod | grep -q "ip_gre_mod"; then - action "Inserting ip_gre module" modprobe ip_gre_mod - fi -} - -function remove_modules { - if lsmod | grep -q "brcompat_mod"; then - action "Removing brcompat module" rmmod brcompat_mod.ko - fi - if lsmod | grep -q "openvswitch_mod"; then - action "Removing openvswitch module" rmmod openvswitch_mod.ko - fi - if lsmod | grep -q "ip_gre_mod"; then - action "Removing ip_gre module" rmmod ip_gre_mod.ko - fi -} - -function start_ovsdb_server { - local syslog_opt="-vANY:SYSLOG:${OVSDB_SERVER_SYSLOG_LOGLEVEL}" - local logfile_file_opt="" - local logfile_level_opt="" - if [ ! -d "$OVSDB_SERVER_RUN_DIR" ]; then - mkdir -p "$OVSDB_SERVER_RUN_DIR" - fi - cd "$OVSDB_SERVER_RUN_DIR" - local remotes= - for remote in $OVSDB_SERVER_REMOTES; do - remotes="$remotes --remote=$remote" - done - if [ -n "$OVSDB_SERVER_FILE_LOGLEVEL" ]; then - logfile_level_opt="-vANY:FILE:${OVSDB_SERVER_FILE_LOGLEVEL}" - logfile_file_opt="--log-file=$OVSDB_SERVER_LOGFILE" - fi - local leak_opt="" - if [ -n "$OVSDB_SERVER_MEMLEAK_LOGFILE" ]; then - leak_opt="--check-leaks=$OVSDB_SERVER_MEMLEAK_LOGFILE" - if [ -e "$OVSDB_SERVER_MEMLEAK_LOGFILE" ]; then - mv "$OVSDB_SERVER_MEMLEAK_LOGFILE" "$OVSDB_SERVER_MEMLEAK_LOGFILE.prev" - fi - fi - local strace_opt="" - local daemonize="y" - if [ -n "$OVSDB_SERVER_STRACE_LOG" ] && [ -n "$OVSDB_SERVER_VALGRIND_LOG" ]; then - printf "Can not start with both VALGRIND and STRACE\n" - exit 1 - fi - if [ -n "$OVSDB_SERVER_STRACE_LOG" ]; then - strace_opt="strace -o $OVSDB_SERVER_STRACE_LOG $OVSDB_SERVER_STRACE_OPT" - daemonize="n" - fi - if [ -n "$OVSDB_SERVER_VALGRIND_LOG" ]; then - valgrind_opt="valgrind --log-file=$OVSDB_SERVER_VALGRIND_LOG $OVSDB_SERVER_VALGRIND_OPT" - daemonize="n" - fi - ssl_opts="--private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert" - if [ "$daemonize" != "y" ]; then - # Start in background and force a "success" message - action "Starting ovsdb_server ($strace_opt$valgrind_opt)" true - (nice -n "$OVSDB_SERVER_PRIORITY" $strace_opt $valgrind_opt "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes $ssl_opts) & - else - action "Starting ovsdb-server" nice -n "$OVSDB_SERVER_PRIORITY" "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes $ssl_opts - fi -} - -function start_vswitchd { - local syslog_opt="-vANY:SYSLOG:${VSWITCHD_SYSLOG_LOGLEVEL}" - local logfile_file_opt="" - local logfile_level_opt="" - if [ ! -d "$VSWITCHD_RUN_DIR" ]; then - mkdir -p "$VSWITCHD_RUN_DIR" - fi - cd "$VSWITCHD_RUN_DIR" - if [ -n "$VSWITCHD_FILE_LOGLEVEL" ]; then - logfile_level_opt="-vANY:FILE:${VSWITCHD_FILE_LOGLEVEL}" - logfile_file_opt="--log-file=$VSWITCHD_LOGFILE" - fi - local leak_opt="" - if [ -n "$VSWITCHD_MEMLEAK_LOGFILE" ]; then - leak_opt="--check-leaks=$VSWITCHD_MEMLEAK_LOGFILE" - if [ -e "$VSWITCHD_MEMLEAK_LOGFILE" ]; then - mv "$VSWITCHD_MEMLEAK_LOGFILE" "$VSWITCHD_MEMLEAK_LOGFILE.prev" - fi - fi - local strace_opt="" - local daemonize="y" - if [ -n "$VSWITCHD_STRACE_LOG" ] && [ -n "$VSWITCHD_VALGRIND_LOG" ]; then - printf "Can not start with both VALGRIND and STRACE\n" - exit 1 - fi - if [ -n "$VSWITCHD_STRACE_LOG" ]; then - strace_opt="strace -o $VSWITCHD_STRACE_LOG $VSWITCHD_STRACE_OPT" - daemonize="n" - fi - if [ -n "$VSWITCHD_VALGRIND_LOG" ]; then - valgrind_opt="valgrind --log-file=$VSWITCHD_VALGRIND_LOG $VSWITCHD_VALGRIND_OPT" - daemonize="n" - fi - local fake_proc_net_opt="" - if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then - fake_proc_net_opt="--fake-proc-net" - fi - if [ "$VSWITCHD_MLOCKALL" != "no" ]; then - mlockall_opt="--mlockall" - fi - if [ "$daemonize" != "y" ]; then - # Start in background and force a "success" message - action "Starting ovs-vswitchd ($strace_opt$valgrind_opt)" true - (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $mlockall_opt "$VSWITCHD_OVSDB_SERVER") & - else - action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $mlockall_opt "$VSWITCHD_OVSDB_SERVER" - fi -} - -function start_brcompatd { - local syslog_opt="-vANY:SYSLOG:${BRCOMPATD_SYSLOG_LOGLEVEL}" - local logfile_file_opt="" - local logfile_level_opt="" - if [ -d "$BRCOMPATD_RUN_DIR" ]; then - mkdir -p "$BRCOMPATD_RUN_DIR" - fi - cd "$BRCOMPATD_RUN_DIR" - if [ -n "$BRCOMPATD_FILE_LOGLEVEL" ]; then - logfile_level_opt="-vANY:FILE:${BRCOMPATD_FILE_LOGLEVEL}" - logfile_file_opt="--log-file=$BRCOMPATD_LOGFILE" - fi - local leak_opt="" - if [ -n "$BRCOMPATD_MEMLEAK_LOGFILE" ]; then - leak_opt="--check-leaks=$BRCOMPATD_MEMLEAK_LOGFILE" - if [ -e "$BRCOMPATD_MEMLEAK_LOGFILE" ]; then - mv "$BRCOMPATD_MEMLEAK_LOGFILE" "$BRCOMPATD_MEMLEAK_LOGFILE.prev" - fi - fi - local strace_opt="" - local daemonize="y" - if [ -n "$BRCOMPATD_STRACE_LOG" ] && [ -n "$BRCOMPATD_VALGRIND_LOG" ]; then - printf "Can not start with both VALGRIND and STRACE\n" - exit 1 - fi - if [ -n "$BRCOMPATD_STRACE_LOG" ]; then - strace_opt="strace -o $BRCOMPATD_STRACE_LOG $BRCOMPATD_STRACE_OPT" - daemonize="n" - fi - if [ -n "$VALGRIND_LOG" ]; then - valgrind_opt="valgrind --log-file=$BRCOMPATD_VALGRIND_LOG $BRCOMPATD_VALGRIND_OPT" - daemonize="n" - fi - appctl_cmd="$appctl --target=/var/run/ovs-vswitchd.\`cat $VSWITCHD_PIDFILE\`.ctl %s" - if [ "$daemonize" != "y" ]; then - # Start in background and force a "success" message - action "Starting ovs-brcompatd ($strace_opt$valgrind_opt)" true - (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd"--no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER") & - else - action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE --detach $monitor_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" - fi -} - -function stop_ovsdb_server { - if [ -f "$OVSDB_SERVER_PIDFILE" ]; then - local pid=$(cat "$OVSDB_SERVER_PIDFILE") - action "Killing ovsdb-server ($pid)" kill -TERM $pid - rm -f "$OVSDB_SERVER_PIDFILE" - fi -} - -function stop_vswitchd { - if [ -f "$VSWITCHD_PIDFILE" ]; then - local pid=$(cat "$VSWITCHD_PIDFILE") - action "Killing ovs-vswitchd ($pid)" kill -TERM $pid - rm -f "$VSWITCHD_PIDFILE" - fi -} - -function stop_brcompatd { - if [ -f "$BRCOMPATD_PIDFILE" ]; then - local pid=$(cat "$BRCOMPATD_PIDFILE") - action "Killing ovs-brcompatd ($pid)" kill -TERM $pid - rm -f "$BRCOMPATD_PIDFILE" - fi -} - -function restart_approval { - if test ! -t 0; then - # Don't prompt if invoked non-interactively. - return 0 - fi - cat </dev/null -} - -function start { - if [ ! -f /etc/xensource-inventory ]; then - printf "vswitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n" - exit 1 - fi - source /etc/xensource-inventory - action "Updating configuration" do_host_call -} - -case "$1" in - start) - start - ;; - stop) - # Nothing to do here. - ;; - restart) - start - ;; - help) - printf "vswitch-xapi-update [start|stop|restart]\n" - ;; - *) - printf "Unknown command: $1\n" - exit 1 - ;; -esac diff --git a/xenserver/etc_logrotate.d_openvswitch b/xenserver/etc_logrotate.d_openvswitch new file mode 100644 index 00000000..22aab36a --- /dev/null +++ b/xenserver/etc_logrotate.d_openvswitch @@ -0,0 +1,16 @@ +# Copyright (C) 2009, 2010 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. + +/var/log/openvswitch/* { + sharedscripts + postrotate + # Tell Open vSwitch daemons to reopen their log files + /usr/bin/ovs-appctl -t ovs-vswitchd vlog/reopen + /usr/bin/ovs-appctl -t ovs-brcompatd vlog/reopen + /usr/bin/ovs-appctl -t ovsdb-server vlog/reopen + endscript +} diff --git a/xenserver/etc_logrotate.d_vswitch b/xenserver/etc_logrotate.d_vswitch deleted file mode 100644 index d6f71afb..00000000 --- a/xenserver/etc_logrotate.d_vswitch +++ /dev/null @@ -1,16 +0,0 @@ -# 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. - -/var/log/ovs-vswitchd.log /var/log/ovs-brcompatd.log { - sharedscripts - postrotate - # Tell ovs-vswitchd and ovs-brcompatd to reopen their log files - /usr/bin/ovs-appctl -t ovs-vswitchd vlog/reopen - /usr/bin/ovs-appctl -t ovs-brcompatd vlog/reopen - /usr/bin/ovs-appctl -t ovsdb-server vlog/reopen - endscript -} diff --git a/xenserver/etc_profile.d_openvswitch.sh b/xenserver/etc_profile.d_openvswitch.sh new file mode 100644 index 00000000..a7e1a0cc --- /dev/null +++ b/xenserver/etc_profile.d_openvswitch.sh @@ -0,0 +1,48 @@ +# Copyright (C) 2009, 2010 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. + +alias vswitch='service openvswitch' +alias openvswitch='service openvswitch' + +function watchdp { + watch ovs-dpctl show "$@" +} + +function watchdpflows { + local grep="" + local dp=$1 + shift + if [ $# -gt 0 ]; then + grep="| grep $@" + fi + watch "ovs-dpctl dump-flows $dp $grep" +} + +function watchflows { + local grep="" + local dp=$1 + shift + bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3) + if [ $# -gt 0 ]; then + grep="| grep $@" + fi + watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep" +} + +function monitorlogs { + local grep="" + if [ $# -gt 0 ]; then + grep="| grep --line-buffered '^==> .* <==$" + for i in "$@"; do + grep="$grep\|$i" + done + grep="$grep'" + fi + cmd="tail -F /var/log/messages /var/log/openvswitch/ovs-vswitchd.log /var/log/openvswitch/ovs-brcompatd.log /var/log/openvswitch/ovsdb-server /var/log/xensource.log $grep | tee /var/log/monitorlogs.out" + printf "cmd: $cmd\n" + eval "$cmd" +} diff --git a/xenserver/etc_profile.d_vswitch.sh b/xenserver/etc_profile.d_vswitch.sh deleted file mode 100644 index a001e215..00000000 --- a/xenserver/etc_profile.d_vswitch.sh +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2009, 2010 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. - -alias vswitch='service vswitch' - -function watchdp { - watch ovs-dpctl show "$@" -} - -function watchdpflows { - local grep="" - local dp=$1 - shift - if [ $# -gt 0 ]; then - grep="| grep $@" - fi - watch "ovs-dpctl dump-flows $dp $grep" -} - -function watchflows { - local grep="" - local dp=$1 - shift - bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3) - if [ $# -gt 0 ]; then - grep="| grep $@" - fi - watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep" -} - -function monitorlogs { - local grep="" - if [ $# -gt 0 ]; then - grep="| grep --line-buffered '^==> .* <==$" - for i in "$@"; do - grep="$grep\|$i" - done - grep="$grep'" - fi - cmd="tail -F /var/log/messages /var/log/ovs-vswitchd.log /var/log/xensource.log $grep | tee /var/log/monitorlogs.out" - printf "cmd: $cmd\n" - eval "$cmd" -} diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update new file mode 100755 index 00000000..8314a1b6 --- /dev/null +++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# +# xapi plugin script to update the cache of configuration items in the +# ovs-vswitchd configuration that are managed in the xapi database when +# integrated with Citrix management tools. + +# Copyright (C) 2009, 2010 Nicira Networks, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TBD: - error handling needs to be improved. Currently this can leave +# TBD: the system in a bad state if anything goes wrong. + +import XenAPIPlugin +import XenAPI +import os +import subprocess + +vsctl="/usr/bin/ovs-vsctl" +cacert_filename="/etc/openvswitch/vswitchd.cacert" + +# Delete the CA certificate, so that we go back to boot-strapping mode +def delete_cacert(): + try: + os.remove(cacert_filename) + except OSError: + # Ignore error if file doesn't exist + pass + +def update(session, args): + pools = session.xenapi.pool.get_all() + # We assume there is only ever one pool... + if len(pools) == 0: + raise XenAPIPlugin.Failure("NO_POOL_FOR_HOST", []) + if len(pools) > 1: + raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", []) + pool = session.xenapi.pool.get_record(pools[0]) + try: + controller = pool["other_config"]["vSwitchController"] + except KeyError, e: + controller = "" + currentController = vswitchCurrentController() + if controller == "" and currentController != "": + delete_cacert() + removeControllerCfg() + return "Successfully removed controller config" + elif controller != currentController: + delete_cacert() + setControllerCfg(controller) + return "Successfully set controller to " + controller + else: + return "No change to configuration" + +def vswitchCurrentController(): + controller = vswitchCfgQuery(["get", "Open_vSwitch", + ".", "managers"]).strip('[]"') + if controller == "": + return controller + if len(controller) < 4 or controller[0:4] != "ssl:": + return controller + else: + return controller.split(':')[1] + +def removeControllerCfg(): + vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", + "--", "del-ssl"]) + +def setControllerCfg(controller): + vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", + "--", "del-ssl", + "--", "--bootstrap", "set-ssl", + "/etc/xensource/xapi-ssl.pem", + cacert_filename, + "--", "set", "Open_vSwitch", ".", + 'managers="ssl:' + controller + ':6632"']) + +def vswitchCfgQuery(action_args): + cmd = [vsctl, "-vANY:console:emer"] + action_args + output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() + if len(output) == 0 or output[0] == None: + output = "" + else: + output = output[0].strip() + return output + +def vswitchCfgMod(action_args): + cmd = [vsctl, "-vANY:console:emer"] + action_args + exitcode = subprocess.call(cmd) + if exitcode != 0: + raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE", + [ str(exitcode) , str(action_args) ]) + +if __name__ == "__main__": + XenAPIPlugin.dispatch({"update": update}) diff --git a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update b/xenserver/etc_xapi.d_plugins_vswitch-cfg-update deleted file mode 100755 index 4cf2d881..00000000 --- a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python -# -# xapi plugin script to update the cache of configuration items in the -# ovs-vswitchd configuration file that are managed in the xapi database -# when integrated with Citrix management tools. - -# Copyright (C) 2009, 2010 Nicira Networks, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# TBD: - error handling needs to be improved. Currently this can leave -# TBD: the system in a bad state if anything goes wrong. - -import XenAPIPlugin -import XenAPI -import os -import subprocess - -vsctl="/usr/bin/ovs-vsctl" -cacert_filename="/etc/ovs-vswitchd.cacert" - -# Delete the CA certificate, so that we go back to boot-strapping mode -def delete_cacert(): - try: - os.remove(cacert_filename) - except OSError: - # Ignore error if file doesn't exist - pass - -def update(session, args): - pools = session.xenapi.pool.get_all() - # We assume there is only ever one pool... - if len(pools) == 0: - raise XenAPIPlugin.Failure("NO_POOL_FOR_HOST", []) - if len(pools) > 1: - raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", []) - pool = session.xenapi.pool.get_record(pools[0]) - try: - controller = pool["other_config"]["vSwitchController"] - except KeyError, e: - controller = "" - currentController = vswitchCurrentController() - if controller == "" and currentController != "": - delete_cacert() - removeControllerCfg() - return "Successfully removed controller config" - elif controller != currentController: - delete_cacert() - setControllerCfg(controller) - return "Successfully set controller to " + controller - else: - return "No change to configuration" - -def vswitchCurrentController(): - controller = vswitchCfgQuery(["get", "Open_vSwitch", - ".", "managers"]).strip('[]"') - if controller == "": - return controller - if len(controller) < 4 or controller[0:4] != "ssl:": - return controller - else: - return controller.split(':')[1] - -def removeControllerCfg(): - vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", - "--", "del-ssl"]) - -def setControllerCfg(controller): - vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", - "--", "del-ssl", - "--", "--bootstrap", "set-ssl", - "/etc/xensource/xapi-ssl.pem", - "/etc/xensource/xapi-ssl.pem", - "/etc/ovs-vswitchd.cacert", - "--", "set", "Open_vSwitch", ".", - 'managers="ssl:' + controller + ':6632"']) - -def vswitchCfgQuery(action_args): - cmd = [vsctl, "-vANY:console:emer"] + action_args - output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() - if len(output) == 0 or output[0] == None: - output = "" - else: - output = output[0].strip() - return output - -def vswitchCfgMod(action_args): - cmd = [vsctl, "-vANY:console:emer"] + action_args - exitcode = subprocess.call(cmd) - if exitcode != 0: - raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE", - [ str(exitcode) , str(action_args) ]) - -if __name__ == "__main__": - XenAPIPlugin.dispatch({"update": update}) diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index 56c710d8..1a38dc4c 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -47,7 +47,7 @@ handle_promiscuous() esac ;; vswitch) - logger -t script-vif "${dev}: Promiscuous ports are not supported via vSwitch." + logger -t script-vif "${dev}: Promiscuous ports are not supported via Open vSwitch." ;; esac fi diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec new file mode 100644 index 00000000..9e6f7994 --- /dev/null +++ b/xenserver/openvswitch-xen.spec @@ -0,0 +1,370 @@ +# Spec file for Open vSwitch. + +# Copyright (C) 2009, 2010 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. + +# When building, the rpmbuild command line should define +# openvswitch_version, xen_version, and build_number using -D arguments. +# for example: +# +# rpmbuild -D "openvswitch_version 0.8.9~1+build123" -D "xen_version 2.6.18-128.1.1.el5.xs5.1.0.483.1000xen" -D "build_number --with-build-number=123" -bb /usr/src/redhat/SPECS/openvswitch-xen.spec +# +%define version %{openvswitch_version}-%{xen_version} + +Name: openvswitch +Summary: Virtual switch +Group: System Environment/Daemons +URL: http://www.openvswitch.org/ +Vendor: Nicira Networks, Inc. +Version: %{openvswitch_version} + +# The entire source code is ASL 2.0 except datapath/ which is GPLv2 +License: ASL 2.0 and GPLv2 +Release: 1 +Source: openvswitch-%{openvswitch_version}.tar.gz +Buildroot: /tmp/openvswitch-xen-rpm +Requires: kernel-xen = %(echo '%{xen_version}' | sed 's/xen$//') + +%description +Open vSwitch provides standard network bridging functions augmented with +support for the OpenFlow protocol for remote per-flow control of +traffic. + +%prep +%setup -q -n openvswitch-%{openvswitch_version} + +%build +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-l26=/lib/modules/%{xen_version}/build --enable-ssl %{build_number} +make %{_smp_mflags} + +%install +rm -rf $RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT +install -d -m 755 $RPM_BUILD_ROOT/etc +install -d -m 755 $RPM_BUILD_ROOT/etc/init.d +install -m 755 xenserver/etc_init.d_openvswitch \ + $RPM_BUILD_ROOT/etc/init.d/openvswitch +install -m 755 xenserver/etc_init.d_openvswitch-xapi-update \ + $RPM_BUILD_ROOT/etc/init.d/openvswitch-xapi-update +install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig +install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d +install -m 755 xenserver/etc_logrotate.d_openvswitch \ + $RPM_BUILD_ROOT/etc/logrotate.d/openvswitch +install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d +install -m 755 xenserver/etc_profile.d_openvswitch.sh \ + $RPM_BUILD_ROOT/etc/profile.d/openvswitch.sh +install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins +install -m 755 xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \ + $RPM_BUILD_ROOT/etc/xapi.d/plugins/openvswitch-cfg-update +install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts +install -m 644 vswitchd/vswitch.ovsschema \ + $RPM_BUILD_ROOT/usr/share/openvswitch/vswitch.ovsschema +install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/interface-reconfigure +install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigure.py +install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py +install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py +install -m 755 xenserver/etc_xensource_scripts_vif \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/vif +install -m 755 xenserver/usr_share_openvswitch_scripts_refresh-network-uuids \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/refresh-network-uuids +install -m 755 xenserver/usr_sbin_xen-bugtool \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/xen-bugtool +install -m 755 xenserver/usr_sbin_brctl \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/brctl +install -m 755 xenserver/usr_share_openvswitch_scripts_sysconfig.template \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/sysconfig.template +install -m 644 \ + xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \ + $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/XSFeatureVSwitch.py + +install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/openvswitch +find datapath/linux-2.6 -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/openvswitch \; + +# Get rid of stuff we don't want to make RPM happy. +rm \ + $RPM_BUILD_ROOT/usr/bin/ovs-controller \ + $RPM_BUILD_ROOT/usr/bin/ovs-discover \ + $RPM_BUILD_ROOT/usr/bin/ovs-kill \ + $RPM_BUILD_ROOT/usr/bin/ovs-openflowd \ + $RPM_BUILD_ROOT/usr/bin/ovs-pki \ + $RPM_BUILD_ROOT/usr/bin/ovs-wdt \ + $RPM_BUILD_ROOT/usr/sbin/ovs-monitor \ + $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \ + $RPM_BUILD_ROOT/usr/share/man/man8/ovs-discover.8 \ + $RPM_BUILD_ROOT/usr/share/man/man8/ovs-kill.8 \ + $RPM_BUILD_ROOT/usr/share/man/man8/ovs-openflowd.8 \ + $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8 +rm -f $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/openvswitch/veth_mod.ko + +install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +if [ ! -f /etc/xensource-inventory ]; then + printf "XenSource inventory not present in /etc/xensource-inventory" + exit 1 +fi + +if [ "$1" = "1" ]; then + if md5sum -c --status </dev/null 2>&1; then :; else + cat >>/etc/sysctl.conf < /dev/null +fi + +# Create default or update existing /etc/sysconfig/openvswitch. +SYSCONFIG=/etc/sysconfig/openvswitch +TEMPLATE=/usr/share/openvswitch/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 /usr/lib/openvswitch/xs-original \ + || printf "Could not create script backup directory.\n" +for f in \ + /opt/xensource/libexec/interface-reconfigure \ + /opt/xensource/libexec/InterfaceReconfigure.py \ + /opt/xensource/libexec/InterfaceReconfigureBridge.py \ + /opt/xensource/libexec/InterfaceReconfigureVswitch.py \ + /etc/xensource/scripts/vif \ + /usr/sbin/xen-bugtool \ + /usr/sbin/brctl +do + s=$(basename "$f") + t=$(readlink "$f") + if [ -f "$f" ] && [ "$t" != "/usr/share/openvswitch/scripts/$s" ]; then + mv "$f" /usr/lib/openvswitch/xs-original/ \ + || printf "Could not save original XenServer $s script\n" + ln -s "/usr/share/openvswitch/scripts/$s" "$f" \ + || printf "Could not link to Open vSwitch $s script\n" + fi +done + +# Install xsconsole plugin +plugin=$(readlink /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py) +if [ "$plugin" != "/usr/share/openvswitch/scripts/XSFeatureVSwitch.py" ]; then + rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py + ln -s /usr/share/openvswitch/scripts/XSFeatureVSwitch.py /usr/lib/xsconsole/plugins-base/ || printf "Could not link to vSswitch xsconsole plugin.\n" +fi + +# Ensure all required services are set to run +for s in openvswitch openvswitch-xapi-update; do + if chkconfig --list $s >/dev/null 2>&1; then + chkconfig --del $s || printf "Could not remove $s init script." + fi + chkconfig --add $s || printf "Could not add $s init script." + chkconfig $s on || printf "Could not enable $s init script." +done + +# Configure system to use Open vSwitch +echo vswitch > /etc/xensource/network.conf + +if [ "$1" = "1" ]; then # $1 = 2 for upgrade + printf "\nYou MUST reboot the server NOW to complete the change to\n" + printf "Open vSwitch. Attempts to modify networking on the server\n" + printf "or any hosted VM will fail until after the reboot and could\n" + printf "leave the server in an state requiring manual recovery.\n\n" +else + printf "\nTo use the new Open vSwitch install, you should reboot the\n" + printf "server now. Failure to do so may result in incorrect operation." + printf "\n\n" +fi + +%preun +if [ "$1" = "0" ]; then # $1 = 1 for upgrade + for s in openvswitch openvswitch-xapi-update; do + chkconfig --del $s || printf "Could not remove $s init script." + done +fi + + +%postun +if [ "$1" = "0" ]; then # $1 = 1 for upgrade + + rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py \ + /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \ + /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo \ + || printf "Could not remove Open vSwitch xsconsole plugin.\n" + + # Restore original XenServer scripts + for f in \ + /opt/xensource/libexec/interface-reconfigure \ + /etc/xensource/scripts/vif \ + /usr/sbin/xen-bugtool \ + /usr/sbin/brctl + do + s=$(basename "$f") + if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then + printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n" + printf "Could not restore original XenServer script.\n" + else + (rm -f "$f" \ + && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \ + || printf "Could not restore original XenServer $s script.\n" + fi + done + + # Remove all configuration files + rm -f /etc/openvswitch/conf.db + rm -f /etc/sysconfig/openvswitch + rm -f /etc/openvswitch/vswitchd.cacert + rm -f /var/xapi/network.dbcache + + # Configure system to use bridge + echo bridge > /etc/xensource/network.conf + + printf "\nYou MUST reboot the server now to complete the change to\n" + printf "standard Xen networking. Attempts to modify networking on the\n" + printf "server or any hosted VM will fail until after the reboot and\n" + printf "could leave the server in a state requiring manual recovery.\n\n" +fi + + +%files +%defattr(-,root,root) +/etc/init.d/openvswitch +/etc/init.d/openvswitch-xapi-update +/etc/xapi.d/plugins/openvswitch-cfg-update +/etc/logrotate.d/openvswitch +/etc/profile.d/openvswitch.sh +/lib/modules/%{xen_version}/kernel/net/openvswitch/openvswitch_mod.ko +/lib/modules/%{xen_version}/kernel/net/openvswitch/brcompat_mod.ko +%if %(echo '%{xen_version}'|awk -F"." '{if ($3>=18) print 1; else print 0;}') +/lib/modules/%{xen_version}/kernel/net/openvswitch/ip_gre_mod.ko +%endif +/usr/share/openvswitch/scripts/refresh-network-uuids +/usr/share/openvswitch/scripts/interface-reconfigure +/usr/share/openvswitch/scripts/InterfaceReconfigure.py +/usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py +/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py +/usr/share/openvswitch/scripts/vif +/usr/share/openvswitch/scripts/xen-bugtool +/usr/share/openvswitch/scripts/XSFeatureVSwitch.py +/usr/share/openvswitch/scripts/brctl +/usr/share/openvswitch/scripts/sysconfig.template +/usr/share/openvswitch/vswitch.ovsschema +/usr/sbin/ovs-brcompatd +/usr/sbin/ovs-vswitchd +/usr/sbin/ovsdb-server +/usr/bin/ovs-appctl +/usr/bin/ovs-dpctl +/usr/bin/ovs-ofctl +/usr/bin/ovs-vsctl +/usr/bin/ovsdb-client +/usr/bin/ovsdb-tool +/usr/share/man/man1/ovsdb-client.1.gz +/usr/share/man/man1/ovsdb-server.1.gz +/usr/share/man/man1/ovsdb-tool.1.gz +/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz +/usr/share/man/man8/ovs-appctl.8.gz +/usr/share/man/man8/ovs-brcompatd.8.gz +/usr/share/man/man8/ovs-dpctl.8.gz +/usr/share/man/man8/ovs-ofctl.8.gz +/usr/share/man/man8/ovs-vsctl.8.gz +/usr/share/man/man8/ovs-vswitchd.8.gz +/var/lib/openvswitch +%exclude /usr/share/openvswitch/scripts/*.pyc +%exclude /usr/share/openvswitch/scripts/*.pyo diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index fba89bed..e75a17d6 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -117,13 +117,13 @@ class VSwitchControllerDialogue(Dialogue): # ChoiceDef(Lang("Restart ovs-brcompatd"), # lambda: self.restartService("vswitch-brcompatd")) ] - self.menu = Menu(self, None, Lang("Configure vSwitch"), choiceDefs) + self.menu = Menu(self, None, Lang("Configure Open vSwitch"), choiceDefs) self.ChangeState("INITIAL") def BuildPane(self): pane = self.NewPane(DialoguePane(self.parent)) - pane.TitleSet(Lang("Configure vSwitch")) + pane.TitleSet(Lang("Configure Open vSwitch")) pane.AddBox() def ChangeState(self, inState): @@ -251,13 +251,13 @@ class VSwitchControllerDialogue(Dialogue): for host in hosts: Layout.Inst().TransientBanner("Updating host %d out of %d" % (self.hostsUpdated + 1, self.hostsInPool)) - session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {}) + session.xenapi.host.call_plugin(host, "openvswitch-cfg-update", "update", {}) self.hostsUpdated = self.hostsUpdated + 1 def _updateThisServer(self, session): data = Data.Inst() host = data.host.opaqueref() - session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {}) + session.xenapi.host.call_plugin(host, "openvswitch-cfg-update", "update", {}) class XSFeatureVSwitch: @@ -266,12 +266,12 @@ class XSFeatureVSwitch: def StatusUpdateHandler(cls, inPane): data = Data.Inst() - inPane.AddTitleField(Lang("vSwitch")) + inPane.AddTitleField(Lang("Open vSwitch")) inPane.NewLine() inPane.AddStatusField(Lang("Version", 20), - VSwitchService.Inst("vswitch", "ovs-vswitchd").version()) + VSwitchService.Inst("openvswitch", "ovs-vswitchd").version()) inPane.NewLine() @@ -295,11 +295,11 @@ class XSFeatureVSwitch: inPane.NewLine() inPane.AddStatusField(Lang("ovs-vswitchd status", 20), - VSwitchService.Inst("vswitch", "ovs-vswitchd").status()) + VSwitchService.Inst("openvswitch", "ovs-vswitchd").status()) inPane.AddStatusField(Lang("ovsdb-server status", 20), - VSwitchService.Inst("vswitch", "ovsdb-server").status()) + VSwitchService.Inst("openvswitch", "ovsdb-server").status()) inPane.AddStatusField(Lang("ovs-brcompatd status", 20), - VSwitchService.Inst("vswitch", "ovs-brcompatd").status()) + VSwitchService.Inst("openvswitch", "ovs-brcompatd").status()) inPane.AddKeyHelpField( { Lang("") : Lang("Reconfigure"), @@ -317,7 +317,7 @@ class XSFeatureVSwitch: { 'menuname' : 'MENU_NETWORK', 'menupriority' : 800, - 'menutext' : Lang('vSwitch') , + 'menutext' : Lang('Open vSwitch') , 'statusupdatehandler' : self.StatusUpdateHandler, 'activatehandler' : self.ActivateHandler } diff --git a/xenserver/usr_sbin_brctl b/xenserver/usr_sbin_brctl index fbaa6ad7..2035a4f6 100755 --- a/xenserver/usr_sbin_brctl +++ b/xenserver/usr_sbin_brctl @@ -22,9 +22,9 @@ import sys argv0 = sys.argv[0] -BRCTL = "/usr/lib/vswitch/xs-original/brctl" +BRCTL = "/usr/lib/openvswitch/xs-original/brctl" VSCTL = "/usr/bin/ovs-vsctl" -OVSDB_SERVER = "unix:/var/run/ovsdb-server" +OVSDB_SERVER = "unix:/var/run/openvswitch/db.sock" # Execute the real brctl program, passing the same arguments that were passed # to us. diff --git a/xenserver/usr_sbin_xen-bugtool b/xenserver/usr_sbin_xen-bugtool index 92fd27fc..539ab028 100755 --- a/xenserver/usr_sbin_xen-bugtool +++ b/xenserver/usr_sbin_xen-bugtool @@ -119,9 +119,10 @@ HP_CMA_LOG = '/var/spool/compaq/cma.log' HP_HPASMD_LOG = '/var/spool/compaq/hpasmd.log' VAR_LOG_DIR = '/var/log/' VNCTERM_CORE_DIR = '/var/xen/vncterm' -VSWITCH_CORE_DIR = '/var/xen/vswitch' -OVS_VSWITCH_CONF = '/etc/ovs-vswitchd.conf.db' -OVS_VSWITCH_DBCACHE = '/var/xapi/network.dbcache' +OPENVSWITCH_CORE_DIR = '/var/xen/openvswitch' +OPENVSWITCH_CONF = '/etc/openvswitch/conf.db' +OPENVSWITCH_DBCACHE = '/var/xapi/network.dbcache' +OPENVSWITCH_LOG_DIR = '/var/log/openvswitch' XENSOURCE_INVENTORY = '/etc/xensource-inventory' OEM_CONFIG_DIR = '/var/xsconfig' OEM_CONFIG_FILES_RE = re.compile(r'^.*xensource-inventory$') @@ -278,9 +279,9 @@ CAP_SYSTEM_LOGS = 'system-logs' CAP_SYSTEM_SERVICES = 'system-services' CAP_TAPDISK_LOGS = 'tapdisk-logs' CAP_VNCTERM = 'vncterm' -CAP_VSWITCH_CONFIG = 'vswitch-config' -CAP_VSWITCH_LOGS = 'vswitch-logs' -CAP_VSWITCH_STATUS = 'vswitch-status' +CAP_OPENVSWITCH_CONFIG = 'openvswitch-config' +CAP_OPENVSWITCH_LOGS = 'openvswitch-logs' +CAP_OPENVSWITCH_STATUS = 'openvswitch-status' CAP_WLB = 'wlb' CAP_X11_LOGS = 'X11' CAP_X11_AUTH = 'X11-auth' @@ -345,10 +346,10 @@ cap(CAP_SYSTEM_SERVICES, PII_NO, max_size=5*KB, max_time=20) cap(CAP_TAPDISK_LOGS, PII_NO, max_size=64*KB) cap(CAP_VNCTERM, PII_MAYBE, checked = False) -cap(CAP_VSWITCH_CONFIG, PII_YES, +cap(CAP_OPENVSWITCH_CONFIG, PII_YES, min_size=0, max_size=20*MB) -cap(CAP_VSWITCH_LOGS, PII_YES, max_size=20*MB) -cap(CAP_VSWITCH_STATUS, PII_YES, max_size=19*KB, +cap(CAP_OPENVSWITCH_LOGS, PII_YES, max_size=20*MB) +cap(CAP_OPENVSWITCH_STATUS, PII_YES, max_size=19*KB, max_time=30) cap(CAP_WLB, PII_NO, max_size=3*MB, max_time=20) @@ -497,7 +498,8 @@ def main(argv = None): CAP_NETWORK_CONFIG, CAP_NETWORK_STATUS, CAP_PROCESS_LIST, CAP_HIGH_AVAILABILITY, CAP_PAM, CAP_PERSISTENT_STATS, CAP_MULTIPATH, CAP_SYSTEM_LOGS, CAP_SYSTEM_SERVICES, CAP_TAPDISK_LOGS, - CAP_VNCTERM, CAP_VSWITCH_CONFIG, CAP_VSWITCH_LOGS, CAP_VSWITCH_STATUS, CAP_WLB, + CAP_VNCTERM, CAP_OPENVSWITCH_CONFIG, + CAP_OPENVSWITCH_LOGS, CAP_OPENVSWITCH_STATUS, CAP_WLB, CAP_X11_LOGS, CAP_X11_AUTH, CAP_XAPI_DEBUG, CAP_XAPI_SUBPROCESS, CAP_XENSERVER_CONFIG, CAP_XENSERVER_DOMAINS, CAP_XENSERVER_DATABASES, CAP_XENSERVER_INSTALL, CAP_XENSERVER_LOGS, CAP_XEN_INFO, CAP_XHA_LIVESET, CAP_YUM] @@ -710,24 +712,25 @@ exclude those logs from the archive. tree_output(CAP_VNCTERM, VNCTERM_CORE_DIR) - file_output(CAP_VSWITCH_CONFIG, [OVS_VSWITCH_CONF]) - file_output(CAP_VSWITCH_CONFIG, [OVS_VSWITCH_DBCACHE]) + file_output(CAP_OPENVSWITCH_CONFIG, [OPENVSWITCH_CONF]) + file_output(CAP_OPENVSWITCH_CONFIG, [OPENVSWITCH_DBCACHE]) - file_output(CAP_VSWITCH_LOGS, - [ VAR_LOG_DIR + x for x in - [ 'ovs-brcompatd.log', 'ovs-vswitchd.log', 'ovsdb-server.log', 'vswitch-cfg-update.log', 'vswitch-xsplugin.log' ] + + file_output(CAP_OPENVSWITCH_LOGS, + [ OPENVSWITCH_LOG_DIR + x for x in + [ 'ovs-brcompatd.log', 'ovs-vswitchd.log', 'ovsdb-server.log', + 'openvswitch-cfg-update.log', 'openvswitch-xsplugin.log' ] + [ f % n for n in range(1, 20) \ for f in ['ovs-brcompatd.log.%d', 'ovs-brcompatd.log.%d.gz', 'ovs-vswitchd.log.%d', 'ovs-vswitchd.log.%d.gz', 'ovsdb-server.log.%d', 'ovsdb-server.log.%d.gz']]]) - cmd_output(CAP_VSWITCH_STATUS, [OVS_DPCTL, 'show']) - tree_output(CAP_VSWITCH_STATUS, VSWITCH_CORE_DIR) + cmd_output(CAP_OPENVSWITCH_STATUS, [OVS_DPCTL, 'show']) + tree_output(CAP_OPENVSWITCH_STATUS, OPENVSWITCH_CORE_DIR) for d in dp_list(): - cmd_output(CAP_VSWITCH_STATUS, [OVS_OFCTL, 'show', d]) - cmd_output(CAP_VSWITCH_STATUS, [OVS_OFCTL, 'status', d]) - cmd_output(CAP_VSWITCH_STATUS, [OVS_OFCTL, 'dump-flows', d]) - cmd_output(CAP_VSWITCH_STATUS, [OVS_DPCTL, 'dump-flows', d]) + cmd_output(CAP_OPENVSWITCH_STATUS, [OVS_OFCTL, 'show', d]) + cmd_output(CAP_OPENVSWITCH_STATUS, [OVS_OFCTL, 'status', d]) + cmd_output(CAP_OPENVSWITCH_STATUS, [OVS_OFCTL, 'dump-flows', d]) + cmd_output(CAP_OPENVSWITCH_STATUS, [OVS_DPCTL, 'dump-flows', d]) cmd_output(CAP_WLB, [XE, 'pool-retrieve-wlb-diagnostics']) diff --git a/xenserver/usr_share_openvswitch_scripts_refresh-network-uuids b/xenserver/usr_share_openvswitch_scripts_refresh-network-uuids new file mode 100755 index 00000000..34fe1e7e --- /dev/null +++ b/xenserver/usr_share_openvswitch_scripts_refresh-network-uuids @@ -0,0 +1,12 @@ +#! /bin/sh + +. /etc/xensource-inventory + +for pif in $(xe pif-list --minimal host-uuid=${INSTALLATION_UUID} currently-attached=true VLAN=-1 | sed 's/,/ /g'); do + printf "Refreshing PIF %s... " $pif + if /opt/xensource/libexec/interface-reconfigure --pif-uuid=$pif up; then + printf "done\n" + else + printf "error!\n" + fi +done diff --git a/xenserver/usr_share_openvswitch_scripts_sysconfig.template b/xenserver/usr_share_openvswitch_scripts_sysconfig.template new file mode 100644 index 00000000..9bd51bc2 --- /dev/null +++ b/xenserver/usr_share_openvswitch_scripts_sysconfig.template @@ -0,0 +1,234 @@ +### Configuration options for openvswitch + +# Copyright (C) 2009, 2010 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. + +# 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 + +# ENABLE_MONITOR: If 'y' then monitor daemon processes and restart them +# if they die due to an error signal. +# ENABLE_MONITOR=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/xen/openvswitch/%e-%t" + +# OVSDB_SERVER_REMOTES: Space-separated list of methods on which to have +# ovsdb-server listen or connect for a JSON-RPC connection. +# OVSDB_SERVER_REMOTES="punix:/var/run/openvswitch/db.sock db:Open_vSwitch,managers" + +# OVSDB_SERVER_DB: File for which ovsdb-server uses for storage. +# OVSDB_SERVER_DB=/etc/openvswitch/conf.db + +# OVSDB_SERVER_PIDFILE: File in which to store the pid of the running +# ovsdb-server. +# OVSDB_SERVER_PIDFILE=/var/run/openvswitch/ovsdb-server.pid + +# OVSDB_SERVER_RUN_DIR: Set the directory in which ovsdb-server should be +# run. This mainly affects where core files will be placed. +# OVSDB_SERVER_RUN_DIR=/var/xen/openvswitch + +# OVSDB_SERVER_PRIORITY: "nice" priority at which to run ovsdb-server and +# related processes. +# OVSDB_SERVER_PRIORITY=-10 + +# OVSDB_SERVER_LOGFILE: File to send the FILE_LOGLEVEL log messages to. +# OVSDB_SERVER_LOGFILE=/var/log/openvswitch/ovsdb-server.log + +# OVSDB_SERVER_FILE_LOGLEVEL: Log level at which to log into the +# OVSDB_SERVER_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. +# OVSDB_SERVER_FILE_LOGLEVEL="" + +# OVSDB_SERVER_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. +# OVSDB_SERVER_SYSLOG_LOGLEVEL="WARN" + +# OVSDB_SERVER_MEMLEAK_LOGFILE: File for logging memory leak data. +# Enabling this option will slow ovsdb-server 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. +# OVSDB_SERVER_MEMLEAK_LOGFILE="" + +# OVSDB_SERVER_STRACE_LOG: File for logging strace output. +# If this is set to a nonempty string, then ovsdb-server will run +# under strace, whose output will be logged to the specified file. +# Enabling this option will slow ovsdb-server significantly. +# OVSDB_SERVER_STRACE_LOG and OVSDB_SERVER_VALGRIND_LOG are mutually +# exclusive. +# OVSDB_SERVER_STRACE_LOG="" + +# OVSDB_SERVER_STRACE_OPT: Options to pass to strace. +# This option's value is honored only when OVSDB_SERVER_STRACE_LOG is +# set to a nonempty string. +# OVSDB_SERVER_STRACE_OPT="" + +# OVSDB_SERVER_VALGRIND_LOG: File for logging valgrind output. +# If this is set to a nonempty string, then ovsdb-server will run +# under valgrind, whose output will be logged to the specified file. +# Enabling this option will slow ovsdb-server by 100X or more. +# valgrind is not installed by default on XenServer systems; you must +# install it by hand to usefully enable this option. +# OVSDB_SERVER_STRACE_LOG and OVSDB_SERVER_VALGRIND_LOG are mutually +# exclusive. +# OVSDB_SERVER_VALGRIND_LOG="" + +# OVSDB_SERVER_VALGRIND_OPT: Options to pass to valgrind. +# This option's value is honored only when OVSDB_SERVER_VALGRIND_LOG is +# set to a nonempty string. +# OVSDB_SERVER_VALGRIND_OPT="" + +# VSWITCHD_OVSDB_SERVER: Method to have ovs-vswitchd initiate a JSON-RPC +# connection to an ovsdb-server instance. +# VSWITCHD_OVSDB_SERVER=unix:/var/run/openvswitch/db.sock + +# VSWITCHD_OVSDB_SCHEMA: Schema file to use for generating a new OVSDB +# ovs-vswitchd database. +# VSWITCHD_OVSDB_SCHEMA=/usr/share/openvswitch/vswitch.ovsschema + +# VSWITCHD_PIDFILE: File in which to store the pid of the running +# ovs-vswitchd. +# VSWITCHD_PIDFILE=/var/run/openvswitch/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/openvswitch + +# VSWITCHD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related +# processes. +# VSWITCHD_PRIORITY=-10 + +# VSWITCHD_MLOCKALL: Whether to pass ovs-vswitchd the --mlockall option. +# This option should be set to "yes" or "no". The default is "yes". +# Enabling this option can avoid networking interruptions due to +# system memory pressure in extraordinary situations, such as multiple +# concurrent VM import operations. +# VSWITCHD_MLOCKALL=yes + +# VSWITCHD_LOGFILE: File to send the FILE_LOGLEVEL log messages to. +# VSWITCHD_LOGFILE=/var/log/openvswitch/ovs-vswitchd.log + +# 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_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_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/openvswitch/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/openvswitch + +# BRCOMPATD_PRIORITY: "nice" priority at which to run ovs-vswitchd and related +# processes. +# BRCOMPATD_PRIORITY=-10 + +# BRCOMPATD_LOGFILE: File to send the FILE_LOGLEVEL log messages to. +# BRCOMPATD_LOGFILE=/var/log/openvswitch/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/usr_share_vswitch_scripts_refresh-network-uuids b/xenserver/usr_share_vswitch_scripts_refresh-network-uuids deleted file mode 100755 index 34fe1e7e..00000000 --- a/xenserver/usr_share_vswitch_scripts_refresh-network-uuids +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -. /etc/xensource-inventory - -for pif in $(xe pif-list --minimal host-uuid=${INSTALLATION_UUID} currently-attached=true VLAN=-1 | sed 's/,/ /g'); do - printf "Refreshing PIF %s... " $pif - if /opt/xensource/libexec/interface-reconfigure --pif-uuid=$pif up; then - printf "done\n" - else - printf "error!\n" - fi -done diff --git a/xenserver/usr_share_vswitch_scripts_sysconfig.template b/xenserver/usr_share_vswitch_scripts_sysconfig.template deleted file mode 100644 index 4d5efcab..00000000 --- a/xenserver/usr_share_vswitch_scripts_sysconfig.template +++ /dev/null @@ -1,234 +0,0 @@ -### Configuration options for vswitch - -# Copyright (C) 2009, 2010 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. - -# 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 - -# ENABLE_MONITOR: If 'y' then monitor daemon processes and restart them -# if they die due to an error signal. -# ENABLE_MONITOR=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" - -# OVSDB_SERVER_REMOTES: Space-separated list of methods on which to have -# ovsdb-server listen or connect for a JSON-RPC connection. -# OVSDB_SERVER_REMOTES="punix:/var/run/ovsdb-server db:Open_vSwitch,managers" - -# OVSDB_SERVER_DB: File for which ovsdb-server uses for storage. -# OVSDB_SERVER_DB=/etc/ovs-vswitchd.conf.db - -# OVSDB_SERVER_PIDFILE: File in which to store the pid of the running -# ovsdb-server. -# OVSDB_SERVER_PIDFILE=/var/run/ovsdb-server.pid - -# OVSDB_SERVER_RUN_DIR: Set the directory in which ovsdb-server should be -# run. This mainly affects where core files will be placed. -# OVSDB_SERVER_RUN_DIR=/var/xen/vswitch - -# OVSDB_SERVER_PRIORITY: "nice" priority at which to run ovsdb-server and -# related processes. -# OVSDB_SERVER_PRIORITY=-10 - -# OVSDB_SERVER_LOGFILE: File to send the FILE_LOGLEVEL log messages to. -# OVSDB_SERVER_LOGFILE=/var/log/ovsdb-server.log - -# OVSDB_SERVER_FILE_LOGLEVEL: Log level at which to log into the -# OVSDB_SERVER_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. -# OVSDB_SERVER_FILE_LOGLEVEL="" - -# OVSDB_SERVER_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. -# OVSDB_SERVER_SYSLOG_LOGLEVEL="WARN" - -# OVSDB_SERVER_MEMLEAK_LOGFILE: File for logging memory leak data. -# Enabling this option will slow ovsdb-server 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. -# OVSDB_SERVER_MEMLEAK_LOGFILE="" - -# OVSDB_SERVER_STRACE_LOG: File for logging strace output. -# If this is set to a nonempty string, then ovsdb-server will run -# under strace, whose output will be logged to the specified file. -# Enabling this option will slow ovsdb-server significantly. -# OVSDB_SERVER_STRACE_LOG and OVSDB_SERVER_VALGRIND_LOG are mutually -# exclusive. -# OVSDB_SERVER_STRACE_LOG="" - -# OVSDB_SERVER_STRACE_OPT: Options to pass to strace. -# This option's value is honored only when OVSDB_SERVER_STRACE_LOG is -# set to a nonempty string. -# OVSDB_SERVER_STRACE_OPT="" - -# OVSDB_SERVER_VALGRIND_LOG: File for logging valgrind output. -# If this is set to a nonempty string, then ovsdb-server will run -# under valgrind, whose output will be logged to the specified file. -# Enabling this option will slow ovsdb-server by 100X or more. -# valgrind is not installed by default on XenServer systems; you must -# install it by hand to usefully enable this option. -# OVSDB_SERVER_STRACE_LOG and OVSDB_SERVER_VALGRIND_LOG are mutually -# exclusive. -# OVSDB_SERVER_VALGRIND_LOG="" - -# OVSDB_SERVER_VALGRIND_OPT: Options to pass to valgrind. -# This option's value is honored only when OVSDB_SERVER_VALGRIND_LOG is -# set to a nonempty string. -# OVSDB_SERVER_VALGRIND_OPT="" - -# VSWITCHD_OVSDB_SERVER: Method to have ovs-vswitchd initiate a JSON-RPC -# connection to an ovsdb-server instance. -# VSWITCHD_OVSDB_SERVER=unix:/var/run/ovsdb-server - -# VSWITCHD_OVSDB_SCHEMA: Schema file to use for generating a new OVSDB -# ovs-vswitchd database. -# VSWITCHD_OVSDB_SCHEMA=/usr/share/vswitch/vswitch.ovsschema - -# 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=-10 - -# VSWITCHD_MLOCKALL: Whether to pass ovs-vswitchd the --mlockall option. -# This option should be set to "yes" or "no". The default is "yes". -# Enabling this option can avoid networking interruptions due to -# system memory pressure in extraordinary situations, such as multiple -# concurrent VM import operations. -# VSWITCHD_MLOCKALL=yes - -# VSWITCHD_LOGFILE: File to send the FILE_LOGLEVEL log messages to. -# VSWITCHD_LOGFILE=/var/log/ovs-vswitchd.log - -# 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_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_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=-10 - -# 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/vswitch-xen.spec b/xenserver/vswitch-xen.spec deleted file mode 100644 index ad0fba41..00000000 --- a/xenserver/vswitch-xen.spec +++ /dev/null @@ -1,374 +0,0 @@ -# Spec file for vswitch and related programs. - -# Copyright (C) 2009, 2010 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. - -# When building, the rpmbuild command line should define -# vswitch_version, xen_version, and build_number using -D arguments. -# for example: -# -# rpmbuild -D "vswitch_version 0.8.9~1+build123" -D "xen_version 2.6.18-128.1.1.el5.xs5.1.0.483.1000xen" -D "build_number --with-build-number=123" -bb /usr/src/redhat/SPECS/vswitch-xen.spec -# -%define version %{vswitch_version}-%{xen_version} - -Name: vswitch -Summary: Virtual switch -Group: System Environment/Daemons -URL: http://www.openvswitch.org/ -Vendor: Nicira Networks, Inc. -Version: %{vswitch_version} - -# The entire source code is ASL 2.0 except datapath/ which is GPLv2 -License: ASL 2.0 and GPLv2 -Release: 1 -Source: openvswitch-%{vswitch_version}.tar.gz -Buildroot: /tmp/vswitch-xen-rpm -Requires: kernel-xen = %(echo '%{xen_version}' | sed 's/xen$//') -# The following Conflicts prevents the "vswitch" package generated by -# this spec file from installing at the same time as the "openvswitch" -# package shipped with XenServer 5.5.900. In fact, the packages -# contain some files with identical names anyhow, so they will not -# coexist, but adding an explicit Conflicts makes this conflict more -# obvious. -Conflicts: openvswitch - -%description -The vswitch provides standard network bridging functions augmented with -support for the OpenFlow protocol for remote per-flow control of -traffic. - -%prep -%setup -q -n openvswitch-%{vswitch_version} - -%build -./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-l26=/lib/modules/%{xen_version}/build --enable-ssl %{build_number} -make %{_smp_mflags} - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT -install -d -m 755 $RPM_BUILD_ROOT/etc -install -d -m 755 $RPM_BUILD_ROOT/etc/init.d -install -m 755 xenserver/etc_init.d_vswitch \ - $RPM_BUILD_ROOT/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 -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d -install -m 755 xenserver/etc_logrotate.d_vswitch \ - $RPM_BUILD_ROOT/etc/logrotate.d/vswitch -install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d -install -m 755 xenserver/etc_profile.d_vswitch.sh \ - $RPM_BUILD_ROOT/etc/profile.d/vswitch.sh -install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins -install -m 755 xenserver/etc_xapi.d_plugins_vswitch-cfg-update \ - $RPM_BUILD_ROOT/etc/xapi.d/plugins/vswitch-cfg-update -install -d -m 755 $RPM_BUILD_ROOT/usr/share/vswitch/scripts -install -m 644 vswitchd/vswitch.ovsschema \ - $RPM_BUILD_ROOT/usr/share/vswitch/vswitch.ovsschema -install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/interface-reconfigure -install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigure.py -install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureBridge.py -install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py -install -m 755 xenserver/etc_xensource_scripts_vif \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/vif -install -m 755 xenserver/usr_share_vswitch_scripts_refresh-network-uuids \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/refresh-network-uuids -install -m 755 xenserver/usr_sbin_xen-bugtool \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/xen-bugtool -install -m 755 xenserver/usr_sbin_brctl \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/brctl -install -m 755 xenserver/usr_share_vswitch_scripts_sysconfig.template \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/sysconfig.template -install -m 644 \ - xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \ - $RPM_BUILD_ROOT/usr/share/vswitch/scripts/XSFeatureVSwitch.py - -install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch -find datapath/linux-2.6 -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch \; - -# Get rid of stuff we don't want to make RPM happy. -rm \ - $RPM_BUILD_ROOT/usr/bin/ovs-controller \ - $RPM_BUILD_ROOT/usr/bin/ovs-discover \ - $RPM_BUILD_ROOT/usr/bin/ovs-kill \ - $RPM_BUILD_ROOT/usr/bin/ovs-openflowd \ - $RPM_BUILD_ROOT/usr/bin/ovs-pki \ - $RPM_BUILD_ROOT/usr/bin/ovs-wdt \ - $RPM_BUILD_ROOT/usr/sbin/ovs-monitor \ - $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \ - $RPM_BUILD_ROOT/usr/share/man/man8/ovs-discover.8 \ - $RPM_BUILD_ROOT/usr/share/man/man8/ovs-kill.8 \ - $RPM_BUILD_ROOT/usr/share/man/man8/ovs-openflowd.8 \ - $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8 -rm -f $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch/veth_mod.ko - -install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -if [ ! -f /etc/xensource-inventory ]; then - printf "XenSource inventory not present in /etc/xensource-inventory" - exit 1 -fi - -if [ "$1" = "1" ]; then - if md5sum -c --status </dev/null 2>&1; then :; else - cat >>/etc/sysctl.conf < /dev/null -fi - -# Create default or update existing /etc/sysconfig/vswitch. -SYSCONFIG=/etc/sysconfig/vswitch -TEMPLATE=/usr/share/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 /usr/lib/vswitch/xs-original \ - || printf "Could not create script backup directory.\n" -for f in \ - /opt/xensource/libexec/interface-reconfigure \ - /opt/xensource/libexec/InterfaceReconfigure.py \ - /opt/xensource/libexec/InterfaceReconfigureBridge.py \ - /opt/xensource/libexec/InterfaceReconfigureVswitch.py \ - /etc/xensource/scripts/vif \ - /usr/sbin/xen-bugtool \ - /usr/sbin/brctl -do - s=$(basename "$f") - t=$(readlink "$f") - if [ -f "$f" ] && [ "$t" != "/usr/share/vswitch/scripts/$s" ]; then - mv "$f" /usr/lib/vswitch/xs-original/ \ - || printf "Could not save original XenServer $s script\n" - ln -s "/usr/share/vswitch/scripts/$s" "$f" \ - || printf "Could not link to vSwitch $s script\n" - fi -done - -# Install xsconsole plugin -plugin=$(readlink /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py) -if [ "$plugin" != "/usr/share/vswitch/scripts/XSFeatureVSwitch.py" ]; then - rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py - ln -s /usr/share/vswitch/scripts/XSFeatureVSwitch.py /usr/lib/xsconsole/plugins-base/ || printf "Could not link to vSswitch xsconsole plugin.\n" -fi - -# Ensure all required services are set to run -for s in vswitch vswitch-xapi-update; do - if chkconfig --list $s >/dev/null 2>&1; then - chkconfig --del $s || printf "Could not remove $s init script." - fi - chkconfig --add $s || printf "Could not add $s init script." - chkconfig $s on || printf "Could not enable $s init script." -done - -# Configure system to use vswitch -echo vswitch > /etc/xensource/network.conf - -if [ "$1" = "1" ]; then # $1 = 2 for upgrade - printf "\nYou MUST reboot the server NOW to complete the change to the\n" - printf "the vSwitch. Attempts to modify networking on the server\n" - printf "or any hosted VM will fail until after the reboot and could\n" - printf "leave the server in an state requiring manual recovery.\n\n" -else - printf "\nTo use the new vSwitch, you should reboot the server\n" - printf "now. Failure to do so may result in incorrect operation.\n\n" -fi - -%preun -if [ "$1" = "0" ]; then # $1 = 1 for upgrade - for s in vswitch vswitch-xapi-update; do - chkconfig --del $s || printf "Could not remove $s init script." - done -fi - - -%postun -if [ "$1" = "0" ]; then # $1 = 1 for upgrade - - rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py \ - /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \ - /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo \ - || printf "Could not remove vSwitch xsconsole plugin.\n" - - # Restore original XenServer scripts - for f in \ - /opt/xensource/libexec/interface-reconfigure \ - /etc/xensource/scripts/vif \ - /usr/sbin/xen-bugtool \ - /usr/sbin/brctl - do - s=$(basename "$f") - if [ ! -f "/usr/lib/vswitch/xs-original/$s" ]; then - printf "Original XenServer $s script not present in /usr/lib/vswitch/xs-original\n" - printf "Could not restore original XenServer script.\n" - else - (rm -f "$f" \ - && mv "/usr/lib/vswitch/xs-original/$s" "$f") \ - || printf "Could not restore original XenServer $s script.\n" - fi - done - - # Remove all configuration files - rm -f /etc/ovs-vswitchd.conf.db - rm -f /etc/sysconfig/vswitch - rm -f /etc/ovs-vswitchd.cacert - rm -f /var/xapi/network.dbcache - - # Configure system to use bridge - echo bridge > /etc/xensource/network.conf - - printf "\nYou MUST reboot the server now to complete the change to\n" - printf "standard Xen networking. Attempts to modify networking on the\n" - printf "server or any hosted VM will fail until after the reboot and\n" - printf "could leave the server in a state requiring manual recovery.\n\n" -fi - - -%files -%defattr(-,root,root) -/etc/init.d/vswitch -/etc/init.d/vswitch-xapi-update -/etc/xapi.d/plugins/vswitch-cfg-update -/etc/logrotate.d/vswitch -/etc/profile.d/vswitch.sh -/lib/modules/%{xen_version}/kernel/net/vswitch/openvswitch_mod.ko -/lib/modules/%{xen_version}/kernel/net/vswitch/brcompat_mod.ko -%if %(echo '%{xen_version}'|awk -F"." '{if ($3>=18) print 1; else print 0;}') -/lib/modules/%{xen_version}/kernel/net/vswitch/ip_gre_mod.ko -%endif -/usr/share/vswitch/scripts/refresh-network-uuids -/usr/share/vswitch/scripts/interface-reconfigure -/usr/share/vswitch/scripts/InterfaceReconfigure.py -/usr/share/vswitch/scripts/InterfaceReconfigureBridge.py -/usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py -/usr/share/vswitch/scripts/vif -/usr/share/vswitch/scripts/xen-bugtool -/usr/share/vswitch/scripts/XSFeatureVSwitch.py -/usr/share/vswitch/scripts/brctl -/usr/share/vswitch/scripts/sysconfig.template -/usr/share/vswitch/vswitch.ovsschema -/usr/sbin/ovs-brcompatd -/usr/sbin/ovs-vswitchd -/usr/sbin/ovsdb-server -/usr/bin/ovs-appctl -/usr/bin/ovs-dpctl -/usr/bin/ovs-ofctl -/usr/bin/ovs-vsctl -/usr/bin/ovsdb-client -/usr/bin/ovsdb-tool -/usr/share/man/man1/ovsdb-client.1.gz -/usr/share/man/man1/ovsdb-server.1.gz -/usr/share/man/man1/ovsdb-tool.1.gz -/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz -/usr/share/man/man8/ovs-appctl.8.gz -/usr/share/man/man8/ovs-brcompatd.8.gz -/usr/share/man/man8/ovs-dpctl.8.gz -/usr/share/man/man8/ovs-ofctl.8.gz -/usr/share/man/man8/ovs-vsctl.8.gz -/usr/share/man/man8/ovs-vswitchd.8.gz -/var/lib/openvswitch -%exclude /usr/share/vswitch/scripts/*.pyc -%exclude /usr/share/vswitch/scripts/*.pyo