[pve-devel] [PATCH manager v2 1/2] add api setter for node maintenance mode

Thomas Skinner thomas at atskinner.net
Sat Sep 20 20:20:48 CEST 2025


Signed-off-by: Thomas Skinner <thomas at atskinner.net>
---
 PVE/API2/Nodes.pm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 48898045..3f31ac6c 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -275,6 +275,7 @@ __PACKAGE__->register_method({
             { name => 'hosts' },
             { name => 'journal' },
             { name => 'lxc' },
+            { name => 'maintenance' },
             { name => 'migrateall' },
             { name => 'netstat' },
             { name => 'network' },
@@ -2663,6 +2664,43 @@ __PACKAGE__->register_method({
     },
 });
 
+__PACKAGE__->register_method({
+    name => 'maintenance_set',
+    protected => 1,
+    path => 'maintenance',
+    method => 'PUT',
+    description =>
+        "Set the maintenance parameters for the node. Currently only supports HA maintenance mode for the LRM on a node.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Console']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            node => get_standard_option('pve-node'),
+            'maintenance-mode' => {
+                description => "Enables or disabled maintenance mode for the HA LRM.",
+                type => 'string',
+                enum => ['enable', 'disable'],
+            },
+        },
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        PVE::Cluster::check_node_exists($param->{node});
+
+        my $cmd =
+            $param->{'maintenance-mode'} eq 'enable'
+            ? 'enable-node-maintenance'
+            : 'disable-node-maintenance';
+        PVE::HA::Config::queue_crm_commands("$cmd $param->{node}");
+
+        return undef;
+    },
+});
+
 # bash completion helper
 
 sub complete_templet_repo {
-- 
2.47.2




More information about the pve-devel mailing list