Added Intel AMT power/reset to BIOS on actions menu of desktop and terminal tab.
Ylian Saint-Hilaire committed
Aug 22, 2022 at 15:48 UTC
571d9d3c7b7b724045b64f5ed3c0b96bf55578fe
3 files changed
+44
-6
amtmanager.js
+33
-3
@@ -946,7 +946,7 @@ module.exports.CreateAmtManager = function (parent) {
946
});
947
}
948
949
- // Perform a power action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset
949
+ // Perform a power action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset, 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL
950
function performPowerAction(nodeid, action) {
951
var devices = obj.amtDevices[nodeid];
952
if (devices == null) return;
@@ -954,14 +954,44 @@ module.exports.CreateAmtManager = function (parent) {
954
var dev = devices[i];
955
// If not LMS, has a AMT stack present and is in connected state, perform power operation.
956
if ((dev.connType != 2) && (dev.state == 1) && (dev.amtstack != null)) {
957
- // Action: 2 = Power on, 8 = Power down, 10 = reset
957
parent.debug('amt', dev.name, "performPowerAction", action);
958
dev.powerAction = action;
960
- try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
959
+ if (action <= 10) {
960
+ // Action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset
961
+ try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
962
+ } else {
963
+ // 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL
964
+ dev.amtstack.BatchEnum(null, ['*AMT_BootSettingData'], performAdvancedPowerActionResponse);
965
+ }
966
}
967
}
968
}
969
970
+ // Response to Intel AMT advanced power action
971
+ function performAdvancedPowerActionResponse(stack, name, responses, status) {
972
+ const dev = stack.dev;
973
+ const action = dev.powerAction;
974
+ delete dev.powerAction;
975
+ if (obj.amtDevices[dev.nodeid] == null) return; // Device no longer exists, ignore this response.
976
+ if (status != 200) return;
977
+ if ((responses['AMT_BootSettingData'] == null) || (responses['AMT_BootSettingData'].response == null)) return;
978
+
979
+ var bootSettingData = responses['AMT_BootSettingData'].response;
980
+ bootSettingData['BIOSSetup'] = ((action >= 11) && (action <= 14));
981
+ bootSettingData['UseSOL'] = ((action >= 13) && (action <= 14));
982
+ if ((action == 11) || (action == 13)) { dev.powerAction = 2; } // Power on
983
+ if ((action == 12) || (action == 14)) { dev.powerAction = 10; } // Reset
984
+
985
+ dev.amtstack.Put('AMT_BootSettingData', bootSettingData, function performAdvancedPowerActionResponseEx(stack, name, response, status, tag) {
986
+ const dev = stack.dev;
987
+ const action = dev.powerAction;
988
+ delete dev.powerAction;
989
+ if (obj.amtDevices[dev.nodeid] == null) return; // Device no longer exists, ignore this response.
990
+ if (status != 200) return;
991
+ try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
992
+ }, 0, 1);
993
+ }
994
+
995
// Response to Intel AMT power action
996
function performPowerActionResponse(stack, name, responses, status) {
997
const dev = stack.dev;
meshuser.js
+2
-2
@@ -3001,8 +3001,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3001
}
3002
3003
if ((command.actiontype >= 300) && (command.actiontype < 400)) {
3004
- if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype != 310)) return; // Invalid action type.
3005
- // Intel AMT power command, actiontype: 2 = Power on, 8 = Power down, 10 = reset
3004
+ if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype < 310) && (command.actiontype > 312)) return; // Invalid action type.
3005
+ // Intel AMT power command, actiontype: 2 = Power on, 8 = Power down, 10 = reset, 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL
3006
parent.parent.DispatchEvent('*', obj, { action: 'amtpoweraction', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, actiontype: command.actiontype - 300 });
3007
} else {
3008
if ((command.actiontype < 2) && (command.actiontype > 4)) return; // Invalid action type.
views/default.handlebars
+9
-1
@@ -7993,12 +7993,16 @@
7993
count++;
7994
y += '<option value=310>' + "Intel® AMT Reset" + '</option>';
7995
y += '<option value=308>' + "Intel® AMT Power off" + '</option>';
7996
+ if ((xxcurrentView == 11) || (xxcurrentView == 12)) { // Only show these options on terminal or desktop tabs
7997
+ y += '<option value=312>' + "Intel® AMT Reset to BIOS" + '</option>';
7998
+ y += '<option value=311>' + "Intel® AMT Power on to BIOS" + '</option>';
7999
+ }
8000
}
8001
if ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && ((rights & 64) != 0)) {
8002
count++;
8003
y += '<option value=302>' + "Intel® AMT Power on" + '</option>';
8004
}
8001
- if ((getNodeAmtVersion(currentNode) >= 15) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && (rights == 0xFFFFFFFF) && ((features & 0x00000400) == 0)) { count++; y += '<option value=107>' + "Intel® AMT One Click Recovery" + '</option>'; } // CIRA (2) or AMT (4) connected
8005
+ if (((xxcurrentView == 11) || (xxcurrentView == 12)) && (getNodeAmtVersion(currentNode) >= 15) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && (rights == 0xFFFFFFFF) && ((features & 0x00000400) == 0)) { count++; y += '<option value=107>' + "Intel® AMT One Click Recovery" + '</option>'; } // CIRA (2) or AMT (4) connected
8006
if (((currentNode.conn & 1) != 0) && ((rights & 32768) != 0)) { count++; y += '<option value=104>' + "Uninstall Agent" + '</option>'; }
8007
}
8008
y += '</select>';
@@ -8056,6 +8060,10 @@
8060
setDialogMode(2, "Intel® AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel® AMT power off?");
8061
} else if (op == 310) { // Intel AMT reset
8062
setDialogMode(2, "Intel® AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel® AMT reset?");
8063
+ } else if (op == 311) { // Intel AMT power on to BIOS
8064
+ setDialogMode(2, "Intel® AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) + ((xxcurrentView == 12) ? 2 : 0) }); }, "Perform Intel® AMT power on to BIOS?");
8065
+ } else if (op == 312) { // Intel AMT reset to BIOS
8066
+ setDialogMode(2, "Intel® AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) + ((xxcurrentView == 12) ? 2 : 0) }); }, "Perform Intel® AMT reset to BIOS?");
8067
} else if ((op == 400) || (op == 401)) {
8068
// Flash / vibrate
8069
meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op), time: parseInt(Q('d2devicetime').value) });