openstack keystone api 实验(curl)

openstack keystone api 实验(curl)


参考文档:

http://keystone.openstack.org/configuration.html

http://keystone.openstack.org/api_curl_examples.html

1、重要概念:

Admin Token
所有服务共享的一个密钥,如果设置不同,那些依赖keystone的服务将无法正常工作。

Tenants
做keystone里,Tenants 是一个高层次的组表示一组用户一个tenant 是一个小组,共同拥有 Nova里的虚拟机,或者Swift里的容器。一个tenant可以有一个或者多个用户,用户可以属于一个或者多个tenant,针对每个tenant,用户拥有一个角色(role)。
Tenants are the high level grouping within Keystone that represent groups of users. A tenant is the grouping that owns virtual machines within Nova, or containers within Swift. A tenant can have zero or more users, Users can be associated with more than one tenant, and each tenant – user pairing can have a role associated with it.

认证几个要素:tenants, users, roles

业务端口:5000
管理端口:35357
2、业务API 测试:

获取版本号:
curl http://0.0.0.0:5000/ | python -mjson.tool
curl http://0.0.0.0:5000/v2.0/ | python -mjson.tool

获取api扩展:
curl http://0.0.0.0:5000/v2.0/extensions | python -mjson.tool

用普通用户登录:
curl -X POST -d ‘{“auth”: {“passwordCredentials”:{“username”: “admin”, “password”: “nova”}}}’ -H “Content-type: application/json” http://0.0.0.0:5000/v2.0/tokens | python -mjson.tool

查看自己的租户:
curl -H “X-Auth-Token:614be856b02449439b116c0b28e94217″ http://0.0.0.0:5000/v2.0/tenants | python -mjson.tool

3、管理API测试:

获取版本号:
curl http://0.0.0.0:35357/ | python -mjson.tool
curl http://0.0.0.0:35357/v2.0/ | python -mjson.tool

获取api扩展:
curl http://0.0.0.0:35357/v2.0/extensions | python -mjson.tool

用角色 admin 登录:

curl -X POST -d ‘{“auth”: {“tenantId”: “6a524dbe23dd4e4ab672cd163c85a27d”, “passwordCredentials”:{“username”: “admin”, “password”: “nova”}}}’ -H “Content-type: application/json” http://0.0.0.0:35357/v2.0/tokens | python -mjson.tool

校验 token 的有效,并返回token的信息:
curl -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://0.0.0.0:35357/v2.0/tokens/82c8d77cac0a4fdba83b2191185ddb39 |python -mjson.tool

使用 HEAD校验,如果返回码是 20X, 表示 token 有效:
curl -I -H “X-Auth-Token: 5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/tokens/5a10b008add4435f8473d2b11d3ba8a8

这个api不对:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/tokens/5a10b008add4435f8473d2b11d3ba8a8/endpoints

返回租户:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/tenants|python -mjson.tool

返回某个租户:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/tenants/6a524dbe23dd4e4ab672cd163c85a27d |python -mjson.tool

返回用户:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/users|python -mjson.tool

返回某个用户:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/users/3ff8fbca9794436c996d8c6e41427530|python -mjson.tool

返回某个租户上,用户授予的角色:
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/tenants/6a524dbe23dd4e4ab672cd163c85a27d/users/3ff8fbca9794436c996d8c6e41427530/roles |python -mjson.tool

返回某个用户的角色:(出错,没有实现,参见 https://bugs.launchpad.net/keystone/+bug/933565)
curl -H “X-Auth-Token:5a10b008add4435f8473d2b11d3ba8a8″ http://0.0.0.0:35357/v2.0/users/3ff8fbca9794436c996d8c6e41427530/roles

你可能感兴趣的:(linux)