summaryrefslogtreecommitdiff
path: root/PVE/API2/Network/SDN/Zones.pm
diff options
context:
space:
mode:
authorAlexandre Derumier <aderumier@odiso.com>2020-10-05 17:09:08 +0200
committerThomas Lamprecht <t.lamprecht@proxmox.com>2020-10-08 11:05:28 +0200
commite8736dac7b67cb70274fc54fc70110bbea541889 (patch)
tree066e69652b15b677a343bec9525e4775e1908746 /PVE/API2/Network/SDN/Zones.pm
parentb184ebc3ad2ff63a264e7901d5ced209832dd171 (diff)
subnets/ipam: allow same subnet on different zones
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'PVE/API2/Network/SDN/Zones.pm')
-rw-r--r--PVE/API2/Network/SDN/Zones.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/PVE/API2/Network/SDN/Zones.pm b/PVE/API2/Network/SDN/Zones.pm
index 54f087d..5ae577b 100644
--- a/PVE/API2/Network/SDN/Zones.pm
+++ b/PVE/API2/Network/SDN/Zones.pm
@@ -9,6 +9,7 @@ use PVE::Cluster qw(cfs_read_file cfs_write_file);
use PVE::Network::SDN;
use PVE::Network::SDN::Vnets;
use PVE::Network::SDN::Zones;
+use PVE::Network::SDN::Subnets;
use PVE::Network::SDN::Dns;
use PVE::Network::SDN::Zones::Plugin;
use PVE::Network::SDN::Zones::VlanPlugin;
@@ -263,6 +264,16 @@ __PACKAGE__->register_method ({
my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
my $opts = $plugin->check_config($id, $param, 0, 1);
+ if($opts->{ipam} ne $scfg->{ipam}) {
+
+ #don't allow ipam change if subnet are defined
+ my $subnets_cfg = PVE::Network::SDN::Subnets::config();
+ foreach my $subnetid (sort keys %{$subnets_cfg->{ids}}) {
+ my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($subnets_cfg, $subnetid);
+ raise_param_exc({ ipam => "can't change ipam if subnet if already defined for this zone"}) if $subnet->{zone} eq $id;
+ }
+ }
+
foreach my $k (%$opts) {
$scfg->{$k} = $opts->{$k};
}