]> git.proxmox.com Git - ovs.git/blame - xenserver/vswitch-xen.spec
xenserver: Ensure that Bridge.other-config:hwaddr and Interface.MAC are set as approp...
[ovs.git] / xenserver / vswitch-xen.spec
CommitLineData
064af421
BP
1# Spec file for vswitch and related programs.
2
fc7ecc66 3# Copyright (C) 2009, 2010 Nicira Networks, Inc.
064af421
BP
4#
5# Copying and distribution of this file, with or without modification,
6# are permitted in any medium without royalty provided the copyright
7# notice and this notice are preserved. This file is offered as-is,
8# without warranty of any kind.
9
10# When building, the rpmbuild command line should define
11# vswitch_version, xen_version, and build_number using -D arguments.
12# for example:
13#
14# 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
15#
16%define version %{vswitch_version}-%{xen_version}
064af421
BP
17
18Name: vswitch
19Summary: Virtual switch
20Group: System Environment/Daemons
b4450809 21URL: http://www.openvswitch.org/
58bd8cce 22Vendor: Nicira Networks, Inc.
064af421 23Version: %{vswitch_version}
acf827ca
JP
24
25# The entire source code is ASL 2.0 except datapath/ which is GPLv2
26License: ASL 2.0 and GPLv2
064af421
BP
27Release: 1
28Source: openvswitch-%{vswitch_version}.tar.gz
29Buildroot: /tmp/vswitch-xen-rpm
d8319dd4 30Requires: kernel-xen = %(echo '%{xen_version}' | sed 's/xen$//')
3cbe3ea5
BP
31# The following Conflicts prevents the "vswitch" package generated by
32# this spec file from installing at the same time as the "openvswitch"
33# package shipped with XenServer 5.5.900. In fact, the packages
34# contain some files with identical names anyhow, so they will not
35# coexist, but adding an explicit Conflicts makes this conflict more
36# obvious.
37Conflicts: openvswitch
064af421
BP
38
39%description
40The vswitch provides standard network bridging functions augmented with
41support for the OpenFlow protocol for remote per-flow control of
42traffic.
43
44%prep
45%setup -q -n openvswitch-%{vswitch_version}
46
47%build
417a8cb6 48./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-l26=/lib/modules/%{xen_version}/build --enable-ssl %{build_number}
fcfb9b2c 49make %{_smp_mflags}
064af421
BP
50
51%install
52rm -rf $RPM_BUILD_ROOT
eaa3c7e8 53make install DESTDIR=$RPM_BUILD_ROOT
064af421
BP
54install -d -m 755 $RPM_BUILD_ROOT/etc
55install -d -m 755 $RPM_BUILD_ROOT/etc/init.d
56install -m 755 xenserver/etc_init.d_vswitch \
57 $RPM_BUILD_ROOT/etc/init.d/vswitch
58install -m 755 xenserver/etc_init.d_vswitch-xapi-update \
59 $RPM_BUILD_ROOT/etc/init.d/vswitch-xapi-update
60install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
064af421
BP
61install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
62install -m 755 xenserver/etc_logrotate.d_vswitch \
63 $RPM_BUILD_ROOT/etc/logrotate.d/vswitch
64install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d
65install -m 755 xenserver/etc_profile.d_vswitch.sh \
66 $RPM_BUILD_ROOT/etc/profile.d/vswitch.sh
67install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins
68install -m 755 xenserver/etc_xapi.d_plugins_vswitch-cfg-update \
69 $RPM_BUILD_ROOT/etc/xapi.d/plugins/vswitch-cfg-update
eaa3c7e8 70install -d -m 755 $RPM_BUILD_ROOT/usr/share/vswitch/scripts
f78b38e9
BP
71install -m 644 vswitchd/vswitch.ovsschema \
72 $RPM_BUILD_ROOT/usr/share/vswitch/vswitch.ovsschema
064af421 73install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \
eaa3c7e8 74 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/interface-reconfigure
680b8c67 75install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \
b3080599 76 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigure.py
680b8c67 77install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \
b3080599 78 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureBridge.py
680b8c67 79install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
b3080599 80 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py
064af421 81install -m 755 xenserver/etc_xensource_scripts_vif \
eaa3c7e8 82 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/vif
5c43922c
BP
83install -m 755 xenserver/usr_share_vswitch_scripts_refresh-network-uuids \
84 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/refresh-network-uuids
16cd277e 85install -m 755 xenserver/usr_sbin_xen-bugtool \
eaa3c7e8 86 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/xen-bugtool
8521345b 87install -m 755 xenserver/usr_sbin_brctl \
eaa3c7e8
BP
88 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/brctl
89install -m 755 xenserver/usr_share_vswitch_scripts_sysconfig.template \
90 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/sysconfig.template
6eab8112 91install -m 644 \
064af421 92 xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
eaa3c7e8 93 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/XSFeatureVSwitch.py
064af421 94
6867bc36
BP
95install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch
96find datapath/linux-2.6 -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch \;
064af421
BP
97
98# Get rid of stuff we don't want to make RPM happy.
eaa3c7e8
BP
99rm \
100 $RPM_BUILD_ROOT/usr/bin/ovs-controller \
101 $RPM_BUILD_ROOT/usr/bin/ovs-discover \
102 $RPM_BUILD_ROOT/usr/bin/ovs-kill \
103 $RPM_BUILD_ROOT/usr/bin/ovs-openflowd \
104 $RPM_BUILD_ROOT/usr/bin/ovs-pki \
105 $RPM_BUILD_ROOT/usr/bin/ovs-wdt \
106 $RPM_BUILD_ROOT/usr/sbin/ovs-monitor \
107 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \
108 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-discover.8 \
109 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-kill.8 \
110 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-openflowd.8 \
111 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8
6867bc36 112rm -f $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch/veth_mod.ko
064af421 113
ac9634f0
BP
114install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
115
064af421
BP
116%clean
117rm -rf $RPM_BUILD_ROOT
118
ac9634f0 119%post
064af421
BP
120if [ ! -f /etc/xensource-inventory ]; then
121 printf "XenSource inventory not present in /etc/xensource-inventory"
122 exit 1
123fi
124
125if [ "$1" = "1" ]; then
a320b341
BP
126 if md5sum -c --status <<EOF
127ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
064af421
BP
128b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
12951970ad613a3996d5997e18e44db47da /opt/xensource/libexec/interface-reconfigure
16cd277e 1305654c8c36699fcc8744ca9cd5b855414 /usr/sbin/xen-bugtool
064af421
BP
131EOF
132 then
a320b341
BP
133 printf "\nVerified host scripts from XenServer 5.5.0.\n\n"
134 elif md5sum -c --status <<EOF
135ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
136b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
65272b91
JG
13751970ad613a3996d5997e18e44db47da /opt/xensource/libexec/interface-reconfigure
138f6519085c2fc5f7bc4eccc294ed62000 /usr/sbin/xen-bugtool
139EOF
140 then
141 printf "\nVerified host scripts from XenServer 5.5.0-24648p (Update 1)\n"
142 printf "or 5.5.0-25727p (Update 2).\n\n"
143 elif md5sum -c --status <<EOF
144ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
145b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
a320b341
BP
146ce451d3c985fd1db6497a363f0d9dedb /opt/xensource/libexec/interface-reconfigure
1472b53f500431fcba5276c896e9e4281b9 /usr/sbin/xen-bugtool
148EOF
fe8b662b 149 then
a320b341
BP
150 printf "\nVerified host scripts from XenServer 5.5.900.\n\n"
151 else
8521345b
BP
152cat <<EOF
153
a320b341
BP
154The original XenServer scripts replaced by this package are not those
155of any supported version of XenServer. This could lead to unexpected
156behavior of your server. Unless you are sure you know what you are
157doing, it is highly recommended that you remove this package
158immediately after the install completes, which will restore the
159XenServer scripts that you were previously using.
8521345b
BP
160
161EOF
162 fi
064af421
BP
163fi
164
1fa5a105 165if test ! -e /var/xapi/network.dbcache; then
064af421
BP
166 if test "$1" = 1; then
167 printf "Creating xapi database cache... "
168 else
169 printf "warning: Open vSwitch is being re-installed or upgraded,\n"
170 printf " but the xapi database cache is missing.\n"
171 printf "Re-creating xapi database cache... "
172 fi
173
057fed2b 174 if /usr/share/vswitch/scripts/interface-reconfigure rewrite; then
064af421
BP
175 printf "done.\n"
176 else
177 printf "FAILED\n"
178 printf "Open vSwitch can only be installed on a XenServer that\n"
179 printf "has connectivity to xapi on the pool master. Please\n"
180 printf "fix connectivity to the pool master, then try again.\n"
181 exit 1
182 fi
183fi
184
6867bc36
BP
185# Ensure that modprobe will find our modules.
186depmod %{xen_version}
187
aa80fd55
BP
188if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
189 cat >>/etc/sysctl.conf <<EOF
190# This works around an issue in xhad, which binds to a particular
191# Ethernet device, which in turn causes ICMP port unreachable messages
192# if packets are received are on the wrong interface, which in turn
193# can happen if we send out ARP replies on every interface (as Linux
194# does by default) instead of just on the interface that has the IP
195# address being ARPed for, which this sysctl setting in turn works
196# around.
197#
198# Bug #1378.
199net.ipv4.conf.all.arp_filter = 1
200EOF
201fi
202
91d38a2e
JP
203if test ! -e /etc/ovs-vswitchd.conf.db; then
204 # Create ovs-vswitchd config database
ef5e2fe5 205 ovsdb-tool -vANY:console:emer create /etc/ovs-vswitchd.conf.db \
f78b38e9 206 /usr/share/vswitch/vswitch.ovsschema \
91d38a2e
JP
207
208 # Create initial table in config database
ef5e2fe5 209 ovsdb-tool -vANY:console:emer transact /etc/ovs-vswitchd.conf.db \
91d38a2e
JP
210 '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
211 > /dev/null
212fi
064af421 213
692c92e0
BP
214# Create default or update existing /etc/sysconfig/vswitch.
215SYSCONFIG=/etc/sysconfig/vswitch
eaa3c7e8 216TEMPLATE=/usr/share/vswitch/scripts/sysconfig.template
692c92e0
BP
217if [ ! -e $SYSCONFIG ]; then
218 cp $TEMPLATE $SYSCONFIG
219else
220 for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
221 do
222 if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
223 echo >> $SYSCONFIG
224 sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
225 fi
226 done
227fi
228
8521345b 229# Replace XenServer files by our versions.
eaa3c7e8 230mkdir -p /usr/lib/vswitch/xs-original \
064af421
BP
231 || printf "Could not create script backup directory.\n"
232for f in \
233 /opt/xensource/libexec/interface-reconfigure \
b3080599
IC
234 /opt/xensource/libexec/InterfaceReconfigure.py \
235 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
236 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
16cd277e 237 /etc/xensource/scripts/vif \
8521345b
BP
238 /usr/sbin/xen-bugtool \
239 /usr/sbin/brctl
064af421
BP
240do
241 s=$(basename "$f")
242 t=$(readlink "$f")
b3080599 243 if [ -f "$f" ] && [ "$t" != "/usr/share/vswitch/scripts/$s" ]; then
eaa3c7e8 244 mv "$f" /usr/lib/vswitch/xs-original/ \
064af421 245 || printf "Could not save original XenServer $s script\n"
eaa3c7e8 246 ln -s "/usr/share/vswitch/scripts/$s" "$f" \
064af421
BP
247 || printf "Could not link to vSwitch $s script\n"
248 fi
249done
250
251# Install xsconsole plugin
252plugin=$(readlink /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py)
eaa3c7e8 253if [ "$plugin" != "/usr/share/vswitch/scripts/XSFeatureVSwitch.py" ]; then
064af421 254 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
eaa3c7e8 255 ln -s /usr/share/vswitch/scripts/XSFeatureVSwitch.py /usr/lib/xsconsole/plugins-base/ || printf "Could not link to vSswitch xsconsole plugin.\n"
064af421
BP
256fi
257
258# Ensure all required services are set to run
259for s in vswitch vswitch-xapi-update; do
260 if chkconfig --list $s >/dev/null 2>&1; then
261 chkconfig --del $s || printf "Could not remove $s init script."
262 fi
263 chkconfig --add $s || printf "Could not add $s init script."
264 chkconfig $s on || printf "Could not enable $s init script."
265done
266
b3080599
IC
267# Configure system to use vswitch
268echo vswitch > /etc/xensource/network.conf
269
064af421
BP
270if [ "$1" = "1" ]; then # $1 = 2 for upgrade
271 printf "\nYou MUST reboot the server NOW to complete the change to the\n"
272 printf "the vSwitch. Attempts to modify networking on the server\n"
273 printf "or any hosted VM will fail until after the reboot and could\n"
274 printf "leave the server in an state requiring manual recovery.\n\n"
275else
276 printf "\nTo use the new vSwitch, you should reboot the server\n"
277 printf "now. Failure to do so may result in incorrect operation.\n\n"
278fi
279
280%preun
281if [ "$1" = "0" ]; then # $1 = 1 for upgrade
282 for s in vswitch vswitch-xapi-update; do
283 chkconfig --del $s || printf "Could not remove $s init script."
284 done
285fi
286
287
288%postun
289if [ "$1" = "0" ]; then # $1 = 1 for upgrade
290
291 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py \
292 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
293 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo \
294 || printf "Could not remove vSwitch xsconsole plugin.\n"
295
296 # Restore original XenServer scripts
297 for f in \
298 /opt/xensource/libexec/interface-reconfigure \
16cd277e 299 /etc/xensource/scripts/vif \
8521345b
BP
300 /usr/sbin/xen-bugtool \
301 /usr/sbin/brctl
064af421
BP
302 do
303 s=$(basename "$f")
eaa3c7e8
BP
304 if [ ! -f "/usr/lib/vswitch/xs-original/$s" ]; then
305 printf "Original XenServer $s script not present in /usr/lib/vswitch/xs-original\n"
064af421
BP
306 printf "Could not restore original XenServer script.\n"
307 else
308 (rm -f "$f" \
eaa3c7e8 309 && mv "/usr/lib/vswitch/xs-original/$s" "$f") \
064af421
BP
310 || printf "Could not restore original XenServer $s script.\n"
311 fi
312 done
313
1cee7f28 314 # Remove all configuration files
fea28b07 315 rm -f /etc/ovs-vswitchd.conf.db
064af421 316 rm -f /etc/sysconfig/vswitch
064af421 317 rm -f /etc/ovs-vswitchd.cacert
1fa5a105 318 rm -f /var/xapi/network.dbcache
064af421 319
b3080599
IC
320 # Configure system to use bridge
321 echo bridge > /etc/xensource/network.conf
064af421 322
064af421
BP
323 printf "\nYou MUST reboot the server now to complete the change to\n"
324 printf "standard Xen networking. Attempts to modify networking on the\n"
325 printf "server or any hosted VM will fail until after the reboot and\n"
326 printf "could leave the server in a state requiring manual recovery.\n\n"
327fi
328
329
330%files
331%defattr(-,root,root)
332/etc/init.d/vswitch
333/etc/init.d/vswitch-xapi-update
334/etc/xapi.d/plugins/vswitch-cfg-update
064af421
BP
335/etc/logrotate.d/vswitch
336/etc/profile.d/vswitch.sh
6867bc36
BP
337/lib/modules/%{xen_version}/kernel/net/vswitch/openvswitch_mod.ko
338/lib/modules/%{xen_version}/kernel/net/vswitch/brcompat_mod.ko
c3e3d2a1
JG
339%if %(echo '%{xen_version}'|awk -F"." '{if ($3>=18) print 1; else print 0;}')
340/lib/modules/%{xen_version}/kernel/net/vswitch/ip_gre_mod.ko
341%endif
5c43922c 342/usr/share/vswitch/scripts/refresh-network-uuids
eaa3c7e8 343/usr/share/vswitch/scripts/interface-reconfigure
b3080599 344/usr/share/vswitch/scripts/InterfaceReconfigure.py
b3080599 345/usr/share/vswitch/scripts/InterfaceReconfigureBridge.py
b3080599 346/usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py
eaa3c7e8
BP
347/usr/share/vswitch/scripts/vif
348/usr/share/vswitch/scripts/xen-bugtool
349/usr/share/vswitch/scripts/XSFeatureVSwitch.py
350/usr/share/vswitch/scripts/brctl
351/usr/share/vswitch/scripts/sysconfig.template
f78b38e9 352/usr/share/vswitch/vswitch.ovsschema
eaa3c7e8
BP
353/usr/sbin/ovs-brcompatd
354/usr/sbin/ovs-vswitchd
f016b27e 355/usr/sbin/ovsdb-server
eaa3c7e8 356/usr/bin/ovs-appctl
eaa3c7e8
BP
357/usr/bin/ovs-dpctl
358/usr/bin/ovs-ofctl
3b135da3 359/usr/bin/ovs-vsctl
f016b27e
BP
360/usr/bin/ovsdb-client
361/usr/bin/ovsdb-tool
362/usr/share/man/man1/ovsdb-client.1.gz
363/usr/share/man/man1/ovsdb-server.1.gz
364/usr/share/man/man1/ovsdb-tool.1.gz
ee402cae 365/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
eaa3c7e8
BP
366/usr/share/man/man8/ovs-appctl.8.gz
367/usr/share/man/man8/ovs-brcompatd.8.gz
eaa3c7e8
BP
368/usr/share/man/man8/ovs-dpctl.8.gz
369/usr/share/man/man8/ovs-ofctl.8.gz
3b135da3 370/usr/share/man/man8/ovs-vsctl.8.gz
eaa3c7e8 371/usr/share/man/man8/ovs-vswitchd.8.gz
ac9634f0 372/var/lib/openvswitch
e8434552
JP
373%exclude /usr/share/vswitch/scripts/*.pyc
374%exclude /usr/share/vswitch/scripts/*.pyo