码迷,mamicode.com
首页 > Windows程序 > 详细

利用OpenStack Rest API 创建镜像

时间:2015-05-25 16:02:04      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:

服务端点:

    image

API:

    POST     /v2/images

Request1:

    Method:Post

    Url: http://192.168.31.147:9292/v2/images

    Headers:

Content-Type: application/json
X-Auth-Token: 4e045ef71a994f8d8caeeab683a11419

    Body:

{
    "name": "registry:5000/centos:v1.0",
    "container_format": "docker",
    "disk_format": "raw"
}

Reponse1:

    Headers:

Status Code: 201 

    Body:

{
    "status": "queued",
    "name": "registry:5000/centos:v1.0",
    "tags": [],
    "container_format": "docker",
    "created_at": "2015-05-22T06:38:10Z",
    "disk_format": "raw",
    "updated_at": "2015-05-22T06:38:10Z",
    "visibility": "private",
    "self": "/v2/images/0482eff2-8406-46a7-8bbb-d43e1ca9c14f",
    "min_disk": 0,
    "protected": false,
    "id": "0482eff2-8406-46a7-8bbb-d43e1ca9c14f",
    "file": "/v2/images/0482eff2-8406-46a7-8bbb-d43e1ca9c14f/file",
    "owner": "67f095375f414c3b8fde844a5e08b88e",
    "min_ram": 0,
    "schema": "/v2/schemas/image"
}

 

Request2:

$ curl -i -X PUT -H "X-Auth-Token: 94f2b7bf4cee4f2c9d2bbe1f2ca785a2" -H "Content-Type: application/octet-stream"  --upload-file /home/centos.tar http://192.168.31.147:9292/v2/images/0482eff2-8406-46a7-8bbb-d43e1ca9c14f/file

Reponse2:

    Headers:

HTTP/1.1 100 Continue

HTTP/1.1 204 No Content
Content-Type: text/html; charset=UTF-8
Content-Length: 0
X-Openstack-Request-Id: req-98582037-dca6-4792-8d4a-a76d04464834
Date: Fri, 22 May 2015 06:38:47 GMT

 

    个人感想:Openstack官网对创建镜像的API描述真心的少啊,而且只有第一步,就是上文提到的request1。request2是笔者废了九牛二虎之力才找到的,且一开始数据源的上传用的是 -d @/home/centos.tar  这个选项,但是经过反复试验,这个选项TM上传文件不完整,800M的文件只能上传230M,反复查找问题也找不到,最终换成--upload-file选项,上传成功,且根据此镜像可正常启动实例。

 

    另外,对于curl 中 --upload-file选项该如何转变为正常的httpClient请求,笔者至今还没有头绪,请大家帮忙

 

利用OpenStack Rest API 创建镜像

标签:

原文地址:http://www.cnblogs.com/zhenyuyaodidiao/p/4527840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!