-
Notifications
You must be signed in to change notification settings - Fork 1
Helper scripts #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Helper scripts #24
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/ | ||
Uh oh!
There was an error while loading. Please reload this page.