• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Nova
  5. Server Volumes Action
  6. Attaching a Volume

Attaching a Volume

Function Description

This interface is used to attach a volume to an ECS.

Interface Format

Method

URI

Description

POST

/v2/{tenant_id}/servers/{server_id}/os-volume_attachments

/v2.1/{tenant_id}/servers/{server_id}/os-volume_attachments

Attaches a volume to an ECS.

Restrictions

  • If the ECS is in the SUSPENDED or PAUSED state, that is, the value of the OS-EXT-STS:vm_state attribute is SUSPENDED or PAUSED, the ECS cannot have a volume attached.
  • The volume to be attached to an ECS must be available.

    In the public cloud system, the attached volumes must be created in the same cascaded OpenStack system of the ECSs.

  • For a disk-intensive ECS, you need to specify the drive letter for attaching volumes while complying with following rules:
    • If the value of 1+3+{count} is less than 26, the volume is attached to the drive letter following the value of 1+3+{count}.
    • If the value of 1+3+{count} is greater than or equal to 26, the volume is attached to the drive letter following the value of 1+4+{count}.

      1 indicates the number corresponding to the system disk drive letter, and 3 or 4 indicates the number of reserved drive letters. {count} indicates the quantity of local disks used by the disk-intensive ECS, and its value is determined by the ECS flavor.

      If the d1.xlarge is selected, the value is 3.

      If d1.2xlarge is selected, the value is 6.

      If d1.4xlarge is selected, the value is 12.

      If d1.8xlarge is selected, the value is 24.

  • The mappings between disk names transmitted using interfaces and those in the OS have the following restrictions:
    • If the cloud service vendor has adjusted the disk name mapping rule, specifically, if special disk names are used to attach cloud disks for Linux, the system ensures consistency of only sequence number of the attached disks. For example, if users attach a cloud disk to the /dev/sdx attachment point, the disk name displayed in the OS is /dev/xvdx or /dev/vdx. Only x corresponds to the attachment point.
    • If the cloud service provider does not adjust the disk name mapping rule, the disk name mapping rule for historical versions is used. In historical versions for Linux, if the device name is /dev/sdd, the disk name displayed in the OS is /dev/xvdg.

      For details, see descriptions of the cloud disk in the online help provided by the service provider.

  • Bootable volumes cannot be attached to BMSs.
  • Only SCSI volumes can be attached to BMSs.

Extension Description

N/A

Request Parameter

Parameter

Type

Mandatory

Description

volumeAttachment

Dict

Yes

Specifies information about a volume to be attached to an ECS.

volumeAttachment information

Parameter

Type

Mandatory

Description

volumeId

UUID

Yes

Specifies the ID of the volume to be attached to an ECS.

device

String

No

Specifies the name of the volume device. The value must conform to the regular expression (^/dev/x{0,1}[a-z]{0,1}d{0,1})([a-z]+)[0-9]*$.

Specify the value by the device names in sequence.

Response Parameter

Table 1 Response Parameter

Parameter

Type

Mandatory

Description

device

String

Yes

Specifies the device name.

serverId

UUID

Yes

Specifies the ECS to which a volume is to be attached.

id

String

Yes

Specifies the attachment ID, which is the same as the volume UUID.

volumeId

String

Yes

Specifies the volume UUID.

Request Example

POST /v2/6fbe9263116a4b68818cf1edce16bc4f/servers/ab258e25-e351-47c7-b6e3-0749c5d9ed6a/os-volume_attachments 
POST /v2.1/6fbe9263116a4b68818cf1edce16bc4f/servers/ab258e25-e351-47c7-b6e3-0749c5d9ed6a/os-volume_attachments
{ 
    "volumeAttachment":{
    "volumeId":"54667652-3029-4af8-9222-2d53066fd61c",
    "device":"/dev/sdb"
    }
}

Response Example

{ 
     "volumeAttachment": {
        "device": "/dev/vdb",
        "serverId": "ab258e25-e351-47c7-b6e3-0749c5d9ed6a",
        "id": "54667652-3029-4af8-9222-2d53066fd61c",
        "volumeId": "54667652-3029-4af8-9222-2d53066fd61c"
    }
}

Returned Values

For details, see section General Request Returned Values.

Error Code

Table 2 Real-time task error codes

Error Code

Description

404

Volume 5ed742b1-1bfe-489a-b6dc-ff366e7b4399 could not be found.

The volume does not exist.