Added --filterid to listdevice in meshctrl.js

This commit is contained in:
Ylian Saint-Hilaire 2021-03-14 14:18:50 -07:00
parent bfffdfd8f4
commit 3b2ef66dcd
2 changed files with 27 additions and 4 deletions

View File

@ -1716,13 +1716,13 @@ module.exports.CreateAmtManager = function (parent) {
// We are not activated now, go to ACM directly.
// If this is Intel AMT 14 or better, we are going to attempt a host-based end-to-end TLS activation.
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]); } }
//if (dev.aquired.majorver >= 14) {
if (dev.aquired.majorver >= 14) {
// Perform host-based TLS ACM activation
//activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo);
//} else {
activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo);
} else {
// Perform host-based ACM activation
activateIntelAmtAcm(dev, mesh.amt.password, acminfo);
//}
}
}
}
}

View File

@ -368,6 +368,7 @@ if (args['_'].length == 0) {
console.log(" --count - Only return the device count.");
console.log(" --json - Show result as JSON.");
console.log(" --csv - Show result as comma seperated values.");
console.log(" --filterid [id,id...] - Show only results for devices with included id.");
break;
}
case 'listusersofdevicegroup': {
@ -1795,6 +1796,28 @@ function serverConnect() {
if ((data.result != null) && (data.result != 'ok')) {
console.log(data.result);
} else {
// Filder devices based on device id.
if (args.filterid) {
var filteridSplit = args.filterid.split(','), filters = [];
for (var i in filteridSplit) {
var f = filteridSplit[i].trim();
var g = f.split('/'); // If there is any / in the id, just grab the last part.
if (g.length > 0) { f = g[g.length - 1]; }
if (f != '') { filters.push(f); }
}
if (filters.length > 0) {
for (var mid in data.nodes) {
var filteredNodes = [];
for (var nid in data.nodes[mid]) {
var n = data.nodes[mid][nid], match = false;
for (var f in filters) { if (n._id.indexOf(filters[f]) >= 0) { match = true; } }
if (match) { filteredNodes.push(n); }
}
data.nodes[mid] = filteredNodes;
}
}
}
if (args.csv) {
// Return a flat list
var nodecount = 0;