Added --filterid to listdevice in meshctrl.js
Ylian Saint-Hilaire committed
Mar 14, 2021 at 14:18 UTC
3b2ef66dcd96913149632bdb168ad0a4273ac57a
2 files changed
+27
-4
amtmanager.js
+4
-4
@@ -1716,13 +1716,13 @@ module.exports.CreateAmtManager = function (parent) {
1716
// We are not activated now, go to ACM directly.
1717
// If this is Intel AMT 14 or better, we are going to attempt a host-based end-to-end TLS activation.
1718
if (typeof dev.intelamt.ver == 'string') { var verSplit = dev.intelamt.ver.split('.'); if (verSplit.length >= 3) { dev.aquired.majorver = parseInt(verSplit[0]); dev.aquired.minorver = parseInt(verSplit[1]); } }
1719
- //if (dev.aquired.majorver >= 14) {
1719
+ if (dev.aquired.majorver >= 14) {
1720
// Perform host-based TLS ACM activation
1721
- //activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo);
1722
- //} else {
1721
+ activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo);
1722
+ } else {
1723
// Perform host-based ACM activation
1724
activateIntelAmtAcm(dev, mesh.amt.password, acminfo);
1725
- //}
1725
+ }
1726
}
1727
}
1728
}
meshctrl.js
+23
@@ -368,6 +368,7 @@ if (args['_'].length == 0) {
368
console.log(" --count - Only return the device count.");
369
console.log(" --json - Show result as JSON.");
370
console.log(" --csv - Show result as comma seperated values.");
371
+ console.log(" --filterid [id,id...] - Show only results for devices with included id.");
372
break;
373
}
374
case 'listusersofdevicegroup': {
@@ -1795,6 +1796,28 @@ function serverConnect() {
1796
if ((data.result != null) && (data.result != 'ok')) {
1797
console.log(data.result);
1798
} else {
1799
+ // Filder devices based on device id.
1800
+ if (args.filterid) {
1801
+ var filteridSplit = args.filterid.split(','), filters = [];
1802
+ for (var i in filteridSplit) {
1803
+ var f = filteridSplit[i].trim();
1804
+ var g = f.split('/'); // If there is any / in the id, just grab the last part.
1805
+ if (g.length > 0) { f = g[g.length - 1]; }
1806
+ if (f != '') { filters.push(f); }
1807
+ }
1808
+ if (filters.length > 0) {
1809
+ for (var mid in data.nodes) {
1810
+ var filteredNodes = [];
1811
+ for (var nid in data.nodes[mid]) {
1812
+ var n = data.nodes[mid][nid], match = false;
1813
+ for (var f in filters) { if (n._id.indexOf(filters[f]) >= 0) { match = true; } }
1814
+ if (match) { filteredNodes.push(n); }
1815
+ }
1816
+ data.nodes[mid] = filteredNodes;
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
if (args.csv) {
1822
// Return a flat list
1823
var nodecount = 0;