diff options
| author | Wolfgang Bumiller <w.bumiller@proxmox.com> | 2023-11-22 11:08:21 +0100 | 
|---|---|---|
| committer | Wolfgang Bumiller <w.bumiller@proxmox.com> | 2023-11-22 12:21:38 +0100 | 
| commit | 3e3cafabaf955d53c4c2d4e346bf5c3a5c6d1852 (patch) | |
| tree | 83a2a8c3c968b295579b4cd2a4eb86c760632d3e /src/PVE/API2/Network/SDN/Zones.pm | |
| parent | 9b448b01547fa7537d8f54cb88b64dfb3ad34b8a (diff) | |
api: take partial configs for PUT /cluster/sdn/zones/<id>
Zones previously expected a complete config, but the API schema
also contains a 'delete' parameter via the SectionConfig's
updateSchema() helper. This was not handled, and instead failed to
validate as part of the config.
The same is true for vnets and subnets, while ipams, dns and
controller entries followed our usual update procedures (but also
ignored the 'delete' parameter).
Since all of our SectionConfig based API endpoints are supposed to
take changes, rather than complete configs, this changes these
endpoints to not replace the full configuration anymore.
This is a major break for automation tools (the web UI already passed
the full config each time).
Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Diffstat (limited to 'src/PVE/API2/Network/SDN/Zones.pm')
| -rw-r--r-- | src/PVE/API2/Network/SDN/Zones.pm | 18 | 
1 files changed, 15 insertions, 3 deletions
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm index 1c3356e..b09c9ad 100644 --- a/src/PVE/API2/Network/SDN/Zones.pm +++ b/src/PVE/API2/Network/SDN/Zones.pm @@ -261,6 +261,11 @@ __PACKAGE__->register_method ({  	my $id = extract_param($param, 'zone');  	my $digest = extract_param($param, 'digest'); +	my $delete = extract_param($param, 'delete'); + +	if ($delete) { +	    $delete = [ PVE::Tools::split_list($delete) ]; +	}  	PVE::Network::SDN::lock_sdn_config(sub {  	    my $zone_cfg = PVE::Network::SDN::Zones::config(); @@ -274,8 +279,17 @@ __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} && !$scfg->{ipam} || $opts->{ipam} ne $scfg->{ipam}) { +	    my $old_ipam = $scfg->{ipam}; + +	    if ($delete) { +		my $options = $plugin->private()->{options}->{$scfg->{type}}; +		PVE::SectionConfig::delete_from_config($scfg, $options, $opts, $delete); +	    } +	    $scfg->{$_} = $opts->{$_} for keys $opts->%*; + +	    my $new_ipam = $scfg->{ipam}; +	    if (!$new_ipam != !$old_ipam || (($new_ipam//'') ne ($old_ipam//''))) {  		# 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();  		for my $subnetid (sort keys %{$subnets_cfg->{ids}}) { @@ -285,8 +299,6 @@ __PACKAGE__->register_method ({  		}  	    } -	    $zone_cfg->{ids}->{$id} = $opts; -  	    my $dnsserver = $opts->{dns};  	    raise_param_exc({ dns => "$dnsserver don't exist"}) if $dnsserver && !$dns_cfg->{ids}->{$dnsserver};  | 
