diff options
| author | Wolfgang Bumiller <w.bumiller@proxmox.com> | 2023-11-22 11:42:24 +0100 |
|---|---|---|
| committer | Wolfgang Bumiller <w.bumiller@proxmox.com> | 2023-11-22 12:28:49 +0100 |
| commit | 4552f5d490d1b96fd73efacd4910e789863c9ef4 (patch) | |
| tree | c37fac7869825154b44ec64f0e87efb6f4010e6b | |
| parent | d4c9897507f3eacf25da030629653299cdca719f (diff) | |
api: take partial configs for PUT /cluster/sdn/vnets/<n>/subnets/<i>
Handle 'delete' parameter and partial updates.
See 2 commits earlier for explanation.
Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
| -rw-r--r-- | src/PVE/API2/Network/SDN/Subnets.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/PVE/API2/Network/SDN/Subnets.pm b/src/PVE/API2/Network/SDN/Subnets.pm index c263cd5..7a4c331 100644 --- a/src/PVE/API2/Network/SDN/Subnets.pm +++ b/src/PVE/API2/Network/SDN/Subnets.pm @@ -247,6 +247,8 @@ __PACKAGE__->register_method ({ my $id = extract_param($param, 'subnet'); my $digest = extract_param($param, 'digest'); + my $delete = extract_param($param, 'delete'); + my $vnet = $param->{vnet}; my $privs = [ 'SDN.Allocate' ]; @@ -266,9 +268,15 @@ __PACKAGE__->register_method ({ PVE::SectionConfig::assert_if_modified($cfg, $digest); my $opts = PVE::Network::SDN::SubnetPlugin->check_config($id, $param, 0, 1); - $cfg->{ids}->{$id} = $opts; - raise_param_exc({ ipam => "you can't change ipam"}) if $opts->{ipam} && $scfg->{ipam} && $opts->{ipam} ne $scfg->{ipam}; + my $data = $cfg->{ids}->{$id}; + if ($delete) { + $delete = [ PVE::Tools::split_list($delete) ]; + my $options = + PVE::Network::SDN::SubnetPlugin->private()->{options}->{$data->{type}}; + PVE::SectionConfig::delete_from_config($data, $options, $opts, $delete); + } + $data->{$_} = $opts->{$_} for keys $opts->%*; my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, $id); PVE::Network::SDN::SubnetPlugin->on_update_hook($zone, $id, $subnet, $scfg); |
