文档首页> 云硬盘 EVS> API参考> API> 云硬盘管理> 查询所有云硬盘详情
更新时间:2024-01-02 GMT+08:00
分享

查询所有云硬盘详情

功能介绍

查询所有云硬盘的详细信息。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/cloudvolumes/detail

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。获取方法请参见"获取项目ID"。

表2 Query参数

参数

是否必选

参数类型

描述

marker

String

通过云硬盘ID进行分页查询,默认为查询第一页数据。marker={{id}}表示查询该云硬盘id后的所有云硬盘的信息(查询结果不包含该id的云硬盘信息)。

name

String

磁盘名称。

limit

Integer

返回结果个数限制。默认值为1000。

最小值:1

最大值:1000

缺省值:1000

sort_key

String

返回结果按该关键字排序,支持id,status,size,created_at等关键字,默认为“created_at”。

offset

Integer

偏移量。 说明:查询云硬盘列表时使用,与limit配合使用。假如共有30个云硬盘,设置offset为11,limit为10,即为从第12个云硬盘开始查询,一次最多可读取10个云硬盘。

sort_dir

String

返回结果按照降序或升序排列,默认为“desc”。 降序:desc 升序:asc

status

String

云硬盘状态,取值可参考:"云硬盘状态" 。

metadata

String

云硬盘元数据。

availability_zone

String

可用区信息。

multiattach

Boolean

是否为共享云硬盘。 true:表示为共享云硬盘。 false:表示为非共享云硬盘。

service_type

String

服务类型,仅支持EVS、DSS、DESS。

dedicated_storage_id

String

专属存储池ID,可过滤出该专属存储池下的所有云硬盘,必须精确匹配。

dedicated_storage_name

String

专属存储池的名字,可过滤出该专属存储池下的所有云硬盘,支持模糊匹配。

volume_type_id

String

云硬盘类型id。通过"查询云硬盘类型列表"可以查到,即volume_types参数说明表格中的“id”

id

String

云硬盘ID。

ids

String

云硬盘id列表,格式为ids=['id1','id2',...,'idx'],返回“ids”中有效id的云硬盘详情,无效的id会被忽略。 支持查询最多60个id对应的云硬盘详情。 如果“id”和“ids”查询参数同时存在,“id”会被忽略。

enterprise_project_id

String

指定企业项目id进行过滤。

传入“all_granted_eps”,代表查询权限范围内的所有企业项目下的云硬盘。

说明:

关于企业项目ID的获取及企业项目特性的详细信息,请参考:"企业管理用户指南"。

server_id

String

云服务器id。

bootable

Boolean

是否为启动盘/系统盘,true表示为启动盘/系统盘,false表示为数据盘

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

count

Integer

查询到的云硬盘总数量,不受分页影响。

volumes_links

Array of Link objects

云硬盘列表查询位置标记。如果本次查询只返回部分列表信息时,会返回查询到的当前云硬盘mark标记的url,可以继续使用这个url查询剩余列表信息。

volumes

Array of VolumeDetail objects

查询请求返回的云硬盘列表。

表5 VolumeDetail

参数

参数类型

描述

id

String

云硬盘的ID。

links

Array of Link objects

云硬盘URI自描述信息。

name

String

云硬盘名称。

status

String

云硬盘状态,请参见云硬盘状态

attachments

Array of Attachment objects

云硬盘的挂载信息。

availability_zone

String

云硬盘所属的AZ信息。

os-vol-host-attr:host

String

预留属性。

source_volid

String

源云硬盘ID,如果是从源云硬盘创建,则有值。

当前云硬盘服务不支持该字段。

snapshot_id

String

快照ID,如果是从快照创建,则有值。

description

String

云硬盘描述。

created_at

String

云硬盘创建时间。 时间格式:UTC YYYY-MM-DDTHH:MM:SS.XXXXXX

os-vol-tenant-attr:tenant_id

String

云硬盘所属的租户ID。租户ID就是项目ID。

