Resize OS Volume Size

This endpoint expands the storage capacity of a volume attached to a Nova Series GPU instance using either the Instance ID or the Volume ID.

Resize Instance Volume Size - Overview

The Nova Series Volume Resize API allows authenticated users to increase the storage capacity of a volume associated with a Nova virtual machine.

You can identify the target volume using either the instance ID or the volume ID. This endpoint is useful for expanding storage capacity when an instance requires additional space for datasets, application files, model checkpoints, or other workloads.

When resize request is accepted, API returns a confirmation message and the requested new storage capacity.

Important Note: Volume capacity can only be increased. Reducing the existing volume size is not supported.

Endpoint

PropertyValue
HTTP MethodPOST
Endpoint/nova/volume/resize
Full URLhttps://cloud.dataoorts.com/api/v1/nova/volume/resize
AuthenticationBearer Token
Content Typeapplication/json
Response FormatJSON

Authentication

This endpoint requires a valid Dataoorts Unify API key.

Include your API key in the Authorization header using the Bearer authentication scheme.

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: application/json

Generate or manage your API key through the Dataoorts Unify API.

Keep your API key confidential and never expose it in public repositories or client-side applications.

Request Parameters

The request body must be sent as JSON.

ParameterTypeRequiredDescription
new_size_gbIntegerYesThe requested new volume capacity in GB. The value must be greater than the existing volume capacity.
instance_idIntegerConditionalThe ID of Nova VM whose attached volume you want to resize. Use this or volume_id.
volume_idString or IntegerConditionalThe ID of the volume you want to resize. Use this or instance_id.

Important: Provide new_size_gb and exactly one of instance_id or volume_id. Volume capacity can only be increased, not decreased.

Request Examples

cURL — Resize Using Instance ID

Use the following command to increase the storage capacity associated with a Nova instance to 1500 GB.

curl --request POST \
  --url "https://cloud.dataoorts.com/api/v1/nova/volume/resize" \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Accept: application/json" \
  --data '{
    "instance_id": 429,
    "new_size_gb": 1500
  }'

cURL — Resize Using Volume ID

You can also identify the target volume directly using its volume ID.

curl --request POST \
  --url "https://cloud.dataoorts.com/api/v1/nova/volume/resize" \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Accept: application/json" \
  --data '{
    "volume_id": "YOUR_VOLUME_ID",
    "new_size_gb": 1500
  }'

Replace YOUR_API_KEY and the example identifiers with your actual values. Ensure that the requested capacity is greater than the volume's existing capacity.

Python Example Implementation

The following example uses the requests library to submit a volume resize request using either an instance ID or a volume ID.

Install the required dependency:

pip install requests
import os
import requests


API_URL = (
    "https://cloud.dataoorts.com"
    "/api/v1/nova/volume/resize"
)


def resize_nova_volume(
    api_key: str,
    new_size_gb: int,
    instance_id: int | None = None,
    volume_id: str | int | None = None,
) -> dict:
    """
    Request an increase in Nova volume capacity.

    Provide either instance_id or volume_id, but not both.

    Args:
        api_key: Your Dataoorts Unify API key.
        new_size_gb: Requested new volume capacity in GB.
        instance_id: Optional ID of the Nova instance.
        volume_id: Optional ID of the target volume.

    Returns:
        dict: The JSON response returned by the API.

    Raises:
        ValueError:
            If the parameters are invalid or the response is not valid JSON.
        requests.exceptions.RequestException:
            If the HTTP request fails or returns an unsuccessful
            HTTP status code.
    """
    if not isinstance(new_size_gb, int) or isinstance(new_size_gb, bool):
        raise ValueError("new_size_gb must be an integer.")

    if new_size_gb <= 0:
        raise ValueError("new_size_gb must be greater than zero.")

    if (instance_id is None) == (volume_id is None):
        raise ValueError(
            "Provide exactly one of instance_id or volume_id."
        )

    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
        "Accept": "application/json",
    }

    payload = {
        "new_size_gb": new_size_gb,
    }

    if instance_id is not None:
        payload["instance_id"] = instance_id
    else:
        payload["volume_id"] = volume_id

    response = requests.post(
        API_URL,
        headers=headers,
        json=payload,
        timeout=60,
    )

    response.raise_for_status()

    try:
        return response.json()
    except requests.exceptions.JSONDecodeError as exc:
        raise ValueError(
            "The API returned an invalid JSON response."
        ) from exc


if __name__ == "__main__":
    api_key = os.getenv("DATAOORTS_API_KEY")

    if not api_key:
        raise RuntimeError(
            "Set the DATAOORTS_API_KEY environment variable."
        )

    try:
        result = resize_nova_volume(
            api_key=api_key,
            instance_id=429,
            new_size_gb=1500,
        )

        print("Status:", result.get("status"))
        print("Message:", result.get("message"))
        print("New Size (GB):", result.get("new_size_gb"))

    except requests.exceptions.RequestException as exc:
        print(f"API request failed: {exc}.")

    except ValueError as exc:
        print(f"Invalid request or response: {exc}.")

Set your API key before running the script.

Linux / macOS

export DATAOORTS_API_KEY="YOUR_API_KEY"
python resize_volume.py

Windows PowerShell

$env:DATAOORTS_API_KEY="YOUR_API_KEY"
python resize_volume.py

To resize using a volume ID instead, replace instance_id=429 with volume_id="YOUR_VOLUME_ID" in the function call.

Example Success Response

When the resize request is accepted, the API returns a JSON response similar to the following:

{
  "message": "Volume resize request accepted. Capacity increased to 1500 GB.",
  "new_size_gb": 1500,
  "status": "success"
}

The returned capacity and message will reflect the actual request.

Response Fields

FieldTypeDescription
statusStringIndicates result of API request. Successful response returns success.
messageStringA message confirming that the volume resize request was accepted.
new_size_gbIntegerThe requested new volume capacity in GB, as reported by the API.

Understanding the Resize Process

After submitting the request:

  1. Dataoorts processes the resize request for the volume identified by instance_id or volume_id.
  2. If the request is accepted, the API returns a confirmation message and the requested capacity.
  3. Check the volume or instance information again, where supported, to verify the resulting storage capacity.

Important: The example response confirms that the resize request was accepted. It should not be interpreted as independent confirmation that every underlying storage operation has completed.

Important Notes

1. Capacity Can Only Increase: The requested new_size_gb must be greater than the existing volume capacity. Decreasing volume size is not supported.

2. One Identifier: Provide either instance_id or volume_id in request. Do not send both identifiers together.

3. Verify the Target: Confirm that identifier points to intended instance or volume before submitting request.

4. Check the Result: A successful response confirms acceptance of the resize request. Verify the updated capacity when the relevant resource information becomes available.

5. Handle Timeouts Carefully: If the request times out or returns an error, check the current volume capacity before retrying to avoid unnecessary repeated resize requests.

Error Handling

If request fails, API may return unsuccessful HTTP status code and JSON response containing an error message.

Your application should handle authentication failures, invalid instance or volume IDs, unsupported capacity changes, network errors, request timeouts, and unexpected response formats. The exact error codes and messages depend on the API response.

In Python, response.raise_for_status() raises an exception for unsuccessful HTTP status codes. Do not assume that every response contains the same fields as a successful response.

Get Help and Support

For assistance with volume resizing or API integration, contact the support team at [email protected].