xref: /spdk/test/openstack/install_devstack.sh (revision 307b8c112ffd90a26d53dd15fad67bd9038ef526)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../..)
5source "$rootdir/test/common/autotest_common.sh"
6
7function usage() {
8	[[ -n $2 ]] && (
9		echo "$2"
10		echo ""
11	)
12	echo "Devstack installation script"
13	echo "Usage: $(basename $1) [OPTIONS]"
14	echo "--branch=BRANCH    Define which version of openstack"
15	echo "                   should be installed. Default is master."
16	echo "-h, --help         Print help and exit"
17
18	exit 0
19}
20
21branch="master"
22while getopts 'h-:' optchar; do
23	case "$optchar" in
24		-)
25			case "$OPTARG" in
26				help) usage $0 ;;
27				branch=*) branch="${OPTARG#*=}" ;;
28			esac
29			;;
30		h) usage $0 ;;
31		*) usage $0 "Invalid argument '$OPTARG'" ;;
32	esac
33done
34
35if [[ -e /opt/stack/devstack/unstack.sh ]]; then
36	cd /opt/stack/devstack
37	su -c "./unstack.sh" -s /bin/bash stack
38fi
39
40mkdir -p /opt/stack
41rm -rf /opt/stack/*
42
43r=0
44until ((++r >= 20)); do
45	if [[ $branch == "master" ]]; then
46		git clone --depth 1 https://opendev.org/openstack-dev/devstack /opt/stack/devstack && break
47		# FIXME: Workaround for broken requirements with suds-jurko<->setuptools
48		export REQUIREMENTS_BRANCH=stable/xena
49	else
50		git clone --depth 1 https://opendev.org/openstack-dev/devstack -b "stable/$branch" /opt/stack/devstack && break
51	fi
52done
53
54# Check if we reached max retries count
55((r < 20))
56
57git clone https://github.com/openstack/os-brick.git /opt/stack/os-brick
58cd /opt/stack/os-brick
59python3 ./setup.py install
60
61cp $rootdir/scripts/vagrant/local.conf /opt/stack/devstack/local.conf
62
63# unset PYTHONPATH set by autotest_common.sh - keystone calls to stevedore's caching api and hits sys.path. In
64# our case the list includes $rootdir/scripts which stack user can't access due to lack of permissions.
65# Setting FORCE=yes allows stack.sh to run under distro versions which are not included in SUPPORTED_DISTROS.
66# This allows us to be more relaxed and run under a bit newer|older versions of the same distro (e.g. ubuntu)
67# in our CI.
68cd /opt/stack/devstack
69./tools/create-stack-user.sh
70chown -R stack:stack /opt/stack
71su -c "PYTHONPATH= FORCE=yes ./stack.sh" -s /bin/bash stack
72source openrc admin admin
73openstack volume type create SPDK --public
74
75if [[ $branch == master ]]; then
76	# FIXME: For some reason tempest won't work unless neutron has securitygroup enabled
77	# (even when testing with security_group disabled in tempest.conf). For the time
78	# being, until someone understands why this seem to be the case, patch the ml2 plugin
79	# config - instead of touching our local.conf which is still valid for the wallaby -
80	# to enable the securitygroup right before the tests start.
81	[[ -e /etc/neutron/plugins/ml2/ml2_conf.ini ]]
82	sed -i -e "s/enable_security_group = False/enable_security_group = True/g" /etc/neutron/plugins/ml2/ml2_conf.ini
83fi
84