I’m using Swift Grizzly Edition on Ubuntu 12.04 LTS.
To offer customers swift you need quotas and/or metric to check which resources your customers used last month. In this article I’ll show you how to setup the quota feature on the Grizzly version of Swift.
I’m assume that you have a running Swift cluster WITHOUT any errors
.
Step1: Change your proxy-server.conf
You need to expand your pipeline with the container and account quota filter.
[pipeline:main]
pipeline = catch_errors healthcheck proxy-logging cache slo tempurl ratelimit authtoken keystone s3token container-quotas account-quotas proxy-logging proxy-server
Now you need to define this both filters at the end of your file
[filter:container-quotas]
use = egg:swift#container_quotas[filter:account-quotas]
use = egg:swift#account_quotas
”’Attention”’
You need to put both filters after auth in the pipeline!
Add to your auth roles the ResellerAdmin role
[filter:keystone]
use = egg:swift#keystoneauth
operator_roles = admin, swiftoperator, ResellerAdmin
Finally swift-init proxy restart
Step2: Create Role
Only an user with the ResellerAdmin role can change the quotas of an account so you need to create a role with keystone and add this to your admin user
keystone role-create –name ResellerAdmin
keystone user-role-add –user admin –role ResellerAdmin –tenant [Customer Tenant]
Step3: Set the quotas
Now you must set the account quotas with the swift cli (or with http curl POST):
swift -V 2 -A https://KEYSTONE.URL:5000/v2.0 -U [CUSTOMER-TENANT]:admin -K [ADMIN-PW] post -m quota-bytes:100000
This are 97.6KB
Step4: Test your quotas
Create two testfiles to check if the quotas are set up correctly
dd if=/dev/zero of=test1.img count=10000 bs=700
10000+0 records in
10000+0 records out
7000000 bytes (7.0 MB) copied, 0.0181041 s, 387 MB/sdd if=/dev/zero of=test1.img count=100 bs=700
100+0 records in
100+0 records out
70000 bytes (70 kB) copied, 0.000393225 s, 178 MB/s
Now try to upload these files
swift -V 2 -A https://KEYSTONE.URL:5000/v2.0 -U [CUSTOMER_TENANT]:[CUSTOMER-USER] -K [PW] upload test test1.img
Object PUT failed: https://xxxx/test/test2.img 413 Request Entity Too Large [first 60 chars of response] ….swift -V 2 -A https://KEYSTONE.URL:5000/v2.0 -U [CUSTOMER_TENANT]:[CUSTOMER-USER] -K [PW] upload test test2.img
test2.imgswift -V 2 -A https://KEYSTONE.URL:5000/v2.0 -U [CUSTOMER_TENANT]:[CUSTOMER-USER] -K [PW] list test
test2.img
Congrats!