You can attach a data disk by setting the data_volumes parameter during ECS creation or attach a data disk after the ECS is created. This section describes how to attach a disk to a created ECS.
Attaching a disk involves the following APIs:
URI format: POST /v2/{tenant_id}/volumes
For details, see section "Creating an EVS Disk (Native OpenStack API v2)" in Elastic Cloud Server API Reference.
POST: https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/volumes
Obtain the endpoint from Regions and Endpoints.
Body
{
"volume": {
"name": "openapi_vol02",
"availability_zone": "eu-de-01",
"description": "create for api test",
"volume_type": "SATA",
"size": 40
}
}
{
"volume": {
"status": "creating",
"user_id": "f79791beca3c48159ac2553fff22e166",
"attachments": [],
"links": [
{
"href": "https://xxx/v2/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"rel": "self"
},
{
"href": "https://xxx/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"rel": "bookmark"
}
],
"availability_zone": "eu-de-01",
"bootable": "false",
"encrypted": false,
"created_at": "2018-05-16T11:19:33.992984",
"description": "create for api test",
"updated_at": null,
"volume_type": "SATA",
"name": "openapi_vol02",
"replication_status": "disabled",
"consistencygroup_id": null,
"source_volid": null,
"snapshot_id": null,
"shareable": false,
"multiattach": false,
"metadata": {
"__system__volume_name": "openapi_vol02"
},
"id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"size": 40
}
}
URI format: POST /v2/{tenant_id}/servers/{server_id}/os-volume_attachments
For details, see section "Attaching a Disk to an ECS" in Elastic Cloud Server API Reference.
https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments
Obtain the endpoint from Regions and Endpoints.
Body
{
"volumeAttachment": {
"volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"device": "/dev/sdb"
}
}
{
"volumeAttachment": {
"id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e",
"device": "/dev/sdb"
}
}
URI format: GET /v2/{tenant_id}/servers/{server_id}/os-volume_attachments
For details, see section "Querying Disks Attached to an ECS" in Elastic Cloud Server API Reference.
https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments
Obtain the endpoint from Regions and Endpoints.
{
"volumeAttachments": [
{
"volumeId": "4fc0b4cc-9d6c-431c-be70-3dfeec2ff6e0",
"id": "4fc0b4cc-9d6c-431c-be70-3dfeec2ff6e0",
"device": "/dev/sda",
"serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e"
},
{
"volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3",
"device": "/dev/sdb",
"serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e"
}
]
}