Merge "Update the Ubuntu 16.04 kubernetes images"
[releng/builder.git] / packer / provision / devstack-pre-pip.sh
index 936ac3bd1bbfd5aca8e4c616fe1ad7e2b3c3503f..8a910d972d4407f38cc2b5add60c2fcea2d5abb2 100644 (file)
@@ -1,7 +1,16 @@
 #!/bin/bash
 
+# force any errors to cause the script and job to end in failure
+set -xeu -o pipefail
+
+# Install xpath
+yum install -y perl-XML-XPath python-pip
+
+# install crudini command line tool for editing config files
+yum install -y crudini
+
 echo '---> Installing non-baseline requirements'
-yum install -y deltarpm python{,-{crypto,devel,lxml,setuptools}} \
+yum install -y deltarpm nc python{,-{crypto,devel,lxml,setuptools}} \
     @development {lib{xml2,xslt,ffi},openssl}-devel git wget
 
 echo '---> Updating net link setup'
@@ -11,28 +20,49 @@ fi
 
 echo '---> Pre-installing yum and pip packages'
 projs="requirements keystone glance cinder neutron nova horizon"
+# shellcheck disable=SC2154
 branch=${os_branch}
+# strip the "stable" off of the branch
+branch_name=$(cut -d'/' -f2 <<< "${branch}")
 
-wget https://bootstrap.pypa.io/get-pip.py
-python get-pip.py
+# Do not upgrade pip to v10. v10 does not allow uninstalling
+# distutils installed packages. This fails the openstack pip installs
+# below when it attempts to uninstall packages.
+# devstack patch that is trying to get pip 10 working:
+# https://review.openstack.org/#/c/561597/
+# wget https://bootstrap.pypa.io/get-pip.py
+# python get-pip.py
 
 mkdir tmp
 cd tmp
 
 git clone https://github.com/openstack-dev/devstack.git
-(cd devstack && git checkout ${branch})
+(cd devstack && git checkout "${branch}")
 sed -e 's/#.*//' devstack/files/rpms/general | xargs yum install -y
 
 base_url=https://github.com/openstack/
 for proj in $projs
 do
-    git clone ${base_url}${proj}
-    (cd ${proj} && git checkout ${branch})
-    pip install -c requirements/upper-constraints.txt -e ${proj}
-    pip install -c requirements/upper-constraints.txt -r ${proj}/test-requirements.txt
+    git clone "${base_url}${proj}"
+    (cd "${proj}" && git checkout "${branch}")
+    pip install -c requirements/upper-constraints.txt -e "${proj}"
+    pip install -c requirements/upper-constraints.txt -r "${proj}/test-requirements.txt"
 done
 
-cd $OLDPWD
+echo '---> Installing openvswitch from relevant openstack branch'
+yum install -y "centos-release-openstack-${branch_name}"
+
+# install 2.8.2 for queens.
+# 2.9.0 is the current version in openstack-queens, but it is buggy.
+# Remove this when https://review.rdoproject.org/r/#/c/13839/ merges and 2.9.2 is in the repo.
+yum repolist
+yum --showduplicates list openvswitch
+if [ "${branch}" == "stable/queens" ]; then
+    yum install -y --nogpgcheck openvswitch-2.8.2-1.el7
+else
+    yum install -y --nogpgcheck openvswitch
+fi
+cd "$OLDPWD"
 rm -fr tmp
 
 # vim: sw=4 ts=4 sts=4 et :