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 |
| 13 | source $NOLABS_VENV/bin/activate > /dev/null |
| 14 | pip install httpie python-openstackclient python-heatclient python-novaclient > /dev/null |
| 15 | source /tmp/openrc |
| 16 | |
| 17 | export STACK_NAME="nordix-nolabs-booking${BOOKING_ID}-${DEPLOY_SCENARIO}" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 18 | export KEYPAIR_NAME="keypair-${STACK_NAME}" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 19 | echo "Info: STACK_NAME is set to $STACK_NAME" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 20 | echo "Info: KEYPAIR_NAME is set to $KEYPAIR_NAME" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 21 | echo "Info: Deleting stack $STACK_NAME" |
| 22 | echo "-------------------------------------------------" |
| 23 | echo openstack stack delete -y --wait $STACK_NAME |
| 24 | openstack stack delete -y --wait $STACK_NAME |
| 25 | echo "-------------------------------------------------" |
Fatih Degirmenci | cc5e9e8 | 2019-10-01 19:56:51 +0200 | [diff] [blame] | 26 | echo "Info: Deleting keypair $KEYPAIR_NAME" |
| 27 | echo "-------------------------------------------------" |
| 28 | echo openstack keypair delete $KEYPAIR_NAME |
| 29 | openstack keypair delete $KEYPAIR_NAME |
| 30 | echo "-------------------------------------------------" |
Fatih Degirmenci | e921738 | 2019-10-01 16:41:46 +0200 | [diff] [blame] | 31 | |
| 32 | # get authentication token |
Fatih Degirmenci | c4e4549 | 2019-10-01 18:30:27 +0200 | [diff] [blame] | 33 | echo "API Request: http --ignore-stdin POST $NOLABS_API_TOKENS_ENDPOINT --auth dummy@dummy.com:dummy | jq -r '.token'" |
| 34 | 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] | 35 | |
| 36 | # update booking status |
| 37 | echo "API Request: http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \"status_text=deploying\" \"Authorization:Bearer DUMMY_TOKEN\"" |
| 38 | http --ignore-stdin PUT $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID \ |
Fatih Degirmenci | 02ae5ec | 2019-10-01 19:14:56 +0200 | [diff] [blame] | 39 | "Authorization:Bearer $NOLABS_TOKEN" \ |
| 40 | status_text=expired \ |
| 41 | floating_ip="N/A" |