Zhengtianbao's Home Page

swift set container quotas

License: CC BY-SA 4.0

开启swift container quotas

设置container quotas的入口是swift-proxy, 因此需要修改proxy-server.conf

[pipeline:main]
pipeline = ... account_quotas container_quotas proxy-server

[filter:account_quotas]
use = egg:swift#account_quotas

[filter:container_quotas]
use = egg:swift#container_quotas

两个egg可以在setup.cfg中找到对应的入口位置:

[entry_points]
...

paste.filter_factory =
    ...
    container_quotas = swift.common.middleware.container_quotas:filter_factory
    account_quotas = swift.common.middleware.account_quotas:filter_factory

修改完后只需要重启swift-proxy-server

API使用说明

  1. 设置quota:

    swift -A -U -K post -m quota-bytes:

  2. 查看某个container的quota:

    swift -A -U -K stat

  3. 删除某个container的quota:

    swift -A -U -K post -m quota-bytes:

    [[email protected] ~]# swift post test -m quota-bytes:5368709120
    [[email protected] ~]# swift stat test
             Account: 1d49717073724f61a66918841071767d
           Container: test
             Objects: 5
               Bytes: 5912
            Read ACL:
           Write ACL:
             Sync To:
            Sync Key:
    Meta Quota-Count: 10000
    Meta Quota-Bytes: 5368709120
       Accept-Ranges: bytes
    X-Storage-Policy: Policy-0
         X-Timestamp: 1436148388.51591
          X-Trans-Id: txdc240e7856da4319bfffa-005660f3be
        Content-Type: text/plain; charset=utf-8
    [[email protected] ~]# swift post test -m quota-bytes:

    
  1. 上传文件当容量不足时将返回错误码 413
    [[email protected] ~]# swift upload hello 3.cap 
    Object PUT failed: http://10.160.0.3:8080/v1/1d49717073724f61a66918841071767d/hello/3.cap 413 Request Entity Too Large   Upload exceeds quota
    

参考链接:

http://docs.openstack.org/juno/config-reference/content/object-storage-account-quotas.html

https://swiftstack.com/docs/admin/middleware/container_quotas.html