From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DED221FF164 for <inbox@lore.proxmox.com>; Fri, 28 Mar 2025 18:14:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BE29884D8; Fri, 28 Mar 2025 18:13:58 +0100 (CET) From: Gabriel Goller <g.goller@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 28 Mar 2025 18:13:08 +0100 Message-Id: <20250328171340.885413-21-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250328171340.885413-1-g.goller@proxmox.com> References: <20250328171340.885413-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.025 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox-perl-rs 1/7] perl-rs: sdn: initial fabric infrastructure X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Add SDN fabric support with OpenFabric and OSPF configuration parsing. Implements PerlSectionConfig wrapper and Perl module exports for fabric configuration management. Signed-off-by: Gabriel Goller <g.goller@proxmox.com> --- pve-rs/Cargo.toml | 6 ++++- pve-rs/Makefile | 1 + pve-rs/src/lib.rs | 1 + pve-rs/src/sdn/fabrics.rs | 50 +++++++++++++++++++++++++++++++++++++++ pve-rs/src/sdn/mod.rs | 1 + 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 pve-rs/src/sdn/fabrics.rs create mode 100644 pve-rs/src/sdn/mod.rs diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index f2e495d33743..441b417a961a 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -39,9 +39,13 @@ proxmox-log = "0.2" proxmox-notify = { version = "0.5", features = ["pve-context"] } proxmox-openid = "0.10" proxmox-resource-scheduling = "0.3.0" +proxmox-schema = "4.0.0" +proxmox-section-config = "2.1.1" proxmox-shared-cache = "0.1.0" proxmox-subscription = "0.5" proxmox-sys = "0.6" proxmox-tfa = { version = "5", features = ["api"] } proxmox-time = "2" -proxmox-ve-config = { version = "0.2.1" } +proxmox-ve-config = { version = "0.2.1", features=["frr"] } +proxmox-frr = { version = "0.1" } +proxmox-network-types = { version = "0.1" } diff --git a/pve-rs/Makefile b/pve-rs/Makefile index d01da692d8c9..86af16eb5e04 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -31,6 +31,7 @@ PERLMOD_PACKAGES := \ PVE::RS::Firewall::SDN \ PVE::RS::OpenId \ PVE::RS::ResourceScheduling::Static \ + PVE::RS::SDN::Fabrics \ PVE::RS::TFA PERLMOD_PACKAGE_FILES := $(addsuffix .pm,$(subst ::,/,$(PERLMOD_PACKAGES))) diff --git a/pve-rs/src/lib.rs b/pve-rs/src/lib.rs index 3de37d17fab6..12ee87a91cc6 100644 --- a/pve-rs/src/lib.rs +++ b/pve-rs/src/lib.rs @@ -15,6 +15,7 @@ pub mod apt; pub mod firewall; pub mod openid; pub mod resource_scheduling; +pub mod sdn; pub mod tfa; #[perlmod::package(name = "Proxmox::Lib::PVE", lib = "pve_rs")] diff --git a/pve-rs/src/sdn/fabrics.rs b/pve-rs/src/sdn/fabrics.rs new file mode 100644 index 000000000000..a761cea36ec0 --- /dev/null +++ b/pve-rs/src/sdn/fabrics.rs @@ -0,0 +1,50 @@ +#[perlmod::package(name = "PVE::RS::SDN::Fabrics", lib = "pve_rs")] +pub mod export { + use std::sync::Mutex; + + use anyhow::Error; + use proxmox_section_config::{ + typed::ApiSectionDataEntry, typed::SectionConfigData as TypedSectionConfigData, + }; + use proxmox_ve_config::sdn::fabric::{ + openfabric::OpenFabricSectionConfig, ospf::OspfSectionConfig, + }; + use serde::{Deserialize, Serialize}; + + pub struct PerlSectionConfig<T> { + pub section_config: Mutex<TypedSectionConfigData<T>>, + } + + impl<T> PerlSectionConfig<T> + where + T: Send + Sync + Clone, + { + pub fn into_inner(self) -> Result<TypedSectionConfigData<T>, anyhow::Error> { + let value = self.section_config.into_inner().unwrap(); + Ok(value) + } + } + + #[derive(Serialize, Deserialize)] + struct AllConfigs { + openfabric: Vec<OpenFabricSectionConfig>, + ospf: Vec<OspfSectionConfig>, + } + + /// Get all the config. This takes the raw openfabric and ospf config, parses, and returns + /// both. + #[export] + fn config(raw_openfabric: &[u8], raw_ospf: &[u8]) -> Result<AllConfigs, Error> { + let raw_openfabric = std::str::from_utf8(raw_openfabric)?; + let raw_ospf = std::str::from_utf8(raw_ospf)?; + + let openfabric = + OpenFabricSectionConfig::parse_section_config("openfabric.cfg", raw_openfabric)?; + let ospf = OspfSectionConfig::parse_section_config("ospf.cfg", raw_ospf)?; + + Ok(AllConfigs { + openfabric: openfabric.into_iter().map(|e| e.1).collect(), + ospf: ospf.into_iter().map(|e| e.1).collect(), + }) + } +} diff --git a/pve-rs/src/sdn/mod.rs b/pve-rs/src/sdn/mod.rs new file mode 100644 index 000000000000..3e3b1376f8d6 --- /dev/null +++ b/pve-rs/src/sdn/mod.rs @@ -0,0 +1 @@ +pub mod fabrics; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel