~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/nova-xcp-network.init

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandleman, Chuck Short
  • Date: 2012-03-02 11:04:04 UTC
  • mfrom: (1.1.47)
  • Revision ID: package-import@ubuntu.com-20120302110404-fr230yakr8hov3dj
Tags: 2012.1~e4-0ubuntu1
[ Adam Gandleman ]
* debian/patches/libvirt-use-console-pipe.patch: Refreshed. 
* debain/nova-volume.upstart.in: Ensure lock directory is created
  (LP: #940780)
* debain/control: Fix nova-compute-$flavor Depends
* debian/control: Add python-iso8601 to python-nova Depends

[ Chuck Short ]
* debian/rules: Fix FTBFS.
* Merge Ubuntu/Debian packaging:
  - Thanks to Julien Danjou, Ghe Rivero, and Thomas Goirand
  - debian/copyright: Update copyright file.
  - debian/nova-api.init, debian/nova-compute.init,
    debian/nova-network.init, debian/nova-objectstore,
    debian/nova-scheduler, debian/nova-volume.init:
    Synchronize init scripts.
  - nova-common.install, debian/rules: Install policy.json
  - debian/rules, debian/nova-xcp-network.install,
    debian/nova-xcp-plugins.install, nova-xcp-plugins.postrm,
    debian/nova-xcp-plugins.doc, debian/nova-xcp-plugins.postinst,
    debian/README.xcp_and_openstack, debian/control,
    debian/ubuntu_xen-openvswitch-nova.rules,
    debian/patches/path-to-the-xenhost.conf-fixup.patch:
    Add Xen XCP support.
  - debian/control,
    debian/nova-compute-{kvm,lxc,qemu,xen,uml}.postinst: Make
    nova-compute a virtual package.
  - Dropped ubuntu_ubuntu_control_vars: We dont use it
* New upstream release.
* Dropped python-babel, it will be handled by langpacks.
* debian/patches/ec2-fixes.patch: Backport turnk fix for ec2
  permissions.
* debian/patches/path-to-the-xenhost.conf-fixup.patch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
### BEGIN INIT INFO
 
4
# Provides:          nova-xcp-network
 
5
# Required-Start:    $remote_fs $syslog
 
6
# Required-Stop:     $remote_fs $syslog
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      0 1 6
 
9
# Short-Description: Apply initial OVS flows for Nova and network rules.
 
10
# Description:       Apply initial OVS flows for Nova, and setup networking
 
11
#                    host rules for multi tenancy protections.
 
12
### END INIT INFO
 
13
 
 
14
# Written by Thomas Goirand <zigo@debian.org> using
 
15
# plugins/xenserver/networking/etc/init.d/{openvswitch-nova,host-up}
 
16
# as examples.
 
17
#
 
18
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
19
#    not use this file except in compliance with the License. You may obtain
 
20
#    a copy of the License at
 
21
#
 
22
#         http://www.apache.org/licenses/LICENSE-2.0
 
23
#
 
24
#    Unless required by applicable law or agreed to in writing, software
 
25
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
26
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
27
#    License for the specific language governing permissions and limitations
 
28
#    under the License.
 
29
 
 
30
. /lib/init/vars.sh
 
31
. /lib/lsb/init-functions
 
32
 
 
33
DESC="XCP openvswitch networking rules"
 
34
NAME="xcp-network"
 
35
 
 
36
OVS_CONFIGURE_BASE_FLOWS=/usr/lib/xcp/plugins/ovs_configure_base_flows.py
 
37
IPTABLES=/sbin/iptables
 
38
EBTABLES=/sbin/ebtables
 
39
ARPTABLES=/sbin/arptables
 
40
 
 
41
# Quick check if everything is there...
 
42
if ! [ -x ${OVS_CONFIGURE_BASE_FLOWS} ] ; then
 
43
        exit 0
 
44
fi
 
45
if ! [ -x ${IPTABLES} -a -x ${EBTABLES} -a -x ${ARPTABLES} ] ; then
 
46
        exit 0
 
47
fi
 
48
if ! [ -x /usr/bin/ovs-ofctl -a -x /usr/bin/ovs-vsctl -a -x /sbin/ip ] ; then
 
49
        exit 0
 
50
fi
 
51
 
 
52
# Load the VERBOSE setting and other rcS variables
 
53
[ -r /lib/init/vars.sh ] && . /lib/init/vars.sh
 
54
 
 
55
# Get $INTERFACES from /etc/default/openvswitch-nova,
 
56
# default to all what is available.
 
57
if [ -r /etc/default/openvswitch-nova ] ; then
 
58
        . /etc/default/openvswitch-nova
 
59
fi
 
60
if [ -z "${INTERFACES}" ] ; then
 
61
        INTERFACES=$(cd /sys/class/net/; /bin/ls -d eth*)
 
62
fi
 
63
 
 
64
# Get $NETWORK_MODE from /etc/xcp/network.conf,
 
65
# default to openvswitch
 
66
if [ -e /etc/xcp/network.conf ] ; then
 
67
        NETWORK_MODE=`cat /etc/xcp/network.conf`
 
68
fi
 
69
 
 
70
if [ -z "${NETWORK_MODE}" ] ; then
 
71
        NETWORK_MODE=openvswitch
 
72
fi
 
73
 
 
74
# Check validity of $NETWORK_MODE
 
75
case "${NETWORK_MODE}" in
 
76
vswitch|openvswitch)
 
