Add prune images endpoint.

Use many-to-many relationship between images and templates.
This commit is contained in:
grossmj committed 2021-08-20 15:58:41 +09:30
1 parent 078c42f185
commit 4d9e4e1059
5 files changed
+90 -13

No files matched your search

+13 -1
View File
@@ -22,7 +22,7 @@ import os
import logging
import urllib.parse
from fastapi import APIRouter, Request, Depends, status
from fastapi import APIRouter, Request, Response, Depends, status
from typing import List
from gns3server import schemas
@@ -125,3 +125,15 @@ async def delete_image(
success = await images_repo.delete_image(image_name)
if not success:
raise ControllerError(f"Image '{image_name}' could not be deleted")
@router.post("/prune", status_code=status.HTTP_204_NO_CONTENT)
async def prune_images(
images_repo: ImagesRepository = Depends(get_repository(ImagesRepository)),
) -> Response:
"""
Prune images not attached to any template.
"""
await images_repo.prune_images()
return Response(status_code=status.HTTP_204_NO_CONTENT)