]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
cli: expose new "crm-command node-maintenance enable/disable" commands
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 20 Mar 2023 12:29:28 +0000 (13:29 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 20 Mar 2023 12:38:23 +0000 (13:38 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLI/ha_manager.pm

index f4873693f019aa26c05870676db297c38d4a649d..a0ebe5716467532b1d5895111e8490eafde0acaa 100644 (file)
@@ -110,6 +110,35 @@ __PACKAGE__->register_method ({
        return undef;
     }});
 
+__PACKAGE__->register_method ({
+    name => 'node-maintenance-set',
+    path => 'node-maintenance-set',
+    method => 'POST',
+    description => "Change the node-maintenance request state.",
+    permissions => {
+       check => ['perm', '/', [ 'Sys.Console' ]],
+    },
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           node => get_standard_option('pve-node'),
+           disable => {
+               description => "Requests disabling or enabling maintenance-mode.",
+               type => 'boolean',
+           },
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       my $cmd = $param->{disable} ? 'disable-node-maintenance' : 'enable-node-maintenance';
+       PVE::HA::Config::queue_crm_commands("$cmd $param->{node}");
+
+       return undef;
+    }
+});
+
 our $cmddef = {
     status => [ __PACKAGE__, 'status'],
     config => [ 'PVE::API2::HA::Resources', 'index', [], {}, sub {
@@ -155,6 +184,10 @@ our $cmddef = {
        migrate => [ "PVE::API2::HA::Resources", 'migrate', ['sid', 'node'] ],
        relocate => [ "PVE::API2::HA::Resources", 'relocate', ['sid', 'node'] ],
        stop => [ __PACKAGE__, 'stop', ['sid', 'timeout'] ],
+       'node-maintenance' => {
+           enable => [ __PACKAGE__, 'node-maintenance-set', ['node'], { disable => 0 } ],
+           disable => [ __PACKAGE__, 'node-maintenance-set', ['node'], { disable => 1 } ],
+       },
     }
 
 };