Bulk attach and detach volume APIs
The bulk attach volume API attaches bulk volumes to a virtual machine. The bulk detach volume API detaches bulk volumes from a virtual machine.
Bulk volume attach option
Starting PowerVC 2.2.1, a new primaryBoot parameter is introduced in the bulk volume attach API. If the parameter is passed, it assigns the volume as rootvg and sets the boot_index as 0 to an empty VM. If the parameter is not passed, it assigns the first boot volume as rootvg to an empty VM.
| Method | URI | Description |
|---|---|---|
| POST | /v2.1/{tenant_id}/servers/{server_id}/action |
Creates or attaches bulk volumes to a virtual machine. Specify the
bulkVolumeAttach action in the request body. |
- Request parameters
-
Table 2. Parameters in the request for bulk volume attach Name Type Description volumeAttachmentList List of all volume IDs to attach. volumeIdString ID of the volume to be attached. primaryBootBoolean Assigns a particular volume ID as rootvg and sets the boot_indexas 0. - Example of request body
-
{ "bulkVolumeAttach": { "volumeAttachment": [ { "volumeId": "26630011-1fc2-47a9-89df-ac70ccf4ecc3", }, { "volumeId": "26630011-1fc2-47a9-89df-ac70ccf4ecc3" }, { "volumeId": "26630011-1fc2-47a9-89df-ac70ccf4ecc3" } ] } } - Example of request body with the
primaryBootparameter -
{ "bulkVolumeAttach": { "volumeAttachment": [ { "volumeId": "22ea0080-e765-4042-94ed-7a80db09c788", "primaryBoot": true }, { "volumeId": "22ea0080-e765-4042-94ed-7a80db09c788" } ] } } - Response code
-
- Normal: Accepted (202)
- Failure: Partial Content (206), Bad Request (400), Unauthorized (401), Forbidden (403), Not Found (404), Internal Server Error (500)
Bulk volume detach option
| Method | URI | Description |
|---|---|---|
| POST | /v2.1/{tenant_id}/servers/{server_id}/action |
Detaches bulk volumes from a virtual machine. Specify the bulkVolumeDetach
action in the request body. |
- Request parameters
-
Table 4. Parameters in the request for bulk volume detach Name Type Description volume_idsList List of volume IDs to detach. Mutually exclusive to detach_all_volumes.allow_rootvgBoolean Pass allow_rootvg = trueif you want to detach root volume.detach_all_volumesBoolean Detaches all volumes except the root volume if passed 'true'. Pass allow_rootvg = trueto detach root volume. Mutually exclusive tovolume_ids. - Example of request body for volume detach
-
{ "bulkVolumeDetach": { "volume_ids": [ "ae6a35cc-ab78-40f5-be44-b7f6c655786c", "61fa8501-d69c-4458-99b0-09a27c808b72" ], "allow_rootvg": true } } - Example of request body to detach all volumes
-
{ "bulkVolumeDetach": { “detach_all_volumes”: true "allow_rootvg": true } } - Example of request body to detach all volumes except root volume
-
{ "bulkVolumeDetach": { “detach_all_volumes”: true } } - Response code
-
- Normal: Accepted (202)
- Failure: Bad Request (400), Forbidden (403)
Notes
- Bulk attach
-
- Primary boot can only be set for a VM with no volumes attached.
- Only one
primaryBootparameter can be set for a VM. - If
primaryBootparameter is not passed, then the API assigns the first boot volume as rootvg. If there are no boot volumes, then the API picks the first data volume as rootvg.
- Bulk detach
-
- VM must be in “stopped” state when you pass the
allow_rootvgparameter as "true" to detach the rootvg volume. In such an instance, make sure to attach another volume as the primary boot to avoid the VM failing on power on. - If you pass
rootvg volume_ids, then make sure to pass theallow_rootvgparameter as "true", otherwise the volume detach action for that volume will be skipped. - You cannot pass
detach_all_volumesandvolume_idstogether.
- VM must be in “stopped” state when you pass the