Can enable autostart of VMs

This commit is contained in:
2023-10-28 17:30:27 +02:00
parent 9a15fb4f60
commit 335aec788e
10 changed files with 304 additions and 56 deletions

View File

@ -90,6 +90,28 @@ pub async fn update(
Ok(HttpResponse::Ok().finish())
}
#[derive(serde::Serialize, serde::Deserialize)]
pub struct VMAutostart {
autostart: bool,
}
/// Get autostart value of a vm
pub async fn get_autostart(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpResult {
Ok(HttpResponse::Ok().json(VMAutostart {
autostart: client.is_domain_autostart(id.uid).await?,
}))
}
/// Configure autostart value for a vm
pub async fn set_autostart(
client: LibVirtReq,
id: web::Path<SingleVMUUidReq>,
body: web::Json<VMAutostart>,
) -> HttpResult {
client.set_domain_autostart(id.uid, body.autostart).await?;
Ok(HttpResponse::Accepted().json("OK"))
}
#[derive(serde::Deserialize)]
pub struct DeleteVMQuery {
keep_files: bool,