volume_image_metadata

Map<String,Object>

云硬盘镜像的元数据。

说明:

关于“volume_image_metadata”字段的详细说明,具体请参见查询镜像详情

volume_type

String

云硬盘类型。

目前支持"SATA","SAS","GPSSD","SSD","ESSD","GPSSD2","ESSD2"七种。

  • "SATA"为普通IO云硬盘(已售罄)

  • "SAS"为高IO云硬盘

  • "GPSSD"为通用型SSD云硬盘

  • "SSD"为超高IO云硬盘

  • "ESSD"为极速IO云硬盘

  • "GPSSD2"为通用型SSD V2云硬盘

  • "ESSD2"为极速型SSD V2云硬盘

size

Integer

云硬盘大小,单位为GiB。

consistencygroup_id

String

预留属性。

bootable

String

是否为启动云硬盘。 true:表示为启动云硬盘。 false:表示为非启动云硬盘。

metadata

Map<String,Object>

云硬盘的元数据。 __system__cmkid metadata中的加密cmkid字段,与__system__encrypted配合表示需要加密,cmkid长度固定为36个字节。

请求获取密钥ID的方法请参考:"查询密钥列表"。

__system__encrypted

metadata中的表示加密功能的字段,0代表不加密,1代表加密。

不指定该字段时,云硬盘的加密属性与数据源保持一致,如果不是从数据源创建的场景,则默认不加密。

full_clone

从快照创建云硬盘时的创建方式。

  • 0表示使用链接克隆方式。

  • 1表示使用全量克隆方式。

hw:passthrough

  • true表示云硬盘的设备类型为SCSI类型,即允许ECS操作系统直接访问底层存储介质。支持SCSI锁命令。

  • false表示云硬盘的设备类型为VBD (虚拟块存储设备 , Virtual Block Device)类型,即为默认类型,VBD只能支持简单的SCSI读写命令。

  • 该字段不存在时,云硬盘默认为VBD类型。

orderID

metadata中的表示云硬盘计费类型的字段。

当该字段有值时,表示该云硬盘的计费类型为包周期计费,否则计费类型为按需计费。

updated_at

String

云硬盘更新时间。 时间格式:UTC YYYY-MM-DDTHH:MM:SS.XXXXXX

encrypted

Boolean

当前云硬盘服务不支持该字段。

replication_status

String

预留属性。

os-volume-replication:extended_status

String

预留属性。

os-vol-mig-status-attr:migstat

String

预留属性。

os-vol-mig-status-attr:name_id

String

预留属性。

shareable

String

是否为共享云硬盘。true为共享盘,false为普通云硬盘。 该字段已经废弃,请使用multiattach。

user_id

String

预留属性。

service_type

String

服务类型,结果为EVS、DSS、DESS。

multiattach

Boolean

是否为共享云硬盘。

dedicated_storage_id

String

云硬盘所属的专属存储池ID。

dedicated_storage_name

String

云硬盘所属的专属存储池的名称。

tags

Map<String,String>

云硬盘的标签。 如果云硬盘有标签,则会有该字段,否则该字段为空。

wwn

String

云硬盘挂载时的唯一标识。

enterprise_project_id

String

云硬盘上绑定的企业项目ID。

关于企业项目ID的获取及企业项目特性的详细信息,请参见:"企业管理用户指南"。

serial_number

String

云硬盘序列号。 只有SCSI类型的非双活云硬盘才会返回该字段,用于与虚拟机中的盘做对应关系。

iops

iops object

云硬盘的iops信息,云硬盘类型是ESSD2、GPSSD2才存在。

throughput

throughput object

云硬盘的吞吐量信息,云硬盘类型是GPSSD2才存在。

表7 Attachment

参数

参数类型

描述

attached_at

String

挂载的时间信息。

时间格式:UTC YYYY-MM-DDTHH:MM:SS.XXXXXX

attachment_id

String

挂载信息对应的ID。

device

String

