Skip to content

Commit 3271169

Browse files
committed
Adds test console auth script
1 parent a060208 commit 3271169

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test-console-auth-api.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
4+
INSTANCE_ID=eaea9be1-d12f-47ea-ad79-7d73cedf0cea
5+
6+
TOKENS_RESP=`curl -s -k -X 'POST' $OS_AUTH_URL/tokens -d '{"auth":{"passwordCredentials":{"username": "'$OS_USERNAME'", "password":"'$OS_PASSWORD'"}, "tenantName":"'$OS_TENANT_NAME'"}}' -H 'Content-type: application/json'`
7+
TOKEN=`echo $TOKENS_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['access']['token']['id']"`
8+
NOVA_URL=`echo $TOKENS_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['access']['serviceCatalog'][0]['endpoints'][0]['adminURL']"`
9+
10+
CONSOLE_RESP=`curl -s -H "X-Auth-Token: $TOKEN" $NOVA_URL/servers/$INSTANCE_ID/action -X "POST" -H 'Content-type: application/json' -d '{"os-getVNCConsole":{"type":"novnc"}}'`
11+
12+
CONSOLE_URL=`echo $CONSOLE_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['console']['url']"`
13+
CONSOLE_TOKEN=`echo $CONSOLE_URL | sed -n 's/.*token\=\(.\+\)/\1/p'`
14+
15+
GET_CONSOLE_CONN_RESP=`curl -s -H "X-Auth-Token: $TOKEN" $NOVA_URL/servers/$INSTANCE_ID/action -X "POST" -H 'Content-type: application/json' -d '{"os-getConsoleConnectInfo":{"token":"'$CONSOLE_TOKEN'"}}'`
16+
17+
echo $GET_CONSOLE_CONN_RESP
18+
19+
HOST=`echo $GET_CONSOLE_CONN_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['host']"`
20+
PORT=`echo $GET_CONSOLE_CONN_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['port']"`
21+
INTERNAL_ACCESS_PATH=`echo $GET_CONSOLE_CONN_RESP | python -c "import json; import sys; d=json.load(sys.stdin); print d['internal_access_path']"`
22+
23+
echo "Host: $HOST"
24+
echo "Port: $PORT"
25+
echo "Internal_access_path: $INTERNAL_ACCESS_PATH"

0 commit comments

Comments
 (0)