glance api 的实验(curl)

参考文档:
http://docs.openstack.org/api/openstack-image-service/1.0/content/requesting-detailed-metadata-on-public-vm-images.html
http://glance.openstack.org/glanceapi.html
http://glance.openstack.org/formats.html
1、登录、获取 token

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

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

2、glance的api实验

获取 images 列表
curl -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images |python -mjson.tool
获取 images列表(详情)
curl -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/detail |python -mjson.tool

可以使用 name, container_format, disk_format, status, size_min, size_max进行帅选
可以使用 sort_key 进行排序, sort_dir (asc, desc(缺省))决定正序、倒序

获取某个image的详细Metadata:
curl -I -X HEAD -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/32b518d8-2dcf-451a-9f8b-ccf5264e17f3
下载某个image, 和上面的方法,相差就是 HEAD和 GET 的方法区别:
curl -X GET -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/32b518d8-2dcf-451a-9f8b-ccf5264e17f3

删除某个image:
curl -X DELETE -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/258ad2d5-d48b-4f95-94f4-10e60ace6e67
查看 image 的Memberships:
curl -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/32b518d8-2dcf-451a-9f8b-ccf5264e17f3/members |python -mjson.tool

查看某个 tenant 共享的image:
curl -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/shared-images/admin |python -mjson.tool

增加某个成员共享:
curl -X PUT -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/32b518d8-2dcf-451a-9f8b-ccf5264e17f3/members/demo

缺省,can_share 是false,可以加入body:
{‘member’:
{‘can_share’: true}
}

删除某个成员共享:
curl -X DELETE -H “X-Auth-Token: 32efbc8c22af4ad6a8f03d051dc3413b” http://192.168.28.5:9292/v1/images/32b518d8-2dcf-451a-9f8b-ccf5264e17f3/members/demo

此条目发表在OpenStack分类目录,贴了, 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注