]> git.proxmox.com Git - pve-network.git/commitdiff
api2: zone: check ipam change if no ipam was defined before too
authorAlexandre Derumier <aderumier@odiso.com>
Thu, 29 Apr 2021 23:15:27 +0000 (01:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 5 May 2021 10:07:47 +0000 (12:07 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/API2/Network/SDN/Zones.pm

index 2163374fecb62e6955ab478ec6e994edccaacdc2..64fb9272d438091d733687d9fd7827995e75264e 100644 (file)
@@ -272,13 +272,13 @@ __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}) {
+           if($opts->{ipam} && !$scfg->{ipam} || $opts->{ipam} ne $scfg->{ipam}) {
 
-               #don't allow ipam change if subnet are defined
+               #don't allow ipam change if subnet are defined for now, need to implement resync ipam content
                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;
+                   raise_param_exc({ ipam => "can't change ipam if a subnet is already defined in this zone"}) if $subnet->{zone} eq $id;
                }
            }