Can get NW filter source XML definition
This commit is contained in:
		@@ -642,3 +642,21 @@ impl Handler<DeleteNetworkFilter> for LibVirtActor {
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Message)]
 | 
			
		||||
#[rtype(result = "anyhow::Result<String>")]
 | 
			
		||||
pub struct GetSourceNetworkFilterXMLReq(pub XMLUuid);
 | 
			
		||||
 | 
			
		||||
impl Handler<GetSourceNetworkFilterXMLReq> for LibVirtActor {
 | 
			
		||||
    type Result = anyhow::Result<String>;
 | 
			
		||||
 | 
			
		||||
    fn handle(
 | 
			
		||||
        &mut self,
 | 
			
		||||
        msg: GetSourceNetworkFilterXMLReq,
 | 
			
		||||
        _ctx: &mut Self::Context,
 | 
			
		||||
    ) -> Self::Result {
 | 
			
		||||
        log::debug!("Get nw filter source XML:\n{}", msg.0.as_string());
 | 
			
		||||
        let nwfilter = NWFilter::lookup_by_uuid_string(&self.m, &msg.0.as_string())?;
 | 
			
		||||
        Ok(nwfilter.get_xml_desc(0)?)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,12 @@ pub async fn get_single(client: LibVirtReq, req: web::Path<NetworkFilterID>) ->
 | 
			
		||||
    Ok(HttpResponse::Ok().json(nwfilter))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get the XML source description of a single network filter
 | 
			
		||||
pub async fn single_src(client: LibVirtReq, req: web::Path<NetworkFilterID>) -> HttpResult {
 | 
			
		||||
    let xml = client.get_single_network_filter_xml(req.uid).await?;
 | 
			
		||||
    Ok(HttpResponse::Ok().content_type("application/xml").body(xml))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Update the information about a single network filter
 | 
			
		||||
pub async fn update(
 | 
			
		||||
    client: LibVirtReq,
 | 
			
		||||
 
 | 
			
		||||
@@ -187,6 +187,13 @@ impl LibVirtClient {
 | 
			
		||||
        self.0.send(libvirt_actor::GetNWFilterXMLReq(id)).await?
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Get the source XML configuration of a single network filter
 | 
			
		||||
    pub async fn get_single_network_filter_xml(&self, id: XMLUuid) -> anyhow::Result<String> {
 | 
			
		||||
        self.0
 | 
			
		||||
            .send(libvirt_actor::GetSourceNetworkFilterXMLReq(id))
 | 
			
		||||
            .await?
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Update the information about a single domain
 | 
			
		||||
    pub async fn update_network_filter(
 | 
			
		||||
        &self,
 | 
			
		||||
 
 | 
			
		||||
@@ -252,6 +252,10 @@ async fn main() -> std::io::Result<()> {
 | 
			
		||||
                "/api/nwfilter/{uid}",
 | 
			
		||||
                web::get().to(nwfilter_controller::get_single),
 | 
			
		||||
            )
 | 
			
		||||
            .route(
 | 
			
		||||
                "/api/nwfilter/{uid}/src",
 | 
			
		||||
                web::get().to(nwfilter_controller::single_src),
 | 
			
		||||
            )
 | 
			
		||||
            .route(
 | 
			
		||||
                "/api/nwfilter/{uid}",
 | 
			
		||||
                web::put().to(nwfilter_controller::update),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user