Updated on 2022-02-22 GMT+08:00

Creating EVS Disks

Function

This API is used to create one or multiple EVS disks.

URI

  • URI format

    POST /v2/{project_id}/volumes

  • Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID.

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

Request

  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    volume

    Object

    Yes

    Specifies the information of the disks to be created. For details, see Parameters in the volume field.

  • Parameters in the volume field

    Parameter

    Type

    Mandatory

    Description

    availability_zone

    String

    Yes

    Specifies the AZ where you want to create the disk. If the AZ does not exist, the disk will fail to create.

    NOTE:

    For details about how to obtain the AZ, see Querying All AZs.

    source_volid

    String

    No

    Specifies the source disk ID. If this parameter is specified, the disk is cloned from an existing disk. Currently, this function is not supported.

    description

    String

    No

    Specifies the disk description. The value can contain a maximum of 255 bytes.

    snapshot_id

    String

    No

    Specifies the snapshot ID. If this parameter is specified, the disk is created from a snapshot.

    NOTE:

    For details about how to obtain the snapshot ID, see Querying Details About EVS Snapshots.

    size

    Integer

    Yes

    Specifies the disk size, in GB. Its value can be as follows:
    • System disk: 1 GB to 1024 GB
    • Data disk: 10 GB to 32768 GB

    This parameter is mandatory when you create an empty disk. You can specify the parameter value as required within the value range.

    This parameter is mandatory when you create the disk from a snapshot. Ensure that the disk size is greater than or equal to the snapshot size.

    This parameter is mandatory when you create the disk from an image. Ensure that the disk size is greater than or equal to the minimum disk capacity required by min_disk in the image attributes.

    name

    String

    No

    Specifies the disk name. The value can contain a maximum of 255 bytes.

    imageRef

    String

    No

    Specifies the image ID. If this parameter is specified, the disk is created from an image.

    volume_type

    String

    No

    Specifies the disk type.

    Currently, only SSD and SAS are supported.
    • SSD: specifies the ultra-high I/O disk type.
    • SAS: specifies the high I/O disk type.

    If the specified disk type is not available in the AZ, the disk will fail to create.

    NOTE:
    • If the disk is created from a snapshot, the volume_type field must be the same as that of the snapshot's source disk.
    • For details about disk types, see Disk Types and Disk Performance in the Elastic Volume Service User Guide.

    metadata

    Object

    No

    Specifies the disk metadata. The length of the key or value in the metadata cannot exceed 255 bytes.

    For details about metadata, see Parameters in the metadata field. The table lists some fields. You can also specify other fields based on the disk creation requirements.

    NOTE:

    Parameter values under metadata cannot be null.

    source_replica

    String

    No

    Specifies the source disk ID. If this parameter is specified, the disk is cloned from an existing disk. Currently, this function is not supported.

    consistencygroup_id

    String

    No

    Reserved field

    shareable

    String

    No

    Specifies whether the disk is shareable. The value can be true (sharable) or false (not sharable). This is an extended attribute. Currently, this field is not supported by EVS.

    NOTE:

    This field is no longer used. Use multiattach.

    multiattach

    Boolean

    No

    Specifies whether the disk is shareable. The default value is false.
    • true: specifies a shared disk.
    • false: specifies a non-shared disk.

    Specifying either two of the source_volid, snapshot_id, and imageRef fields is not supported.

  • Parameters in the metadata field

    Parameter

    Type

    Mandatory

    Description

    hw:passthrough

    String

    No

    • If this parameter is set to true, the disk device type is SCSI, which allows ECS OSs to directly access the underlying storage media and supports SCSI reservation commands.
    • If this parameter is set to false, the disk device type will be VBD, which supports only simple SCSI read/write commands.
    • If this parameter does not exist, the disk device type will be VBD, the default type.
      NOTE:

      If parameter shareable is set to true and parameter hw:passthrough is not specified, shared VBD disks are created.

    full_clone

    String

    No

    If the disk is created from a snapshot and linked cloning needs to be used, set this parameter to 0.

    The preceding table provides only some parameters in metadata for your reference. You can also specify other fields based on the disk creation requirements.

    • If the disk is created from a snapshot, hw:passthrough is not supported, and the newly created disk has the same device type as that of the snapshot's source disk.
    • If the disk is created from an image, hw:passthrough is not supported, and the device type of newly created disk is VBD.
  • Example request
    {
        "volume": {
            "name": "openapi_vol01", 
            "imageRef": "027cf713-45a6-45f0-ac1b-0ccc57ac12e2", 
            "availability_zone": "az-dc-1", 
            "description": "create for api test", 
            "volume_type": "SATA", 
            "metadata": {
                "volume_owner": "openapi"
            },  
            "multiattach": false, 
            "size": 40
        }, 
    }

