Can get domains list

This commit is contained in:
2023-10-09 19:16:33 +02:00
parent b69c97e6fe
commit 908b0f4c56
4 changed files with 49 additions and 0 deletions

View File

@ -24,6 +24,24 @@ pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
Ok(HttpResponse::Ok().json(id))
}
/// Get the list of domains
pub async fn list_all(client: LibVirtReq) -> HttpResult {
let list = client.get_full_list().await?;
let mut out = Vec::with_capacity(list.len());
for entry in list {
let info = VMInfo::from_domain(entry)?;
out.push(VMInfoAndState {
state: client
.get_domain_state(info.uuid.expect("Domain without UUID !"))
.await?,
info,
})
}
Ok(HttpResponse::Ok().json(out))
}
#[derive(serde::Deserialize)]
pub struct SingleVMUUidReq {
uid: DomainXMLUuid,