更新时间:2024-02-23 GMT+08:00

查询镜像列表

功能介绍

根据不同条件查询镜像列表信息。

华为云不再提供Windows操作系统类型的镜像查询。

URI

GET /v2/cloudimages{?__isregistered,__imagetype,__whole_image,__system__cmkid,protected,visibility,owner,id,status,name,flavor_id,container_format,disk_format,min_ram,min_disk,__os_bit,__platform,marker,limit,sort_key,sort_dir,__os_type,tag,member_status,__support_kvm,__support_xen,__support_largememory,__support_diskintensive,__support_highperformance,__support_xen_gpu_type,__support_kvm_gpu_type,__support_xen_hana,__support_kvm_infiniband,virtual_env_type,enterprise_project_id,created_at,updated_at,architecture}

可以在URI后面用‘?’和‘&’添加不同的查询条件组合,请参考请求样例。

表1 查询参数

参数

是否必选

参数类型

描述

__isregistered

String

镜像是否可用,取值为true,扩展接口会默认为true,普通用户只能查询取值为true的镜像。

__imagetype

String

镜像类型,目前支持以下类型:

  • 公共镜像:gold
  • 私有镜像:private
  • 共享镜像:shared
  • 市场镜像:market
说明:

当前租户共享给其他租户的私有镜像或当前租户接受的共享镜像中,__imagetype均为shared,可用owner字段进行区分。当前租户接受的共享镜像可用member_status进行过滤查询。

__whole_image

Boolean

是否为整机镜像,取值为true/false。

__system__cmkid

String

加密镜像所使用的密钥ID。可以从镜像服务控制台获取,或者调用查询镜像详情(OpenStack原生)API查询。

protected

Boolean

镜像是否是受保护,取值为true/false,一般查询公共镜像时候取值为true,查询私有镜像可以不指定。

visibility

String

是否被其他租户可见,取值如下:

  • public:公共镜像
  • private:私有镜像
  • shared:共享镜像

owner

String

镜像属于哪个租户。

id

String

镜像ID。

status

String

镜像状态。取值如下:

  • queued:表示镜像元数据已经创建成功,等待上传镜像文件。
  • saving:表示镜像正在上传文件到后端存储。
  • deleted:表示镜像已经删除。
  • killed:表示镜像上传错误。
  • active:表示镜像可以正常使用。

name

String

镜像名称,匹配规则为精确匹配。name参数说明请参考镜像属性

flavor_id

String

用于通过云服务器规格过滤出可用公共镜像,取值为规格ID。

约束:

  • 仅支持通过单个规格进行过滤。
  • 仅支持按照云服务器规格进行过滤,裸金属服务器暂不支持。

    如果需要查看某裸金属服务器规格支持的公共镜像,可以使用“__support_s4l=true”标签。其中,s4l为裸金属服务器规格的board_type,若规格为“physical.s4.large”,则填入“s4l”。调用示例请参考常用列表查询方法

container_format

String

容器类型,取值为bare。

disk_format

String

镜像格式,目前支持zvhd2、vhd、zvhd、raw、qcow2、iso。非iso格式时默认值是zvhd2。

min_ram

Integer

镜像运行需要的最小内存,单位为MB。参数取值依据云服务器的规格限制,一般设置为0。

min_disk

Integer

镜像运行需要的最小磁盘,单位为GB 。取值为40~255GB。

__os_bit

String

操作系统位数,一般取值为32或者64。

__platform

String

镜像平台分类,取值为Windows、Ubuntu、Red Hat、SUSE、CentOS、Debian、OpenSUSE、Oracle Linux、Fedora、Other、CoreOS、EulerOS和Huawei Cloud EulerOS等。

marker

String

用于分页,表示从哪个镜像开始查询,取值为镜像ID。

limit

Integer

用于分页,表示查询几条镜像记录,取值为整数,默认取值为500。

sort_key

String

用于排序,表示按照哪个字段排序。取值为镜像属性name、container_format、disk_format、status、id、size、created_at字段,默认为创建时间。

sort_dir

String