Response

  • Parameter description

    Parameter

    Type

    Description

    volume

    Object

    Specifies the information of the created disks. For details, see Parameters in the volumes field.

    error

    Object

    Specifies the error message returned when an error occurs. For details, see Parameters in the error field.

  • Parameters in the volumes field

    Parameter

    Type

    Description

    id

    String

    Specifies the disk ID.

    links

    list

    Specifies the disk URI. For details, see Parameters in the links field.

    name

    String

    Specifies the disk name.

    status

    String

    Specifies the disk status. For details, see EVS Disk Status.

    attachments

    list

    Specifies the disk attachment information. For details, see Parameters in the attachments field.

    availability_zone

    String

    Specifies the AZ to which the disk belongs.

    bootable

    String

    Specifies whether the disk is bootable.
    • true: specifies a bootable disk.
    • false: specifies a non-bootable disk.

    encrypted

    Boolean

    Currently, this field is not supported by EVS.

    created_at

    String

    Specifies the time when the disk was created.

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

    description

    String

    Specifies the disk description.

    volume_type

    String

    Specifies the disk type.

    Currently, only SSD and SAS are supported.
    • SSD: specifies the ultra-high I/O disk type.
    • SAS: specifies the high I/O disk type.

    replication_status

    String

    Reserved field

    consistencygroup_id

    String

    Specifies the ID of the consistency group where the disk belongs.

    Currently, this field is not supported by EVS.

    source_volid

    String

    Specifies the source disk ID.

    Currently, this field is not supported by EVS.

    snapshot_id

    String

    Specifies the snapshot ID.

    metadata

    Object

    Specifies the disk metadata. For details, see Parameters in the metadata field.

    size

    Integer

    Specifies the disk size, in GB.

    user_id

    String

    Reserved field

    updated_at

    String

    Specifies the time when the disk was updated.

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

    shareable

    Boolean

    Specifies whether the disk is shareable.

    NOTE:

    This field is no longer used. Use multiattach.

    multiattach

    Boolean

    Specifies whether the disk is shareable.
    • true: specifies a shared disk.
    • false: specifies a non-shared disk.
  • Parameters in the links field

    Parameter

    Type

    Description

    href

    String

    Specifies the corresponding shortcut link.

    rel

    String

    Specifies the shortcut link marker name.

  • Parameters in the attachments field

    Parameter

    Type

    Description

    server_id

    String

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

    attachment_id

    String

    Specifies the ID of the attachment information.

    attached_at

    String

    Specifies the time when the disk was attached.

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

    host_name

    String

    Specifies the name of the physical host accommodating the server to which the disk is attached.

    volume_id

    String

    Specifies the disk ID.

    device

    String

    Specifies the device name.

    id

    String

    Specifies the ID of the attached resource.

  • Parameters in the metadata field

    Parameter

    Type

    Description

    full_clone

    String

    Specifies the clone method. When the disk is created from a snapshot, the parameter value is 0, indicating the linked cloning method.

  • Parameters in the error field

    Parameter

    Type

    Description

    message

    String

    Specifies the error message returned when an error occurs.

    code

    String

    Specifies the error code returned when an error occurs.

    For details about the error code, see Error Codes.

  • Example response
    {
        "volume": {
            "attachments": [ ], 
            "availability_zone": "az-dc-1", 
            "bootable": "false", 
            "consistencygroup_id": null, 
            "created_at": "2016-05-25T02:38:40.392463", 
            "description": "create for api test", 
            "encrypted": false, 
            "id": "8dd7c486-8e9f-49fe-bceb-26aa7e312b66", 
            "links": [
                {
                    "href": "https://volume.localdomain.com:8776/v2/5dd0b0056f3d47b6ab4121667d35621a/volumes/8dd7c486-8e9f-49fe-bceb-26aa7e312b66", 
                    "rel": "self"
                }, 
                {
                    "href": "https://volume.localdomain.com:8776/5dd0b0056f3d47b6ab4121667d35621a/volumes/8dd7c486-8e9f-49fe-bceb-26aa7e312b66", 
                    "rel": "bookmark"
                }
            ], 
            "metadata": {
                "volume_owner": "openapi"
            }, 
            "name": "openapi_vol01", 
            "replication_status": "disabled", 
            "multiattach": false, 
            "size": 40, 
            "snapshot_id": null, 
            "source_volid": null, 
            "status": "creating", 
            "updated_at": null, 
            "user_id": "39f6696ae23740708d0f358a253c2637", 
            "volume_type": "SATA"
        }
    }

    or

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

    In the preceding example, error indicates a general error, for example, badRequest or itemNotFound. An example is provided as follows:

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

Status Codes

  • Normal

    202

Error Codes

For details, see Error Codes.