Add REST route to get networks list

This commit is contained in:
2023-10-31 10:51:13 +01:00
parent f2237d4f2f
commit 2741faa95b
7 changed files with 125 additions and 2 deletions

View File

@ -14,7 +14,7 @@ impl LibVirtClient {
}
/// Get the full list of domain
pub async fn get_full_list(&self) -> anyhow::Result<Vec<DomainXML>> {
pub async fn get_full_domains_list(&self) -> anyhow::Result<Vec<DomainXML>> {
let ids = self.0.send(libvirt_actor::GetDomainsListReq).await??;
let mut info = Vec::with_capacity(ids.len());
for id in ids {
@ -96,4 +96,19 @@ impl LibVirtClient {
pub async fn update_network(&self, network: NetworkXML) -> anyhow::Result<XMLUuid> {
self.0.send(libvirt_actor::DefineNetwork(network)).await?
}
/// Get the full list of networks
pub async fn get_full_networks_list(&self) -> anyhow::Result<Vec<NetworkXML>> {
let ids = self.0.send(libvirt_actor::GetNetworksListReq).await??;
let mut info = Vec::with_capacity(ids.len());
for id in ids {
info.push(self.get_single_network(id).await?)
}
Ok(info)
}
/// Get the information about a single network
pub async fn get_single_network(&self, id: XMLUuid) -> anyhow::Result<NetworkXML> {
self.0.send(libvirt_actor::GetNetworkXMLReq(id)).await?
}
}