xref: /spdk/test/openstack/install_devstack.sh (revision 2f5c602574a98ede645991abe279a96e19c50196)
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	else
48		git clone --depth 1 https://opendev.org/openstack-dev/devstack -b "stable/$branch" /opt/stack/devstack && break
49	fi
50done
51
52# Check if we reached max retries count
53((r < 20))
54
55git clone https://github.com/openstack/os-brick.git /opt/stack/os-brick
56cd /opt/stack/os-brick
57python3 ./setup.py install
58
59cp $rootdir/scripts/vagrant/local.conf /opt/stack/devstack/local.conf
60
61cd /opt/stack/devstack
62./tools/create-stack-user.sh
63chown -R stack:stack /opt/stack
64su -c "./stack.sh" -s /bin/bash stack
65source openrc admin admin
66openstack volume type create SPDK --public
67
68if [[ $branch == master ]]; then
69	# FIXME: For some reason tempest won't work unless neutron has securitygroup enabled
70	# (even when testing with security_group disabled in tempest.conf). For the time
71	# being, until someone understands why this seem to be the case, patch the ml2 plugin
72	# config - instead of touching our local.conf which is still valid for the wallaby -
73	# to enable the securitygroup right before the tests start.
74	[[ -e /etc/neutron/plugins/ml2/ml2_conf.ini ]]
75	sed -i -e "s/enable_security_group = False/enable_security_group = True/g" /etc/neutron/plugins/ml2/ml2_conf.ini
76fi
77