Updated on 2024-02-27 GMT+08:00

Updating an EVS Disk

Function

This API is used to update the name and description of an EVS disk.

Calling Method

For details, see Calling APIs.

URI

PUT /v2/{project_id}/cloudvolumes/{volume_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

The project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

volume_id

Yes

String

The disk ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

The user token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

volume

Yes

UpdateVolumeOption object

The information of the disk to be modified.

Table 4 UpdateVolumeOption

Parameter

Mandatory

Type

Description

description

No

String

The new description of the disk. name and description cannot be null at the same time. You can enter up to 85 characters.

name

No

String

The new name of the disk. name and description cannot be null at the same time. You can enter up to 64 characters.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

attachments

Array of Attachment objects

Whether the disk is attached.

availability_zone

String

The AZ to which the disk belongs.

bootable

String

Whether the disk is bootable.

created_at

String

The time when the disk was created.

id

String

The disk ID.

links

Array of Link objects

The disk URI.

metadata

VolumeMetadata object

The disk metadata.

multiattach

Boolean

Whether the disk is shareable.

name

String

The disk name.

os-vol-host-attr:host

String

The reserved field.

os-vol-tenant-attr:tenant_id

String

The ID of the project to which the disk belongs.

shareable

String

Whether the disk is shareable.

size

Integer

The disk size.

snapshot_id

String

The snapshot ID.

source_volid

String

The reserved field.

status

String

The disk status.

volume_image_metadata

Object

The metadata of the disk image.

NOTE:

For details about the volume_image_metadata field, see Querying Image Details (Native OpenStack API).

volume_type

String

The disk type.

description

String

The disk description.

os-volume-replication:extended_status

String

The reserved field.

Table 6 Attachment

Parameter

Type

Description

attached_at

String

The time when the disk was attached.

Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX

attachment_id

String

The attachment ID.

device

String

The device name.

host_name

String

The name of the physical host housing the cloud server to which the disk is attached.

id

String

The ID of the attached disk.

server_id

String

The ID of the server to which the disk is attached.

volume_id

String

The disk ID.

Table 8 VolumeMetadata

Parameter

Type

Description

__system__cmkid

String

The encryption CMK ID in metadata. This parameter is used together with __system__encrypted for encryption. The length of cmkid is fixed at 36 bytes.

For details about how to obtain the key ID, see Querying the Key List.

__system__encrypted

String

The encryption field in metadata. The value can be 0 (no encryption) or 1 (encryption). If this parameter is not specified, the encryption attribute of the disk is the same as that of the data source. If the disk is not created from a data source, the disk is not encrypted by default.

full_clone

String

The creation method when the disk is created from a snapshot.

  • 0: linked clone

  • 1: full clone

hw:passthrough

String

  • If this parameter value is true, the disk device type is SCSI, which allows ECS OSs to directly access the underlying storage media. SCSI reservation commands are supported.

  • If this parameter is set to false, the disk device type is VBD, which is also the default type. VBD supports only simple SCSI read/write commands.

  • If this parameter is not specified, the disk device type is VBD.

orderID

String

The parameter that describes the disk billing mode in metadata. If this parameter has a value, the disk is billed on a yearly/monthly basis. If not, the disk is billed on a pay-per-use basis.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error

Error object

The error message returned if an error occurs. For details, seeParameters in the error field.

Table 10 Error

Parameter

Type

Description

code

String

The error code returned if an error occurs. For the error codes and their meanings, see Error Codes.

message

String

The error message returned if an error occurs.

Example Requests

Updating the EVS disk name and description

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

{
  "volume" : {
    "name" : "test_volume",
    "description" : "test"
  }
}

Example Responses

Status code: 200

OK

{
  "id" : "36ba39af-3579-4e6e-adfc-b764349c0f77",
  "links" : [ {
    "href" : "https://volume.region.xxx.xxx-tsi.de/v2/3cfb09080bd944d0b4cdd72ef26857bd/volumes/36ba39af-3579-4e6e-adfc-b764349c0f77",
    "rel" : "self"
  }, {
    "href" : "https://volume.region.xxx.xxx-tsi.de/3cfb09080bd944d0b4cdd72ef26857bd/volumes/36ba39af-3579-4e6e-adfc-b764349c0f77",
    "rel" : "bookmark"
  } ],
  "name" : "newVolume",
  "status" : "in-use",
  "attachments" : [ {
    "server_id" : "c3d3250c-7ce5-42cc-b620-dd2b63d19ca5",
    "attachment_id" : "011a2bdb-a033-4479-845b-50bd8ed7f4d4",
    "attached_at" : "2017-05-23T11:27:38.604815",
    "volume_id" : "36ba39af-3579-4e6e-adfc-b764349c0f77",
    "device" : "/dev/sdf",
    "id" : "36ba39af-3579-4e6e-adfc-b764349c0f77"
  } ],
  "description" : "new volume",
  "multiattach" : false,
  "shareable" : false,
  "size" : 10,
  "metadata" : {
    "hw:passthrough" : "false"
  },
  "bootable" : "false",
  "availability_zone" : "az-dc-1",
  "created_at" : "2017-05-23T09:49:44.481299",
  "volume_type" : "SATA"
}

Status code: 400

Bad Request

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

SDK Sample Code

The SDK sample code is as follows.

Updating the EVS disk name and description

 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
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 UpdateVolumeSolution {

    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();
        UpdateVolumeRequest request = new UpdateVolumeRequest();
        UpdateVolumeRequestBody body = new UpdateVolumeRequestBody();
        UpdateVolumeOption volumebody = new UpdateVolumeOption();
        volumebody.withDescription("test")
            .withName("test_volume");
        body.withVolume(volumebody);
        request.withBody(body);
        try {
            UpdateVolumeResponse response = client.updateVolume(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());
        }
    }
}

Updating the EVS disk name and description

 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
# 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 = UpdateVolumeRequest()
        volumebody = UpdateVolumeOption(
            description="test",
            name="test_volume"
        )
        request.body = UpdateVolumeRequestBody(
            volume=volumebody
        )
        response = client.update_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)

Updating the EVS disk name and description

 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
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.UpdateVolumeRequest{}
	descriptionVolume:= "test"
	nameVolume:= "test_volume"
	volumebody := &model.UpdateVolumeOption{
		Description: &descriptionVolume,
		Name: &nameVolume,
	}
	request.Body = &model.UpdateVolumeRequestBody{
		Volume: volumebody,
	}
	response, err := client.UpdateVolume(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

OK

400

Bad Request

Error Codes

See Error Codes.