用于排序,表示升序还是降序,取值为asc和desc。与sort_key一起组合使用,默认为降序desc。

__os_type

String

镜像系统类型,取值如下:

  • Linux
  • Windows
  • Other

tag

String

标签,用户为镜像增加自定义标签后可以通过该参数过滤查询。

说明:

系统近期对标签功能进行了升级。如果之前添加的Tag为“Key.Value”的形式,则查询的时候需要使用“Key=Value”的格式来查询。例如:之前添加的tag为“a.b”,则升级后,查询时需使用“tag=a=b”。

member_status

String

成员状态。目前取值有accepted、rejected、pending。accepted表示已经接受共享的镜像,rejected表示已经拒绝了其他用户共享的镜像,pending表示需要确认的其他用户的共享镜像。需要在查询时,设置“visibility”参数为“shared”。

__support_kvm

String

如果镜像支持KVM,取值为true,否则无需增加该属性。

__support_xen

String

如果镜像支持XEN,取值为true,否则无需增加该属性。

__support_largememory

String

表示该镜像支持超大内存。如果镜像支持超大内存,取值为true,否则无需增加该属性。

镜像操作系统类型请参考“弹性云服务器类型与支持的操作系统版本”。

__support_diskintensive

String

表示该镜像支持密集存储。如果镜像支持密集存储性能,则值为true,否则无需增加该属性。

__support_highperformance

String

表示该镜像支持高计算性能。如果镜像支持高计算性能,则值为true,否则无需增加该属性。

__support_xen_gpu_type

String

表示该镜像是支持XEN虚拟化平台下的GPU优化类型,取值参考表2。如果不支持XEN虚拟化下GPU类型,无需添加该属性。该属性与“__support_xen”和“__support_kvm”属性不共存。

__support_kvm_gpu_type

String

表示该镜像是支持KVM虚拟化平台下的GPU类型,取值参考表3。如果不支持KVM虚拟化下GPU类型,无需添加该属性。该属性与“__support_xen”和“__support_kvm”属性不共存。

__support_xen_hana

String

如果镜像支持XEN虚拟化下HANA类型,取值为true。否则,无需添加该属性。

该属性与“__support_xen”和“__support_kvm”属性不共存。

__support_kvm_infiniband

String

如果镜像支持KVM虚拟化下Infiniband网卡类型,取值为true。否则,无需添加该属性。

该属性与“__support_xen”属性不共存。

virtual_env_type

String

镜像使用环境类型:FusionCompute、Ironic、DataImage、IsoImage。

  • 如果是云服务器镜像(即系统盘镜像),则取值为FusionCompute。
  • 如果是数据盘镜像,则取值是DataImage。
  • 如果是裸金属服务器镜像,则取值是Ironic。
  • 如果是ISO镜像,则取值是IsoImage。

enterprise_project_id

String

表示查询某个企业项目下的镜像。
  • 取值为0,表示查询属于default企业项目下的镜像。
  • 取值为UUID,表示查询属于该UUID对应的企业项目下的镜像。
  • 取值为all_granted_eps,表示查询当前用户所有企业项目下的镜像。

    关于企业项目ID的获取及企业项目特性的详细信息,请参考“企业中心总览”。

created_at

String

镜像创建时间。支持按照时间点过滤查询,取值格式为“操作符:UTC时间”。

其中操作符支持如下几种:

  • gt:大于
  • gte:大于等于
  • lt:小于
  • lte:小于等于
  • eq:等于
  • neq:不等于

时间格式支持:yyyy-MM-ddThh:mm:ssZ或者yyyy-MM-dd hh:mm:ss

例如,查询创建时间在2018-10-28 10:00:00之前的镜像,可以通过如下条件过滤:

created_at=lt:2018-10-28T10:00:00Z

updated_at

String

镜像修改时间。支持按照时间点过滤查询,取值格式为“操作符:UTC时间”。

其中操作符支持如下几种:

  • gt:大于
  • gte:大于等于
  • lt:小于
  • lte:小于等于
  • eq:等于
  • neq:不等于

