VirtWeb/virtweb_backend/src/libvirt_client.rs

26 lines
866 B
Rust
Raw Normal View History

2023-09-06 16:54:38 +00:00
use crate::actors::libvirt_actor;
2023-10-04 09:18:50 +00:00
use crate::actors::libvirt_actor::LibVirtActor;
use crate::libvirt_lib_structures::{DomainXML, DomainXMLUuid};
use crate::libvirt_rest_structures::HypervisorInfo;
2023-09-06 16:54:38 +00:00
use actix::Addr;
#[derive(Clone)]
pub struct LibVirtClient(pub Addr<LibVirtActor>);
impl LibVirtClient {
/// Get hypervisor info
pub async fn get_info(&self) -> anyhow::Result<HypervisorInfo> {
self.0.send(libvirt_actor::GetHypervisorInfo).await?
}
2023-10-04 09:18:50 +00:00
2023-10-04 17:03:20 +00:00
/// Get the information about a single domain
pub async fn get_single_domain(&self, id: DomainXMLUuid) -> anyhow::Result<DomainXML> {
self.0.send(libvirt_actor::GetDomainXMLReq(id)).await?
}
2023-10-04 09:18:50 +00:00
/// Update a domain
pub async fn update_domain(&self, xml: DomainXML) -> anyhow::Result<DomainXMLUuid> {
self.0.send(libvirt_actor::DefineDomainReq(xml)).await?
}
2023-09-06 16:54:38 +00:00
}