summaryrefslogtreecommitdiff
path: root/src/PVE/Network/SDN/Subnets.pm
diff options
context:
space:
mode:
authorStefan Hanreich <s.hanreich@proxmox.com>2023-11-17 12:39:40 +0100
committerThomas Lamprecht <t.lamprecht@proxmox.com>2023-11-18 15:59:50 +0100
commita1845dad8032395f6679300af3d3100b5ded31d9 (patch)
tree0e5ceb011e98cab2f9087a1193bc448e31b0f489 /src/PVE/Network/SDN/Subnets.pm
parente8ca5bc60308d0c3ae16e0551179cbe9b681f8d3 (diff)
sdn: preparations for DHCP plugin
Add the option to retrieve the running configuration instead of only the pending configuration via the config methods. Refactor methods using the running config to utilize the new parameter. Add helper methods and return additional attributes from the getter functions that are needed by the dhcp plugins. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Diffstat (limited to 'src/PVE/Network/SDN/Subnets.pm')
-rw-r--r--src/PVE/Network/SDN/Subnets.pm25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/PVE/Network/SDN/Subnets.pm b/src/PVE/Network/SDN/Subnets.pm
index 6bb42e5..f654d3a 100644
--- a/src/PVE/Network/SDN/Subnets.pm
+++ b/src/PVE/Network/SDN/Subnets.pm
@@ -23,7 +23,9 @@ sub sdn_subnets_config {
my $scfg = $cfg->{ids}->{$id};
die "sdn subnet '$id' does not exist\n" if (!$noerr && !$scfg);
- if($scfg) {
+ if ($scfg) {
+ $scfg->{id} = $id;
+
my ($zone, $network, $mask) = split(/-/, $id);
$scfg->{cidr} = "$network/$mask";
$scfg->{zone} = $zone;
@@ -35,7 +37,14 @@ sub sdn_subnets_config {
}
sub config {
- my $config = cfs_read_file("sdn/subnets.cfg");
+ my ($running) = @_;
+
+ if ($running) {
+ my $cfg = PVE::Network::SDN::running_config();
+ return $cfg->{subnets};
+ }
+
+ return cfs_read_file("sdn/subnets.cfg");
}
sub write_config {
@@ -61,16 +70,8 @@ sub complete_sdn_subnet {
sub get_subnet {
my ($subnetid, $running) = @_;
- my $cfg = {};
- if($running) {
- my $cfg = PVE::Network::SDN::running_config();
- $cfg = $cfg->{subnets};
- } else {
- $cfg = PVE::Network::SDN::Subnets::config();
- }
-
- my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, $subnetid, 1);
- return $subnet;
+ my $cfg = PVE::Network::SDN::Subnets::config($running);
+ return PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, $subnetid, 1);
}
sub find_ip_subnet {