Can get domain info
This commit is contained in:
@ -4,6 +4,7 @@ use crate::libvirt_rest_structures::*;
|
||||
use actix::{Actor, Context, Handler, Message};
|
||||
use virt::connect::Connect;
|
||||
use virt::domain::Domain;
|
||||
use virt::sys::VIR_DOMAIN_XML_SECURE;
|
||||
|
||||
pub struct LibVirtActor {
|
||||
m: Connect,
|
||||
@ -57,6 +58,22 @@ impl Handler<GetHypervisorInfo> for LibVirtActor {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<DomainXML>")]
|
||||
pub struct GetDomainXMLReq(pub DomainXMLUuid);
|
||||
|
||||
impl Handler<GetDomainXMLReq> for LibVirtActor {
|
||||
type Result = anyhow::Result<DomainXML>;
|
||||
|
||||
fn handle(&mut self, msg: GetDomainXMLReq, _ctx: &mut Self::Context) -> Self::Result {
|
||||
log::debug!("Get domain XML:\n{}", msg.0.as_string());
|
||||
let domain = Domain::lookup_by_uuid_string(&self.m, &msg.0.as_string())?;
|
||||
let xml = domain.get_xml_desc(VIR_DOMAIN_XML_SECURE)?;
|
||||
log::debug!("XML = {}", xml);
|
||||
Ok(serde_xml_rs::from_str(&xml)?)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<DomainXMLUuid>")]
|
||||
pub struct DefineDomainReq(pub DomainXML);
|
||||
|
Reference in New Issue
Block a user