[pve-devel] [PATCH manager] Add context menu entry for WoL calls to nodes in GUI

Christian Ebner c.ebner at proxmox.com
Thu Jan 24 14:38:22 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>
---
 www/manager6/node/CmdMenu.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
index 05a92f62..0bf6f246 100644
--- a/www/manager6/node/CmdMenu.js
+++ b/www/manager6/node/CmdMenu.js
@@ -84,6 +84,29 @@ 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',
+	    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: gettext("Wake on LAN packet send for '" + response.result.data + "'")
+			});
+		    }
+		});
+	    }
 	}
     ],
 
@@ -108,10 +131,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