summaryrefslogtreecommitdiff
path: root/src/PVE/API2/Network/SDN/Vnets.pm
diff options
context:
space:
mode:
authorStefan Hanreich <s.hanreich@proxmox.com>2025-07-29 11:29:30 +0200
committerThomas Lamprecht <t.lamprecht@proxmox.com>2025-07-29 12:59:51 +0200
commitf5966bbacd2998234795fb02f56bff24c7ecf7d6 (patch)
treee60247bd424744276281349640b5fdc6f8df248b /src/PVE/API2/Network/SDN/Vnets.pm
parentf7d4f22a42a506e6cd60f0de8fbac9f580b85c6f (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/Vnets.pm')
-rw-r--r--src/PVE/API2/Network/SDN/Vnets.pm21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm
index 5608283..e6eb5d4 100644
--- a/src/PVE/API2/Network/SDN/Vnets.pm
+++ b/src/PVE/API2/Network/SDN/Vnets.pm
@@ -205,13 +205,19 @@ __PACKAGE__->register_method({
permissions => {
check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']],
},
- parameters => PVE::Network::SDN::VnetPlugin->createSchema(),
+ parameters => PVE::Network::SDN::VnetPlugin->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, 'vnet');
+ my $lock_token = extract_param($param, 'lock-token');
PVE::Cluster::check_cfs_quorum();
mkdir("/etc/pve/sdn");
@@ -238,6 +244,7 @@ __PACKAGE__->register_method({
},
"create sdn vnet object failed",
+ $lock_token,
);
return undef;
@@ -254,7 +261,12 @@ __PACKAGE__->register_method({
description => "Require 'SDN.Allocate' permission on '/sdn/zones/<zone>/<vnet>'",
user => 'all',
},
- parameters => PVE::Network::SDN::VnetPlugin->updateSchema(),
+ parameters => PVE::Network::SDN::VnetPlugin->updateSchema(
+ undef,
+ {
+ 'lock-token' => get_standard_option('pve-sdn-lock-token'),
+ },
+ ),
returns => { type => 'null' },
code => sub {
my ($param) = @_;
@@ -262,6 +274,7 @@ __PACKAGE__->register_method({
my $id = extract_param($param, 'vnet');
my $digest = extract_param($param, 'digest');
my $delete = extract_param($param, 'delete');
+ my $lock_token = extract_param($param, 'lock-token');
my $privs = ['SDN.Allocate'];
&$check_vnet_access($id, $privs);
@@ -307,6 +320,7 @@ __PACKAGE__->register_method({
},
"update sdn vnet object failed",
+ $lock_token,
);
return undef;
@@ -332,6 +346,7 @@ __PACKAGE__->register_method({
completion => \&PVE::Network::SDN::Vnets::complete_sdn_vnets,
},
),
+ 'lock-token' => get_standard_option('pve-sdn-lock-token'),
},
},
returns => { type => 'null' },
@@ -339,6 +354,7 @@ __PACKAGE__->register_method({
my ($param) = @_;
my $id = extract_param($param, 'vnet');
+ my $lock_token = extract_param($param, 'lock-token');
my $privs = ['SDN.Allocate'];
&$check_vnet_access($id, $privs);
@@ -356,6 +372,7 @@ __PACKAGE__->register_method({
},
"delete sdn vnet object failed",
+ $lock_token,
);
return undef;