Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 31 additions & 53 deletions charts/files/operator_dashboard.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": {},
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "10.4.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
Expand All @@ -49,7 +18,7 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"id": 43,
"links": [],
"panels": [
{
Expand All @@ -68,7 +37,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"description": "",
"fieldConfig": {
Expand Down Expand Up @@ -155,7 +124,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -172,7 +141,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand Down Expand Up @@ -204,7 +173,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"description": "",
"fieldConfig": {
Expand Down Expand Up @@ -250,8 +219,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -291,7 +259,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand Down Expand Up @@ -325,7 +293,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"description": "",
"fieldConfig": {
Expand Down Expand Up @@ -371,8 +339,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -412,7 +379,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -428,7 +395,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand Down Expand Up @@ -462,7 +429,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"description": "",
"fieldConfig": {
Expand Down Expand Up @@ -508,8 +475,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -549,7 +515,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -566,7 +532,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -591,10 +557,14 @@
"list": [
{
"allValue": "",
"current": {},
"current": {
"selected": false,
"text": "5fcc12ae-513f-4eac-a2e0-e7772f191282",
"value": "5fcc12ae-513f-4eac-a2e0-e7772f191282"
},
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"definition": "label_values(coral_credits_allocation_hours_per_project,project_id)",
"hide": 0,
Expand All @@ -615,10 +585,18 @@
"type": "query"
},
{
"current": {},
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"definition": "label_values(coral_credits_allocation_hours_per_project,resource_class)",
"hide": 2,
Expand Down
59 changes: 20 additions & 39 deletions charts/files/user_dashboard.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": {},
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "10.4.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
Expand All @@ -49,13 +18,13 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"id": 42,
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"description": "",
"fieldConfig": {
Expand Down Expand Up @@ -142,7 +111,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -158,7 +127,7 @@
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "builder",
Expand All @@ -183,10 +152,14 @@
"list": [
{
"allValue": "",
"current": {},
"current": {
"selected": false,
"text": "5fcc12ae-513f-4eac-a2e0-e7772f191282",
"value": "5fcc12ae-513f-4eac-a2e0-e7772f191282"
},
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"definition": "label_values(coral_credits_allocation_hours_per_project,project_id)",
"hide": 0,
Expand All @@ -207,10 +180,18 @@
"type": "query"
},
{
"current": {},
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
"uid": "prometheus"
},
"definition": "label_values(coral_credits_allocation_hours_per_project,resource_class)",
"hide": 2,
Expand Down
61 changes: 61 additions & 0 deletions tools/scripts/add-credits-to-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
set -eu

SITE="https://credits.apps.staging.hpc.cam.ac.uk"


# Set up some variables
CONTENT_TYPE="Content-Type: application/json"

TOKEN="CHANGE THIS AFTER REDEPLOY"
Copy link
Member

@JohnGarbutt JohnGarbutt Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change these to required params for the script please? Or maybe just a required env variable, in the case of the token?


AUTH_HEADER="Authorization: Bearer $TOKEN"

# rcp-azimuth-cloud-portal-dev
PROJECT_ID="79b2c7925276436091fa9301c4b05fd2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, lets make this a script parameter.


# 3. Add an account
echo "Adding an account:"
ACCOUNT_ID=$(curl -s -X POST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" -d \
'{
"name": "Tes1452 Account",
"email": "[email protected]"
}' \
$SITE/account/ | jq -r '.url')
echo "Account URL: $ACCOUNT_ID"

PROVIDER_ID="$SITE/resource_provider/1/"

echo "Adding a resource provider account:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this script fails when the account already exists, I think we need to make the script idempotent, ideally.

RPA_ID=$(curl -s -X POST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" -d \
"{
\"account\": \"$ACCOUNT_ID\",
\"provider\": \"$PROVIDER_ID\",
\"project_id\": \"$PROJECT_ID\"
}" \
$SITE/resource_provider_account/| jq -r '.id')
echo "Resource Provider Account ID: $RPA_ID"

START_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
END_DATE=$(date -u -d "+30 day" +"%Y-%m-%dT%H:%M:%SZ")
# 5. Add some credit allocation
echo "Adding credit allocation:"
ALLOCATION_ID=$(curl -s -X POST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" -d \
"{
\"name\": \"Test Allocation\",
\"account\": \"$ACCOUNT_ID\",
\"start\": \"$START_DATE\",
\"end\": \"$END_DATE\"
}" \
$SITE/allocation/ | jq -r '.id')
echo "Credit Allocation ID: $ALLOCATION_ID"

# 6. Add allocation to resource
echo "Adding allocation to resources:"
curl -s -X POST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" -d \
"{
\"VCPU\": 10000,
\"MEMORY_MB\": 24000000,
\"DISK_GB\": 50000
}" \
$SITE/allocation/$ALLOCATION_ID/resources/
Loading