Loading
close

镜像

time 更新时间:2022-05-11 19:38:38

镜像列表查询

功能介绍

列出镜像列表。

URI

GET /v2/images

请求消息

参数 参数类型 是否必选 描述
changes-since string 根据镜像的最后更新时间过滤查询。
name string 根据镜像的名称过滤查询。
status string 根据镜像的状态进行过滤查询。
sort-key string 设置查询的排序依据
sort-dir string 设置排序的方向
type string 根据镜像类型进行过滤查询
limit integer 设置查询的最大限制

请求示例

GET /v2/images?limit=20&sort_key=name&sort_dir=asc

响应消息

参数 参数类型 描述
images array 镜像列表对象。
id string 镜像的UUID。
name string 镜像的名字。

响应示例

{
    "images": [
        {
            "id": "fake_image_id1",
            "links": [
                {
                    "href": "fake_href",
                    "rel": "self"
                },
                {
                    "href": "fake_href",
                    "rel": "bookmark"
                },
                {
                    "href": "fake_href",
                    "rel": "alternate",
                    "type": "application/vnd.openstack.image"
                }
            ],
            "name": "fakeimage7"
        },
        {
            "id": "fake_image_id2",
            "links": [
                {
                    "href": "fake_href",
                    "rel": "self"
                },
                {
                    "href": "fake_href",
                    "rel": "bookmark"
                },
                {
                    "href": "fake_href",
                    "rel": "alternate",
                    "type": "application/vnd.openstack.image"
                }
            ],
            "name": "fakeimage123456"
        }
}

正常响应代码

200

创建镜像

功能介绍

创建虚拟机镜像。

前提条件

  • 云平台服务正常。

    URI

    POST /v2/images

    请求消息

    参数 参数类型 是否必选 描述
    container_format enum 镜像容器格式。
    disk_format enum 镜像格式。
    id string 镜像ID,UUID格式。
    min_disk string 镜像要求的最小磁盘大小,单位GB。
    min_ram integer 镜像要求的最小内存大小,单位MB。
    name integer 镜像名称。
    protected boolean 镜像能否删除。
    tags array 镜像标签。
    visibility string 镜像对所有用户是否可见。

请求示例

创建一个镜像:

{
  "name": "fake_image",
  "container_format": "bare",
  "min_ram": 512,
  "disk_format": "qcow2",
  "visibility": "public",
  "min_disk": 1
}

响应消息

参数 参数类型 描述
location string 外部存储访问镜像文件的URI。
checksum string 镜像文件的哈希值。
created_at string 镜像创建时间。ISO8601时间格式。
file string 镜像文件的URI。
container_format enum 镜像容器格式。
disk_format enum 镜像格式。
id string 镜像ID,UUID格式。
min_disk string 镜像要求的最小磁盘大小,单位GB。
min_ram integer 镜像要求的最小内存大小,单位MB。
name integer 镜像名称。
protected boolean 镜像能否删除。
tags array 镜像标签。
visibility string 镜像对所有用户是否可见。
owner string 镜像租户。
schema string 描述镜像架构的URI。
self string 镜像的URI。
size integer 镜像大小。大于0。
status string 镜像状态。
update_at string 镜像更新时间。ISO8601时间格式。
virtual_size integer 镜像的虚拟大小,值可能为空。
locations array 描述镜像位置的对象列表。

响应示例

{
  "status": "queued",
  "name": "fake_image",
  "tags": [],
  "container_format": "bare",
  "created_at": "2021-02-25T11:28:54Z",
  "size": null,
  "disk_format": "qcow2",
  "updated_at": "2021-02-25T11:28:54Z",
  "visibility": "public",
  "locations": [],
  "self": "/v2/images/4d5d0496-d499-4407-a79b-013c4f89200c",
  "min_disk": 1,
  "protected": false,
  "id": "4d5d0496-d499-4407-a79b-013c4f89200c",
  "file": "/v2/images/4d5d0496-d499-4407-a79b-013c4f89200c/file",
  "checksum": null,
  "owner": "3a9a3a792b024d509d3852022b9f8436",
  "virtual_size": null,
  "min_ram": 512,
  "schema": "/v2/schemas/image"
}

正常响应代码

201

镜像配置修改

功能介绍

修改虚拟机镜像配置,比如镜像名字。

前提条件

  • 云平台服务正常。
  • 镜像状态为可用或者排队中。

    URI

    PATCH /v2/images/{image_id}

    请求消息

    参数 参数类型 是否必选 描述
    image_id string 镜像ID,UUID格式。

请求示例

修改镜像配置:

[
  { "path": "/min_ram", "value": 512, "op": "replace" },
  { "path": "/min_disk", "value": 1, "op": "replace" },
  { "path": "/name", "value": "fake_image1", "op": "replace" }
]

响应消息

参数 参数类型 描述
checksum string 镜像文件的哈希值。
created_at string 镜像创建时间。ISO8601时间格式。
file string 镜像文件的URI。
container_format enum 镜像容器格式。
disk_format enum 镜像格式。
id string 镜像ID,UUID格式。
min_disk string 镜像要求的最小磁盘大小,单位GB。
min_ram integer 镜像要求的最小内存大小,单位MB。
name integer 镜像名称。
protected boolean 镜像能否删除。
tags array 镜像标签。
visibility string 镜像对所有用户是否可见。
owner string 镜像租户。
schema string 描述镜像架构的URI。
self string 镜像的URI。
size integer 镜像大小。大于0。
status string 镜像状态。
update_at string 镜像更新时间。ISO8601时间格式。
virtual_size integer 镜像的虚拟大小,值可能为空。
locations array 描述镜像位置的对象列表。
description string 镜像描述信息。

响应示例

{
  "container_format": "bare",
  "min_ram": 512,
  "locations": [
    {
      "URI": "fake_URI",
      "metadata": {}
    }
  ],
  "file": "/v2/images/fake_image_id/file",
  "owner": "fake_owner",
  "id": "fake_image_id",
  "size": 528,
  "os_distro": "others",
  "self": "/v2/images/fake_image_id",
  "disk_format": "qcow2",
  "schema": "/v2/schemas/image",
  "status": "active",
  "description": "test_description",
  "tags": [],
  "visibility": "private",
  "updated_at": "2021-02-26T02:54:47Z",
  "min_disk": 1,
  "virtual_size": null,
  "name": "fake_image1",
  "checksum": "fake_checksum",
  "created_at": "2021-02-25T11:28:54Z",
  "protected": false
}

正常响应代码

200

镜像下载

功能介绍

下载虚拟机镜像。

前提条件

  • 云平台服务正常。
  • 镜像文件存在。

    URI

    GET /v2/images/{image_id}/file

    请求消息

    参数 参数类型 是否必选 描述
    image_id string 镜像ID,UUID格式。

响应消息

下载成功后会在指定目录下保存镜像文件。

正常响应代码

200

镜像删除

功能介绍

删除镜像。

URI

DELETE /v2/images/{image_id}

参数 是否必选 描述
image_id 要删除镜像的uuid。

请求示例

DELETE /v2/images/6ff0eaa6-a444-441b-b769-78099d06f985

响应消息

对DELETE操作成功的响应没有任何内容。

正常响应代码

204

此篇文章对你是否有帮助?
没帮助
locked-file

您暂无权限访问该产品