summaryrefslogtreecommitdiff
path: root/src/PVE/API2/Network/SDN/Controllers.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/Controllers.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/Controllers.pm')
-rw-r--r--src/PVE/API2/Network/SDN/Controllers.pm21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/PVE/API2/Network/SDN/Controllers.pm b/src/PVE/API2/Network/SDN/Controllers.pm
index e6eb4cb..5c2b6c3 100644
--- a/src/PVE/API2/Network/SDN/Controllers.pm
+++ b/src/PVE/API2/Network/SDN/Controllers.pm
@@ -168,13 +168,19 @@ __PACKAGE__->register_method({
permissions => {
check => ['perm', '/sdn/controllers', ['SDN.Allocate']],
},
- parameters => PVE::Network::SDN::Controllers::Plugin->createSchema(),
+ parameters => PVE::Network::SDN::Controllers::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, 'controller');
+ my $lock_token = extract_param($param, 'lock-token');
my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($type);
my $opts = $plugin->check_config($id, $param, 1, 1);
@@ -204,6 +210,7 @@ __PACKAGE__->register_method({
},
"create sdn controller object failed",
+ $lock_token,
);
return undef;
@@ -219,7 +226,12 @@ __PACKAGE__->register_method({
permissions => {
check => ['perm', '/sdn/controllers', ['SDN.Allocate']],
},
- parameters => PVE::Network::SDN::Controllers::Plugin->updateSchema(),
+ parameters => PVE::Network::SDN::Controllers::Plugin->updateSchema(
+ undef,
+ {
+ 'lock-token' => get_standard_option('pve-sdn-lock-token'),
+ },
+ ),
returns => { type => 'null' },
code => sub {
my ($param) = @_;
@@ -227,6 +239,7 @@ __PACKAGE__->register_method({
my $id = extract_param($param, 'controller');
my $digest = extract_param($param, 'digest');
my $delete = extract_param($param, 'delete');
+ my $lock_token = extract_param($param, 'lock-token');
PVE::Network::SDN::lock_sdn_config(
sub {
@@ -257,6 +270,7 @@ __PACKAGE__->register_method({
},
"update sdn controller object failed",
+ $lock_token,
);
return undef;
@@ -281,6 +295,7 @@ __PACKAGE__->register_method({
completion => \&PVE::Network::SDN::Controllers::complete_sdn_controllers,
},
),
+ 'lock-token' => get_standard_option('pve-sdn-lock-token'),
},
},
returns => { type => 'null' },
@@ -288,6 +303,7 @@ __PACKAGE__->register_method({
my ($param) = @_;
my $id = extract_param($param, 'controller');
+ my $lock_token = extract_param($param, 'lock-token');
PVE::Network::SDN::lock_sdn_config(
sub {
@@ -307,6 +323,7 @@ __PACKAGE__->register_method({
},
"delete sdn controller object failed",
+ $lock_token,
);
return undef;