blob: 42446dd75fe00123ae6f977db6494b514a8c8a8b [file] [log] [blame]
Fatih Degirmencie9217382019-10-01 16:41:46 +02001#!/bin/bash
Fatih Degirmencif5e2b332019-10-02 07:38:02 +02002set -o errexit
3set -o nounset
4set -o pipefail
Fatih Degirmencie9217382019-10-01 16:41:46 +02005
6cd $WORKSPACE
7
8# install dependencies
Fatih Degirmenci346bfa82019-10-01 20:13:47 +02009sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" > /dev/null
Fatih Degirmencie9217382019-10-01 16:41:46 +020010sudo apt install -y virtualenv jq > /dev/null
11/bin/rm -rf $NOLABS_VENV && mkdir -p $NOLABS_VENV
12virtualenv -p python3 $NOLABS_VENV > /dev/null
Fatih Degirmenci165f3f32019-10-02 08:14:38 +020013set +u
Fatih Degirmencie9217382019-10-01 16:41:46 +020014source $NOLABS_VENV/bin/activate > /dev/null
Fatih Degirmenci165f3f32019-10-02 08:14:38 +020015set -u
Fatih Degirmencie9217382019-10-01 16:41:46 +020016pip install httpie python-openstackclient python-heatclient python-novaclient > /dev/null
17source /tmp/openrc
18
19export STACK_NAME="nordix-nolabs-booking${BOOKING_ID}-${DEPLOY_SCENARIO}"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020020export KEYPAIR_NAME="keypair-${STACK_NAME}"
Fatih Degirmencie9217382019-10-01 16:41:46 +020021echo "Info: STACK_NAME is set to $STACK_NAME"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020022echo "Info: KEYPAIR_NAME is set to $KEYPAIR_NAME"
Fatih Degirmencie9217382019-10-01 16:41:46 +020023echo "Info: Deleting stack $STACK_NAME"
24echo "-------------------------------------------------"
Fatih Degirmenci552a75b2020-02-02 09:01:17 +010025echo openstack stack delete -y $STACK_NAME
26openstack stack delete -y $STACK_NAME
Fatih Degirmencie9217382019-10-01 16:41:46 +020027echo "-------------------------------------------------"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020028echo "Info: Deleting keypair $KEYPAIR_NAME"
29echo "-------------------------------------------------"
30echo openstack keypair delete $KEYPAIR_NAME
31openstack keypair delete $KEYPAIR_NAME
32echo "-------------------------------------------------"
Fatih Degirmencie9217382019-10-01 16:41:46 +020033
34# get authentication token
Fatih Degirmencic4e45492019-10-01 18:30:27 +020035echo "API Request: http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth dummy@dummy.com:dummy | jq -r '.token'"
36NOLABS_TOKEN=$(http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth $NOLABS_API_USERNAME:$NOLABS_API_PASSWORD | jq -r '.token')
Fatih Degirmencie9217382019-10-01 16:41:46 +020037
38# update booking status
39echo "API Request: http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \"status_text=deploying\" \"Authorization:Bearer DUMMY_TOKEN\""
40http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \
Fatih Degirmenci02ae5ec2019-10-01 19:14:56 +020041 "Authorization:Bearer $NOLABS_TOKEN" \
42 status_text=expired \
43 floating_ip="N/A"