[pve-devel] [PATCH pve-network v4 03/21] fabrics: add fabrics module

Gabriel Goller g.goller at proxmox.com
Wed Jul 2 16:50:23 CEST 2025


From: Stefan Hanreich <s.hanreich at proxmox.com>

Add a new basic Fabrics module that can be used for reading and
writing the fabrics configuration file.

Co-authored-by: Gabriel Goller <g.goller at proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 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





More information about the pve-devel mailing list