郁闷,之前写的一篇curl的文章怎么莫名其妙的没有了,简略记录一下:
第一步:拿到token
curl -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "xxx"}}}' -H "Content-type: application/json" http://xxx:5000/v2.0/tokens | python -m json.tool
"token": {
"audit_ids": [
"Gpwcp3fkTlO0WMKmor9wmQ"
],
"expires": "2015-03-20T01:23:38Z",
"id": "fc1b2493ba314c29a3c8f71a3eca665a",
"issued_at": "2015-03-20T00:23:38.989053",
"tenant": {
"description": "admin tenant",
"enabled": true,
"id": "d63f0cca2367489780c2e29e1034c02b",
"name": "admin"
}
},
第二步,根据token去call rest api:
curl -H "X-Auth-Token:fc1b2493ba314c29a3c8f71a3eca665a" http://xxx:6385/v1/ports/9f10c0b8-4400-4e04-8db0-e42c7f689425 | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 423 100 423 0 0 5134 0 --:--:-- --:--:-- --:--:-- 5158
{
"address": "xxxx",
"created_at": "2015-03-19T04:46:03+00:00",
"extra": {},
"links": [
{
"href": "http://xxxx:6385/v1/ports/9f10c0b8-4400-4e04-8db0-e42c7f689425",
"rel": "self"
},
{
"href": "http://xxxx:6385/ports/9f10c0b8-4400-4e04-8db0-e42c7f689425",
"rel": "bookmark"
}
],
"node_uuid": "8cdc7750-9d66-4353-ab3e-99fe82e739e2",
"updated_at": null,
"uuid": "9f10c0b8-4400-4e04-8db0-e42c7f689425"
}
curl的命令使用http://www.cnblogs.com/gbyukg/p/3326825.html 讲解还不错,基本用法都有了