Resize VM
/v2.1/servers/{server_id}/actionResizing moves a VM to another flavor, which changes vCPUs and RAM, and usually the root disk. It is a three-step operation:
- Ask for the resize, passing the target
flavorRef. - The VM goes to
VERIFY_RESIZEand stays there until you confirm or revert. - Confirm to keep the new size, or revert to go back to the old flavor.
Source: resize-server
Request
Prerequisites
- The VM must be
SHUTOFF. Stop it first with{"os-stop": null}(see VM Actions). - The target flavor must exist and be visible to your project (see List Flavors).
- Your project quota must have room for the target size.
Parameters
server_idstringrequiredpathThe UUID of the VM.
resizeobjectrequiredbodyResize action wrapper.
1 field
flavorRefstringrequiredbodyThe UUID of the target flavor.
confirmResizenullrequiredbodyKeep the new flavor.
revertResizenullrequiredbodyReturn to the previous flavor.
Step 1 — request the resize
Using curl
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{"resize": {"flavorRef": "468c0c15-08bd-4e1d-8564-5053ce12966b"}}' \
https://api.vietnix.cloud:8774/v2.1/servers/{server_id}/action
Step 2 — check the result
curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
https://api.vietnix.cloud:8774/v2.1/servers/{server_id}
In the response, status should be VERIFY_RESIZE and OS-EXT-SRV-ATTR:instance_name and flavor should already point to the target size. Boot the VM and check that the guest sees the new CPU/RAM before confirming.
Step 3 — confirm or revert
# keep the new flavor
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{"confirmResize": null}' \
https://api.vietnix.cloud:8774/v2.1/servers/{server_id}/action
# go back to the previous flavor
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{"revertResize": null}' \
https://api.vietnix.cloud:8774/v2.1/servers/{server_id}/action
Response
Status Code
Success
| Status Code | Description |
|---|---|
| 202 - Accepted | The resize or revert request was accepted. |
| 204 - No Content | The resize was confirmed. |
Error
| Status Code | Description |
|---|---|
| 400 - Bad Request | The flavor is invalid or the request body is malformed. |
| 401 - Unauthorized | User must authenticate before making a request. |
| 403 - Forbidden | Policy does not allow current user to do this operation. |
| 404 - Not Found | The VM or the flavor does not exist. |
| 409 - Conflict | The VM is not in a status that allows this action, for example resizing a running VM, or confirming when no resize is pending. |
Do not confirm before the guest has booted successfully on the new flavor. Once the resize is confirmed, going back means another resize. A VM left in VERIFY_RESIZE still consumes resources and cannot be resized again until it is confirmed or reverted.
Shrinking can fail when the new root disk is smaller than the data already on it, or when the image does not support the target disk size. For volume-backed VMs, the volume size does not change with the flavor; extend the volume separately if needed.