| #!/bin/bash |
| set -o errexit |
| set -o nounset |
| set -o pipefail |
| |
| cd $WORKSPACE |
| |
| # install dependencies |
| sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" > /dev/null |
| sudo apt install -y virtualenv jq > /dev/null |
| /bin/rm -rf $NOLABS_VENV && mkdir -p $NOLABS_VENV |
| virtualenv -p python3 $NOLABS_VENV > /dev/null |
| set +u |
| source $NOLABS_VENV/bin/activate > /dev/null |
| set -u |
| pip install httpie python-openstackclient python-heatclient python-novaclient > /dev/null |
| source /tmp/openrc |
| |
| export STACK_NAME="nordix-nolabs-booking${BOOKING_ID}-${DEPLOY_SCENARIO}" |
| export KEYPAIR_NAME="keypair-${STACK_NAME}" |
| echo "Info: STACK_NAME is set to $STACK_NAME" |
| echo "Info: KEYPAIR_NAME is set to $KEYPAIR_NAME" |
| echo "Info: Deleting stack $STACK_NAME" |
| echo "-------------------------------------------------" |
| echo openstack stack delete -y --wait $STACK_NAME |
| openstack stack delete -y --wait $STACK_NAME |
| echo "-------------------------------------------------" |
| echo "Info: Deleting keypair $KEYPAIR_NAME" |
| echo "-------------------------------------------------" |
| echo openstack keypair delete $KEYPAIR_NAME |
| openstack keypair delete $KEYPAIR_NAME |
| echo "-------------------------------------------------" |
| |
| # get authentication token |
| echo "API Request: http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth dummy@dummy.com:dummy | jq -r '.token'" |
| NOLABS_TOKEN=$(http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth $NOLABS_API_USERNAME:$NOLABS_API_PASSWORD | jq -r '.token') |
| |
| # update booking status |
| echo "API Request: http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \"status_text=deploying\" \"Authorization:Bearer DUMMY_TOKEN\"" |
| http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \ |
| "Authorization:Bearer $NOLABS_TOKEN" \ |
| status_text=expired \ |
| floating_ip="N/A" |