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
83 $ovs_ctl --protocol=gre enable-protocol
85 touch /var/lock/subsys/openvswitch
88 force_reload_kmod () {
89 start force-reload-kmod
91 # Restart the high-availability daemon if it is running. Otherwise
92 # it loses its heartbeat and reboots the system after a few minutes.
93 if pidof xhad >/dev/null && test -e /etc/xensource/xhad.conf; then
94 PATH=$PATH:/opt/xensource/xha
95 action "Stopping HA daemon" ha_stop_daemon
96 action "Starting HA daemon" ha_start_daemon
99 action "Stopping ovs-xapi-sync" stop_daemon ovs-xapi-sync
100 action "Starting ovs-xapi-sync" start_ovs_xapi_sync
105 stop_daemon ovs-xapi-sync
106 rm -f /var/lock/subsys/openvswitch
109 ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl
122 # The main OVS daemons keep up-to-date, but ovs-xapi-sync needs help.
123 if daemon_is_running ovs-xapi-sync; then
124 action "Configuring Open vSwitch external IDs" \
125 ovs-appctl -t ovs-xapi-sync flush-cache
129 $ovs_ctl status && daemon_status ovs-xapi-sync
138 printf "openvswitch [start|stop|restart|reload|force-reload|status|version]\n"
141 printf "Unknown command: $1\n"