diff options
| author | Stefan Lendl <s.lendl@proxmox.com> | 2024-04-05 15:17:58 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2024-04-08 17:57:18 +0200 |
| commit | 2f37fddc0ebcb039df3703ff4a251d33f05e9f2e (patch) | |
| tree | d4a0c21059d2558384c484c58791c5a0ec64f943 /src | |
| parent | 27b54a086b527322c6c192c0654e5bd7f9334fc5 (diff) | |
sdn: zones: extract function that reads datacenter config
The datacenter_config() functions in SDN::Zones::Plugin is a simple
wrapper that reads datacenter.cfg via cfs.
This allows mocking datacenter.cfg in tests.
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 3 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Zones/Plugin.pm | 5 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Zones/SimplePlugin.pm | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm index 655a9f0..4843756 100644 --- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -3,6 +3,7 @@ package PVE::Network::SDN::Zones::EvpnPlugin; use strict; use warnings; use PVE::Network::SDN::Zones::VxlanPlugin; +use PVE::Network::SDN::Zones::Plugin; use PVE::Exception qw(raise raise_param_exc); use PVE::JSONSchema qw(get_standard_option); use PVE::Tools qw($IPV4RE); @@ -294,7 +295,7 @@ sub on_update_hook { } if (!defined($zone_cfg->{ids}->{$zoneid}->{'mac'})) { - my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg'); + my $dc = PVE::Network::SDN::Zones::Plugin->datacenter_config(); $zone_cfg->{ids}->{$zoneid}->{'mac'} = PVE::Tools::random_ether_addr($dc->{mac_prefix}); } } diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm index b55b967..247d0b2 100644 --- a/src/PVE/Network/SDN/Zones/Plugin.pm +++ b/src/PVE/Network/SDN/Zones/Plugin.pm @@ -356,4 +356,9 @@ sub get_bridge_ifaces { return @bridge_ifaces; } + +sub datacenter_config { + return PVE::Cluster::cfs_read_file('datacenter.cfg'); +} + 1; diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm index c996bf3..65e9ad4 100644 --- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm +++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -139,7 +139,7 @@ sub vnet_update_hook { raise_param_exc({ tag => "vlan tag is not allowed on simple zone"}) if defined($tag); if (!defined($vnet->{mac})) { - my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg'); + my $dc = PVE::Network::SDN::Zones::Plugin::datacenter_config(); $vnet->{mac} = PVE::Tools::random_ether_addr($dc->{mac_prefix}); } } |
