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