blob: d07d2675c69f515ba5c467f08549010dab94d3d0 [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#
Attila Fazekas1f316be2015-01-26 16:39:57 +010015# - Fedora:
Dean Troyer49ba2242013-08-09 19:51:20 -050016# - set selinux not enforcing
Attila Fazekas1f316be2015-01-26 16:39:57 +010017# - uninstall firewalld (f20 only)
18
Dean Troyer49ba2242013-08-09 19:51:20 -050019
Dean Troyerdc97cb72015-03-28 08:20:50 -050020# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
Dean Troyer04a35112014-08-15 14:03:52 -050021# or in a sub-shell
22if [[ -z "$TOP_DIR" ]]; then
23 set -o errexit
24 set -o xtrace
Dean Troyer9acc12a2013-08-09 15:09:31 -050025
Dean Troyer04a35112014-08-15 14:03:52 -050026 # Keep track of the current directory
27 TOOLS_DIR=$(cd $(dirname "$0") && pwd)
28 TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
Dean Troyer9acc12a2013-08-09 15:09:31 -050029
Dean Troyerdc97cb72015-03-28 08:20:50 -050030 # Change dir to top of DevStack
Dean Troyer04a35112014-08-15 14:03:52 -050031 cd $TOP_DIR
Dean Troyer9acc12a2013-08-09 15:09:31 -050032
Dean Troyer04a35112014-08-15 14:03:52 -050033 # Import common functions
34 source $TOP_DIR/functions
Dean Troyer9acc12a2013-08-09 15:09:31 -050035
Dean Troyer04a35112014-08-15 14:03:52 -050036 FILES=$TOP_DIR/files
37fi
Dean Troyer9acc12a2013-08-09 15:09:31 -050038
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070039# Keystone Port Reservation
40# -------------------------
Dean Troyerdc97cb72015-03-28 08:20:50 -050041# Reserve and prevent ``KEYSTONE_AUTH_PORT`` and ``KEYSTONE_AUTH_PORT_INT`` from
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070042# being used as ephemeral ports by the system. The default(s) are 35357 and
43# 35358 which are in the Linux defined ephemeral port range (in disagreement
44# with the IANA ephemeral port range). This is a workaround for bug #1253482
45# where Keystone will try and bind to the port and the port will already be
46# in use as an ephemeral port by another process. This places an explicit
47# exception into the Kernel for the Keystone AUTH ports.
48keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358}
49
Dean Troyerdc97cb72015-03-28 08:20:50 -050050# Only do the reserved ports when available, on some system (like containers)
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020051# where it's not exposed we are almost pretty sure these ports would be
Dean Troyerdc97cb72015-03-28 08:20:50 -050052# exclusive for our DevStack.
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020053if sysctl net.ipv4.ip_local_reserved_ports >/dev/null 2>&1; then
54 # Get any currently reserved ports, strip off leading whitespace
55 reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070056
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020057 if [[ -z "${reserved_ports}" ]]; then
58 # If there are no currently reserved ports, reserve the keystone ports
59 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
60 else
61 # If there are currently reserved ports, keep those and also reserve the
Dean Troyerdc97cb72015-03-28 08:20:50 -050062 # Keystone specific ports. Duplicate reservations are merged into a single
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020063 # reservation (or range) automatically by the kernel.
64 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
65 fi
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070066else
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020067 echo_summary "WARNING: unable to reserve keystone ports"
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070068fi
69
Clark Boylanc9a9e412017-03-29 10:28:55 -070070# Ubuntu Cloud Archive
71#---------------------
72# We've found that Libvirt on Xenial is flaky and crashes enough to be
73# a regular top e-r bug. Opt into Ubuntu Cloud Archive if on Xenial to
74# get newer Libvirt.
75if [[ "$DISTRO" = "xenial" ]]; then
76 # This pulls in apt-add-repository
77 install_package "software-properties-common"
78 # Use UCA for newer libvirt. Should give us libvirt 2.5.0.
79 if [[ -f /etc/ci/mirror_info.sh ]] ; then
80 # If we are on a nodepool provided host and it has told us about where
81 # we can find local mirrors then use that mirror.
82 source /etc/ci/mirror_info.sh
83
84 sudo apt-add-repository -y "deb $NODEPOOL_UCA_MIRROR xenial-updates/ocata main"
Clark Boylanc9a9e412017-03-29 10:28:55 -070085 else
86 # Otherwise use upstream UCA
87 sudo add-apt-repository -y cloud-archive:ocata
88 fi
Ian Wienand71d20e62017-04-21 11:48:12 +100089
90 # Disable use of libvirt wheel since a cached wheel build might be
91 # against older libvirt binary. Particularly a problem if using
92 # the openstack wheel mirrors, but can hit locally too.
93 # TODO(clarkb) figure out how to use upstream wheel again.
94 iniset -sudo /etc/pip.conf "global" "no-binary" "libvirt-python"
95
Paul Belanger1f92d442017-04-13 12:07:57 -040096 # Force update our APT repos, since we added UCA above.
97 REPOS_UPDATED=False
98 apt_get_update
Clark Boylanc9a9e412017-03-29 10:28:55 -070099fi
100
Dean Troyer49ba2242013-08-09 19:51:20 -0500101
102# Python Packages
103# ---------------
104
Dean Troyer65f1af62013-10-16 12:10:13 -0500105# get_package_path python-package # in import notation
Ian Wienandaee18c72014-02-21 15:35:08 +1100106function get_package_path {
Dean Troyer65f1af62013-10-16 12:10:13 -0500107 local package=$1
108 echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
109}
110
111
Dean Troyer9acc12a2013-08-09 15:09:31 -0500112# Pre-install affected packages so we can fix the permissions
Dean Troyer65f1af62013-10-16 12:10:13 -0500113# These can go away once we are confident that pip 1.4.1+ is available everywhere
114
115# Fix prettytable 0.7.2 permissions
116# Don't specify --upgrade so we use the existing package if present
Jeremy Stanley6ec66bb2014-12-22 17:17:51 +0000117pip_install 'prettytable>=0.7'
Dean Troyer65f1af62013-10-16 12:10:13 -0500118PACKAGE_DIR=$(get_package_path prettytable)
119# Only fix version 0.7.2
120dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
121if [[ -d $dir ]]; then
122 sudo chmod +r $dir/*
123fi
124
125# Fix httplib2 0.8 permissions
126# Don't specify --upgrade so we use the existing package if present
Aaron Rosen1e4551d2013-09-16 13:58:08 -0700127pip_install httplib2
Dean Troyer65f1af62013-10-16 12:10:13 -0500128PACKAGE_DIR=$(get_package_path httplib2)
129# Only fix version 0.8
130dir=$(echo $PACKAGE_DIR-0.8*)
131if [[ -d $dir ]]; then
132 sudo chmod +r $dir/*
133fi
Dean Troyer49ba2242013-08-09 19:51:20 -0500134
Attila Fazekasd7967a42014-06-12 11:41:54 +0200135if is_fedora; then
Dean Troyer49ba2242013-08-09 19:51:20 -0500136 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +0100137 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -0500138 if selinuxenabled; then
139 sudo setenforce 0
140 fi
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500141
Ian Wienande82bac02015-08-25 14:29:08 +1000142 FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD)
Ian Wienand3380a162015-05-15 13:12:02 +1000143 if [[ $FORCE_FIREWALLD == "False" ]]; then
Kashyap Chamarthy7c9df102015-01-02 18:39:29 +0100144 # On Fedora 20 firewalld interacts badly with libvirt and
Ian Wienand3380a162015-05-15 13:12:02 +1000145 # slows things down significantly (this issue was fixed in
146 # later fedoras). There was also an additional issue with
147 # firewalld hanging after install of libvirt with polkit [1].
148 # firewalld also causes problems with neturon+ipv6 [2]
149 #
150 # Note we do the same as the RDO packages and stop & disable,
151 # rather than remove. This is because other packages might
152 # have the dependency [3][4].
153 #
154 # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031
155 # [2] https://bugs.launchpad.net/neutron/+bug/1455303
156 # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp
157 # [4] http://docs.openstack.org/developer/devstack/guides/neutron.html
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500158 if is_package_installed firewalld; then
Ian Wienand3380a162015-05-15 13:12:02 +1000159 sudo systemctl disable firewalld
Ben Nemec64b2ebc2015-06-05 12:22:36 -0500160 # The iptables service files are no longer included by default,
161 # at least on a baremetal Fedora 21 Server install.
162 install_package iptables-services
Ian Wienand3380a162015-05-15 13:12:02 +1000163 sudo systemctl enable iptables
164 sudo systemctl stop firewalld
165 sudo systemctl start iptables
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500166 fi
167 fi
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200168
Kashyap Chamarthy90bc5862015-12-01 18:04:40 +0100169 if [[ "$os_VENDOR" == "Fedora" ]] && [[ "$os_RELEASE" -ge "22" ]]; then
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200170 # requests ships vendored version of chardet/urllib3, but on
171 # fedora these are symlinked back to the primary versions to
172 # avoid duplication of code on disk. This is fine when
173 # maintainers keep things in sync, but since devstack takes
174 # over and installs later versions via pip we can end up with
175 # incompatible versions.
176 #
177 # The rpm package is not removed to preserve the dependent
178 # packages like cloud-init; rather we remove the symlinks and
179 # force a re-install of requests so the vendored versions it
180 # wants are present.
181 #
182 # Realted issues:
183 # https://bugs.launchpad.net/glance/+bug/1476770
184 # https://bugzilla.redhat.com/show_bug.cgi?id=1253823
185
Mark Hamzy746e72d2015-10-14 13:42:18 -0500186 base_path=$(get_package_path requests)/packages
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200187 if [ -L $base_path/chardet -o -L $base_path/urllib3 ]; then
Mark Hamzy746e72d2015-10-14 13:42:18 -0500188 sudo rm -f $base_path/{chardet,urllib3}
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200189 # install requests with the bundled urllib3 to avoid conflicts
190 pip_install --upgrade --force-reinstall requests
191 fi
192 fi
Attila Fazekasd7967a42014-06-12 11:41:54 +0200193fi
Vigneshvar.A.S834b8042015-02-14 01:05:55 +0530194
195# The version of pip(1.5.4) supported by python-virtualenv(1.11.4) has
Kenneth Giustidf6c1ff2016-07-07 09:28:58 -0400196# connection issues under proxy so re-install the latest version using
197# pip. To avoid having pip's virtualenv overwritten by the distro's
198# package (e.g. due to installing a distro package with a dependency
199# on python-virtualenv), first install the distro python-virtualenv
200# to satisfy any dependencies then use pip to overwrite it.
201
202install_package python-virtualenv
203pip_install -U --force-reinstall virtualenv