时间格式支持:yyyy-MM-ddThh:mm:ssZ或者yyyy-MM-dd hh:mm:ss

例如,查询修改时间在2018-10-28 10:00:00之前的镜像,可以通过如下条件过滤:

updated_at=lt:2018-10-28T10:00:00Z

architecture

String

镜像架构类型。取值包括:

  • x86
  • arm

请求消息

请求参数

请求示例

按查询条件查询镜像列表,其中,镜像类型为公共镜像,排序为镜像名称,查询镜像记录为1条。

GET https://{Endpoint}/v2/cloudimages?__imagetype=gold&sort_key=name&limit=1

常用列表查询方法

  • 公共镜像列表查询

    GET /v2/cloudimages?__imagetype=gold&visibility=public&protected=true

  • 私有镜像列表查询

    GET /v2/cloudimages?owner={project_id}

  • 可以使用的共享镜像列表

    GET /v2/cloudimages?member_status=accepted&visibility=shared&__imagetype=shared

  • 被拒绝的共享镜像列表

    GET /v2/cloudimages?member_status=rejected&visibility=shared&__imagetype=shared

  • 未接受的共享镜像列表

    GET /v2/cloudimages?member_status=pending&visibility=shared&__imagetype=shared

  • 裸金属服务器某规格支持的公共镜像列表

    GET /v2/cloudimages?__imagetype=gold&__support_xxx=true&virtual_env_type=Ironic

