Fixed support for Intel vPro(R) Manageability Migration Tool

Ylian Saint-Hilaire committed Sep 3, 2022 at 12:38 UTC cae47b89a4a07852777b052fad2da80d6fdda9d2
1 file changed +8 -7
meshuser.js
+8 -7
@@ -5116,21 +5116,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5116 var amtDevices = [];
5117
5118 // Decode a JSON file from the Intel SCS migration tool
5119 - if ((typeof command.amtdevices == 'object') && (typeof command.amtdevices.ApplicationData == 'object') && (command.amtdevices.ApplicationData.Application == 'Intel EMA Migration Tool') && (Array.isArray(command.amtdevices['Managed Systems']))) {
5120 - for (var i in command.amtdevices['Managed Systems']) {
5121 - const importDev = command.amtdevices['Managed Systems'][i];
5119 + if ((typeof command.amtdevices == 'object') && (typeof command.amtdevices.ApplicationData == 'object') && (command.amtdevices.ApplicationData.Application == 'Intel vPro(R) Manageability Migration Tool') && (typeof command.amtdevices['ManagedSystems'] == 'object') && (Array.isArray(command.amtdevices['ManagedSystems']['ManagedSystemsList']))) {
5120 + for (var i in command.amtdevices['ManagedSystems']['ManagedSystemsList']) {
5121 + const importDev = command.amtdevices['ManagedSystems']['ManagedSystemsList'][i];
5122 var host = null;
5123 - if ((typeof importDev.curr_AMTFqdn == 'string') && (importDev.curr_AMTFqdn != '')) { host = importDev.curr_AMTFqdn; }
5124 - if ((host == null) && (typeof importDev.curr_AMTIPv4 == 'string') && (importDev.curr_AMTIPv4 != '')) { host = importDev.curr_AMTIPv4; }
5123 + if ((typeof importDev.Fqdn == 'string') && (importDev.Fqdn != '')) { host = importDev.Fqdn; }
5124 + if ((host == null) && (typeof importDev.IPv4 == 'string') && (importDev.IPv4 != '')) { host = importDev.IPv4; }
5125 if (host != null) {
5126 // Create a new Intel AMT device
5127 const nodeid = 'node/' + domain.id + '/' + parent.crypto.randomBytes(48).toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
5128 const device = { type: 'node', _id: nodeid, meshid: mesh._id, mtype: 1, icon: 1, name: host, host: host, domain: domain.id, intelamt: { user: 'admin', state: 2 } };
5129
5130 // Add optional fields
5131 - if (typeof importDev.AMTVersion == 'string') { device.intelamt.ver = importDev.AMTVersion; }
5131 + if (typeof importDev.AmtVersion == 'string') { device.intelamt.ver = importDev.AmtVersion; }
5132 if (typeof importDev.ConfiguredPassword == 'string') { device.intelamt.pass = importDev.ConfiguredPassword; }
5133 - if (typeof importDev.uuid == 'string') { device.intelamt.uuid = importDev.uuid; }
5133 + if (typeof importDev.Uuid == 'string') { device.intelamt.uuid = importDev.Uuid; }
5134 + if (importDev.ConnectionType == 'TLS') { device.intelamt.tls = 1; }
5135
5136 // Check if we are already adding a device with the same hostname, if so, skip it.
5137 var skip = false;