| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 1 | #!/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 Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 8 | # | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 9 | # - prettytable 0.7.2 permissions are 600 in the package and | 
|  | 10 | #   pip 1.4 doesn't fix it (1.3 did) | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 11 | # | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 12 | # - httplib2 0.8 permissions are 600 in the package and | 
|  | 13 | #   pip 1.4 doesn't fix it (1.3 did) | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 14 | # | 
| Attila Fazekas | 1f316be | 2015-01-26 16:39:57 +0100 | [diff] [blame] | 15 | # - Fedora: | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 16 | #   - set selinux not enforcing | 
| Attila Fazekas | 1f316be | 2015-01-26 16:39:57 +0100 | [diff] [blame] | 17 | #   - uninstall firewalld (f20 only) | 
|  | 18 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 19 |  | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 20 | # If ``TOP_DIR`` is set we're being sourced rather than running stand-alone | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 21 | # or in a sub-shell | 
|  | 22 | if [[ -z "$TOP_DIR" ]]; then | 
|  | 23 | set -o errexit | 
|  | 24 | set -o xtrace | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 25 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 26 | # Keep track of the current directory | 
|  | 27 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) | 
|  | 28 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 29 |  | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 30 | # Change dir to top of DevStack | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 31 | cd $TOP_DIR | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 32 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 33 | # Import common functions | 
|  | 34 | source $TOP_DIR/functions | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 35 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 36 | FILES=$TOP_DIR/files | 
|  | 37 | fi | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 38 |  | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 39 | # Keystone Port Reservation | 
|  | 40 | # ------------------------- | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 41 | # Reserve and prevent ``KEYSTONE_AUTH_PORT`` and ``KEYSTONE_AUTH_PORT_INT`` from | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 42 | # 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. | 
|  | 48 | keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358} | 
|  | 49 |  | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 50 | # Only do the reserved ports when available, on some system (like containers) | 
| Chmouel Boudjnah | 8fceb49 | 2014-10-02 20:58:20 +0200 | [diff] [blame] | 51 | # where it's not exposed we are almost pretty sure these ports would be | 
| Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 52 | # exclusive for our DevStack. | 
| Chmouel Boudjnah | 8fceb49 | 2014-10-02 20:58:20 +0200 | [diff] [blame] | 53 | if 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 Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 56 |  | 
| Chmouel Boudjnah | 8fceb49 | 2014-10-02 20:58:20 +0200 | [diff] [blame] | 57 | 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 Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 62 | # Keystone specific ports. Duplicate reservations are merged into a single | 
| Chmouel Boudjnah | 8fceb49 | 2014-10-02 20:58:20 +0200 | [diff] [blame] | 63 | # reservation (or range) automatically by the kernel. | 
|  | 64 | sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports} | 
|  | 65 | fi | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 66 | else | 
| Chmouel Boudjnah | 8fceb49 | 2014-10-02 20:58:20 +0200 | [diff] [blame] | 67 | echo_summary "WARNING: unable to reserve keystone ports" | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 68 | fi | 
|  | 69 |  | 
| Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 70 | # 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. | 
| Amrith Kumar | bb436d3 | 2017-05-10 08:21:04 -0400 | [diff] [blame] | 75 | # Make it possible to switch this based on an environment variable as | 
|  | 76 | # libvirt 2.5.0 doesn't handle nested virtualization quite well and this | 
|  | 77 | # is required for the trove development environment. | 
| Matt Riedemann | ffe691e | 2016-01-12 17:58:44 -0800 | [diff] [blame] | 78 | # The Pike UCA has qemu 2.10 but libvirt 3.6, therefore if | 
|  | 79 | # ENABLE_VOLUME_MULTIATTACH is True, we can't use the Pike UCA | 
|  | 80 | # because multiattach won't work with those package versions. | 
|  | 81 | # We can remove this check when the UCA has libvirt>=3.10. | 
|  | 82 | if [[ "${ENABLE_UBUNTU_CLOUD_ARCHIVE}" == "True" && "$DISTRO" = "xenial" && \ | 
|  | 83 | "${ENABLE_VOLUME_MULTIATTACH}" == "False" ]]; then | 
| Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 84 | # This pulls in apt-add-repository | 
|  | 85 | install_package "software-properties-common" | 
|  | 86 | # Use UCA for newer libvirt. Should give us libvirt 2.5.0. | 
|  | 87 | if [[ -f /etc/ci/mirror_info.sh ]] ; then | 
|  | 88 | # If we are on a nodepool provided host and it has told us about where | 
|  | 89 | # we can find local mirrors then use that mirror. | 
|  | 90 | source /etc/ci/mirror_info.sh | 
|  | 91 |  | 
| Matt Riedemann | 917ad09 | 2017-09-20 14:46:48 +0000 | [diff] [blame] | 92 | sudo apt-add-repository -y "deb $NODEPOOL_UCA_MIRROR xenial-updates/pike main" | 
| Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 93 | else | 
|  | 94 | # Otherwise use upstream UCA | 
| Matt Riedemann | 917ad09 | 2017-09-20 14:46:48 +0000 | [diff] [blame] | 95 | sudo add-apt-repository -y cloud-archive:pike | 
| Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 96 | fi | 
| Ian Wienand | 71d20e6 | 2017-04-21 11:48:12 +1000 | [diff] [blame] | 97 |  | 
|  | 98 | # Disable use of libvirt wheel since a cached wheel build might be | 
|  | 99 | # against older libvirt binary.  Particularly a problem if using | 
|  | 100 | # the openstack wheel mirrors, but can hit locally too. | 
|  | 101 | # TODO(clarkb) figure out how to use upstream wheel again. | 
|  | 102 | iniset -sudo /etc/pip.conf "global" "no-binary" "libvirt-python" | 
|  | 103 |  | 
| Paul Belanger | 1f92d44 | 2017-04-13 12:07:57 -0400 | [diff] [blame] | 104 | # Force update our APT repos, since we added UCA above. | 
|  | 105 | REPOS_UPDATED=False | 
|  | 106 | apt_get_update | 
| Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 107 | fi | 
|  | 108 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 109 |  | 
|  | 110 | # Python Packages | 
|  | 111 | # --------------- | 
|  | 112 |  | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 113 | # get_package_path python-package    # in import notation | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 114 | function get_package_path { | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 115 | local package=$1 | 
|  | 116 | echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])") | 
|  | 117 | } | 
|  | 118 |  | 
|  | 119 |  | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 120 | # Pre-install affected packages so we can fix the permissions | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 121 | # These can go away once we are confident that pip 1.4.1+ is available everywhere | 
|  | 122 |  | 
|  | 123 | # Fix prettytable 0.7.2 permissions | 
|  | 124 | # Don't specify --upgrade so we use the existing package if present | 
| Jeremy Stanley | 6ec66bb | 2014-12-22 17:17:51 +0000 | [diff] [blame] | 125 | pip_install 'prettytable>=0.7' | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 126 | PACKAGE_DIR=$(get_package_path prettytable) | 
|  | 127 | # Only fix version 0.7.2 | 
|  | 128 | dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*) | 
|  | 129 | if [[ -d $dir ]]; then | 
|  | 130 | sudo chmod +r $dir/* | 
|  | 131 | fi | 
|  | 132 |  | 
|  | 133 | # Fix httplib2 0.8 permissions | 
|  | 134 | # Don't specify --upgrade so we use the existing package if present | 
| Aaron Rosen | 1e4551d | 2013-09-16 13:58:08 -0700 | [diff] [blame] | 135 | pip_install httplib2 | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 136 | PACKAGE_DIR=$(get_package_path httplib2) | 
|  | 137 | # Only fix version 0.8 | 
|  | 138 | dir=$(echo $PACKAGE_DIR-0.8*) | 
|  | 139 | if [[ -d $dir ]]; then | 
|  | 140 | sudo chmod +r $dir/* | 
|  | 141 | fi | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 142 |  | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 143 | if is_fedora; then | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 144 | # Disable selinux to avoid configuring to allow Apache access | 
| Gonéri Le Bouder | 394c11c | 2013-11-05 10:35:55 +0100 | [diff] [blame] | 145 | # to Horizon files (LP#1175444) | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 146 | if selinuxenabled; then | 
|  | 147 | sudo setenforce 0 | 
|  | 148 | fi | 
| Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 149 |  | 
| Ian Wienand | e82bac0 | 2015-08-25 14:29:08 +1000 | [diff] [blame] | 150 | FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD) | 
| Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 151 | if [[ $FORCE_FIREWALLD == "False" ]]; then | 
| Kashyap Chamarthy | 7c9df10 | 2015-01-02 18:39:29 +0100 | [diff] [blame] | 152 | # On Fedora 20 firewalld interacts badly with libvirt and | 
| Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 153 | # slows things down significantly (this issue was fixed in | 
|  | 154 | # later fedoras).  There was also an additional issue with | 
|  | 155 | # firewalld hanging after install of libvirt with polkit [1]. | 
|  | 156 | # firewalld also causes problems with neturon+ipv6 [2] | 
|  | 157 | # | 
|  | 158 | # Note we do the same as the RDO packages and stop & disable, | 
|  | 159 | # rather than remove.  This is because other packages might | 
|  | 160 | # have the dependency [3][4]. | 
|  | 161 | # | 
|  | 162 | # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031 | 
|  | 163 | # [2] https://bugs.launchpad.net/neutron/+bug/1455303 | 
|  | 164 | # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp | 
| Takashi NATSUME | fa00777 | 2017-07-22 08:59:43 +0900 | [diff] [blame] | 165 | # [4] https://docs.openstack.org/devstack/latest/guides/neutron.html | 
| Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 166 | if is_package_installed firewalld; then | 
| Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 167 | sudo systemctl disable firewalld | 
| Ben Nemec | 64b2ebc | 2015-06-05 12:22:36 -0500 | [diff] [blame] | 168 | # The iptables service files are no longer included by default, | 
|  | 169 | # at least on a baremetal Fedora 21 Server install. | 
|  | 170 | install_package iptables-services | 
| Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 171 | sudo systemctl enable iptables | 
|  | 172 | sudo systemctl stop firewalld | 
|  | 173 | sudo systemctl start iptables | 
| Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 174 | fi | 
|  | 175 | fi | 
| Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 176 |  | 
| Kashyap Chamarthy | 90bc586 | 2015-12-01 18:04:40 +0100 | [diff] [blame] | 177 | if  [[ "$os_VENDOR" == "Fedora" ]] && [[ "$os_RELEASE" -ge "22" ]]; then | 
| Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 178 | # requests ships vendored version of chardet/urllib3, but on | 
|  | 179 | # fedora these are symlinked back to the primary versions to | 
|  | 180 | # avoid duplication of code on disk.  This is fine when | 
|  | 181 | # maintainers keep things in sync, but since devstack takes | 
|  | 182 | # over and installs later versions via pip we can end up with | 
|  | 183 | # incompatible versions. | 
|  | 184 | # | 
|  | 185 | # The rpm package is not removed to preserve the dependent | 
|  | 186 | # packages like cloud-init; rather we remove the symlinks and | 
|  | 187 | # force a re-install of requests so the vendored versions it | 
|  | 188 | # wants are present. | 
|  | 189 | # | 
|  | 190 | # Realted issues: | 
|  | 191 | # https://bugs.launchpad.net/glance/+bug/1476770 | 
|  | 192 | # https://bugzilla.redhat.com/show_bug.cgi?id=1253823 | 
|  | 193 |  | 
| Mark Hamzy | 746e72d | 2015-10-14 13:42:18 -0500 | [diff] [blame] | 194 | base_path=$(get_package_path requests)/packages | 
| Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 195 | if [ -L $base_path/chardet -o -L $base_path/urllib3 ]; then | 
| Mark Hamzy | 746e72d | 2015-10-14 13:42:18 -0500 | [diff] [blame] | 196 | sudo rm -f $base_path/{chardet,urllib3} | 
| Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 197 | # install requests with the bundled urllib3 to avoid conflicts | 
|  | 198 | pip_install --upgrade --force-reinstall requests | 
|  | 199 | fi | 
|  | 200 | fi | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 201 | fi | 
| Vigneshvar.A.S | 834b804 | 2015-02-14 01:05:55 +0530 | [diff] [blame] | 202 |  | 
|  | 203 | # The version of pip(1.5.4) supported by python-virtualenv(1.11.4) has | 
| Kenneth Giusti | df6c1ff | 2016-07-07 09:28:58 -0400 | [diff] [blame] | 204 | # connection issues under proxy so re-install the latest version using | 
|  | 205 | # pip. To avoid having pip's virtualenv overwritten by the distro's | 
|  | 206 | # package (e.g. due to installing a distro package with a dependency | 
|  | 207 | # on python-virtualenv), first install the distro python-virtualenv | 
|  | 208 | # to satisfy any dependencies then use pip to overwrite it. | 
|  | 209 |  | 
| Ian Wienand | 2d57f93 | 2017-08-03 14:35:37 +1000 | [diff] [blame] | 210 | # ... but, for infra builds, the pip-and-virtualenv [1] element has | 
|  | 211 | # already done this to ensure the latest pip, virtualenv and | 
|  | 212 | # setuptools on the base image for all platforms.  It has also added | 
|  | 213 | # the packages to the yum/dnf ignore list to prevent them being | 
|  | 214 | # overwritten with old versions.  F26 and dnf 2.0 has changed | 
|  | 215 | # behaviour that means re-installing python-virtualenv fails [2]. | 
|  | 216 | # Thus we do a quick check if we're in the infra environment by | 
|  | 217 | # looking for the mirror config script before doing this, and just | 
|  | 218 | # skip it if so. | 
|  | 219 |  | 
|  | 220 | # [1] https://git.openstack.org/cgit/openstack/diskimage-builder/tree/ \ | 
|  | 221 | #        diskimage_builder/elements/pip-and-virtualenv/ \ | 
|  | 222 | #            install.d/pip-and-virtualenv-source-install/04-install-pip | 
|  | 223 | # [2] https://bugzilla.redhat.com/show_bug.cgi?id=1477823 | 
|  | 224 |  | 
|  | 225 | if [[ ! -f /etc/ci/mirror_info.sh ]]; then | 
|  | 226 | install_package python-virtualenv | 
|  | 227 | pip_install -U --force-reinstall virtualenv | 
|  | 228 | fi |