Can get domain state through a dedicated route
This commit is contained in:
@ -131,6 +131,22 @@ pub async fn resume(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpR
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct DomainStateRes {
|
||||
state: DomainState,
|
||||
}
|
||||
|
||||
/// Get the state of a VM
|
||||
pub async fn state(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpResult {
|
||||
Ok(match client.get_domain_state(id.uid).await {
|
||||
Ok(s) => HttpResponse::Ok().json(DomainStateRes { state: s }),
|
||||
Err(e) => {
|
||||
log::error!("Failed to get domain state {:?} ! {e}", id.uid);
|
||||
HttpResponse::InternalServerError().json("Failed to get domain state!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
|
Reference in New Issue
Block a user