Intel AMT manager improvements.

Ylian Saint-Hilaire committed Oct 7, 2020 at 16:59 UTC 6f23c450b012a654a479d1c22c1a6e9ed57aefb1
1 file changed +12 -6
amtmanager.js
+12 -6
@@ -1,5 +1,5 @@
1 /**
2 -* @description MeshCentral remote desktop multiplexor
2 +* @description MeshCentral Intel AMT manager
3 * @author Ylian Saint-Hilaire
4 * @copyright Intel Corporation 2018-2020
5 * @license Apache-2.0
@@ -29,7 +29,7 @@ module.exports.CreateAmtManager = function(parent) {
29 // Load the Intel AMT admin accounts
30 if ((typeof parent.args.amtmanager == 'object') && (Array.isArray(parent.args.amtmanager.amtadminaccount) == true)) {
31 for (var i in parent.args.amtmanager.amtadminaccount) {
32 - var c = parent.args.amtmanager.amtadminaccount[i], c2 = { user: "admin" };
32 + var c = parent.args.amtmanager.amtadminaccount[i], c2 = { user: 'admin' };
33 if (typeof c.user == 'string') { c2.user = c.user; }
34 if (typeof c.pass == 'string') { c2.pass = c.pass; obj.amtAdminAccounts.push(c2); }
35 }
@@ -107,6 +107,7 @@ module.exports.CreateAmtManager = function(parent) {
107 const dev = obj.amtDevices[nodeid];
108 if (dev == null) return;
109 if (dev.amtstack != null) { dev.amtstack.wsman.comm.FailAllError = 999; delete dev.amtstack; } // Disconnect any active connections.
110 + if (dev.polltimer != null) { clearInterval(dev.polltimer); delete dev.polltimer; }
111 delete obj.amtDevices[nodeid];
112 }
113
@@ -246,6 +247,11 @@ module.exports.CreateAmtManager = function(parent) {
247 //console.log(dev.nodeid, dev.name, dev.host, dev.aquired);
248 UpdateDevice(dev);
249 attemptFetchHardwareInventory(dev); // See if we need to get hardware inventory
250 +
251 + // Start power polling
252 + var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
253 + ppfunc.dev = dev;
254 + dev.polltimer = new setTimeout(ppfunc, 290000); // Poll for power state every 4 minutes 50 seconds.
255 fetchPowerState(dev);
256 } else {
257 // We got a bad response
@@ -260,7 +266,7 @@ module.exports.CreateAmtManager = function(parent) {
266 // We are unable to authenticate to this device, clear Intel AMT credentials.
267 ClearDeviceCredentials(dev);
268 }
263 - console.log(dev.nodeid, dev.name, dev.host, status, 'Bad response');
269 + //console.log(dev.nodeid, dev.name, dev.host, status, 'Bad response');
270 removeDevice(dev.nodeid);
271 }
272 }
@@ -375,7 +381,7 @@ module.exports.CreateAmtManager = function(parent) {
381 var wired = null, wireless = null;
382 for (var i in responses['AMT_EthernetPortSettings'].responses) {
383 var netif = responses['AMT_EthernetPortSettings'].responses[i];
378 - if ((netif.MACAddress != null) && (netif.MACAddress != "00-00-00-00-00-00")) {
384 + if ((netif.MACAddress != null) && (netif.MACAddress != '00-00-00-00-00-00')) {
385 if (netif.WLANLinkProtectionLevel != null) { wireless = netif; } else { wired = netif; }
386 }
387 }
@@ -387,7 +393,7 @@ module.exports.CreateAmtManager = function(parent) {
393 if (wired != null) {
394 var x = {};
395 x.family = 'IPv4';
390 - x.type = "ethernet";
396 + x.type = 'ethernet';
397 x.address = wired.IPAddress;
398 x.netmask = wired.SubnetMask;
399 x.mac = wired.MACAddress.split('-').join(':').toUpperCase();
@@ -398,7 +404,7 @@ module.exports.CreateAmtManager = function(parent) {
404 if (wireless != null) {
405 var x = {};
406 x.family = 'IPv4';
401 - x.type = "wireless";
407 + x.type = 'wireless';
408 x.address = wireless.IPAddress;
409 x.netmask = wireless.SubnetMask;
410 x.mac = wireless.MACAddress.split('-').join(':').toUpperCase();