add support for PXE reboot/power (#6298)
wow committed
Aug 2, 2024 at 12:48 UTC
999ae7f67f34fa77ab71c67c776431463d12cbfb
3 files changed
+14
-7
amtmanager.js
+6
-5
@@ -955,7 +955,7 @@ module.exports.CreateAmtManager = function (parent) {
955
});
956
}
957
958
- // 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
958
+ // 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, 15 = Power on to PXE, 16 = Reset to PXE
959
function performPowerAction(nodeid, action) {
960
console.log('performPowerAction', nodeid, action);
961
var devices = obj.amtDevices[nodeid];
@@ -970,7 +970,7 @@ module.exports.CreateAmtManager = function (parent) {
970
// Action: 2 = Power up, 5 = Power cycle, 8 = Power down, 10 = Reset
971
try { dev.amtstack.RequestPowerStateChange(action, performPowerActionResponse); } catch (ex) { }
972
} else {
973
- // 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL
973
+ // 11 = Power on to BIOS, 12 = Reset to BIOS, 13 = Power on to BIOS with SOL, 14 = Reset to BIOS with SOL, 15 = Power on to PXE, 16 = Reset to PXE
974
dev.amtstack.BatchEnum(null, ['*AMT_BootSettingData'], performAdvancedPowerActionResponse);
975
}
976
}
@@ -1003,8 +1003,8 @@ module.exports.CreateAmtManager = function (parent) {
1003
// Ready boot parameters
1004
bootSettingData['BIOSSetup'] = ((action >= 11) && (action <= 14));
1005
bootSettingData['UseSOL'] = ((action >= 13) && (action <= 14));
1006
- if ((action == 11) || (action == 13)) { dev.powerAction = 2; } // Power on
1007
- if ((action == 12) || (action == 14)) { dev.powerAction = 10; } // Reset
1006
+ if ((action == 11) || (action == 13) || (action == 15)) { dev.powerAction = 2; } // Power on
1007
+ if ((action == 12) || (action == 14) || (action == 16)) { dev.powerAction = 10; } // Reset
1008
1009
// Set boot parameters
1010
dev.amtstack.Put('AMT_BootSettingData', bootSettingData, function (stack, name, response, status, tag) {
@@ -1015,7 +1015,8 @@ module.exports.CreateAmtManager = function (parent) {
1015
const dev = stack.dev;
1016
if ((obj.amtDevices[dev.nodeid] == null) || (status != 200)) return; // Device no longer exists or error
1017
// Set boot order
1018
- dev.amtstack.CIM_BootConfigSetting_ChangeBootOrder(null, function (stack, name, response, status) {
1018
+ var bootDevice = (action === 15 || action === 16) ? '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: Force PXE Boot</Selector></SelectorSet></ReferenceParameters>' : null;
1019
+ dev.amtstack.CIM_BootConfigSetting_ChangeBootOrder(bootDevice, function (stack, name, response, status) {
1020
const dev = stack.dev;
1021
if ((obj.amtDevices[dev.nodeid] == null) || (status != 200)) return; // Device no longer exists or error
1022
// Perform power action
meshuser.js
+2
-2
@@ -3129,8 +3129,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3129
}
3130
3131
if ((command.actiontype >= 300) && (command.actiontype < 400)) {
3132
- if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype < 310) && (command.actiontype > 312)) return; // Invalid action type.
3133
- // 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
3132
+ if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype < 310) && (command.actiontype > 316)) return; // Invalid action type.
3133
+ // 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, 15 = Power on to PXE, 16 = Reset to PXE
3134
parent.parent.DispatchEvent('*', obj, { action: 'amtpoweraction', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, actiontype: command.actiontype - 300 });
3135
} else {
3136
if ((command.actiontype < 2) && (command.actiontype > 4)) return; // Invalid action type.
views/default.handlebars
+6
@@ -8451,6 +8451,8 @@
8451
if ((xxcurrentView == 11) || (xxcurrentView == 12)) { // Only show these options on terminal or desktop tabs
8452
y += '<option value=312>' + "Intel® AMT Reset to BIOS" + '</option>';
8453
y += '<option value=311>' + "Intel® AMT Power on to BIOS" + '</option>';
8454
+ y += '<option value=315>' + "Intel® AMT Power on to PXE" + '</option>';
8455
+ y += '<option value=316>' + "Intel® AMT Reset to PXE" + '</option>';
8456
}
8457
}
8458
if ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && ((rights & 64) != 0)) {
@@ -8519,6 +8521,10 @@
8521
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?");
8522
} else if (op == 312) { // Intel AMT reset to BIOS
8523
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?");
8524
+ } else if (op == 315) { // Intel AMT power to PXE
8525
+ 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 PXE?");
8526
+ } else if (op == 316) { // Intel AMT reset to PXE
8527
+ 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 PXE?");
8528
} else if ((op == 400) || (op == 401)) {
8529
// Flash / vibrate
8530
meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: parseInt(op), time: parseInt(Q('d2devicetime').value) });