Attaching a Disk to an ECS
Scenarios
If the existing disks of an ECS fail to meet service requirements, for example, due to insufficient disk space or poor disk performance, you can attach more available disks to the ECS, or call the EVS disk creation API to create disks and attach them to the ECS. To attach an EVS disk to an ECS, you need to call the desired API.
A data disk can be attached by setting the data_volumes parameter during ECS creation or after the ECS is created. This section describes how to attach a disk to a created ECS.
Involved APIs
Attaching a disk involves the following APIs:
Procedure
- Create an EVS disk.
- Create an EVS disk.
- API
URI format: POST /v2/{project_id}/volumes
For details, see Creating EVS Disks.
- Example request
POST https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/volumes
Obtain {endpoint} from Regions and Endpoints.
Body:
{ "volume": { "name": "openapi_vol02", "availability_zone":"az_test_01", "description": "create for api test", "volume_type": "SSD", "size": 40 } }
- Example response
{ "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": "az_test_01", "bootable": "false", "encrypted": false, "created_at": "2018-05-16T11:19:33.992984", "description": "create for api test", "updated_at": null, "volume_type": "SSD", "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 } }
- API
- Record the volume ID in the response.
- Create an EVS disk.
- Attach the disk to the ECS.
- API
URI format: POST /v2.1/{project_id}/servers/{server_id}/os-volume_attachments
For details, see Attaching a Disk to an ECS.
- Example request
POST https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments
Obtain {endpoint} from Regions and Endpoints.
Body:
{ "volumeAttachment": { "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "device": "/dev/sdb" } }
- Example response
{ "volumeAttachment": { "id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e", "device": "/dev/sdb" } }
- API
- Verify the disk attachment.
- API
URI format: GET /v2.1/{project_id}/servers/{server_id}/os-volume_attachments
For details, see Querying Disks Attached to an ECS.
- Example request
GET https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments
Obtain {endpoint} from Regions and Endpoints.
- Example response
{ "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" } ] }
- API
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot