Added Intel AMT wake support.

Ylian Saint-Hilaire committed Oct 7, 2020 at 14:06 UTC b12b6fa26b1aee2da3a91e921d07f9040de476d1
2 files changed +22
amtmanager.js
+17
@@ -59,6 +59,11 @@ module.exports.CreateAmtManager = function(parent) {
59
60 // React to node being removed
61 if (event.action == 'removenode') { removeDevice(event.nodeid); }
62 +
63 + // React to node wakeup command, perform Intel AMT wake if possible
64 + if ((event.action == 'wakedevices') && (Array.isArray(event.nodeids))) {
65 + for (var i in event.nodeids) { performPowerAction(event.nodeids[i], 2); }
66 + }
67 }
68
69 // Remove a device
@@ -69,6 +74,18 @@ module.exports.CreateAmtManager = function(parent) {
74 delete obj.amtDevices[nodeid];
75 }
76
77 + // Perform a power action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset
78 + function performPowerAction(nodeid, action) {
79 + var dev = obj.amtDevices[nodeid];
80 + if ((dev == null) || (dev.amtstack == null)) return;
81 + try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
82 + }
83 +
84 + // Response to Intel AMT power action
85 + function performPowerActionResponse(stack, name, responses, status) {
86 + //console.log('performPowerActionResponse', status);
87 + }
88 +
89 // Update information about a device
90 function fetchIntelAmtInformation(nodeid) {
91 parent.db.Get(nodeid, function (err, nodes) {
meshuser.js
+5
@@ -3539,6 +3539,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3539 // - We should get a full list of all MAC's to wake first.
3540 // - We should try to only have one agent per subnet (using Gateway MAC) send a wake-on-lan.
3541 if (common.validateArray(command.nodeids, 1) == false) break; // Check nodeid's
3542 +
3543 + // Event wakeup, this will cause Intel AMT wake operations on this and other servers.
3544 + parent.parent.DispatchEvent('*', obj, { action: 'wakedevices', userid: user._id, username: user.name, nodeids: command.nodeids, domain: domain.id, nolog: 1 });
3545 +
3546 + // Perform wake-on-lan
3547 for (i in command.nodeids) {
3548 // Get the node and the rights for this node
3549 parent.GetNodeWithRights(domain, user, command.nodeids[i], function (node, rights, visible) {