From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 78C521FF183 for ; Wed, 2 Jul 2025 16:51:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4C7E71E6C2; Wed, 2 Jul 2025 16:51:33 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Wed, 2 Jul 2025 16:50:23 +0200 Message-Id: <20250702145101.894299-39-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250702145101.894299-1-g.goller@proxmox.com> References: <20250702145101.894299-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.018 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 pve-network v4 03/21] fabrics: add fabrics module X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" From: Stefan Hanreich Add a new basic Fabrics module that can be used for reading and writing the fabrics configuration file. Co-authored-by: Gabriel Goller Signed-off-by: Stefan Hanreich --- src/PVE/Network/SDN/Fabrics.pm | 47 ++++++++++++++++++++++++++++++++++ src/PVE/Network/SDN/Makefile | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/PVE/Network/SDN/Fabrics.pm diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm new file mode 100644 index 000000000000..89a8ae88507d --- /dev/null +++ b/src/PVE/Network/SDN/Fabrics.pm @@ -0,0 +1,47 @@ +package PVE::Network::SDN::Fabrics; + +use strict; +use warnings; + +use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_lock_file cfs_write_file); +use PVE::JSONSchema qw(get_standard_option); +use PVE::INotify; +use PVE::RS::SDN::Fabrics; + +cfs_register_file( + 'sdn/fabrics.cfg', \&parse_fabrics_config, \&write_fabrics_config, +); + +sub parse_fabrics_config { + my ($filename, $raw) = @_; + return $raw // ''; +} + +sub write_fabrics_config { + my ($filename, $config) = @_; + return $config // ''; +} + +sub config { + my ($running) = @_; + + if ($running) { + my $running_config = PVE::Network::SDN::running_config(); + + # if the config hasn't yet been applied after the introduction of + # fabrics then the key does not exist in the running config so we + # default to an empty hash + my $fabrics_config = $running_config->{fabrics}->{ids} // {}; + return PVE::RS::SDN::Fabrics->running_config($fabrics_config); + } + + my $fabrics_config = cfs_read_file("sdn/fabrics.cfg"); + return PVE::RS::SDN::Fabrics->config($fabrics_config); +} + +sub write_config { + my ($config) = @_; + cfs_write_file("sdn/fabrics.cfg", $config->to_raw(), 1); +} + +1; diff --git a/src/PVE/Network/SDN/Makefile b/src/PVE/Network/SDN/Makefile index 3e6e5fb4c6f2..a256642e3044 100644 --- a/src/PVE/Network/SDN/Makefile +++ b/src/PVE/Network/SDN/Makefile @@ -1,4 +1,4 @@ -SOURCES=Vnets.pm VnetPlugin.pm Zones.pm Controllers.pm Subnets.pm SubnetPlugin.pm Ipams.pm Dns.pm Dhcp.pm +SOURCES=Vnets.pm VnetPlugin.pm Zones.pm Controllers.pm Subnets.pm SubnetPlugin.pm Ipams.pm Dns.pm Dhcp.pm Fabrics.pm PERL5DIR=${DESTDIR}/usr/share/perl5 -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel