Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 1 | #!/bin/bash |
Fatih Degirmenci | f5e2b33 | 2019-10-02 07:38:02 +0200 | [diff] [blame] | 2 | set -o errexit |
| 3 | set -o nounset |
| 4 | set -o pipefail |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 5 | |
| 6 | cd $WORKSPACE |
| 7 | |
| 8 | # install dependencies |
Fatih Degirmenci | 346bfa8 | 2019-10-01 20:13:47 +0200 | [diff] [blame] | 9 | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" > /dev/null |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 10 | sudo apt install -y virtualenv jq > /dev/null |
| 11 | /bin/rm -rf $NOLABS_VENV && mkdir -p $NOLABS_VENV |
| 12 | virtualenv -p python3 $NOLABS_VENV > /dev/null |
Fatih Degirmenci | 165f3f3 | 2019-10-02 08:14:38 +0200 | [diff] [blame] | 13 | set +u |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 14 | source $NOLABS_VENV/bin/activate > /dev/null |
Fatih Degirmenci | 165f3f3 | 2019-10-02 08:14:38 +0200 | [diff] [blame] | 15 | set -u |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 16 | pip install httpie python-openstackclient python-heatclient python-novaclient > /dev/null |
| 17 | source /tmp/openrc |
| 18 | |
| 19 | export STACK_NAME="nordix-nolabs-booking${BOOKING_ID}-${DEPLOY_SCENARIO}" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 20 | export KEYPAIR_NAME="keypair-${STACK_NAME}" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 21 | echo "Info: STACK_NAME is set to $STACK_NAME" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 22 | echo "Info: KEYPAIR_NAME is set to $KEYPAIR_NAME" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 23 | echo "Info: Deleting stack $STACK_NAME" |
| 24 | echo "-------------------------------------------------" |
Fatih Degirmenci | 552a75b | 2020-02-02 09:01:17 +0100 | [diff] [blame^] | 25 | echo openstack stack delete -y $STACK_NAME |
| 26 | openstack stack delete -y $STACK_NAME |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 27 | echo "-------------------------------------------------" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 28 | echo "Info: Deleting keypair $KEYPAIR_NAME" |
| 29 | echo "-------------------------------------------------" |
| 30 | echo openstack keypair delete $KEYPAIR_NAME |
| 31 | openstack keypair delete $KEYPAIR_NAME |
| 32 | echo "-------------------------------------------------" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 33 | |
| 34 | # get authentication token |
Fatih Degirmenci | c4e4549 | 2019-10-01 18:30:27 +0200 | [diff] [blame] | 35 | echo "API Request: http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth dummy@dummy.com:dummy | jq -r '.token'" |
| 36 | NOLABS_TOKEN=$(http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth $NOLABS_API_USERNAME:$NOLABS_API_PASSWORD | jq -r '.token') |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 37 | |
| 38 | # update booking status |
| 39 | echo "API Request: http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \"status_text=deploying\" \"Authorization:Bearer DUMMY_TOKEN\"" |
| 40 | http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \ |
Fatih Degirmenci | 02ae5ec | 2019-10-01 19:14:56 +0200 | [diff] [blame] | 41 | "Authorization:Bearer $NOLABS_TOKEN" \ |
| 42 | status_text=expired \ |
| 43 | floating_ip="N/A" |