blob: 32626dc0ea0e78a8a27939e39a425f0b27bcf955 [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
13source $NOLABS_VENV/bin/activate > /dev/null
14pip install httpie python-openstackclient python-heatclient python-novaclient > /dev/null
15source /tmp/openrc
16
17export STACK_NAME="nordix-nolabs-booking${BOOKING_ID}-${DEPLOY_SCENARIO}"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020018export KEYPAIR_NAME="keypair-${STACK_NAME}"
Fatih Degirmencie9217382019-10-01 16:41:46 +020019echo "Info: STACK_NAME is set to $STACK_NAME"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020020echo "Info: KEYPAIR_NAME is set to $KEYPAIR_NAME"
Fatih Degirmencie9217382019-10-01 16:41:46 +020021echo "Info: Deleting stack $STACK_NAME"
22echo "-------------------------------------------------"
23echo openstack stack delete -y --wait $STACK_NAME
24openstack stack delete -y --wait $STACK_NAME
25echo "-------------------------------------------------"
Fatih Degirmencicc5e9e82019-10-01 19:56:51 +020026echo "Info: Deleting keypair $KEYPAIR_NAME"
27echo "-------------------------------------------------"
28echo openstack keypair delete $KEYPAIR_NAME
29openstack keypair delete $KEYPAIR_NAME
30echo "-------------------------------------------------"
Fatih Degirmencie9217382019-10-01 16:41:46 +020031
32# get authentication token
Fatih Degirmencic4e45492019-10-01 18:30:27 +020033echo "API Request: http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth dummy@dummy.com:dummy | jq -r '.token'"
34NOLABS_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 +020035
36# update booking status
37echo "API Request: http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \"status_text=deploying\" \"Authorization:Bearer DUMMY_TOKEN\""
38http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \
Fatih Degirmenci02ae5ec2019-10-01 19:14:56 +020039 "Authorization:Bearer $NOLABS_TOKEN" \
40 status_text=expired \
41 floating_ip="N/A"