Getting & Setting a storage quota via cURL in gateway

The easiest way to set and get quotas per domain or tenants is via the content portal as detailed here.

https://perifery.atlassian.net/wiki/spaces/public/pages/2443818631

However if you have a batch of domains that you need to set a quota on or if you have a regular check that you want to report the management api is there to give you a hand.

https://perifery.atlassian.net/wiki/spaces/public/pages/2443822511

 

How to get the status of Quotas

In the docs this is what is written to check wether the feature is enabled at all , do this first with the user that you are attempting to perform quota checks with.

The permission rquired is ListDomain ,

GET /_admin/manage/quota/status

translated to cURL

curl -iL -u <user>:<password> 'http://<gateway-ip>:<gateway-port>/_admin/manage/quota/status'

the expected output for that would be

HTTP/1.1 200 OK Date: Mon, 24 Apr 2023 15:36:44 GMT Content-Type: application/json Server: Cloud Gateway SCSP/7.10.4 Gateway-Request-Id: 34A21DA7ADAAFB8E Gateway-Manage-API-Version: 2.0 Content-Length: 47 {"queueSize":1,"stateChanges":1,"enabled":true}

How to check on a single domain

 

The permission required at a userlevel on the domain / bucket or tenant that you are querying here is GetQuota

The api spec is like this

HEAD /_admin/manage/tenants/{T}/ quota/check domains/{D}/quota/check domains/{D}/buckets/{B}/quota/check

What we would do in a query would be like the below.

In this scenario the 10.42.0.63 address is my gateway and the 8084 port is my SCSP endpoint.

curl -IL -u <user>:<password> http://10.42.0.63:8084/_admin/manage/tenants/<tenant>/domains/<domain>/quota/check

cURL -IL is a head request.

if we just wanted to check the tenant quota the request for a tenant named tenant1 would look like this.

curl -IL -u <user>:<password> http://10.42.0.63:8084/_admin/manage/tenants/tenant1/quota/check

 

for a domain in tenant1 called domain1 the request would look like this

curl -IL -u <user>:<password> http://10.42.0.63:8084/_admin/manage/tenants/tenant1/domains/domain1/quota/check

The output for a quota check looks like this.

Date: Tue, 25 Apr 2023 08:42:27 GMT Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0 x-caringo-meta-quota-state: ok Content-Type: application/json Server: Cloud Gateway SCSP/7.10.4 Gateway-Request-Id: 1AFB9FB1D5017843 Gateway-Manage-API-Version: 2.0 Content-Length: 0 HTTP/1.1 200 OK

note the header output

x-caringo-meta-quota-state: ok


Quota Metric Check

curl -IL -u periferyadmin:Datacore1! http://10.42.0.63:8084/_admin/manage/tenants/_system/domains/avi-transporter-mk1.local/quota/storage

response

Date: Tue, 25 Apr 2023 08:42:28 GMT Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0 x-caringo-meta-quota-storage-limit: nowrite; 10737418240 x-caringo-meta-quota-storage-current: ok; 0; 2023-04-24T15:36:44.744Z x-caringo-meta-quota-email: no@email.com Content-Type: application/json Server: Cloud Gateway SCSP/7.10.4 Gateway-Request-Id: C17B962FBAE8FA2A Gateway-Manage-API-Version: 2.0 Content-Length: 0 HTTP/1.1 200 OK

note the headers in the response.

x-caringo-meta-quota-storage-limit: nowrite; 10737418240 x-caringo-meta-quota-storage-current: ok; 0; 2023-04-24T15:36:44.744Z x-caringo-meta-quota-email: no@email.com

The storage-limit and action here are the value to pay attention to.

The action on hitting the limit is nowrite and the size is 10GB the value is reported in Bytes 10737418240 = 10GB

 

Setting a storage limit

The api for a storage limit looks like this

PUT /_admin/manage/tenants/{T}/ quota/{M}/limit domains/{D}/quota/{M}/limit domains/{D}/buckets/{B}/quota/{M}/limit

translated to cURL →

curl -L -X PUT -u <user>:<password> "http://10.42.0.63:8084/_admin/manage/tenants/tenant1/domains/domain1/quota/storage/limit?limit=10GB&state=nowrite"

Note that the email field is a separate request.

System Tenant

In many scenarios multi tenancy may not be required for a cluster and often the System Tenant is what is used. In this case you can still use quotas but requests like this

curl -L -X PUT -u <user>:<password> "http://10.42.0.63:8084/_admin/manage/tenants/SYSTEM TENANT/domains/domain1/quota/storage/limit?limit=10GB&state=nowrite"

or this

curl -L -X PUT -u <user>:<password> "http://10.42.0.63:8084/_admin/manage/tenants/SYSTEM%20TENANT/domains/domain1/quota/storage/limit?limit=10GB&state=nowrite"

will fail

That is because the system tenant has a special path in the management api.

_system

So if your domain is in the system tenant and not in a named tenant you can use this kind of cURL call.

curl -L -X PUT -u <user>:<password> "http://10.42.0.63:8084/_admin/manage/tenants/_system/domains/domain1/quota/storage/limit?limit=10GB&state=nowrite"

 

© DataCore Software Corporation. · https://www.datacore.com · All rights reserved.