首页 > 代码库 > openstack API debug OpenstackEveryProject_CLI,curl_based
openstack API debug OpenstackEveryProject_CLI,curl_based
1,基于Openstack 每个服务组件client客户端,eg,nova 客户端软件包名称是python-novaclient,
别的都一样,把python-novaclient (nova替换成组件名称)
在使用组件客户端调用API前你必须得配置admin管理rc文件或是在调用时直接输入--os-auth-username= 个人感觉配置rc文件很方便,不知你是怎么认为的.
admin (superUser admin 的Rc文件)
Example,rc OS_AUTH_URL根据你的环境自行配置修改.
Example demo tenant
调用
....基于Openstack components 的各自CLI 调用调试OpenStack API自己根据man 来哦,Ruiy认为人贵于勤;
<二,基于curl调用Openstack components API>
1,基于租户的用户认证获取API(其实这里Ruiy又得说一句了,其实我们在调用API的过程中输入每个用户的token和TenantAuthenticate(TenantName/passwd))
关于租户UserCredential和project间的关系
Ruiy认为类似于svn下的项目和权限用户一样的概念;
1,基于curl调用API获取toekn
curl -i ‘http://5.10.124.181:5000/v2.0/tokens‘ -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ‘{"auth": {"tenantName": "demo", "passwordCredentials": {"username": "demo", "password": "321"}}}‘
2,not know tenantName or id,you can send an authentication request
with an empty tenant (基于passwordCredential获取租户id)
curl -i ‘http://5.10.124.181:5000/v2.0/tokens‘ -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ‘{"auth": {"tenantName": "", "passwordCredentials": {"username": "demo", "password": "321"}}}‘
3,Use the Identity API to request a list of tenants
curl -i http://5.10.124.181:5000/v2.0/tenants -X GET -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: 3be3f0b35ecf498596d79cdac92f8482"
4,Use the Identity API to request a list of endpoints
curl -i -X GET http://5.10.124.181:35357/v2.0/endpoints -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: 09e5cd53f9464b549ef40270ce050141"
Ruiy在此随便说点,关于每个OpenStack的endpointServiceCatalog的3个管理url
adminurl,internalurl,publicurl;
5,Use the Compute API to list servers
curl -v -H "X-Auth-Token:3da1d59d15354f299593f96ab0c1e135" http://5.10.124.181:8774/v2/f963230ce6d54dc2a4a7b42b3f9989b4/servers
基于Openstack 组件CLI调试API
组件客户端程序安装(使用pip(python index package)tool)
pip install [--upgrade] python-PROJECT
client (update更新repo,git repo) (upgrade,升级基于git repo安装的软件包的版本)
注意了升级一个软件包的完整命令是pip install --upgrade python-PROJECTclient 当然我们这里演示的是openstack 项目组件客户端程序的 安装及升级
卸载的 话
pip uninstall python-novaclient
Example,演示基于CLI命令launch an vm(VSI) instance
To launch instances, you must choose a name, an image, and a flavor for your instance(这里实例化一个VSI virtual server instance稍微和one有点不同,但也仅仅是基于命令行,基于web的展开虚机实例)
一样,即直接运行一个完整的镜像即可.
1,获取镜像
2,获取flavor
nova boot --image 2a20a472-b5dc-4565-b1a3-28978091d010 --flavor 3 my_instance
显示查看我们刚刚创建的虚机的详细的信息
查看rc environment variable
openstack API debug OpenstackEveryProject_CLI,curl_based