挂载点。

host_name

String

云硬盘挂载到的云服务器对应的物理主机的名称。

id

String

挂载的资源ID。

server_id

String

云硬盘挂载到的云服务器的 ID。

volume_id

String

云硬盘ID。

表8 iops

参数

参数类型

描述

frozened

Boolean

冻结标签。

缺省值:false

id

String

云硬盘iops标识。

total_val

Integer

iops大小。

表9 throughput

参数

参数类型

描述

frozened

Boolean

冻结标签。

缺省值:false

id

String

云硬盘吞吐量标识。

total_val

Integer

吞吐量大小。

状态码: 400

表10 响应Body参数

参数

参数类型

描述

error

Error object

出现错误时,返回的错误码。错误码和其对应的含义请参考错误码说明

表11 Error

参数

参数类型

描述

code

String

出现错误时,返回的错误码。错误码和其对应的含义请参考错误码说明

message

String

出现错误时,返回的错误消息。

请求示例

  • 查询云硬盘id为e92ba908-82f8-4728-b8cc-82f2f56bd461、40g42920-4243-420f-8bb2-a0bd7660fbd8、b1fd8dcc-dd67-4edf-b89e-87c3485112ec的云硬盘详情,从第1条记录开始查询,返回结果中的记录数不超过100个,返回结果按云硬盘大小排序。

    GET https://{endpoint}/v2/{project_id}/cloudvolumes/detail?ids=['e92ba908-82f8-4728-b8cc-82f2f56bd461', '40g42920-4243-420f-8bb2-a0bd7660fbd8', 'b1fd8dcc-dd67-4edf-b89e-87c3485112ec']&offset=0&limit=100&sort_key=size&sort_dir=asc
  • 查询id为3ffcbe9d-e5bf-45f4-aa0a-670b54bda66c的云服务器下的所有共享数据盘详情,返回结果按照升序排列。

    GET https://{endpoint}/v2/{project_id}/cloudvolumes/detail?server_id=3ffcbe9d-e5bf-45f4-aa0a-670b54bda66c&multiattach=true&sort_dir=asc

响应示例

状态码: 200

OK

{
  "count" : 1,
  "volumes" : [ {
    "attachments" : [ ],
    "availability_zone" : "az-dc-1",
    "bootable" : "false",
    "created_at" : "2016-05-25T02:42:10.856332",
    "id" : "b104b8db-170d-441b-897a-3c8ba9c5a214",
    "links" : [ {
      "href" : "https://volume.localdomain.com:8776/v2/dd14c6ac581f40059e27f5320b60bf2f/volumes/b104b8db-170d-441b-897a-3c8ba9c5a214",
      "rel" : "self"
    }, {
      "href" : "https://volume.localdomain.com:8776/dd14c6ac581f40059e27f5320b60bf2f/volumes/b104b8db-170d-441b-897a-3c8ba9c5a214",
      "rel" : "bookmark"
    } ],
    "metadata" : { },
    "name" : "zjb_u25_test",
    "os-vol-host-attr:host" : "pod01.xxx#SATA",
    "volume_image_metadata" : { },
    "os-vol-tenant-attr:tenant_id" : "dd14c6ac581f40059e27f5320b60bf2f",
    "replication_status" : "disabled",
    "multiattach" : false,
    "size" : 1,
    "status" : "available",
    "updated_at" : "2016-05-25T02:42:22.341984",
    "user_id" : "b0524e8342084ef5b74f158f78fc3049",
    "volume_type" : "SATA",
    "service_type" : "EVS",
    "wwn" : " 688860300000d136fa16f48f05992360"
  } ],
  "volumes_links" : [ {
    "href" : "https://volume.localdomain.com:8776/v2/dd14c6ac581f40059e27f5320b60bf2f/volumes/detail?limit=1&marker=b104b8db-170d-441b-897a-3c8ba9c5a214",
    "rel" : "next"
  } ]
}

状态码: 400

Bad Request

