mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-26 23:54:35 +02:00
api: list Docker image details and delete images
GET /computes/{compute_id}/docker/images now returns the daemon image
id, size and creation date in addition to the tag, so a UI can show
and compare images instead of bare names. The fields are optional to
keep the response compatible with older computes.
Add DELETE /computes/{compute_id}/docker/images/{image} which removes
the image from the compute Docker daemon. The image name is passed as
a path so names with a slash or a tag separator work. A daemon that
refuses because a container uses the image answers a conflict; the
force query parameter removes it anyway.
The compute also drops the controller digest to local id translation
recorded when the image was synced, since it no longer matches
anything on the daemon.
This commit is contained in:
7 files changed
+145
-7
No files matched your search
@@ -73,6 +73,22 @@ async def load_docker_image(
|
||||
await docker_manager.load_image(request.stream(), image=image, digest=digest)
|
||||
|
||||
|
||||
@router.delete("/docker/images/{image:path}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def delete_docker_image(
|
||||
image: str,
|
||||
force: bool = Query(False, description="Remove the image even if a container uses it"),
|
||||
) -> None:
|
||||
"""
|
||||
Delete a Docker image from the Docker daemon.
|
||||
|
||||
The daemon refuses to delete an image used by a container (even a stopped
|
||||
one) and answers a conflict, unless force is set.
|
||||
"""
|
||||
|
||||
docker_manager = Docker.instance()
|
||||
await docker_manager.delete_image(urllib.parse.unquote(image), force=force)
|
||||
|
||||
|
||||
@router.get("/dynamips/images")
|
||||
async def get_dynamips_images() -> List[dict]:
|
||||
"""
|
||||
|
||||
@@ -247,6 +247,29 @@ async def docker_load_image(compute_id: Union[str, UUID], request: Request) -> N
|
||||
await compute.http_query("POST", "/docker/images/load", data=request.stream(), timeout=None)
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/{compute_id}/docker/images/{image:path}",
|
||||
status_code=status.HTTP_204_NO_CONTENT,
|
||||
dependencies=[Depends(has_privilege("Compute.Modify"))],
|
||||
)
|
||||
async def docker_delete_image(
|
||||
compute_id: Union[str, UUID],
|
||||
image: str,
|
||||
force: bool = Query(False, description="Remove the image even if a container uses it"),
|
||||
) -> None:
|
||||
"""
|
||||
Delete a Docker image on a compute.
|
||||
|
||||
The compute refuses to delete an image used by a container (even a stopped
|
||||
one) and answers a conflict, unless force is set.
|
||||
|
||||
Required privilege: Compute.Modify
|
||||
"""
|
||||
|
||||
compute = Controller.instance().get_compute(str(compute_id))
|
||||
await compute.http_query("DELETE", f"/docker/images/{image}", params={"force": str(force).lower()})
|
||||
|
||||
|
||||
@router.get("/{compute_id}/virtualbox/vms", response_model=List[schemas.ComputeVirtualBoxVM])
|
||||
async def virtualbox_vms(compute_id: Union[str, UUID]) -> List[schemas.ComputeVirtualBoxVM]:
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user