[pve-devel] [PATCH v2 manager] Add context menu entry for WoL calls to nodes in GUI
Christian Ebner
c.ebner at proxmox.com
Fri Jan 25 11:32:27 CET 2019
This adds a context menu entry to the cluster nodes which triggers the wake on
LAN API call for the selected node.
The entry is disabled if the node is already running or the user has no
Sys.PowerMgmt capabilities.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Thanks for the feedback, here the changes for version 2:
* Added iconCls with suggested power-off icon
* Success message is now formated by Ext.String.format()
* Success message now includes also the nodename
www/manager6/node/CmdMenu.js | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
index 05a92f62..f718f69a 100644
--- a/www/manager6/node/CmdMenu.js
+++ b/www/manager6/node/CmdMenu.js
@@ -84,6 +84,30 @@ Ext.define('PVE.node.CmdMenu', {
var me = this.up('menu');
PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, me.nodename, undefined);
}
+ },
+ { xtype: 'menuseparator' },
+ {
+ text: gettext('Wake-on-LAN'),
+ itemId: 'wakeonlan',
+ iconCls: 'fa fa-fw fa-power-off',
+ handler: function() {
+ var me = this.up('menu');
+ Proxmox.Utils.API2Request({
+ param: {},
+ url: '/nodes/' + me.nodename + '/wakeonlan',
+ method: 'POST',
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response, opts) {
+ Ext.Msg.show({
+ title: 'Success',
+ icon: Ext.Msg.INFO,
+ msg: Ext.String.format(gettext("Wake on LAN packet send for '{0}': '{1}'"), me.nodename, response.result.data)
+ });
+ }
+ });
+ }
}
],
@@ -108,10 +132,15 @@ Ext.define('PVE.node.CmdMenu', {
me.getComponent('bulkstart').setDisabled(true);
me.getComponent('bulkstop').setDisabled(true);
me.getComponent('bulkmigrate').setDisabled(true);
+ me.getComponent('wakeonlan').setDisabled(true);
}
if (!caps.nodes['Sys.Console']) {
me.getComponent('shell').setDisabled(true);
}
+
+ if (me.pveSelNode.data.running) {
+ me.getComponent('wakeonlan').setDisabled(true);
+ }
}
});
--
2.11.0
More information about the pve-devel
mailing list