blob: e4dbdf4afcbcdad4362a19e04ac676d1cbe13a26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/bin/bash
#
# openvswitch-nova
#
# chkconfig: 2345 10 89
# description: Apply initial OVS flows for Nova
# Copyright 2011 OpenStack LLC.
# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
# All Rights Reserved.
#
# 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.
# source function library
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
else
echo "$0: missing LSB shell function library" >&2
exit 1
fi
OVS_CONFIGURE_BASE_FLOWS=/etc/xensource/scripts/ovs_configure_base_flows.py
if test -e /etc/sysconfig/openvswitch-nova; then
. /etc/sysconfig/openvswitch-nova
else
echo "$0: missing configuration file: /etc/sysconfig/openvswitch-nova"
exit 1
fi
if test -e /etc/xensource/network.conf; then
NETWORK_MODE=$(cat /etc/xensource/network.conf)
fi
case ${NETWORK_MODE:=openvswitch} in
vswitch|openvswitch)
;;
bridge)
exit 0
;;
*)
echo "Open vSwitch disabled (/etc/xensource/network.conf is invalid)" >&2
exit 0
;;
esac
function run_ovs_conf_base_flows {
# expected format: DEVICE_BRIDGES="eth0:xenbr0 eth1:xenbr1"
for pair in $DEVICE_BRIDGES; do
# below in $info, physical device is [0], bridge name is [1]
info=${pair//:/ }
/usr/bin/python $OVS_CONFIGURE_BASE_FLOWS $1 ${info[0]} ${info[1]}
done
}
function start {
run_ovs_conf_base_flows online
}
function stop {
run_ovs_conf_base_flows offline
}
function restart {
run_ovs_conf_base_flows reset
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "usage: openvswitch-nova [start|stop|restart]"
exit 1
;;
esac
|