77
        ;;
 
78
bridge)
 
79
        exit 0
 
80
        ;;
 
81
*)
 
82
        echo "Open vSwitch disabled (/etc/xcp/network.conf is invalid)" >&2
 
83
        exit 0
 
84
        ;;
 
85
esac
 
86
 
 
87
run_ovs_conf_base_flows () {
 
88
        my_action="${1}"
 
89
        my_all_interfaces=$(cd /sys/class/net/; /bin/ls -d eth*)
 
90
        for i in ${INTERFACES} ; do
 
91
                /usr/bin/python $OVS_CONFIGURE_BASE_FLOWS $my_action $i
 
92
        done
 
93
}
 
94
 
 
95
# Functions to configure the firewall to work with openvswitch, XCP and nova
 
96
iptables_up () {
 
97
        ${IPTABLES} -P FORWARD DROP
 
98
        for i in ${INTERFACES} ; do
 
99
                ${IPTABLES} -A FORWARD -m physdev --physdev-in ${i} -j ACCEPT
 
100
        done
 
101
}
 
102
ebtables_up () {
 
103
        ${EBTABLES} -P FORWARD DROP
 
104
        for i in ${INTERFACES} ; do
 
105
                ${EBTABLES} -A FORWARD -o ${i} -j ACCEPT
 
106
        done
 
107
}
 
108
arptables_up () {
 
109
        ${ARPTABLES} -P FORWARD DROP
 
110
        for i in ${INTERFACES} ; do
 
111
                ${ARPTABLES} -A FORWARD --opcode Request --in-interface ${i} -j ACCEPT
 
112
                ${ARPTABLES} -A FORWARD --opcode Reply --in-interface ${i} -j ACCEPT
 
113
        done
 
114
}
 
115
iptables_down () {
 
116
        ${IPTABLES} -P FORWARD ACCEPT
 
117
        for i in ${INTERFACES} ; do
 
118
                ${IPTABLES} -D FORWARD -m physdev --physdev-in ${i} -j ACCEPT
 
119
        done
 
120
}
 
121
ebtables_down () {
 
122
        ${EBTABLES} -P FORWARD ACCEPT
 
123
        for i in ${INTERFACES} ; do
 
124
                ${EBTABLES} -D FORWARD -o ${i} -j ACCEPT
 
125
        done
 
126
}
 
127
arptables_down () {
 
128
        ${ARPTABLES} -P FORWARD ACCEPT
 
129
        for i in ${INTERFACES} ; do
 
130
                ${ARPTABLES} -D FORWARD --opcode Request --in-interface ${i} -j ACCEPT
 
131
                ${ARPTABLES} -D FORWARD --opcode Reply --in-interface ${i} -j ACCEPT
 
132
        done
 
133
}
 
134
 
 
135
case "${1}" in
 
136
start)
 
137
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
 
138
        iptables_up
 
139
        ebtables_up
 
140
        arptables_up
 
141
        run_ovs_conf_base_flows online
 
142
        [ "$VERBOSE" != no ] && log_end_msg 0
 
143
        ;;
 
144
stop)
 
145
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 
146
        run_ovs_conf_base_flows offline
 
147
        iptables_down
 
148
        ebtables_down
 
149
        arptables_down
 
150
        [ "$VERBOSE" != no ] && log_end_msg 0
 
151
        ;;
 
152
reload|force-reload)
 
153
        [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
 
154
        run_ovs_conf_base_flows reset
 
155
        [ "$VERBOSE" != no ] && log_end_msg 0
 
156
        ;;
 
157
restart)
 
158
        $0 start
 
159
        sleep 1
 
160
        $0 stop
 
161
        ;;
 
162
*)
 
163
        echo "Usage: $0 {start|stop|status|restart|reload|force-reload}" >&2
 
164
        ;;
 
165
esac
 
166
 
 
167
exit 0