Fix: Use lf-activate-venv to install openstack dep
[releng/global-jjb.git] / shell / openstack-stack-create.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017, 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> Create HEAT stack"
12
13 os_cloud="${OS_CLOUD:-vex}"
14 stack_name="${OS_STACK_NAME}"
15 stack_template="${OS_STACK_TEMPLATE}"
16 stack_template_dir="/opt/ciman/${OS_STACK_TEMPLATE_DIR:-openstack-hot}"
17 stack_parameters="$WORKSPACE/stack-parameters.yaml"
18
19 set -eux -o pipefail
20
21 # shellcheck disable=SC1090
22 source ~/lf-env.sh
23
24 # Check if openstack venv was previously created
25 if [ -f "/tmp/.os_lf_venv" ]; then
26     os_lf_venv=$(cat "/tmp/.os_lf_venv")
27 fi
28
29 if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then
30     echo "Re-use existing venv: ${os_lf_venv}"
31     PATH=$os_lf_venv/bin:$PATH
32 else
33     lf-activate-venv --python python3 "cryptography<3.4" \
34         "lftools[openstack]" \
35         kubernetes \
36         "niet~=1.4.2" \
37         python-heatclient \
38         python-openstackclient \
39         python-magnumclient \
40         setuptools \
41         "openstacksdk<0.99" \
42         yq
43 fi
44 openstack --os-cloud "$os_cloud" limits show --absolute
45
46 pushd "$stack_template_dir" || exit 1
47 lftools openstack --os-cloud "$os_cloud" stack create \
48     "$stack_name" "$stack_template" "$stack_parameters"
49 popd