5 # chkconfig: 2345 09 91
6 # description: Manage Open vSwitch kernel modules and user-space daemons
8 # Copyright (C) 2009, 2010, 2011 Nicira, Inc.
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at:
14 # http://www.apache.org/licenses/LICENSE-2.0
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
22 # Provides: openvswitch-switch
25 # Default-Start: 2 3 4 5
27 # Short-Description: Open vSwitch switch
30 .
/usr
/share
/openvswitch
/scripts
/ovs-lib ||
exit 1
31 .
/etc
/xensource-inventory
32 test -e /etc
/sysconfig
/openvswitch
&& .
/etc
/sysconfig
/openvswitch
34 case `cat /etc/xensource/network.conf` in
41 echo "Open vSwitch disabled (/etc/xensource/network.conf is invalid)" >&2
46 start_ovs_xapi_sync
() {
47 if daemon_is_running ovs-xapi-sync
; then
48 log_success_msg
"ovs-xapi-sync is already running"
50 PYTHONPATH
=/usr
/share
/openvswitch
/python \
51 /usr
/share
/openvswitch
/scripts
/ovs-xapi-sync \
52 --log-file --pidfile --detach --monitor unix
:/var
/run
/openvswitch
/db.sock
57 set ovs_ctl
${1-start}
58 set "$@" --system-id="$INSTALLATION_UUID"
59 set "$@" --system-type="$PRODUCT_BRAND"
60 set "$@" --system-version="$PRODUCT_VERSION-$BUILD_NUMBER"
61 set "$@" --external-id=xs-system-uuid
="$INSTALLATION_UUID"
62 set "$@" --daemon-cwd=/var
/xen
/openvswitch
63 if test X
"$FORCE_COREFILES" != X
; then
64 set "$@" --force-corefiles="$FORCE_COREFILES"
66 if test X
"$OVSDB_SERVER_PRIORITY" != X
; then
67 set "$@" --ovsdb-server-priority="$OVSDB_SERVER_PRIORITY"
69 if test X
"$VSWITCHD_PRIORITY" != X
; then
70 set "$@" --ovs-vswitchd-priority="$VSWITCHD_PRIORITY"
72 if test X
"$VSWITCHD_MLOCKALL" != X
; then
73 set "$@" --mlockall="$VSWITCHD_MLOCKALL"
75 if test ! -e /var
/run
/openvswitch.booted
; then
76 touch /var
/run
/openvswitch.booted
77 set "$@" --delete-bridges
79 set "$@" $OVS_CTL_OPTS
84 ovs_ctl
--protocol=gre enable-protocol
86 touch /var
/lock
/subsys
/openvswitch
89 force_reload_kmod
() {
90 start force-reload-kmod
92 # Restart the high-availability daemon if it is running. Otherwise
93 # it loses its heartbeat and reboots the system after a few minutes.
94 if pidof xhad
>/dev
/null
&& test -e /etc
/xensource
/xhad.conf
; then
95 PATH
=$PATH:/opt
/xensource
/xha
96 action
"Stopping HA daemon" ha_stop_daemon
97 action
"Starting HA daemon" ha_start_daemon
100 action
"Stopping ovs-xapi-sync" stop_daemon ovs-xapi-sync
101 action
"Starting ovs-xapi-sync" start_ovs_xapi_sync
106 stop_daemon ovs-xapi-sync
107 rm -f /var
/lock
/subsys
/openvswitch
111 if [ "$1" = "--save-flows=yes" ]; then
112 stop_daemon ovs-xapi-sync
132 # The main OVS daemons keep up-to-date, but ovs-xapi-sync needs help.
133 if daemon_is_running ovs-xapi-sync
; then
134 action
"Configuring Open vSwitch external IDs" \
135 ovs-appctl
-t ovs-xapi-sync flush-cache
139 ovs_ctl status
&& daemon_status ovs-xapi-sync
148 printf "openvswitch [start|stop|restart|reload|force-reload|status|version]\n"
151 printf "Unknown command: $1\n"