响应消息

  • 响应参数

    参数

    参数类型

    描述

    images

    Array of objects

    镜像详情。

    具体请参见表2

    表2 images字段说明

    参数

    参数类型

    描述

    file

    String

    镜像文件下载和上传链接。

    owner

    String

    镜像属于哪个租户。

    id

    String

    镜像ID。

    size

    Long

    目前暂时不使用。

    self

    String

    镜像链接信息。

    schema

    String

    镜像视图。

    status

    String

    镜像状态。取值如下:

    • queued:表示镜像元数据已经创建成功,等待上传镜像文件。
    • saving:表示镜像正在上传文件到后端存储。
    • deleted:表示镜像已经删除。
    • killed:表示镜像上传错误。
    • active:表示镜像可以正常使用。

    tags

    Array of strings

    镜像标签列表,提供用户可以自定义管理私有镜像的能力。用户可以通过镜像标签接口为每个镜像增加不同的标签,在查询接口中可以根据标签进行过滤。

    visibility

    String

    是否被其他租户可见,取值如下:

    • private:表示私有镜像。
    • public:表示公共镜像。
    • shared:表示共享镜像。

    name

    String

    镜像名称。name参数说明请参考镜像属性

    checksum

    String

    目前暂时不使用。

    protected

    Boolean

    是否是受保护的,受保护的镜像不允许删除。取值为true或false。

    container_format

    String

    容器类型。

    min_ram

    Integer

    镜像运行最小内存,单位为MB。取值参考云服务器规格限制,一般设置为0。

    max_ram

    String

    镜像支持的最大内存,单位为MB。取值可以参考云服务器规格限制,一般不设置。

    updated_at

    String

    更新时间。格式为UTC时间。

    __os_bit

    String

    操作系统位数,一般取值为“32”或者“64”。

    __os_version

    String

    操作系统具体版本。

    __description

    String

    镜像描述信息。_description参数说明请参考镜像属性

    disk_format

    String

    镜像格式,目前支持zvhd2、vhd、zvhd、raw、qcow2、iso。非iso格式时默认值是zvhd2。

    __isregistered

    String

    是否是注册过的镜像,取值为“true”或者“false”。

    __platform

    String

    镜像平台分类,取值为Windows、Ubuntu、Red Hat、SUSE、CentOS、Debian、OpenSUSE、Oracle Linux、Fedora、Other、CoreOS和EulerOS。

    __os_type

    String

    操作系统类型,目前取值Linux、Windows、Other。

    min_disk

    Integer

    镜像运行需要的最小磁盘,单位为GB 。取值为40~255GB。

    virtual_env_type

    String

    镜像使用环境类型:FusionCompute、Ironic、DataImage、IsoImage。

    • 如果是云服务器镜像,则取值为FusionCompute。
    • 如果是数据盘镜像,则取值是DataImage。
    • 如果是裸金属服务器镜像,则取值是Ironic。
    • 如果是ISO镜像,则取值是IsoImage。

    __image_source_type

    String

    镜像后端存储类型,目前支持uds。

    __imagetype

    String

    镜像类型,目前支持以下类型:

    • 公共镜像:gold
    • 私有镜像:private
    • 共享镜像:shared
    • 市场镜像:market

    created_at

    String

    创建时间。格式为UTC时间。

    virtual_size

    Integer

    目前暂时不使用。

    __originalimagename

    String

    父镜像ID。

    公共镜像或通过文件创建的私有镜像,取值为空。

    __backup_id

    String

    备份ID。如果是备份创建的镜像,则填写为备份的ID,否则为空。

    __productcode

    String

    市场镜像的产品ID。

    __image_size

    String

    镜像文件的大小,单位为字节。

    __data_origin

    String

    镜像来源。

    公共镜像为空。

    __lazyloading

    String

    镜像是否支持延迟加载。取值为true、false、True或False。

    active_at

    String

    镜像状态变为正常的时间。

    __image_displayname

    String

    对外展示名称。

    __os_feature_list

    String

    镜像附加属性。该属性采用JSON格式来标识镜像支持的高级特性清单。

    __support_kvm

    String

    如果镜像支持KVM,取值为true,否则无需增加该属性。

    __support_xen

    String

    如果镜像支持XEN,取值为true,否则无需增加该属性。

    __support_largememory

    String

    表示该镜像支持超大内存。如果镜像支持超大内存,取值为true,否则无需增加该属性。

    __support_diskintensive

    String

    表示该镜像支持密集存储。如果镜像支持密集存储性能,则值为true,否则无需增加该属性。

    __support_highperformance

    String

    表示该镜像支持高计算性能。如果镜像支持高计算性能,则值为true,否则无需增加该属性。

    __support_xen_gpu_type

    String

    表示该镜像是支持XEN虚拟化平台下的GPU优化类型,取值参考表2。如果不支持XEN虚拟化下GPU类型,无需添加该属性。该属性与“__support_xen”和“__support_kvm”属性不共存。

    __support_kvm_gpu_type

    String

    表示该镜像是支持KVM虚拟化平台下的GPU类型,取值参考表3

    如果不支持KVM虚拟化下GPU类型,无需添加该属性。该属性与“__support_xen”和“__support_kvm”属性不共存。

    __support_xen_hana

    String

    如果镜像支持XEN虚拟化下HANA类型,取值为true。否则,无需添加该属性。

    该属性与“__support_xen”和“__support_kvm”属性不共存。

    __support_kvm_infiniband

    String

    如果镜像支持KVM虚拟化下Infiniband网卡类型,取值为true。否则,无需添加该属性。

    该属性与“__support_xen”属性不共存。

    __system_support_market

    Boolean

    表示当前镜像是否支持发布为市场镜像。

    • true:支持
    • false:不支持

    __is_offshelved

    String

    表示当前市场镜像是否下架。

    • true:已下架
    • false:未下架

    enterprise_project_id

    String

    表示当前镜像所属的企业项目。

    • 取值为0或无该值,表示属于default企业项目。
    • 取值为UUID,表示属于该UUID对应的企业项目。

      关于企业项目特性的详细信息,请参考“企业中心总览”。

    __root_origin

    String

    表示当前镜像来源是从外部导入。取值:file。

    __sequence_num

    String

    表示当前镜像对应云服务器的系统盘插槽位置。

    取值样例:0。

    __support_fc_inject

    String

    表示当前镜像支持Cloud-Init密码/密钥注入方式。

    如果取值为“true”,表示该镜像不支持Cloud-Init注入密码/密钥,其他取值时表示支持Cloud-Init注入密钥/密码。

    说明:

    该特性参数只对ECS系统盘镜像生效,其他类型镜像不生效。

    hw_firmware_type

    String

    云服务器的启动方式。目前支持:

    • bios:表示bios引导启动。
    • uefi:表示uefi引导启动。

    hw_vif_multiqueue_enabled

    String

    镜像是否支持网卡多队列。取值为“true”或者“false”。

    __support_arm

    String

    是否是ARM架构类型的镜像。取值为“true”或者“false”。

    __support_agent_list

    String

    镜像是否支持企业主机安全或主机监控。

    • hss:企业主机安全
    • ces:主机监控

    取值样例:

    "__support_agent_list": "hss,ces"

    说明:

    如果查询结果无此字段,表示镜像不支持企业主机安全或主机监控。

    __system__cmkid

    String

    加密镜像所使用的密钥ID。

    __account_code

    String

    收费镜像标识。

    __support_amd

    String

    是否是AMD架构类型的镜像。取值为“true”或者“false”。

  • 响应样例
    STATUS CODE 200
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    {
      "images": [
        {
          "schema": "/v2/schemas/image",
          "min_disk": 100,
          "created_at": "2018-09-06T14:03:27Z",
          "__image_source_type": "uds",
          "container_format": "bare",
          "file": "/v2/images/bc6bed6e-ba3a-4447-afcc-449174a3eb52/file",
          "updated_at": "2018-09-06T15:17:33Z",
          "protected": true,
          "checksum": "d41d8cd98f00b204e9800998ecf8427e",
          "id": "bc6bed6e-ba3a-4447-afcc-449174a3eb52",
          "__isregistered": "true",
          "min_ram": 2048,
          "__lazyloading": "true",
          "owner": "1bed856811654c1cb661a6ca845ebc77",
          "__os_type": "Linux",
          "__imagetype": "gold",
          "visibility": "public",
          "virtual_env_type": "FusionCompute",
          "tags": [],
          "__platform": "CentOS",
          "size": 0,
          "__os_bit": "64",
          "__os_version": "CentOS 7.3 64bit",
          "name": "CentOS 7.3 64bit vivado",
          "self": "/v2/images/bc6bed6e-ba3a-4447-afcc-449174a3eb52",
          "disk_format": "zvhd2",
          "virtual_size": null,
          "hw_firmware_type": "bios",
          "status": "active",
          "__support_fc_inject":"true"
        },
        {
          "schema": "/v2/schemas/image",
          "min_disk": 100,
          "created_at": "2018-09-06T14:03:05Z",
          "__image_source_type": "uds",
          "container_format": "bare",
          "file": "/v2/images/0328c25e-c840-4496-81ac-c4e01b214b1f/file",
          "updated_at": "2018-09-25T14:27:40Z",
          "protected": true,
          "checksum": "d41d8cd98f00b204e9800998ecf8427e",
          "id": "0328c25e-c840-4496-81ac-c4e01b214b1f",
          "__isregistered": "true",
          "min_ram": 2048,
          "__lazyloading": "true",
          "owner": "1bed856811654c1cb661a6ca845ebc77",
          "__os_type": "Linux",
          "__imagetype": "gold",
          "visibility": "public",
          "virtual_env_type": "FusionCompute",
          "tags": [],
          "__platform": "CentOS",
          "size": 0,
          "__os_bit": "64",
          "__os_version": "CentOS 7.3 64bit",
          "name": "CentOS 7.3 64bit with sdx",
          "self": "/v2/images/0328c25e-c840-4496-81ac-c4e01b214b1f",
          "disk_format": "zvhd2",
          "virtual_size": null,
          "hw_firmware_type": "bios",
          "status": "active",
          "__support_fc_inject":"true"
        }
      ]
    }
    

返回值

  • 正常

    200

  • 异常

    返回值

    说明

    400 Bad Request

    请求错误,具体返回错误码请参考错误码

    401 Unauthorized

    鉴权失败。

    403 Forbidden

    没有操作权限。

    404 Not Found

    找不到资源。

    500 Internal Server Error

    服务内部错误。

    503 Service Unavailable

    服务不可用。