Account Quotas

Click on the Account Quotas link on the Manage Cluster page Middleware tab to enable and configure the Account Quotas middleware.

../../_images/account-quotas.png

Setting the limit in bytes

Pre-authenticate the superuser to get the token:

swift -A <auth_url> -U <superuser name> -K <superuser password> stat -v

$ swift -A http://swift.example.com/auth/v1.0 -U superman -K superman stat -v
StorageURL: http://swift.example.com/v1/AUTH_superman
Auth Token: AUTH_tkb5bab9e25a274b4a853fe2587b5dc8f9
   Account: AUTH_superman
Containers: 0
   Objects: 0
     Bytes: 0
Content-Type: text/plain; charset=utf-8
X-Timestamp: 1375225766.50237
X-Trans-Id: tx88ac2ec242fd4af6a1e3d-0051f847a6
X-Put-Timestamp: 1375225766.50237

Pre-authenticate the regular user to get the storage url:

swift -A <auth_url> -U <username> -K <password> stat -v

$ swift -A http://swift.example.com/auth/v1.0 -U bob -K bob stat -v
StorageURL: http://swift.example.com/v1/AUTH_bob
Auth Token: AUTH_tkb5bab9e25fe2587b5dc8f9a274b4a853
   Account: AUTH_bob
Containers: 0
   Objects: 0
     Bytes: 0
Content-Type: text/plain; charset=utf-8
X-Timestamp: 1375225766.50237
X-Trans-Id: tx42fd4af6a1e3d88ac2ec2-0051f847a6
X-Put-Timestamp: 1375225779.50263

swift --os-auth-token <token> --os-storage-url <storage_url> post -m quota-bytes:<value>

$ swift --os-auth-token AUTH_tkb5bab9e25a274b4a853fe2587b5dc8f9 \
    --os-storage-url http://swift.example.com/v1/AUTH_bob \
    post -m quota-bytes:307200

curl -i -H "X-Auth-Token: <token>" -H "X-Account-Meta-Quota-Bytes: <value>" -X PUT <storage_url>

curl -i -H "X-Auth-Token: AUTH_tk19023523c67c442ea9650d2813c627b4" -X PUT \
    https://swift.example.com/v1/AUTH_bob -H "X-Account-Meta-Quota-Bytes: 307200"
HTTP/1.1 201 Created
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txd4ea7d2b677946b3a889d-00520aba6c
Date: Tue, 13 Aug 2013 22:59:56 GMT

Exceeding the limit(s)

Using the swift command line client:

$ swift -A https://swift.example.com/auth/v1.0 -U bob -K bob upload cont2 one-hundred-k-file
Object PUT failed: https://swift.example.com:443/v1/AUTH_bob/cont2/one-hundred-k-file
413 Request Entity Too Large   Upload exceeds quota.

Or using curl:

$ curl -i -H "X-Auth-Token: AUTH_tk19023523c67c442ea9650d2813c627b4" -X PUT \
    http://swift.example.com/v1/AUTH_bob/by_bytes/18.txt \
    --data-binary @one-hundred-k-file
HTTP/1.1 413 Request Entity Too Large
Content-Length: 21
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txc7025b39394d43a682325-00520a968c
Date: Tue, 13 Aug 2013 20:26:52 GMT

Upload exceeds quota.