From 8d337d56feae66c4602e7dc50f9a047f536c137a Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 22 May 2024 12:20:55 +0100 Subject: [PATCH] stackenv: Run through shellcheck, enable verbosity Signed-off-by: Stephen Finucane --- script/stackenv | 61 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/script/stackenv b/script/stackenv index e154dadd34..c23ea4831f 100644 --- a/script/stackenv +++ b/script/stackenv @@ -1,35 +1,60 @@ +#!/usr/bin/env bash + # Prep the testing environment by creating the required testing resources and # environment variables. This env is for CI jobs so you might need to modify # this according to your setup +set -euxo pipefail + DEVSTACK_PATH=${DEVSTACK_PATH:-/opt/stack/new/devstack} -pushd $DEVSTACK_PATH + +pushd "$DEVSTACK_PATH" + +set +u +# shellcheck disable=SC1091 source openrc admin admin -openstack flavor create m1.acctest --id 99 --ram 512 --disk 10 --vcpu 1 --ephemeral 10 -openstack flavor create m1.resize --id 98 --ram 512 --disk 11 --vcpu 1 --ephemeral 10 +set -u + +_FLAVOR_ID=99 +_FLAVOR_ALT_ID=98 +openstack flavor create m1.acctest --id "$_FLAVOR_ID" --ram 512 --disk 10 --vcpu 1 --ephemeral 10 +openstack flavor create m1.resize --id "$_FLAVOR_ALT_ID" --ram 512 --disk 11 --vcpu 1 --ephemeral 10 openstack keypair create magnum _NETWORK_ID=$(openstack network show private -c id -f value) _SUBNET_ID=$(openstack subnet show private-subnet -c id -f value) _EXTGW_ID=$(openstack network show public -c id -f value) _IMAGE=$(openstack image list | grep -i cirros | head -n 1) -_IMAGE_ID=$(echo $_IMAGE | awk -F\| '{print $2}' | tr -d ' ') -_IMAGE_NAME=$(echo $_IMAGE | awk -F\| '{print $3}' | tr -d ' ') -_MAGNUM_IMAGE_ID=$(openstack image list --format value -c Name -c ID | grep coreos | cut -d ' ' -f 1) -if [ -z "$_MAGNUM_IMAGE_ID" ]; then +_IMAGE_ID=$(echo "$_IMAGE" | awk -F\| '{print $2}' | tr -d ' ') +_IMAGE_NAME=$(echo "$_IMAGE" | awk -F\| '{print $3}' | tr -d ' ') + +cat > "openrc" <> "openrc" <> openrc -echo export OS_IMAGE_ID="$_IMAGE_ID" >> openrc -echo export OS_NETWORK_ID="$_NETWORK_ID" >> openrc -echo export OS_SUBNET_ID="$_SUBNET_ID" >> openrc -echo export OS_EXTGW_ID="$_EXTGW_ID" >> openrc -echo export OS_POOL_NAME="public" >> openrc -echo export OS_FLAVOR_ID=99 >> openrc -echo export OS_FLAVOR_ID_RESIZE=98 >> openrc -echo export OS_DOMAIN_ID=default >> openrc -echo export OS_MAGNUM_IMAGE_ID="$_MAGNUM_IMAGE_ID" >> openrc -echo export OS_MAGNUM_KEYPAIR=magnum >> openrc + +set +u +# shellcheck disable=SC1091 source openrc admin admin +set -u + if [[ "${OS_SYSTEM_SCOPE:-}" == "all" ]]; then unset PROJECT_NAME unset TENANT_NAME