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/Zones.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/Zones.pm')
| -rw-r--r-- | src/PVE/API2/Network/SDN/Zones.pm | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm index e53e6e7..0e4726b 100644 --- a/src/PVE/API2/Network/SDN/Zones.pm +++ b/src/PVE/API2/Network/SDN/Zones.pm @@ -207,13 +207,19 @@ __PACKAGE__->register_method({ permissions => { check => ['perm', '/sdn/zones', ['SDN.Allocate']], }, - parameters => PVE::Network::SDN::Zones::Plugin->createSchema(), + parameters => PVE::Network::SDN::Zones::Plugin->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 $id = extract_param($param, 'zone'); + my $lock_token = extract_param($param, 'lock-token'); my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($type); my $opts = $plugin->check_config($id, $param, 1, 1); @@ -256,6 +262,7 @@ __PACKAGE__->register_method({ }, "create sdn zone object failed", + $lock_token, ); return; @@ -271,7 +278,12 @@ __PACKAGE__->register_method({ permissions => { check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']], }, - parameters => PVE::Network::SDN::Zones::Plugin->updateSchema(), + parameters => PVE::Network::SDN::Zones::Plugin->updateSchema( + undef, + { + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + ), returns => { type => 'null' }, code => sub { my ($param) = @_; @@ -279,6 +291,7 @@ __PACKAGE__->register_method({ my $id = extract_param($param, 'zone'); my $digest = extract_param($param, 'digest'); my $delete = extract_param($param, 'delete'); + my $lock_token = extract_param($param, 'lock-token'); if ($delete) { $delete = [PVE::Tools::split_list($delete)]; @@ -344,6 +357,7 @@ __PACKAGE__->register_method({ }, "update sdn zone object failed", + $lock_token, ); return; @@ -368,6 +382,7 @@ __PACKAGE__->register_method({ completion => \&PVE::Network::SDN::Zones::complete_sdn_zones, }, ), + 'lock-token' => get_standard_option('pve-sdn-lock-token'), }, }, returns => { type => 'null' }, @@ -375,6 +390,7 @@ __PACKAGE__->register_method({ my ($param) = @_; my $id = extract_param($param, 'zone'); + my $lock_token = extract_param($param, 'lock-token'); PVE::Network::SDN::lock_sdn_config( sub { @@ -391,6 +407,7 @@ __PACKAGE__->register_method({ PVE::Network::SDN::Zones::write_config($cfg); }, "delete sdn zone object failed", + $lock_token, ); return; |
