api: add controller endpoint to load Docker images on a compute

Add POST /computes/{compute_id}/docker/images/load. It streams an
uploaded docker save tar (plain or gzip) to the compute, which loads
it into its Docker daemon. Clients can now install image packages
such as iol-xe-17-18-02.tar.gz without SSH access to the server.

The body is proxied without buffering (async iterable to chunked
transfer) and runs with no total timeout, like the existing image
sync path between computes.
This commit is contained in:
YueGuobin committed 2026-11-06 10:00:17 +08:00
1 parent 111a4b756c
commit 092202615e
2 files changed
+41 -1

No files matched your search

+21 -1
View File
@@ -21,7 +21,7 @@ API routes for computes.
from typing import Any, List, Optional, Union
from uuid import UUID
from fastapi import APIRouter, Body, Depends, Query, status
from fastapi import APIRouter, Body, Depends, Query, Request, status
import gns3server.db.models as models
from gns3server import schemas
@@ -227,6 +227,26 @@ async def docker_pull_image(
await compute.forward("POST", "docker", "images/pull", data={"image": image})
@router.post(
"/{compute_id}/docker/images/load",
status_code=status.HTTP_204_NO_CONTENT,
dependencies=[Depends(has_privilege("Compute.Modify"))],
)
async def docker_load_image(compute_id: Union[str, UUID], request: Request) -> None:
"""
Load a Docker image on a compute from a docker save tar stream.
The tar archive (plain or gzip compressed) is streamed to the compute
and loaded into its Docker daemon, without buffering the whole file
in the controller memory.
Required privilege: Compute.Modify
"""
compute = Controller.instance().get_compute(str(compute_id))
await compute.http_query("POST", "docker/images/load", data=request.stream(), timeout=None)
@router.get("/{compute_id}/virtualbox/vms", response_model=List[schemas.ComputeVirtualBoxVM])
async def virtualbox_vms(compute_id: Union[str, UUID]) -> List[schemas.ComputeVirtualBoxVM]:
"""