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 [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id DCA6E1FF15C for <inbox@lore.proxmox.com>; Fri, 4 Apr 2025 18:30:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 952C5377D6; Fri, 4 Apr 2025 18:29:26 +0200 (CEST) From: Gabriel Goller <g.goller@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 4 Apr 2025 18:28:28 +0200 Message-Id: <20250404162908.563060-18-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250404162908.563060-1-g.goller@proxmox.com> References: <20250404162908.563060-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.023 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 v2 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/debian/control | 5 ++++ pve-rs/src/lib.rs | 1 + pve-rs/src/sdn/fabrics.rs | 50 +++++++++++++++++++++++++++++++++++++++ pve-rs/src/sdn/mod.rs | 1 + 6 files changed, 63 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..bdfff6adf685 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -33,15 +33,19 @@ perlmod = { version = "0.13.5", features = ["exporter"] } proxmox-apt = { version = "0.11.5", features = ["cache"] } proxmox-apt-api-types = "1.0" proxmox-config-digest = "0.1" +proxmox-frr = { version = "0.1" } proxmox-http = { version = "0.9", features = ["client-sync", "client-trait"] } proxmox-http-error = "0.1.0" proxmox-log = "0.2" +proxmox-network-types = { version = "0.1" } 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.2", features=["frr"] } 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/debian/control b/pve-rs/debian/control index 8dadddf3d74f..5e3b8f662ad0 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -18,15 +18,19 @@ Build-Depends: cargo:native <!nocheck>, librust-proxmox-apt-0.11+default-dev (>= 0.11.5-~~), librust-proxmox-apt-api-types-1+default-dev, librust-proxmox-config-digest-0.1+default-dev, + librust-proxmox-frr-0.1+default-dev, librust-proxmox-http-0.9+client-sync-dev, librust-proxmox-http-0.9+client-trait-dev, librust-proxmox-http-0.9+default-dev, librust-proxmox-http-error-0.1+default-dev, librust-proxmox-log-0.2+default-dev, + librust-proxmox-network-types-0.1+default-dev <!nocheck>, librust-proxmox-notify-0.5+default-dev, librust-proxmox-notify-0.5+pve-context-dev, librust-proxmox-openid-0.10+default-dev, librust-proxmox-resource-scheduling-0.3+default-dev, + librust-proxmox-schema-4+default-dev <!nocheck>, + librust-proxmox-section-config-2+default-dev (>= 2.1.2-~~) <!nocheck>, librust-proxmox-shared-cache-0.1+default-dev, librust-proxmox-subscription-0.5+default-dev, librust-proxmox-sys-0.6+default-dev, @@ -34,6 +38,7 @@ Build-Depends: cargo:native <!nocheck>, librust-proxmox-tfa-5+default-dev, librust-proxmox-time-2+default-dev, librust-proxmox-ve-config-dev (>= 0.2.1-~~), + librust-proxmox-ve-config+frr-dev (>= 0.2.1-~~), librust-serde-1+default-dev, librust-serde-bytes-0.11+default-dev, librust-serde-json-1+default-dev, 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