diff options
| author | Alexandre Derumier <aderumier@odiso.com> | 2020-10-05 17:09:08 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2020-10-08 11:05:28 +0200 |
| commit | e8736dac7b67cb70274fc54fc70110bbea541889 (patch) | |
| tree | 066e69652b15b677a343bec9525e4775e1908746 /PVE/API2/Network/SDN/Vnets.pm | |
| parent | b184ebc3ad2ff63a264e7901d5ced209832dd171 (diff) | |
subnets/ipam: allow same subnet on different zones
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'PVE/API2/Network/SDN/Vnets.pm')
| -rw-r--r-- | PVE/API2/Network/SDN/Vnets.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/PVE/API2/Network/SDN/Vnets.pm b/PVE/API2/Network/SDN/Vnets.pm index 5fe524b..3a995a8 100644 --- a/PVE/API2/Network/SDN/Vnets.pm +++ b/PVE/API2/Network/SDN/Vnets.pm @@ -17,6 +17,7 @@ use PVE::API2::Network::SDN::Subnets; use Storable qw(dclone); use PVE::JSONSchema qw(get_standard_option); use PVE::RPCEnvironment; +use PVE::Exception qw(raise raise_param_exc); use PVE::RESTHandler; @@ -193,9 +194,7 @@ __PACKAGE__->register_method ({ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type}); $plugin->vnet_update_hook($cfg->{ids}->{$id}); - my $subnet_cfg = PVE::Network::SDN::Subnets::config(); - - PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg, $subnet_cfg); + PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg); PVE::Network::SDN::Vnets::write_config($cfg); @@ -226,7 +225,12 @@ __PACKAGE__->register_method ({ PVE::SectionConfig::assert_if_modified($cfg, $digest); + my $opts = PVE::Network::SDN::VnetPlugin->check_config($id, $param, 0, 1); + raise_param_exc({ zone => "missing zone"}) if !$opts->{zone}; + my $subnets = PVE::Network::SDN::Vnets::get_subnets($id); + raise_param_exc({ zone => "can't change zone if subnets exists"}) if($subnets && $opts->{zone} ne $cfg->{ids}->{$id}->{zone}); + $cfg->{ids}->{$id} = $opts; my $zone_cfg = PVE::Network::SDN::Zones::config(); @@ -235,9 +239,7 @@ __PACKAGE__->register_method ({ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type}); $plugin->vnet_update_hook($cfg->{ids}->{$id}); - my $subnet_cfg = PVE::Network::SDN::Subnets::config(); - - PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg, $subnet_cfg); + PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg); PVE::Network::SDN::Vnets::write_config($cfg); |
