blob: 6f680b860ecb4b087b5374a18235fc50b8bd4db8 [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"
85
86 # Disable use of libvirt wheel here as presence of mirror implies
87 # presence of cached wheel build against older libvirt binary.
88 # TODO(clarkb) figure out how to use wheel again.
89 sudo bash -c 'echo "no-binary = libvirt-python" >> /etc/pip.conf'
90 else
91 # Otherwise use upstream UCA
92 sudo add-apt-repository -y cloud-archive:ocata
93 fi
94 sudo apt-get update
95fi
96
Dean Troyer49ba2242013-08-09 19:51:20 -050097
98# Python Packages
99# ---------------
100
Dean Troyer65f1af62013-10-16 12:10:13 -0500101# get_package_path python-package # in import notation
Ian Wienandaee18c72014-02-21 15:35:08 +1100102function get_package_path {
Dean Troyer65f1af62013-10-16 12:10:13 -0500103 local package=$1
104 echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
105}
106
107
Dean Troyer9acc12a2013-08-09 15:09:31 -0500108# Pre-install affected packages so we can fix the permissions
Dean Troyer65f1af62013-10-16 12:10:13 -0500109# These can go away once we are confident that pip 1.4.1+ is available everywhere
110
111# Fix prettytable 0.7.2 permissions
112# Don't specify --upgrade so we use the existing package if present
Jeremy Stanley6ec66bb2014-12-22 17:17:51 +0000113pip_install 'prettytable>=0.7'
Dean Troyer65f1af62013-10-16 12:10:13 -0500114PACKAGE_DIR=$(get_package_path prettytable)
115# Only fix version 0.7.2
116dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
117if [[ -d $dir ]]; then
118 sudo chmod +r $dir/*
119fi
120
121# Fix httplib2 0.8 permissions
122# Don't specify --upgrade so we use the existing package if present
Aaron Rosen1e4551d2013-09-16 13:58:08 -0700123pip_install httplib2
Dean Troyer65f1af62013-10-16 12:10:13 -0500124PACKAGE_DIR=$(get_package_path httplib2)
125# Only fix version 0.8
126dir=$(echo $PACKAGE_DIR-0.8*)
127if [[ -d $dir ]]; then
128 sudo chmod +r $dir/*
129fi
Dean Troyer49ba2242013-08-09 19:51:20 -0500130
Attila Fazekasd7967a42014-06-12 11:41:54 +0200131if is_fedora; then
Dean Troyer49ba2242013-08-09 19:51:20 -0500132 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +0100133 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -0500134 if selinuxenabled; then
135 sudo setenforce 0
136 fi
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500137
Ian Wienande82bac02015-08-25 14:29:08 +1000138 FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD)
Ian Wienand3380a162015-05-15 13:12:02 +1000139 if [[ $FORCE_FIREWALLD == "False" ]]; then
Kashyap Chamarthy7c9df102015-01-02 18:39:29 +0100140 # On Fedora 20 firewalld interacts badly with libvirt and
Ian Wienand3380a162015-05-15 13:12:02 +1000141 # slows things down significantly (this issue was fixed in
142 # later fedoras). There was also an additional issue with
143 # firewalld hanging after install of libvirt with polkit [1].
144 # firewalld also causes problems with neturon+ipv6 [2]
145 #
146 # Note we do the same as the RDO packages and stop & disable,
147 # rather than remove. This is because other packages might
148 # have the dependency [3][4].
149 #
150 # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031
151 # [2] https://bugs.launchpad.net/neutron/+bug/1455303
152 # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp
153 # [4] http://docs.openstack.org/developer/devstack/guides/neutron.html
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500154 if is_package_installed firewalld; then
Ian Wienand3380a162015-05-15 13:12:02 +1000155 sudo systemctl disable firewalld
Ben Nemec64b2ebc2015-06-05 12:22:36 -0500156 # The iptables service files are no longer included by default,
157 # at least on a baremetal Fedora 21 Server install.
158 install_package iptables-services
Ian Wienand3380a162015-05-15 13:12:02 +1000159 sudo systemctl enable iptables
160 sudo systemctl stop firewalld
161 sudo systemctl start iptables
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500162 fi
163 fi
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200164
Kashyap Chamarthy90bc5862015-12-01 18:04:40 +0100165 if [[ "$os_VENDOR" == "Fedora" ]] && [[ "$os_RELEASE" -ge "22" ]]; then
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200166 # requests ships vendored version of chardet/urllib3, but on
167 # fedora these are symlinked back to the primary versions to
168 # avoid duplication of code on disk. This is fine when
169 # maintainers keep things in sync, but since devstack takes
170 # over and installs later versions via pip we can end up with
171 # incompatible versions.
172 #
173 # The rpm package is not removed to preserve the dependent
174 # packages like cloud-init; rather we remove the symlinks and
175 # force a re-install of requests so the vendored versions it
176 # wants are present.
177 #
178 # Realted issues:
179 # https://bugs.launchpad.net/glance/+bug/1476770
180 # https://bugzilla.redhat.com/show_bug.cgi?id=1253823
181
Mark Hamzy746e72d2015-10-14 13:42:18 -0500182 base_path=$(get_package_path requests)/packages
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200183 if [ -L $base_path/chardet -o -L $base_path/urllib3 ]; then
Mark Hamzy746e72d2015-10-14 13:42:18 -0500184 sudo rm -f $base_path/{chardet,urllib3}
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200185 # install requests with the bundled urllib3 to avoid conflicts
186 pip_install --upgrade --force-reinstall requests
187 fi
188 fi
Attila Fazekasd7967a42014-06-12 11:41:54 +0200189fi
Vigneshvar.A.S834b8042015-02-14 01:05:55 +0530190
191# The version of pip(1.5.4) supported by python-virtualenv(1.11.4) has
Kenneth Giustidf6c1ff2016-07-07 09:28:58 -0400192# connection issues under proxy so re-install the latest version using
193# pip. To avoid having pip's virtualenv overwritten by the distro's
194# package (e.g. due to installing a distro package with a dependency
195# on python-virtualenv), first install the distro python-virtualenv
196# to satisfy any dependencies then use pip to overwrite it.
197
198install_package python-virtualenv
199pip_install -U --force-reinstall virtualenv