swift使用reseller角色来设置container的quota



keystone role-create --name=reseller

keystone tenant-create --name testreseller --description "testTenant" --enabled true
keystone user-create --name=testreseller --pass=testreseller
keystone user-role-add --user=testreseller --tenant=testreseller --role=swiftDevRole

keystone user-role-add --user=testreseller --tenant=testreseller --role=reseller



 curl -d '{"auth": {"tenantName": "testreseller", "passwordCredentials":{"username": "testreseller", "password": "testreseller"}}}' -H "Content-type: application/json" http://192.168.81.158:5000/v2.0/tokens
    #设置环境变量。
    export STORAGE_URL=http://192.168.81.158:8080/v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1
    export TOKEN_ID=dc31a565a57f450e9900cb9bb08e60cc

#设置account的meta,提示报错。说明reseller角色不能设置account的quota,只能ResellerAdmin角色才可以设置account的quota.
 curl -d '' -H "X-Auth-Token:${TOKEN_ID}" -H "X-Account-Meta-Quota-Bytes: 560992" "${STORAGE_URL}"  
<html><h1>Forbidden</h1><p>Access was denied to this resource.</p></html>[houzhizhen@HOUZHIZHEN temp1]$

#创建testContainer容器。
curl -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer"
 curl -d '' -H "X-Auth-Token:${TOKEN_ID}" -H "X-Container-Meta-Quota-Bytes: 20000000" "${STORAGE_URL}/testContainer"  


  curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer/10_2mfile" -T 10mfile

* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> PUT /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer/10_2mfile HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> Content-Length: 10485760
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Last-Modified: Thu, 15 May 2014 02:08:47 GMT
< Content-Length: 0
< Etag: 6fbfcf47ebe4358fda67c50adde8582f
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx9855a3e4daa94d0597220-00537421ae
< Date: Thu, 15 May 2014 02:08:47 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0


curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer/10_1mfile" -T 10mfile

* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> PUT /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer/10_1mfile HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> Content-Length: 10485760
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Last-Modified: Thu, 15 May 2014 02:08:53 GMT
< Content-Length: 0
< Etag: 6fbfcf47ebe4358fda67c50adde8582f
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx1a9fd3db14884f9f90580-00537421b4
< Date: Thu, 15 May 2014 02:08:52 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0


  curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer/10_3mfile" -T 10mfile

* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> PUT /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer/10_3mfile HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> Content-Length: 10485760
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Last-Modified: Thu, 15 May 2014 02:09:00 GMT
< Content-Length: 0
< Etag: 6fbfcf47ebe4358fda67c50adde8582f
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx8876b6aca2c44a1286077-00537421bb
< Date: Thu, 15 May 2014 02:08:59 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0


 curl -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer/"

10_1mfile
10_2mfile
10_3mfile


 curl -v -d '' -H "X-Auth-Token:${TOKEN_ID}" -H "X-Container-Meta-Quota-Bytes: 20000000" "${STORAGE_URL}/testContainer"  

* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> POST /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> X-Container-Meta-Quota-Bytes: 20000000
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: txbfe239f445184eb49f67b-00537421e0
< Date: Thu, 15 May 2014 02:09:36 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0


curl --head -H "X-Auth-Token:${TOKEN_ID}" -H "X-Container-Meta-Quota-Bytes: 20000000" "${STORAGE_URL}/testContainer"  

HTTP/1.1 204 No Content
Content-Length: 0
X-Container-Object-Count: 3
Accept-Ranges: bytes
X-Timestamp: 1400119701.34437
X-Container-Bytes-Used: 31457280
Content-Type: text/plain; charset=utf-8
X-Container-Meta-Quota-Bytes: 20000000
X-Trans-Id: tx857dd6d1a2194ad8a7849-00537421fa
Date: Thu, 15 May 2014 02:10:02 GMT

#创建container
 curl -v -d '' -H "X-Auth-Token:${TOKEN_ID}"  "${STORAGE_URL}/testContainer"  
* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> POST /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx015c2be4fc274a16bd021-005374224b
< Date: Thu, 15 May 2014 02:11:23 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0

#查看container元数据,说明不是quota发生作用不是即时的。
 curl --head -H "X-Auth-Token:${TOKEN_ID}"  "${STORAGE_URL}/testContainer"  
HTTP/1.1 204 No Content
Content-Length: 0
X-Container-Object-Count: 3
Accept-Ranges: bytes
X-Timestamp: 1400119701.34437
X-Container-Bytes-Used: 31457280
Content-Type: text/plain; charset=utf-8
X-Container-Meta-Quota-Bytes: 20000000
X-Trans-Id: txf42436c682a842479f519-0053742255
Date: Thu, 15 May 2014 02:11:33 GMT


#上传文件,显示不成功。
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer/10_4mfile" -T 10mfile
* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> PUT /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer/10_4mfile HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:01df62e4b41d46d7a0ebd357e2e3061c
> Content-Length: 10485760
> Expect: 100-continue
>
< HTTP/1.1 413 Request Entity Too Large
< Content-Length: 21
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx3ab17dbf1d40468dbb3b1-005374226f
< Date: Thu, 15 May 2014 02:11:59 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0

#使用ResellerAdmin角色的test的用户设置testreseller的account quota.
curl -d '' -H "X-Auth-Token:${TOKEN_ID}"  -H "X-Account-Meta-Quota-Bytes: 50000000" "http://192.168.81.158:8080/v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1"  

#使用testreseller帐户
 curl -d '{"auth": {"tenantName": "testreseller", "passwordCredentials":{"username": "testreseller", "password": "testreseller"}}}' -H "Content-type: application/json" http://192.168.81.158:5000/v2.0/tokens
    #设置环境变量。
    export STORAGE_URL=http://192.168.81.158:8080/v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1
    export TOKEN_ID=01df62e4b41d46d7a0ebd357e2e3061c


 curl --head -H "X-Auth-Token:${TOKEN_ID}"  "${STORAGE_URL}"  
HTTP/1.1 204 No Content
Content-Length: 0
X-Account-Container-Count: 1
X-Account-Object-Count: 0
X-Timestamp: 1400119701.27879
X-Account-Bytes-Used: 0
X-Account-Meta-Quota-Bytes: 50000000
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
X-Trans-Id: txd44346f397a947ec96caf-00537424df
Date: Thu, 15 May 2014 02:22:23 GMT

curl -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1"
#上传5个10M会成功,因为account的X-Account-Bytes-Used不会即时更新。
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_1mfile" -T 10mfile
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_2mfile" -T 10mfile
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_3mfile" -T 10mfile
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_4mfile" -T 10mfile
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_5mfile" -T 10mfile
curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/10_6mfile" -T 10mfile
#上传100m文件,会不成功。

curl -v -X PUT -H "X-Auth-Token:${TOKEN_ID}" "${STORAGE_URL}/testContainer1/100_1mfile" -T 100mfile
* About to connect() to 192.168.81.158 port 8080 (#0)
*   Trying 192.168.81.158... connected
* Connected to 192.168.81.158 (192.168.81.158) port 8080 (#0)
> PUT /v1/AUTH_e2e0947b070c4a48ae2d6079e27d7cd1/testContainer1/100_1mfile HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.81.158:8080
> Accept: */*
> X-Auth-Token:acc89c8df43948fe8e0a7a87b1b35293
> Content-Length: 104857600
> Expect: 100-continue
>
< HTTP/1.1 413 Request Entity Too Large
< Content-Length: 108
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx1e13dc86af6849fe9ca23-0053743949
< Date: Thu, 15 May 2014 03:49:29 GMT
<
* Connection #0 to host 192.168.81.158 left intact
* Closing connection #0

<html><h1>Request Entity Too Large</h1><p>The body of your request was too large for this server.</p></html>


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值