]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/run-backend-api-request.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / run-backend-api-request.sh
CommitLineData
11fdf7f2
TL
1#!/bin/bash
2
3CURR_DIR=`pwd`
9f95a23c
TL
4[ -z "$BUILD_DIR" ] && BUILD_DIR=build
5cd ../../../../${BUILD_DIR}
11fdf7f2
TL
6API_URL=`./bin/ceph mgr services 2>/dev/null | jq .dashboard | sed -e 's/"//g' -e 's!/$!!g'`
7if [ "$API_URL" = "null" ]; then
8 echo "Couldn't retrieve API URL, exiting..." >&2
9 exit 1
10fi
11cd $CURR_DIR
12
13TOKEN=`curl --insecure -s -H "Content-Type: application/json" -X POST \
14 -d '{"username":"admin","password":"admin"}' $API_URL/api/auth \
15 | jq .token | sed -e 's/"//g'`
16
17echo "METHOD: $1"
18echo "URL: ${API_URL}${2}"
19echo "DATA: $3"
20echo ""
21
22curl --insecure -s -b /tmp/cd-cookie.txt -H "Authorization: Bearer $TOKEN " \
23 -H "Content-Type: application/json" -X $1 -d "$3" ${API_URL}$2 | jq
24