openstack restful 常用API

//验证接入是否成功
curl -s -X POST http://192.168.122.106:5000/v2.0/tokens   -H "Content-Type: application/json"   -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "futong"}}}'   | python -m json.tool
//flavor   b0c25687874947dfa9f1a1b4798aa04e->tokenid fd60f7ca67104404a92001c4e2fcee5b->项目id
curl -s -H "X-Auth-Token: b0c25687874947dfa9f1a1b4798aa04e"   http://controller:8774/v2/fd60f7ca67104404a92001c4e2fcee5b/flavors   | python -m json.tool
//images
curl -s -H "X-Auth-Token: b0c25687874947dfa9f1a1b4798aa04e"   http://controller:8774/v2/fd60f7ca67104404a92001c4e2fcee5b/images   | python -m json.tool
//servers instances
curl -s -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:8774/v2/fd60f7ca67104404a92001c4e2fcee5b/servers   | python -m json.tool
//users
curl -s -H "X-Auth-Token: 1b633654d90f435199f411d3ab5b7a78"   http://controller:5000/v3/users   | python -m json.tool
//domain


//project
curl -s -H "X-Auth-Token: 88648a0d04374be2ad23b34515a3f4d9"   http://controller:5000/v3/projects   | python -m json.tool
//network
curl -s -H "X-Auth-Token: fd60f7ca67104404a92001c4e2fcee5b"   http://controller:9696/v2.0/networks   | python -m json.tool
//extensions
curl -s -H "X-Auth-Token: a3a12eac648340d88c59cff06c7319e7"   http://controller:9696/v2.0/extensions   | python -m json.tool
//ports
curl -s -H "X-Auth-Token: a3a12eac648340d88c59cff06c7319e7"   http://controller:9696/v2.0/ports   | python -m json.tool
//floatingips
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/floatingips | python -m json.tool
//routers
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/routers | python -m json.tool
//subnetpools
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/subnetpools | python -m json.tool
//subnets
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/subnets | python -m json.tool
//Security group rules
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/security-group-rules | python -m json.tool
//Security groups
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/security-groups | python -m json.tool
//quotas
curl -s  -H "X-Auth-Token: 32044b734d7f4dab9e995db62333a44f"   http://controller:9696/v2.0/quotas | python -m json.tool
//search nova-compute 
curl -s -H "X-Auth-Token: 5ecde7ef8de948de823e3a03703f02da"   http://controller:8774/v2/fd60f7ca67104404a92001c4e2fcee5b/os-services?binary=nova-compute   | python -m json.tool


openstack 接入 用户名、密码验证,这有几点说明:
1.如果接入用户没有项目内(即没有租户,没有project),那么无法获得其他信息。
2.如果接入用户在项目内的角色不是管理员,同样没有权利获取其他信息
3.如果接入用户同时在多个项目内(在多个租户下),是否遍历所有信息;


// check ip port username password and get token
curl -s -X POST http://192.168.122.106:5000/v2.0/tokens   -H "Content-Type: application/json"   -d '{"auth": {"tenantName": "", "passwordCredentials": {"username": "admin", "password": "futong"}}}'   | python -m json.tool
//get tenants by token
curl -s -H "X-Auth-Token: 92896669f5b44783ba4b156e4bac4c6c"   http://controller:5000/v2.0/tenants   | python -m json.tool
//get token1  by tenantsname  again
curl -s -X POST http://192.168.122.106:5000/v2.0/tokens   -H "Content-Type: application/json"   -d '{"auth": {"tenantName": "", "passwordCredentials": {"username": "admin", "password": "futong"}}}'   | python -m json.tool
//get role by metadata roles is admin
curl -s -H "X-Auth-Token: 1688d2cef8114255a017e5c5eae931ca"   http://controller:5000/v3/roles/87895af3333d44ccb8f44e9616559e80   | python -m json.tool
//get 
{"auth": {"identity": {"methods": ["password"],"password": {"user": {"name": "admin","domain": {"name": "Default"},"password": "devstacker"}}}}}

你可能感兴趣的:(openstack)