1 # Spec file for vswitch and related programs.
3 # Copyright (C) 2009, 2010 Nicira Networks, Inc.
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.
10 # When building, the rpmbuild command line should define
11 # vswitch_version, xen_version, and build_number using -D arguments.
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
16 %define version %{vswitch_version}-%{xen_version}
19 Summary: Virtual switch
20 Group: System Environment/Daemons
21 URL: http://www.openvswitch.org/
22 Version: %{vswitch_version}
24 # The entire source code is ASL 2.0 except datapath/ which is GPLv2
25 License: ASL 2.0 and GPLv2
27 Source: openvswitch-%{vswitch_version}.tar.gz
28 Buildroot: /tmp/vswitch-xen-rpm
29 Requires: kernel-xen = %(echo '%{xen_version}' | sed 's/xen$//')
30 # The following Conflicts prevents the "vswitch" package generated by
31 # this spec file from installing at the same time as the "openvswitch"
32 # package shipped with XenServer 5.5.900. In fact, the packages
33 # contain some files with identical names anyhow, so they will not
34 # coexist, but adding an explicit Conflicts makes this conflict more
36 Conflicts: openvswitch
39 The vswitch provides standard network bridging functions augmented with
40 support for the OpenFlow protocol for remote per-flow control of
44 %setup -q -n openvswitch-%{vswitch_version}
47 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-l26=/lib/modules/%{xen_version}/build --enable-ssl %{build_number}
51 rm -rf $RPM_BUILD_ROOT
52 make install DESTDIR=$RPM_BUILD_ROOT
53 install -d -m 755 $RPM_BUILD_ROOT/etc
54 install -d -m 755 $RPM_BUILD_ROOT/etc/init.d
55 install -m 755 xenserver/etc_init.d_vswitch \
56 $RPM_BUILD_ROOT/etc/init.d/vswitch
57 install -m 755 xenserver/etc_init.d_vswitch-xapi-update \
58 $RPM_BUILD_ROOT/etc/init.d/vswitch-xapi-update
59 install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
60 install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
61 install -m 755 xenserver/etc_logrotate.d_vswitch \
62 $RPM_BUILD_ROOT/etc/logrotate.d/vswitch
63 install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d
64 install -m 755 xenserver/etc_profile.d_vswitch.sh \
65 $RPM_BUILD_ROOT/etc/profile.d/vswitch.sh
66 install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins
67 install -m 755 xenserver/etc_xapi.d_plugins_vswitch-cfg-update \
68 $RPM_BUILD_ROOT/etc/xapi.d/plugins/vswitch-cfg-update
69 install -d -m 755 $RPM_BUILD_ROOT/usr/share/vswitch/scripts
70 install -m 644 vswitchd/vswitch.ovsschema \
71 $RPM_BUILD_ROOT/usr/share/vswitch/vswitch.ovsschema
72 install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \
73 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/interface-reconfigure
74 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \
75 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigure.py
76 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \
77 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureBridge.py
78 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
79 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py
80 install -m 755 xenserver/etc_xensource_scripts_vif \
81 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/vif
82 install -m 755 xenserver/usr_share_vswitch_scripts_dump-vif-details \
83 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/dump-vif-details
84 install -m 755 xenserver/usr_share_vswitch_scripts_refresh-xs-network-uuids \
85 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/refresh-xs-network-uuids
86 install -m 755 xenserver/usr_sbin_xen-bugtool \
87 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/xen-bugtool
88 install -m 755 xenserver/usr_sbin_brctl \
89 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/brctl
90 install -m 755 xenserver/usr_share_vswitch_scripts_sysconfig.template \
91 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/sysconfig.template
93 xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
94 $RPM_BUILD_ROOT/usr/share/vswitch/scripts/XSFeatureVSwitch.py
96 install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch
97 find datapath/linux-2.6 -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch \;
99 # Get rid of stuff we don't want to make RPM happy.
101 $RPM_BUILD_ROOT/usr/bin/ovs-controller \
102 $RPM_BUILD_ROOT/usr/bin/ovs-discover \
103 $RPM_BUILD_ROOT/usr/bin/ovs-kill \
104 $RPM_BUILD_ROOT/usr/bin/ovs-openflowd \
105 $RPM_BUILD_ROOT/usr/bin/ovs-pki \
106 $RPM_BUILD_ROOT/usr/bin/ovs-wdt \
107 $RPM_BUILD_ROOT/usr/sbin/ovs-monitor \
108 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \
109 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-discover.8 \
110 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-kill.8 \
111 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-openflowd.8 \
112 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8
113 rm -f $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/net/vswitch/veth_mod.ko
115 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
118 rm -rf $RPM_BUILD_ROOT
121 if [ ! -f /etc/xensource-inventory ]; then
122 printf "XenSource inventory not present in /etc/xensource-inventory"
126 if [ "$1" = "1" ]; then
127 if md5sum -c --status <<EOF
128 ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
129 b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
130 51970ad613a3996d5997e18e44db47da /opt/xensource/libexec/interface-reconfigure
131 5654c8c36699fcc8744ca9cd5b855414 /usr/sbin/xen-bugtool
134 printf "\nVerified host scripts from XenServer 5.5.0.\n\n"
135 elif md5sum -c --status <<EOF
136 ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
137 b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
138 51970ad613a3996d5997e18e44db47da /opt/xensource/libexec/interface-reconfigure
139 f6519085c2fc5f7bc4eccc294ed62000 /usr/sbin/xen-bugtool
142 printf "\nVerified host scripts from XenServer 5.5.0-24648p (Update 1)\n"
143 printf "or 5.5.0-25727p (Update 2).\n\n"
144 elif md5sum -c --status <<EOF
145 ca141d60061dcfdade73e75abc6529b5 /usr/sbin/brctl
146 b8e9835862ef1a9cec2a3f477d26c989 /etc/xensource/scripts/vif
147 ce451d3c985fd1db6497a363f0d9dedb /opt/xensource/libexec/interface-reconfigure
148 2b53f500431fcba5276c896e9e4281b9 /usr/sbin/xen-bugtool
151 printf "\nVerified host scripts from XenServer 5.5.900.\n\n"
155 The original XenServer scripts replaced by this package are not those
156 of any supported version of XenServer. This could lead to unexpected
157 behavior of your server. Unless you are sure you know what you are
158 doing, it is highly recommended that you remove this package
159 immediately after the install completes, which will restore the
160 XenServer scripts that you were previously using.
166 if test ! -e /var/xapi/network.dbcache; then
167 if test "$1" = 1; then
168 printf "Creating xapi database cache... "
170 printf "warning: Open vSwitch is being re-installed or upgraded,\n"
171 printf " but the xapi database cache is missing.\n"
172 printf "Re-creating xapi database cache... "
175 if /usr/share/vswitch/scripts/interface-reconfigure rewrite; then
179 printf "Open vSwitch can only be installed on a XenServer that\n"
180 printf "has connectivity to xapi on the pool master. Please\n"
181 printf "fix connectivity to the pool master, then try again.\n"
186 # Ensure that modprobe will find our modules.
187 depmod %{xen_version}
189 if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
190 cat >>/etc/sysctl.conf <<EOF
191 # This works around an issue in xhad, which binds to a particular
192 # Ethernet device, which in turn causes ICMP port unreachable messages
193 # if packets are received are on the wrong interface, which in turn
194 # can happen if we send out ARP replies on every interface (as Linux
195 # does by default) instead of just on the interface that has the IP
196 # address being ARPed for, which this sysctl setting in turn works
200 net.ipv4.conf.all.arp_filter = 1
204 if test ! -e /etc/ovs-vswitchd.conf.db; then
205 # Create ovs-vswitchd config database
206 ovsdb-tool -vANY:console:emer create /etc/ovs-vswitchd.conf.db \
207 /usr/share/vswitch/vswitch.ovsschema \
209 # Create initial table in config database
210 ovsdb-tool -vANY:console:emer transact /etc/ovs-vswitchd.conf.db \
211 '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
215 # Create default or update existing /etc/sysconfig/vswitch.
216 SYSCONFIG=/etc/sysconfig/vswitch
217 TEMPLATE=/usr/share/vswitch/scripts/sysconfig.template
218 if [ ! -e $SYSCONFIG ]; then
219 cp $TEMPLATE $SYSCONFIG
221 for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
223 if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
225 sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
230 # Replace XenServer files by our versions.
231 mkdir -p /usr/lib/vswitch/xs-original \
232 || printf "Could not create script backup directory.\n"
234 /opt/xensource/libexec/interface-reconfigure \
235 /opt/xensource/libexec/InterfaceReconfigure.py \
236 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
237 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
238 /etc/xensource/scripts/vif \
239 /usr/sbin/xen-bugtool \
244 if [ -f "$f" ] && [ "$t" != "/usr/share/vswitch/scripts/$s" ]; then
245 mv "$f" /usr/lib/vswitch/xs-original/ \
246 || printf "Could not save original XenServer $s script\n"
247 ln -s "/usr/share/vswitch/scripts/$s" "$f" \
248 || printf "Could not link to vSwitch $s script\n"
252 # Install xsconsole plugin
253 plugin=$(readlink /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py)
254 if [ "$plugin" != "/usr/share/vswitch/scripts/XSFeatureVSwitch.py" ]; then
255 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
256 ln -s /usr/share/vswitch/scripts/XSFeatureVSwitch.py /usr/lib/xsconsole/plugins-base/ || printf "Could not link to vSswitch xsconsole plugin.\n"
259 # Ensure all required services are set to run
260 for s in vswitch vswitch-xapi-update; do
261 if chkconfig --list $s >/dev/null 2>&1; then
262 chkconfig --del $s || printf "Could not remove $s init script."
264 chkconfig --add $s || printf "Could not add $s init script."
265 chkconfig $s on || printf "Could not enable $s init script."
268 # Configure system to use vswitch
269 echo vswitch > /etc/xensource/network.conf
271 if [ "$1" = "1" ]; then # $1 = 2 for upgrade
272 printf "\nYou MUST reboot the server NOW to complete the change to the\n"
273 printf "the vSwitch. Attempts to modify networking on the server\n"
274 printf "or any hosted VM will fail until after the reboot and could\n"
275 printf "leave the server in an state requiring manual recovery.\n\n"
277 printf "\nTo use the new vSwitch, you should reboot the server\n"
278 printf "now. Failure to do so may result in incorrect operation.\n\n"
282 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
283 for s in vswitch vswitch-xapi-update; do
284 chkconfig --del $s || printf "Could not remove $s init script."
290 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
292 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py \
293 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
294 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo \
295 || printf "Could not remove vSwitch xsconsole plugin.\n"
297 # Restore original XenServer scripts
299 /opt/xensource/libexec/interface-reconfigure \
300 /etc/xensource/scripts/vif \
301 /usr/sbin/xen-bugtool \
305 if [ ! -f "/usr/lib/vswitch/xs-original/$s" ]; then
306 printf "Original XenServer $s script not present in /usr/lib/vswitch/xs-original\n"
307 printf "Could not restore original XenServer script.\n"
310 && mv "/usr/lib/vswitch/xs-original/$s" "$f") \
311 || printf "Could not restore original XenServer $s script.\n"
315 # Remove all configuration files
316 rm -f /etc/ovs-vswitchd.conf.db
317 rm -f /etc/sysconfig/vswitch
318 rm -f /etc/ovs-vswitchd.cacert
319 rm -f /var/xapi/network.dbcache
321 # Configure system to use bridge
322 echo bridge > /etc/xensource/network.conf
324 printf "\nYou MUST reboot the server now to complete the change to\n"
325 printf "standard Xen networking. Attempts to modify networking on the\n"
326 printf "server or any hosted VM will fail until after the reboot and\n"
327 printf "could leave the server in a state requiring manual recovery.\n\n"
332 %defattr(-,root,root)
334 /etc/init.d/vswitch-xapi-update
335 /etc/xapi.d/plugins/vswitch-cfg-update
336 /etc/logrotate.d/vswitch
337 /etc/profile.d/vswitch.sh
338 /lib/modules/%{xen_version}/kernel/net/vswitch/openvswitch_mod.ko
339 /lib/modules/%{xen_version}/kernel/net/vswitch/brcompat_mod.ko
340 %if %(echo '%{xen_version}'|awk -F"." '{if ($3>=18) print 1; else print 0;}')
341 /lib/modules/%{xen_version}/kernel/net/vswitch/ip_gre_mod.ko
343 /usr/share/vswitch/scripts/dump-vif-details
344 /usr/share/vswitch/scripts/refresh-xs-network-uuids
345 /usr/share/vswitch/scripts/interface-reconfigure
346 /usr/share/vswitch/scripts/InterfaceReconfigure.py
347 /usr/share/vswitch/scripts/InterfaceReconfigure.pyc
348 /usr/share/vswitch/scripts/InterfaceReconfigure.pyo
349 /usr/share/vswitch/scripts/InterfaceReconfigureBridge.py
350 /usr/share/vswitch/scripts/InterfaceReconfigureBridge.pyc
351 /usr/share/vswitch/scripts/InterfaceReconfigureBridge.pyo
352 /usr/share/vswitch/scripts/InterfaceReconfigureVswitch.py
353 /usr/share/vswitch/scripts/InterfaceReconfigureVswitch.pyc
354 /usr/share/vswitch/scripts/InterfaceReconfigureVswitch.pyo
355 /usr/share/vswitch/scripts/vif
356 /usr/share/vswitch/scripts/xen-bugtool
357 /usr/share/vswitch/scripts/XSFeatureVSwitch.py
358 /usr/share/vswitch/scripts/brctl
359 /usr/share/vswitch/scripts/sysconfig.template
360 # Following two files are generated automatically by rpm. We don't
361 # really need them and they won't be used on the XenServer, but there
362 # isn't an obvious place to get rid of them since they are generated
363 # after the install script runs. Since they are small, we just
365 /usr/share/vswitch/scripts/XSFeatureVSwitch.pyc
366 /usr/share/vswitch/scripts/XSFeatureVSwitch.pyo
367 /usr/share/vswitch/vswitch.ovsschema
368 /usr/sbin/ovs-brcompatd
369 /usr/sbin/ovs-vswitchd
370 /usr/sbin/ovsdb-server
375 /usr/bin/ovsdb-client
377 /usr/share/man/man1/ovsdb-client.1.gz
378 /usr/share/man/man1/ovsdb-server.1.gz
379 /usr/share/man/man1/ovsdb-tool.1.gz
380 /usr/share/man/man8/ovs-appctl.8.gz
381 /usr/share/man/man8/ovs-brcompatd.8.gz
382 /usr/share/man/man8/ovs-dpctl.8.gz
383 /usr/share/man/man8/ovs-ofctl.8.gz
384 /usr/share/man/man8/ovs-vsctl.8.gz
385 /usr/share/man/man8/ovs-vswitchd.8.gz