From 9035659931481baef2659445564f274a9a998e94 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Mon, 26 Mar 2018 12:02:41 +0100 Subject: [PATCH] mgr/dashboard: added script to execute backend API requests Example of usage: ``` $ ./run-backend-api-request.sh POST /api/rbd '{"name": "myimage2", "pool_name": "rbd", "size": 53687091200, "obj_size": 4194304, "features": ["exclusive-lock", "journaling", "layering"], "stripe_unit": null, "stripe_count": null, "data_pool": null}' $ ./run-backend-api-request.sh GET /api/rbd ``` Signed-off-by: Ricardo Dias --- .../mgr/dashboard/run-backend-api-request.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 src/pybind/mgr/dashboard/run-backend-api-request.sh diff --git a/src/pybind/mgr/dashboard/run-backend-api-request.sh b/src/pybind/mgr/dashboard/run-backend-api-request.sh new file mode 100755 index 00000000000..28876747638 --- /dev/null +++ b/src/pybind/mgr/dashboard/run-backend-api-request.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +CURR_DIR=`pwd` +cd ../../../../build +API_URL=`./bin/ceph mgr services 2>/dev/null | jq .dashboard | sed -e 's/"//g' -e 's!/$!!g'` +cd $CURR_DIR + +curl -s -c /tmp/cd-cookie.txt -H "Content-Type: application/json" -X POST -d '{"username":"admin","password":"admin"}' $API_URL/api/auth > /dev/null + +echo "API_ENDPOINT: $API_URL" +echo "METHOD: $1" +echo "PATH: $2" +echo "DATA: $3" +echo "" + +curl -s -b /tmp/cd-cookie.txt -H "Content-Type: application/json" -X $1 -d "$3" ${API_URL}$2 | jq -- 2.39.5