diff options
| author | Stefan Hanreich <s.hanreich@proxmox.com> | 2025-07-16 15:07:58 +0200 | 
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2025-07-17 00:10:34 +0200 | 
| commit | 074d2a69a90b32bcb4fcf5e6c9d5c830237cbe8f (patch) | |
| tree | 8df0b05fdfca3eead9250f78631eb2e44b751924 /src | |
| parent | 8380f81faf7dd83d752a860b263fe52ae08d3393 (diff) | |
fabrics: add fabrics module
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@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Link: https://lore.proxmox.com/20250716130837.585796-38-g.goller@proxmox.com
Diffstat (limited to 'src')
| -rw-r--r-- | src/PVE/Network/SDN/Fabrics.pm | 47 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Makefile | 2 | 
2 files changed, 48 insertions, 1 deletions
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm new file mode 100644 index 0000000..89a8ae8 --- /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 3e6e5fb..a256642 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  | 
