From c4e45493866a5c5d1f780506446c4f63b0c15ea1 Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Tue, 1 Oct 2019 18:30:27 +0200 Subject: [PATCH] Add nolabs tokens api endpoint Change-Id: I4178cde2257defaafedbe3e34ffe1a5918f1ed34 --- jjb/nolabs/delete-booking.sh | 4 ++-- jjb/nolabs/handle-booking.sh | 10 +++++----- jjb/nolabs/nolabs-booking-jobs.yaml | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jjb/nolabs/delete-booking.sh b/jjb/nolabs/delete-booking.sh index 5dcea5b4..9a0053e9 100644 --- a/jjb/nolabs/delete-booking.sh +++ b/jjb/nolabs/delete-booking.sh @@ -19,8 +19,8 @@ openstack stack delete -y --wait $STACK_NAME echo "-------------------------------------------------" # get authentication token -echo "API Request: http --ignore-stdin POST http://188.212.108.245/api/tokens --auth dummy@dummy.com:dummy | jq -r '.token'" -NOLABS_TOKEN=$(http --ignore-stdin POST http://188.212.108.245/api/tokens --auth $NOLABS_API_USERNAME:$NOLABS_API_PASSWORD | jq -r '.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\"" diff --git a/jjb/nolabs/handle-booking.sh b/jjb/nolabs/handle-booking.sh index 15630106..b6b9066b 100644 --- a/jjb/nolabs/handle-booking.sh +++ b/jjb/nolabs/handle-booking.sh @@ -10,7 +10,7 @@ source $NOLABS_VENV/bin/activate > /dev/null pip install httpie > /dev/null # check if the booking is cancelled or not -echo "API Request: http --ignore-stdin GET $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID | jq -r '.status_text" +echo "API Request: http --ignore-stdin GET $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID | jq -r '.status_text'" BOOKING_STATUS=$(http --ignore-stdin GET $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID | jq -r '.status_text') if [[ $BOOKING_STATUS != 'new' ]]; then echo "Info: Booking is either cancelled or not valid! Exiting!" @@ -18,12 +18,12 @@ if [[ $BOOKING_STATUS != 'new' ]]; then fi # get authentication token -echo "API Request: http --ignore-stdin POST http://188.212.108.245/api/tokens --auth dummy@dummy.com:dummy | jq -r '.token'" -NOLABS_TOKEN=$(http --ignore-stdin POST http://188.212.108.245/api/tokens --auth $NOLABS_API_USERNAME:$NOLABS_API_PASSWORD | jq -r '.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') 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 "status_text=deploying" \ - "Authorization:Bearer $NOLABS_TOKEN" - + "Authorization:Bearer $NOLABS_TOKEN" + # get ssh public key of the user echo "API Request: http GET $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID | jq -r '.user_id'" NOLABS_USER_ID=$(http GET $NOLABS_API_BOOKINGS_ENDPOINT/$BOOKING_ID | jq -r '.user_id') diff --git a/jjb/nolabs/nolabs-booking-jobs.yaml b/jjb/nolabs/nolabs-booking-jobs.yaml index 3281466e..4923df6a 100644 --- a/jjb/nolabs/nolabs-booking-jobs.yaml +++ b/jjb/nolabs/nolabs-booking-jobs.yaml @@ -59,9 +59,11 @@ target-site: - 'test': + api-tokens-endpoint: 'http://188.212.108.245/api/tokens' api-users-endpoint: 'http://188.212.108.245/api/users' api-bookings-endpoint: 'http://188.212.108.245/api/bookings' - 'production': + api-tokens-endpoint: 'https://labs.nordix.org/api/tokens' api-users-endpoint: 'https://labs.nordix.org/api/users' api-bookings-endpoint: 'https://labs.nordix.org/api/bookings' @@ -100,6 +102,10 @@ name: DEPLOY_SCENARIO default: 'k8-mycoolplugin-mycoolfeature' description: 'Scenario to deploy for the booking. Default is a non-existent scenario to prevent running the job by mistake.' + - string: + name: NOLABS_API_TOKENS_ENDPOINT + default: '{api-tokens-endpoint}' + description: 'API endpoint for tokens.' - string: name: NOLABS_API_USERS_ENDPOINT default: '{api-users-endpoint}' -- 2.25.1