{
  "error" : {
    "message" : "XXXX",
    "code" : "XXX"
  }
}

SDK代码示例

SDK代码示例如下。

Java

 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
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.evs.v2.region.EvsRegion;
import com.huaweicloud.sdk.evs.v2.*;
import com.huaweicloud.sdk.evs.v2.model.*;


public class ListVolumesSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        EvsClient client = EvsClient.newBuilder()
                .withCredential(auth)
                .withRegion(EvsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListVolumesRequest request = new ListVolumesRequest();
        request.withMarker("<marker>");
        request.withName("<name>");
        request.withLimit(<limit>);
        request.withSortKey("<sort_key>");
        request.withOffset(<offset>);
        request.withSortDir("<sort_dir>");
        request.withStatus("<status>");
        request.withMetadata("<metadata>");
        request.withAvailabilityZone("<availability_zone>");
        request.withMultiattach(<multiattach>);
        request.withServiceType("<service_type>");
        request.withDedicatedStorageId("<dedicated_storage_id>");
        request.withDedicatedStorageName("<dedicated_storage_name>");
        request.withVolumeTypeId("<volume_type_id>");
        request.withId("<id>");
        request.withIds("<ids>");
        request.withEnterpriseProjectId("<enterprise_project_id>");
        request.withServerId("<server_id>");
        try {
            ListVolumesResponse response = client.listVolumes(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 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
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkevs.v2.region.evs_region import EvsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkevs.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = EvsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(EvsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListVolumesRequest()
        request.marker = "<marker>"
        request.name = "<name>"
        request.limit = <limit>
        request.sort_key = "<sort_key>"
        request.offset = <offset>
        request.sort_dir = "<sort_dir>"
        request.status = "<status>"
        request.metadata = "<metadata>"
        request.availability_zone = "<availability_zone>"
        request.multiattach = <Multiattach>
        request.service_type = "<service_type>"
        request.dedicated_storage_id = "<dedicated_storage_id>"
        request.dedicated_storage_name = "<dedicated_storage_name>"
        request.volume_type_id = "<volume_type_id>"
        request.id = "<id>"
        request.ids = "<ids>"
        request.enterprise_project_id = "<enterprise_project_id>"
        request.server_id = "<server_id>"
        response = client.list_volumes(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 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
69
70
71
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    evs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := evs.NewEvsClient(
        evs.EvsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListVolumesRequest{}
	markerRequest:= "<marker>"
	request.Marker = &markerRequest
	nameRequest:= "<name>"
	request.Name = &nameRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	sortKeyRequest:= "<sort_key>"
	request.SortKey = &sortKeyRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	sortDirRequest:= "<sort_dir>"
	request.SortDir = &sortDirRequest
	statusRequest:= "<status>"
	request.Status = &statusRequest
	metadataRequest:= "<metadata>"
	request.Metadata = &metadataRequest
	availabilityZoneRequest:= "<availability_zone>"
	request.AvailabilityZone = &availabilityZoneRequest
	multiattachRequest:= <multiattach>
	request.Multiattach = &multiattachRequest
	serviceTypeRequest:= "<service_type>"
	request.ServiceType = &serviceTypeRequest
	dedicatedStorageIdRequest:= "<dedicated_storage_id>"
	request.DedicatedStorageId = &dedicatedStorageIdRequest
	dedicatedStorageNameRequest:= "<dedicated_storage_name>"
	request.DedicatedStorageName = &dedicatedStorageNameRequest
	volumeTypeIdRequest:= "<volume_type_id>"
	request.VolumeTypeId = &volumeTypeIdRequest
	idRequest:= "<id>"
	request.Id = &idRequest
	idsRequest:= "<ids>"
	request.Ids = &idsRequest
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	serverIdRequest:= "<server_id>"
	request.ServerId = &serverIdRequest
	response, err := client.ListVolumes(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

400

Bad Request

错误码

请参见错误码

分享:

    相关文档

    相关产品