Can get domains screenshots

This commit is contained in:
2023-10-13 15:27:01 +02:00
parent 4c29184a3b
commit 0a00e43216
6 changed files with 329 additions and 35 deletions

View File

@ -130,3 +130,17 @@ pub async fn resume(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpR
}
})
}
/// Take a screenshot of a VM
pub async fn screenshot(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpResult {
Ok(match client.screenshot_domain(id.uid).await {
Ok(b) => HttpResponse::Ok().content_type("image/png").body(b),
Err(e) => {
log::error!(
"Failed to take the screenshot of a domain {:?} ! {e}",
id.uid
);
HttpResponse::InternalServerError().json("Failed to take the screenshot of the domain!")
}
})
}