diff options
| author | Stefan Hanreich <s.hanreich@proxmox.com> | 2025-07-29 11:29:30 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2025-07-29 12:59:51 +0200 |
| commit | f5966bbacd2998234795fb02f56bff24c7ecf7d6 (patch) | |
| tree | e60247bd424744276281349640b5fdc6f8df248b /src/PVE/API2/Network/SDN/Subnets.pm | |
| parent | f7d4f22a42a506e6cd60f0de8fbac9f580b85c6f (diff) | |
api: add lock-token parameter to all api calls
The parameter is optional, so all existing create/update/delete
invocations can work as before, only failing if the global lock is
currently set. This ensures backwards-compatibility with the existing
calls to the API in the frontend. If the lock is set, users will get
an error message when trying to modify the configuration from the web
UI.
Co-authored-by: Gabriel Goller <g.goller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Link: https://lore.proxmox.com/20250729092933.90118-3-g.goller@proxmox.com
Diffstat (limited to 'src/PVE/API2/Network/SDN/Subnets.pm')
| -rw-r--r-- | src/PVE/API2/Network/SDN/Subnets.pm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/PVE/API2/Network/SDN/Subnets.pm b/src/PVE/API2/Network/SDN/Subnets.pm index c9f5452..fc56532 100644 --- a/src/PVE/API2/Network/SDN/Subnets.pm +++ b/src/PVE/API2/Network/SDN/Subnets.pm @@ -190,13 +190,19 @@ __PACKAGE__->register_method({ description => "Require 'SDN.Allocate' permission on '/sdn/zones/<zone>/<vnet>'", user => 'all', }, - parameters => PVE::Network::SDN::SubnetPlugin->createSchema(), + parameters => PVE::Network::SDN::SubnetPlugin->createSchema( + undef, + { + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + ), returns => { type => 'null' }, code => sub { my ($param) = @_; my $type = extract_param($param, 'type'); my $cidr = extract_param($param, 'subnet'); + my $lock_token = extract_param($param, 'lock-token'); my $vnet = $param->{vnet}; my $privs = ['SDN.Allocate']; @@ -234,6 +240,7 @@ __PACKAGE__->register_method({ }, "create sdn subnet object failed", + $lock_token, ); return undef; @@ -250,7 +257,12 @@ __PACKAGE__->register_method({ description => "Require 'SDN.Allocate' permission on '/sdn/zones/<zone>/<vnet>'", user => 'all', }, - parameters => PVE::Network::SDN::SubnetPlugin->updateSchema(), + parameters => PVE::Network::SDN::SubnetPlugin->updateSchema( + undef, + { + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + ), returns => { type => 'null' }, code => sub { my ($param) = @_; @@ -258,6 +270,7 @@ __PACKAGE__->register_method({ my $id = extract_param($param, 'subnet'); my $digest = extract_param($param, 'digest'); my $delete = extract_param($param, 'delete'); + my $lock_token = extract_param($param, 'lock-token'); my $vnet = $param->{vnet}; @@ -295,6 +308,7 @@ __PACKAGE__->register_method({ }, "update sdn subnet object failed", + $lock_token, ); return undef; @@ -321,6 +335,7 @@ __PACKAGE__->register_method({ completion => \&PVE::Network::SDN::Subnets::complete_sdn_subnets, }, ), + 'lock-token' => get_standard_option('pve-sdn-lock-token'), }, }, returns => { type => 'null' }, @@ -329,6 +344,8 @@ __PACKAGE__->register_method({ my $id = extract_param($param, 'subnet'); my $vnet = extract_param($param, 'vnet'); + my $lock_token = extract_param($param, 'lock-token'); + my $privs = ['SDN.Allocate']; &$check_vnet_access($vnet, $privs); @@ -354,6 +371,7 @@ __PACKAGE__->register_method({ }, "delete sdn subnet object failed", + $lock_token, ); return undef; |
