Skip to main content

Resize VM

POST/v2.1/servers/{server_id}/action

Resizing moves a VM to another flavor, which changes vCPUs and RAM, and usually the root disk. It is a three-step operation:

  1. Ask for the resize, passing the target flavorRef.
  2. The VM goes to VERIFY_RESIZE and stays there until you confirm or revert.
  3. Confirm to keep the new size, or revert to go back to the old flavor.
info

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_idstringrequiredpath

The UUID of the VM.

resizeobjectrequiredbody

Resize action wrapper.

1 field
flavorRefstringrequiredbody

The UUID of the target flavor.

confirmResizenullrequiredbody

Keep the new flavor.

revertResizenullrequiredbody

Return 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 CodeDescription
202 - AcceptedThe resize or revert request was accepted.
204 - No ContentThe resize was confirmed.

Error​

Status CodeDescription
400 - Bad RequestThe flavor is invalid or the request body is malformed.
401 - UnauthorizedUser must authenticate before making a request.
403 - ForbiddenPolicy does not allow current user to do this operation.
404 - Not FoundThe VM or the flavor does not exist.
409 - ConflictThe VM is not in a status that allows this action, for example resizing a running VM, or confirming when no resize is pending.
warning

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.

note

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.