From: Tiago Sousa via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Tiago Sousa <joao.sousa@eurotux.com>
Subject: [pve-devel] [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API
Date: Mon, 2 Jun 2025 17:10:52 +0100 [thread overview]
Message-ID: <mailman.181.1748881051.395.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20250602161052.170879-1-joao.sousa@eurotux.com>
[-- Attachment #1: Type: message/rfc822, Size: 8418 bytes --]
From: Tiago Sousa <joao.sousa@eurotux.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC pve-manager 1/1] add ha node maintenance mode to the UI and API
Date: Mon, 2 Jun 2025 17:10:52 +0100
Message-ID: <20250602161052.170879-2-joao.sousa@eurotux.com>
Signed-off-by: Tiago Sousa <joao.sousa@eurotux.com>
---
PVE/API2/Nodes.pm | 45 ++++++++++++++++++++++++++++++++++++
www/manager6/Utils.js | 1 +
| 36 +++++++++++++++++++++++++++--
3 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 791d2dec..f2365e59 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -21,6 +21,7 @@ use PVE::DataCenterConfig;
use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
use PVE::Firewall;
use PVE::HA::Config;
+use PVE::HA::Usage;
use PVE::HA::Env::PVE2;
use PVE::INotify;
use PVE::JSONSchema qw(get_standard_option);
@@ -300,6 +301,7 @@ __PACKAGE__->register_method ({
{ name => 'vncshell' },
{ name => 'vzdump' },
{ name => 'wakeonlan' },
+ { name => 'node-maintenance-set' },
];
push @$result, { name => 'sdn' } if $have_sdn;
@@ -802,6 +804,49 @@ __PACKAGE__->register_method({
return $wol_config->{mac};
}});
+__PACKAGE__->register_method({
+ name => 'node-maintenance-set',
+ path => 'node-maintenance-set',
+ method => 'POST',
+ permissions => {
+ check => ['perm', '/nodes/{node}', [ 'Sys.PowerMgmt' ]],
+ },
+ protected => 1,
+ description => "Set node maintenance mode (enable or disable)",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ disable => {
+ description => "Requests disabling or enabling maintenance-mode.",
+ type => 'boolean',
+ },
+ },
+ },
+ returns => {
+ type => 'string',
+ format => 'string',
+ description => '',
+ },
+ code => sub {
+ my ($param) = @_;
+ my $node = $param->{node};
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ PVE::Cluster::check_node_exists($node);
+ my $state = $param->{disable} ? 'disable' : 'enable';
+ my $hacmd = sub {
+ my $upid = shift;
+ print "Requesting to $state HA node maintenance for node $node\n";
+ my $cmd = ['ha-manager', 'crm-command', 'node-maintenance', $state, $node];
+ PVE::Tools::run_command($cmd);
+ return;
+ };
+
+ return $rpcenv->fork_worker('hamaintenance', undef, $authuser, $hacmd);
+ }});
+
__PACKAGE__->register_method({
name => 'rrd',
path => 'rrd',
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 1f6778cd..48dac090 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -2034,6 +2034,7 @@ Ext.define('PVE.Utils', {
hamigrate: ['HA', gettext('Migrate')],
hashutdown: ['HA', gettext('Shutdown')],
hastart: ['HA', gettext('Start')],
+ hamaintenance: ['HA', gettext('Node Maintenance')],
hastop: ['HA', gettext('Stop')],
imgcopy: ['', gettext('Copy data')],
imgdel: ['', gettext('Erase data')],
--git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
index 7bdfebc5..0a8dc008 100644
--- a/www/manager6/node/CmdMenu.js
+++ b/www/manager6/node/CmdMenu.js
@@ -94,6 +94,34 @@ Ext.define('PVE.node.CmdMenu', {
PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, nodename, undefined);
},
},
+ {
+ text: gettext('Enter Maintenance Mode'),
+ itemId: 'entermaintenance',
+ iconCls: 'fa fa-fw fa-building',
+ handler: function() {
+ let nodename = this.up('menu').nodename;
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${nodename}/node-maintenance-set`,
+ params: { disable: 0 },
+ method: 'POST',
+ failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ },
+ },
+ {
+ text: gettext('Exit Maintenance Mode'),
+ itemId: 'exitmaintenance',
+ iconCls: 'fa fa-fw fa-building',
+ handler: function() {
+ let nodename = this.up('menu').nodename;
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${nodename}/node-maintenance-set`,
+ params: { disable: 1 },
+ method: 'POST',
+ failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ },
+ },
{ xtype: 'menuseparator' },
{
text: gettext('Wake-on-LAN'),
@@ -150,11 +178,15 @@ Ext.define('PVE.node.CmdMenu', {
}
if (!caps.nodes['Sys.Console']) {
me.getComponent('shell').setDisabled(true);
- }
+ }
+ if (me.pveSelNode.data.hastate === 'maintenance') {
+ me.getComponent('entermaintenance').setVisible(false);
+ } else {
+ me.getComponent('exitmaintenance').setVisible(false);
+ }
if (me.pveSelNode.data.running) {
me.getComponent('wakeonlan').setDisabled(true);
}
-
if (PVE.Utils.isStandaloneNode()) {
me.getComponent('bulkmigrate').setVisible(false);
}
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next parent reply other threads:[~2025-06-02 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250602161052.170879-1-joao.sousa@eurotux.com>
2025-06-02 16:10 ` Tiago Sousa via pve-devel [this message]
[not found] ` <20250602161052.170879-2-joao.sousa@eurotux.com>
2025-06-03 6:35 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mailman.181.1748881051.395.pve-devel@lists.proxmox.com \
--to=pve-devel@lists.proxmox.com \
--cc=joao.sousa@eurotux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal