Support delete Qemu disk image from API

Return the real disk image name in the 'hdx_disk_image_backed' property for Qemu VMs
This commit is contained in:
grossmj committed 2022-04-14 17:01:54 +07:00
1 parent a1c76ec4f2
commit e50bed5bee
13 files changed
+191 -42

No files matched your search

+2 -1
View File
@@ -52,12 +52,13 @@ router = APIRouter()
@router.get("", response_model=List[schemas.Image])
async def get_images(
images_repo: ImagesRepository = Depends(get_repository(ImagesRepository)),
image_type: Optional[schemas.ImageType] = None
) -> List[schemas.Image]:
"""
Return all images.
"""
return await images_repo.get_images()
return await images_repo.get_images(image_type)
@router.post("/upload/{image_path:path}", response_model=schemas.Image, status_code=status.HTTP_201_CREATED)
+15
View File
@@ -348,6 +348,21 @@ async def update_disk_image(
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.delete("/{node_id}/qemu/disk_image/{disk_name}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_disk_image(
disk_name: str,
node: Node = Depends(dep_node)
) -> Response:
"""
Delete a Qemu disk image.
"""
if node.node_type != "qemu":
raise ControllerBadRequestError("Deleting a disk image is only supported on a Qemu node")
await node.delete(f"/disk_image/{disk_name}")
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.get("/{node_id}/files/{file_path:path}")
async def get_file(file_path: str, node: Node = Depends(dep_node)) -> Response:
"""