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

查询单个云硬盘详情

功能介绍

查询单个云硬盘的详细信息。支持企业项目授权功能。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/cloudvolumes/{volume_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

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

volume_id

String

云硬盘ID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

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

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

volume

VolumeDetail object

云硬盘详情。

表4 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才存在。

表6 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。

表7 iops

参数

参数类型

描述

frozened

Boolean

冻结标签。

缺省值:false

id

String

云硬盘iops标识。

total_val

Integer

iops大小。

表8 throughput

参数

参数类型

描述

frozened

Boolean

冻结标签。

缺省值:false

id

String

云硬盘吞吐量标识。

total_val

Integer

吞吐量大小。

状态码: 400

表9 响应Body参数

参数

参数类型

描述

error

Error object

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

表10 Error

参数

参数类型

描述

code

String

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

message

String

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

请求示例

GET https://{endpoint}/v2/{project_id}/cloudvolumes/{volume_id}

响应示例

状态码: 200

云硬盘的信息。

{
  "volume" : {
    "attachments" : [ ],
    "links" : [ {
      "href" : "https://volume.az0.dc1.domainname.com/v2/40acc331ac784f34842ba4f08ff2be48/volumes/591ac654-26d8-41be-bb77-4f90699d2d41",
      "rel" : "self"
    }, {
      "href" : "https://volume.az0.dc1.domainname.com/40acc331ac784f34842ba4f08ff2be48/volumes/591ac654-26d8-41be-bb77-4f90699d2d41",
      "rel" : "bookmark"
    } ],
    "availability_zone" : "az-dc-1",
    "os-vol-host-attr:host" : "az-dc-1#SSD",
    "multiattach" : true,
    "updated_at" : "2016-02-03T02:19:29.895237",
    "replication_status" : "disabled",
    "id" : "591ac654-26d8-41be-bb77-4f90699d2d41",
    "size" : 40,
    "user_id" : "fd03ee73295e45478d88e15263d2ee4e",
    "os-vol-tenant-attr:tenant_id" : "40acc331ac784f34842ba4f08ff2be48",
    "metadata" : { },
    "tags" : {
      "key1" : "value1",
      "key2" : "value2"
    },
    "status" : "available",
    "description" : "auto-created_from_restore_from_backup",
    "name" : "restore_backup_0115efb3-678c-4a9e-bff6-d3cd278238b9",
    "bootable" : "false",
    "created_at" : "2016-02-03T02:19:11.723797",
    "service_type" : "EVS",
    "wwn" : " 688860300000d136fa16f48f05992360"
  }
}

状态码: 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
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 ShowVolumeSolution {

    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();
        ShowVolumeRequest request = new ShowVolumeRequest();
        try {
            ShowVolumeResponse response = client.showVolume(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
# 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 = ShowVolumeRequest()
        response = client.show_volume(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
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.ShowVolumeRequest{}
	response, err := client.ShowVolume(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

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

状态码

状态码

描述

200

云硬盘的信息。

400

Bad Request

错误码

请参见错误码

分享:

    相关文档

    相关产品