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

@ -59,6 +59,26 @@ impl Handler<GetHypervisorInfo> for LibVirtActor {
}
}
#[derive(Message)]
#[rtype(result = "anyhow::Result<Vec<DomainXMLUuid>>")]
pub struct GetDomainsListReq;
impl Handler<GetDomainsListReq> for LibVirtActor {
type Result = anyhow::Result<Vec<DomainXMLUuid>>;
fn handle(&mut self, _msg: GetDomainsListReq, _ctx: &mut Self::Context) -> Self::Result {
log::debug!("Get full list of domains");
let domains = self.m.list_all_domains(0)?;
let mut ids = Vec::with_capacity(domains.len());
for d in domains {
ids.push(DomainXMLUuid::parse_from_str(&d.get_uuid_string()?)?);
}
Ok(ids)
}
}
#[derive(Message)]
#[rtype(result = "anyhow::Result<DomainXML>")]
pub struct GetDomainXMLReq(pub DomainXMLUuid);