blob: b8beb01583ffc2ad545e5340280814560918770b [file] [log] [blame]
Dean Troyer9acc12a2013-08-09 15:09:31 -05001#!/usr/bin/env bash
2
3# **fixup_stuff.sh**
4
5# fixup_stuff.sh
6#
7# All distro and package specific hacks go in here
Adam Spierscb961592013-10-05 12:11:07 +01008#
Dean Troyer9acc12a2013-08-09 15:09:31 -05009# - prettytable 0.7.2 permissions are 600 in the package and
10# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010011#
Dean Troyer9acc12a2013-08-09 15:09:31 -050012# - httplib2 0.8 permissions are 600 in the package and
13# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010014#
Dean Troyer49ba2242013-08-09 19:51:20 -050015# - RHEL6:
Adam Spierscb961592013-10-05 12:11:07 +010016#
Dean Troyer49ba2242013-08-09 19:51:20 -050017# - set selinux not enforcing
18# - (re)start messagebus daemon
19# - remove distro packages python-crypto and python-lxml
20# - pre-install hgtools to work around a bug in RHEL6 distribute
21# - install nose 1.1 from EPEL
22
Dean Troyer04a35112014-08-15 14:03:52 -050023# If TOP_DIR is set we're being sourced rather than running stand-alone
24# or in a sub-shell
25if [[ -z "$TOP_DIR" ]]; then
26 set -o errexit
27 set -o xtrace
Dean Troyer9acc12a2013-08-09 15:09:31 -050028
Dean Troyer04a35112014-08-15 14:03:52 -050029 # Keep track of the current directory
30 TOOLS_DIR=$(cd $(dirname "$0") && pwd)
31 TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
Dean Troyer9acc12a2013-08-09 15:09:31 -050032
Dean Troyer04a35112014-08-15 14:03:52 -050033 # Change dir to top of devstack
34 cd $TOP_DIR
Dean Troyer9acc12a2013-08-09 15:09:31 -050035
Dean Troyer04a35112014-08-15 14:03:52 -050036 # Import common functions
37 source $TOP_DIR/functions
Dean Troyer9acc12a2013-08-09 15:09:31 -050038
Dean Troyer04a35112014-08-15 14:03:52 -050039 FILES=$TOP_DIR/files
40fi
Dean Troyer9acc12a2013-08-09 15:09:31 -050041
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070042# Keystone Port Reservation
43# -------------------------
44# Reserve and prevent $KEYSTONE_AUTH_PORT and $KEYSTONE_AUTH_PORT_INT from
45# being used as ephemeral ports by the system. The default(s) are 35357 and
46# 35358 which are in the Linux defined ephemeral port range (in disagreement
47# with the IANA ephemeral port range). This is a workaround for bug #1253482
48# where Keystone will try and bind to the port and the port will already be
49# in use as an ephemeral port by another process. This places an explicit
50# exception into the Kernel for the Keystone AUTH ports.
51keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358}
52
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020053# only do the reserved ports when available, on some system (like containers)
54# where it's not exposed we are almost pretty sure these ports would be
55# exclusive for our devstack.
56if sysctl net.ipv4.ip_local_reserved_ports >/dev/null 2>&1; then
57 # Get any currently reserved ports, strip off leading whitespace
58 reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070059
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020060 if [[ -z "${reserved_ports}" ]]; then
61 # If there are no currently reserved ports, reserve the keystone ports
62 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
63 else
64 # If there are currently reserved ports, keep those and also reserve the
65 # keystone specific ports. Duplicate reservations are merged into a single
66 # reservation (or range) automatically by the kernel.
67 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
68 fi
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070069else
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020070 echo_summary "WARNING: unable to reserve keystone ports"
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070071fi
72
Dean Troyer49ba2242013-08-09 19:51:20 -050073
74# Python Packages
75# ---------------
76
Dean Troyer65f1af62013-10-16 12:10:13 -050077# get_package_path python-package # in import notation
Ian Wienandaee18c72014-02-21 15:35:08 +110078function get_package_path {
Dean Troyer65f1af62013-10-16 12:10:13 -050079 local package=$1
80 echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
81}
82
83
Dean Troyer9acc12a2013-08-09 15:09:31 -050084# Pre-install affected packages so we can fix the permissions
Dean Troyer65f1af62013-10-16 12:10:13 -050085# These can go away once we are confident that pip 1.4.1+ is available everywhere
86
87# Fix prettytable 0.7.2 permissions
88# Don't specify --upgrade so we use the existing package if present
Attila Fazekas3a823192013-11-24 18:53:20 +010089pip_install 'prettytable>0.7'
Dean Troyer65f1af62013-10-16 12:10:13 -050090PACKAGE_DIR=$(get_package_path prettytable)
91# Only fix version 0.7.2
92dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
93if [[ -d $dir ]]; then
94 sudo chmod +r $dir/*
95fi
96
97# Fix httplib2 0.8 permissions
98# Don't specify --upgrade so we use the existing package if present
Aaron Rosen1e4551d2013-09-16 13:58:08 -070099pip_install httplib2
Dean Troyer65f1af62013-10-16 12:10:13 -0500100PACKAGE_DIR=$(get_package_path httplib2)
101# Only fix version 0.8
102dir=$(echo $PACKAGE_DIR-0.8*)
103if [[ -d $dir ]]; then
104 sudo chmod +r $dir/*
105fi
Dean Troyer49ba2242013-08-09 19:51:20 -0500106
Attila Fazekasd7967a42014-06-12 11:41:54 +0200107if is_fedora; then
Dean Troyer49ba2242013-08-09 19:51:20 -0500108 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +0100109 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -0500110 if selinuxenabled; then
111 sudo setenforce 0
112 fi
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500113
114 FORCE_FIREWALLD=$(trueorfalse False $FORCE_FIREWALLD)
115 if [[ ${DISTRO} =~ (f19|f20) && $FORCE_FIREWALLD == "False" ]]; then
116 # On Fedora 19 and 20 firewalld interacts badly with libvirt and
117 # slows things down significantly. However, for those cases
118 # where that combination is desired, allow this fix to be skipped.
119
120 # There was also an additional issue with firewalld hanging
121 # after install of libvirt with polkit. See
122 # https://bugzilla.redhat.com/show_bug.cgi?id=1099031
123 if is_package_installed firewalld; then
124 uninstall_package firewalld
125 fi
126 fi
127
Attila Fazekasd7967a42014-06-12 11:41:54 +0200128fi
129
130# RHEL6
131# -----
132
133if [[ $DISTRO =~ (rhel6) ]]; then
Dean Troyer49ba2242013-08-09 19:51:20 -0500134
Ian Wienand8fdb42f2014-07-30 11:27:54 +1000135 # install_pip.sh installs the latest setuptools over the packaged
136 # version. We can't really uninstall the packaged version if it
137 # is there, because it may remove other important things like
138 # cloud-init. Things work, but there can be an old egg file left
139 # around from the package that causes some really strange
140 # setuptools errors. Remove it, if it is there
141 sudo rm -f /usr/lib/python2.6/site-packages/setuptools-0.6*.egg-info
142
Dean Troyer49ba2242013-08-09 19:51:20 -0500143 # If the ``dbus`` package was installed by DevStack dependencies the
144 # uuid may not be generated because the service was never started (PR#598200),
145 # causing Nova to stop later on complaining that ``/var/lib/dbus/machine-id``
146 # does not exist.
147 sudo service messagebus restart
148
149 # The following workarounds break xenserver
150 if [ "$VIRT_DRIVER" != 'xenserver' ]; then
151 # An old version of ``python-crypto`` (2.0.1) may be installed on a
152 # fresh system via Anaconda and the dependency chain
153 # ``cas`` -> ``python-paramiko`` -> ``python-crypto``.
154 # ``pip uninstall pycrypto`` will remove the packaged ``.egg-info``
Adam Spierscb961592013-10-05 12:11:07 +0100155 # file but leave most of the actual library files behind in
Dean Troyer49ba2242013-08-09 19:51:20 -0500156 # ``/usr/lib64/python2.6/Crypto``. Later ``pip install pycrypto``
157 # will install over the packaged files resulting
158 # in a useless mess of old, rpm-packaged files and pip-installed files.
159 # Remove the package so that ``pip install python-crypto`` installs
160 # cleanly.
161 # Note: other RPM packages may require ``python-crypto`` as well.
162 # For example, RHEL6 does not install ``python-paramiko packages``.
163 uninstall_package python-crypto
164
165 # A similar situation occurs with ``python-lxml``, which is required by
166 # ``ipa-client``, an auditing package we don't care about. The
167 # build-dependencies needed for ``pip install lxml`` (``gcc``,
168 # ``libxml2-dev`` and ``libxslt-dev``) are present in
169 # ``files/rpms/general``.
170 uninstall_package python-lxml
171 fi
172
173 # ``setup.py`` contains a ``setup_requires`` package that is supposed
174 # to be transient. However, RHEL6 distribute has a bug where
175 # ``setup_requires`` registers entry points that are not cleaned
176 # out properly after the setup-phase resulting in installation failures
177 # (bz#924038). Pre-install the problem package so the ``setup_requires``
178 # dependency is satisfied and it will not be installed transiently.
179 # Note we do this before the track-depends in ``stack.sh``.
180 pip_install hgtools
181
182
183 # RHEL6's version of ``python-nose`` is incompatible with Tempest.
184 # Install nose 1.1 (Tempest-compatible) from EPEL
185 install_package python-nose1.1
186 # Add a symlink for the new nosetests to allow tox for Tempest to
187 # work unmolested.
188 sudo ln -sf /usr/bin/nosetests1.1 /usr/local/bin/nosetests
189
Attila Fazekas522cfe02014-04-11 11:14:07 +0200190 # workaround for https://code.google.com/p/unittest-ext/issues/detail?id=79
191 install_package python-unittest2 patch
192 pip_install discover
193 (cd /usr/lib/python2.6/site-packages/; sudo patch <"$FILES/patches/unittest2-discover.patch" || echo 'Assume already applied')
194 # Make sure the discover.pyc is up to date
195 sudo rm /usr/lib/python2.6/site-packages/discover.pyc || true
196 sudo python -c 'import discover'
Dean Troyer49ba2242013-08-09 19:51:20 -0500197fi