1.请求tokens
curl -d '{"auth":{"tenantName": "adminTenant", "passwordCredentials":{"username": "admin", "password": "admin"}}}' -H "Content-type: application/json" http://s1:5000/v2.0/tokens | python -mjson.tool
curl -d '{"auth":{"tenantName": "service", "passwordCredentials":{"username": "swift", "password": "swiftwxjxy"}}}' -H "Content-type: application/json" http://s1:5000/v2.0/tokens | python -mjson.tool
curl -d '{"auth":{"tenantName": "service", "passwordCredentials":{"username": "swift", "password": "SWIFT_PASS"}}}' -H "Content-type: application/json" http://hadoop131:5000/v2.0/tokens | python -mjson.tool
curl -d '{"auth":{"tenantName": "service", "passwordCredentials":{"username": "toon", "password": "toon"}}}' -H "Content-type: application/json" http://hadoop131:5000/v2.0/tokens | python -mjson.tool
curl -v -H 'X-Auth-Token:ccd8edf8d62a4494a2619c638f3d1cda' http://s1:8080/ curl -d '{"auth":{"tenantName": "service", "passwordCredentials":{"username": "swift", "password": "swiftwxjxy"}}}' -H "Content-type: application/json" http://s1:5000/v2.0/tokens | python -mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
117 1189 108 1189 0 105 4341 383 --:--:-- --:--:-- --:--:-- 3970
{
"access": {
"metadata": {
"is_admin": 0,
"roles": [
"9dec73a7c15f42acac4732bd0e2c625c"
]
},
"serviceCatalog": [
{
"endpoints": [
{
"adminURL": "http://172.28.19.249:8080",
"id": "10e9ff63a0d84723bdf1551b8a0fa3ea",
"internalURL": "http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681",
"publicURL": "http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681",
"region": "regionOne"
}
],
"endpoints_links": [],
"name": "swift",
"type": "object-store"
},
{
"endpoints": [
{
"adminURL": "http://172.28.19.249:35357/v2.0",
"id": "0d7d073354a4413eb4bf4fab00552177",
"internalURL": "http://172.28.19.249:5000/v2.0",
"publicURL": "http://172.28.19.249:5000/v2.0",
"region": "regionOne"
}
],
"endpoints_links": [],
"name": "keystone",
"type": "identity"
}
],
"token": {
"audit_ids": [
"mhex3978QaeqrNCw2SbprA"
],
"expires": "2017-03-31T10:33:33Z",
"id": "5bbecea611614591a61d9fb14eb28862",
"issued_at": "2017-03-31T09:33:33.598021",
"tenant": {
"description": "Service Tenant",
"enabled": true,
"id": "68c17b5d56aa49c9baad4d66d4e63681",
"name": "service"
}
},
"user": {
"id": "7b09c8d4d05046afb75c5f31860ceadf",
"name": "swift",
"roles": [
{
"name": "admin"
}
],
"roles_links": [],
"username": "swift"
}
}
}
2.接着就可以用获取到的token和Endpoint访问Swift服务了。
先用其中一个Endpoint(PC2)查看该Account的信息。
curl -v -H 'X-Auth-Token:a127f6438e494a15bb42492e9d2e9fb4' http://hadoop131:8082/v1/AUTH_82a98efa4e424c35bf8cf81692e5df33
curl -v -H 'X-Auth-Token:941ea5b0a1e54f6c84603725c054dfcc' http://s1:8080/v1/AUTH_54d3db64adfc4731b5222cac974f8bc5
curl -v -H 'X-Auth-Token:ce8592109c104e9181e253a6d6dd003e' http://hadoop131:8082/v1/AUTH_a7175ad88f0e41cd9b887a02fcd264fa
3.查看租户信息
curl -X HEAD -i -H 'X-Auth-Token: 8466f9ac5f6e467ab86f4b602876809b' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681
HTTP/1.1 204 No Content
Content-Type: text/plain; charset=utf-8
X-Account-Object-Count: 0
X-Timestamp: 1490953224.82666
X-Account-Bytes-Used: 0
X-Account-Container-Count: 0
X-Put-Timestamp: 1490953224.82666
Content-Length: 0
X-Trans-Id: tx56e89aebe5e542d391f77-0058de2408
Date: Fri, 31 Mar 2017 09:40:24 GMT
创建容器:
curl -i -X PUT -H 'X-Auth-Token:68c150d9ea1f43f7aa204abd81bcdb69' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681 /test
查看容器
curl -i -X GET -H 'X-Auth-Token:8466f9ac5f6e467ab86f4b602876809b' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681/bucket?limit=3
查看container的metadata
curl -i -X HEAD -H 'X-Auth-Token:8466f9ac5f6e467ab86f4b602876809b ' http://172.28.19.249:8080/v1 /AUTH_68c17b5d56aa49c9baad4d66d4e63681 /bucket
container的DELETE
curl -i -X DELETE -H 'X-Auth-Token:8466f9ac5f6e467ab86f4b602876809b ' http://172.28.19.249:8080/v1 /AUTH_68c17b5d56aa49c9baad4d66d4e63681 /test
上传:
time curl -k -i -X PUT -T "test.mp4" -H 'X-Auth-Token:8466f9ac5f6e467ab86f4b602876809b' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681/test/test.mp4
HTTP/1.1 100 Continue
HTTP/1.1 201 Created
Last-Modified: Wed, 05 Apr 2017 08:31:05 GMT
Content-Length: 0
Etag: 7207cc0d52572ba67307f0383b8a25a7
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx44ca9f7417e3440685ec1-0058e4ab48
Date: Wed, 05 Apr 2017 08:31:44 GMT
real 0m39.863s
user 0m0.131s
sys 0m1.396s
下载:
curl -k -X GET -H 'X-Auth-Token:965374a1d8e74cef9d5d5f2a86577c62' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681/test/test.mp4> install.log.backup
time curl -k -X GET -H 'X-Auth-Token:965374a1d8e74cef9d5d5f2a86577c62' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681/test/test.mp4> install.log.backup
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1783M 100 1783M 0 0 60.2M 0 0:00:29 0:00:29 --:--:-- 54.5M
real 0m31.019s
user 0m0.367s
sys 0m3.144s
time curl -H 'X-Auth-Token:965374a1d8e74cef9d5d5f2a86577c62' http://172.28.19.249:8080/v1/AUTH_68c17b5d56aa49c9baad4d66d4e63681/test/test.mp4> install.log.backup
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1783M 100 1783M 0 0 55.8M 0 0:00:31 0:00:31 --:--:-- 63.2M
real 0m32.440s
user 0m0.402s
sys 0m3.262s
swift:
1.统计
swift --os-auth-url=http://s1:5000/v2.0 --os-username=swift --os-tenant-name=service --os-password=swiftwxjxy stat