On Wed, Jul 02, 2025 at 04:50:16PM +0200, Gabriel Goller wrote: > From: Stefan Hanreich <s.hanre...@proxmox.com> > > We use proxmox-ve-config to generate a FRR config and serialize it > with the proxmox-frr crate in order to return it to perl in its > internally used format (an array of strings). The Perl SDN module in > turn merges it with the FRR configuration generated by Perl modules > and persists it to the FRR configuration file. > > We also provide a method that returns a list of daemons, that are > required to be enabled for the current FRR configuration. This is used > by Perl to write the daemons configuration file of FRR. > > Co-authored-by: Gabriel Goller <g.gol...@proxmox.com> > Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> > --- > pve-rs/src/bindings/sdn/fabrics.rs | 49 +++++++++++++++++++++++++++++- > 1 file changed, 48 insertions(+), 1 deletion(-) > > diff --git a/pve-rs/src/bindings/sdn/fabrics.rs > b/pve-rs/src/bindings/sdn/fabrics.rs > index 2efa1c6306ae..a7a740f5aac9 100644 > --- a/pve-rs/src/bindings/sdn/fabrics.rs > +++ b/pve-rs/src/bindings/sdn/fabrics.rs > @@ -5,7 +5,7 @@ pub mod pve_rs_sdn_fabrics { > //! This provides the configuration for the SDN fabrics, as well as > helper methods for reading > //! / writing the configuration, as well as for generating ifupdown2 and > FRR configuration. > > - use std::collections::BTreeMap; > + use std::collections::{BTreeMap, HashSet}; > use std::ops::Deref; > use std::sync::Mutex; > > @@ -14,6 +14,7 @@ pub mod pve_rs_sdn_fabrics { > use serde::{Deserialize, Serialize}; > > use perlmod::Value; > + use proxmox_frr::serializer::to_raw_config; > use proxmox_section_config::typed::SectionConfigData; > use proxmox_ve_config::common::valid::Validatable; > > @@ -31,6 +32,7 @@ pub mod pve_rs_sdn_fabrics { > }, > FabricConfig, FabricEntry, > }; > + use proxmox_ve_config::sdn::frr::FrrConfigBuilder; > > /// A SDN Fabric config instance. > #[derive(Serialize, Deserialize)] > @@ -302,4 +304,49 @@ pub mod pve_rs_sdn_fabrics { > > Ok(hex::encode(hash)) > } > + > + /// Class method: Return all FRR daemons that need to be enabled for > this fabric configuration > + /// instance.
Method* Daemons? Or would "services" make more sense (and a `.service` suffix?) > + #[export] > + pub fn enabled_daemons( > + #[try_from_ref] this: &PerlFabricConfig, > + node_id: NodeId, > + ) -> Vec<String> { > + let config = this.fabric_config.lock().unwrap(); > + > + let node_fabrics = config > + .values() > + .filter(|fabric| fabric.get_node(&node_id).is_ok()); > + > + let mut daemons = HashSet::new(); > + > + for fabric in node_fabrics { > + match fabric { > + FabricEntry::Ospf(_) => { > + daemons.insert("ospfd"); > + } > + FabricEntry::Openfabric(_) => { > + daemons.insert("fabricd"); > + } > + }; > + } > + > + daemons.into_iter().map(String::from).collect() > + } > + > + /// Class method: Return the FRR configuration for this config instance, > as an array of > + /// strings, where each line represents a line in the FRR configuration. > + #[export] > + pub fn get_frr_raw_config( > + #[try_from_ref] this: &PerlFabricConfig, > + node_id: NodeId, > + ) -> Result<Vec<String>, Error> { > + let config = this.fabric_config.lock().unwrap(); > + > + let frr_config = FrrConfigBuilder::default() > + .add_fabrics(config.clone().into_valid()?) > + .build(node_id)?; > + > + to_raw_config(&frr_config) > + } > } > -- > 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel