Can get domains list
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user