Added Intel AMT power/reset to BIOS on actions menu of desktop and terminal tab.

This commit is contained in:
Ylian Saint-Hilaire 2022-08-22 15:48:50 -07:00
parent fcfe4d964e
commit 571d9d3c7b
3 changed files with 44 additions and 6 deletions

View File

@ -946,7 +946,7 @@ module.exports.CreateAmtManager = function (parent) {
}); });
} }
// Perform a power action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset // 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
function performPowerAction(nodeid, action) { function performPowerAction(nodeid, action) {
var devices = obj.amtDevices[nodeid]; var devices = obj.amtDevices[nodeid];
if (devices == null) return; if (devices == null) return;
@ -954,14 +954,44 @@ module.exports.CreateAmtManager = function (parent) {
var dev = devices[i]; var dev = devices[i];
// If not LMS, has a AMT stack present and is in connected state, perform power operation. // If not LMS, has a AMT stack present and is in connected state, perform power operation.
if ((dev.connType != 2) && (dev.state == 1) && (dev.amtstack != null)) { if ((dev.connType != 2) && (dev.state == 1) && (dev.amtstack != null)) {
// Action: 2 = Power on, 8 = Power down, 10 = reset
parent.debug('amt', dev.name, "performPowerAction", action); parent.debug('amt', dev.name, "performPowerAction", action);
dev.powerAction = action; dev.powerAction = action;
try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { } if (action <= 10) {
// Action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset
try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
} else {
// 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL
dev.amtstack.BatchEnum(null, ['*AMT_BootSettingData'], performAdvancedPowerActionResponse);
}
} }
} }
} }
// Response to Intel AMT advanced power action
function performAdvancedPowerActionResponse(stack, name, responses, status) {
const dev = stack.dev;
const action = dev.powerAction;
delete dev.powerAction;
if (obj.amtDevices[dev.nodeid] == null) return; // Device no longer exists, ignore this response.
if (status != 200) return;
if ((responses['AMT_BootSettingData'] == null) || (responses['AMT_BootSettingData'].response == null)) return;
var bootSettingData = responses['AMT_BootSettingData'].response;
bootSettingData['BIOSSetup'] = ((action >= 11) && (action <= 14));
bootSettingData['UseSOL'] = ((action >= 13) && (action <= 14));
if ((action == 11) || (action == 13)) { dev.powerAction = 2; } // Power on
if ((action == 12) || (action == 14)) { dev.powerAction = 10; } // Reset
dev.amtstack.Put('AMT_BootSettingData', bootSettingData, function performAdvancedPowerActionResponseEx(stack, name, response, status, tag) {
const dev = stack.dev;
const action = dev.powerAction;
delete dev.powerAction;
if (obj.amtDevices[dev.nodeid] == null) return; // Device no longer exists, ignore this response.
if (status != 200) return;
try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
}, 0, 1);
}
// Response to Intel AMT power action // Response to Intel AMT power action
function performPowerActionResponse(stack, name, responses, status) { function performPowerActionResponse(stack, name, responses, status) {
const dev = stack.dev; const dev = stack.dev;

View File

@ -3001,8 +3001,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} }
if ((command.actiontype >= 300) && (command.actiontype < 400)) { if ((command.actiontype >= 300) && (command.actiontype < 400)) {
if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype != 310)) return; // Invalid action type. if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype < 310) && (command.actiontype > 312)) return; // Invalid action type.
// Intel AMT power command, actiontype: 2 = Power on, 8 = Power down, 10 = reset // 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
parent.parent.DispatchEvent('*', obj, { action: 'amtpoweraction', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, actiontype: command.actiontype - 300 }); parent.parent.DispatchEvent('*', obj, { action: 'amtpoweraction', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, actiontype: command.actiontype - 300 });
} else { } else {
if ((command.actiontype < 2) && (command.actiontype > 4)) return; // Invalid action type. if ((command.actiontype < 2) && (command.actiontype > 4)) return; // Invalid action type.

View File

@ -7993,12 +7993,16 @@
count++; count++;
y += '<option value=310>' + "Intel&reg; AMT Reset" + '</option>'; y += '<option value=310>' + "Intel&reg; AMT Reset" + '</option>';
y += '<option value=308>' + "Intel&reg; AMT Power off" + '</option>'; y += '<option value=308>' + "Intel&reg; AMT Power off" + '</option>';
if ((xxcurrentView == 11) || (xxcurrentView == 12)) { // Only show these options on terminal or desktop tabs
y += '<option value=312>' + "Intel&reg; AMT Reset to BIOS" + '</option>';
y += '<option value=311>' + "Intel&reg; AMT Power on to BIOS" + '</option>';
}
} }
if ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && ((rights & 64) != 0)) { if ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && ((rights & 64) != 0)) {
count++; count++;
y += '<option value=302>' + "Intel&reg; AMT Power on" + '</option>'; y += '<option value=302>' + "Intel&reg; AMT Power on" + '</option>';
} }
if ((getNodeAmtVersion(currentNode) >= 15) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && (rights == 0xFFFFFFFF) && ((features & 0x00000400) == 0)) { count++; y += '<option value=107>' + "Intel&reg; AMT One Click Recovery" + '</option>'; } // CIRA (2) or AMT (4) connected 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&reg; AMT One Click Recovery" + '</option>'; } // CIRA (2) or AMT (4) connected
if (((currentNode.conn & 1) != 0) && ((rights & 32768) != 0)) { count++; y += '<option value=104>' + "Uninstall Agent" + '</option>'; } if (((currentNode.conn & 1) != 0) && ((rights & 32768) != 0)) { count++; y += '<option value=104>' + "Uninstall Agent" + '</option>'; }
} }
y += '</select>'; y += '</select>';
@ -8056,6 +8060,10 @@
setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel&reg; AMT power off?"); setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel&reg; AMT power off?");
} else if (op == 310) { // Intel AMT reset } else if (op == 310) { // Intel AMT reset
setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel&reg; AMT reset?"); setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) }); }, "Perform Intel&reg; AMT reset?");
} else if (op == 311) { // Intel AMT power on to BIOS
setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) + ((xxcurrentView == 12) ? 2 : 0) }); }, "Perform Intel&reg; AMT power on to BIOS?");
} else if (op == 312) { // Intel AMT reset to BIOS
setDialogMode(2, "Intel&reg; AMT Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op) + ((xxcurrentView == 12) ? 2 : 0) }); }, "Perform Intel&reg; AMT reset to BIOS?");
} else if ((op == 400) || (op == 401)) { } else if ((op == 400) || (op == 401)) {
// Flash / vibrate // Flash / vibrate
meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op), time: parseInt(Q('d2devicetime').value) }); meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op), time: parseInt(Q('d2devicetime').value) });