lib/utils/job-utils/catalog-searcher.js
function _getJbodExtDriveIdCatalog(nodeId, driveId, physicalDiskData, vendors){
        //Devide ID in SCSI ID is used to match megaraid DID
        //This feature is only qualified on servers with one RAID card
        //An alternative method is to use logic wwid
        //to find "OS Device Name" in smart catalog and get megaraid DID
        var scsiIds = driveId.scsiId.split(':');
        var deviceId = scsiIds[2];
        var controllerId = scsiIds[0];
        /**
        *physicalDiskCatalog.data example, not fully displayed:
        *    "Controllers": [
        *    {
        *        "Command Status": {
        *            "Controller": 0,
        *            "Description": "Show Drive Information Succeeded.",
        *            "Status": "Success"
        *        },
        *        "Response Data": {
        *            "Drive /c0/e252/s0": [
        *                {
        *                    "DG": 0,
        *                    "DID": 0,
        *                    "EID:Slt": "252:0",
        *                    "Intf": "SAS",
        *                    "Med": "HDD",
        *                    "Model": "ST1200MM0088    ",
        *                    "PI": "N",
        *                    "SED": "N",
        *                    "SeSz": "512B",
        *                    "Size": "1.091 TB",
        *                    "Sp": "U",
        *                    "State": "Onln"
        *                }
        */
        var driveDataList,
            driveBaseInfoList = {},
            matchedBaseInfo,
            matchedBaseInfoKey;

        _.forEach(physicalDiskData.Controllers, function(controller){
            if (controller['Command Status'].Controller.toString() === controllerId) {
                driveDataList = controller['Response Data'];
                return false;
            }
        });

        //Filter Drive Basic information from Response Data
        //Drive Basic information is the only one has array as element
        _.forEach(driveDataList, function(driveInfo, key){
            if(_.isArray(driveInfo)) {
                driveBaseInfoList[key] = driveInfo[0];
            }
        });

        _.forEach(driveBaseInfoList, function(info, key){
            if(info.DID.toString() === deviceId){
                matchedBaseInfoKey = key;
                return false;
            }
        });

        if (matchedBaseInfoKey ) {
            // Base info key example:
            //  "Drive /c0/e252/s0"
            var match = matchedBaseInfoKey.match(/.*\/c(\d+)\/e(\d+)\/s(\d+)/);
            matchedBaseInfo = driveBaseInfoList[matchedBaseInfoKey];
            driveId.controllerId = controllerId; 
            driveId.deviceIds = [matchedBaseInfo.DID];
            driveId.slotIds = matchedBaseInfoKey.split(' ').slice(-1);
            driveId.size = matchedBaseInfo.Size;
            driveId.type = matchedBaseInfo.State;
            driveId.controllerVendor = vendors[_.parseInt(controllerId)];
            driveId.physicalDisks = [{
                protocol: matchedBaseInfo.Intf,
                model: matchedBaseInfo.Model,
                deviceId: matchedBaseInfo.DID,
                slotId: match[3],
                size: matchedBaseInfo.Size,
                type: matchedBaseInfo.Med,
                enclosureId: match[2]
            }];
        }
        return driveId;
    }
function _getJbodExtDriveIdCatalog(nodeId, driveId, physicalDiskData, vendors){
        //Devide ID in SCSI ID is used to match megaraid DID
        //This feature is only qualified on servers with one RAID card
        //An alternative method is to use logic wwid
        //to find "OS Device Name" in smart catalog and get megaraid DID
        var scsiIds = driveId.scsiId.split(':');
        var deviceId = scsiIds[2];
        var controllerId = scsiIds[0];
        /**
        *physicalDiskCatalog.data example, not fully displayed:
        *    "Controllers": [
        *    {
        *        "Command Status": {
        *            "Controller": 0,
        *            "Description": "Show Drive Information Succeeded.",
        *            "Status": "Success"
        *        },
        *        "Response Data": {
        *            "Drive /c0/e252/s0": [
        *                {
        *                    "DG": 0,
        *                    "DID": 0,
        *                    "EID:Slt": "252:0",
        *                    "Intf": "SAS",
        *                    "Med": "HDD",
        *                    "Model": "ST1200MM0088    ",
        *                    "PI": "N",
        *                    "SED": "N",
        *                    "SeSz": "512B",
        *                    "Size": "1.091 TB",
        *                    "Sp": "U",
        *                    "State": "Onln"
        *                }
        */
        var driveDataList,
            driveBaseInfoList = {},
            matchedBaseInfo,
            matchedBaseInfoKey;

        _.forEach(physicalDiskData.Controllers, function(controller){
            if (controller['Command Status'].Controller.toString() === controllerId) {
                driveDataList = controller['Response Data'];
                return false;
            }
        });

        //Filter Drive Basic information from Response Data
        //Drive Basic information is the only one has array as element
        _.forEach(driveDataList, function(driveInfo, key){
            if(_.isArray(driveInfo)) {
                driveBaseInfoList[key] = driveInfo[0];
            }
        });

        _.forEach(driveBaseInfoList, function(info, key){
            if(info.DID.toString() === deviceId){
                matchedBaseInfoKey = key;
                return false;
            }
        });

        if (matchedBaseInfoKey ) {
            // Base info key example:
            //  "Drive /c0/e252/s0"
            var match = matchedBaseInfoKey.match(/.*\/c(\d+)\/e(\d+)\/s(\d+)/);
            matchedBaseInfo = driveBaseInfoList[matchedBaseInfoKey];
            driveId.controllerId = controllerId; 
            driveId.deviceIds = [matchedBaseInfo.DID];
            driveId.slotIds = matchedBaseInfoKey.split(' ').slice(-1);
            driveId.size = matchedBaseInfo.Size;
            driveId.type = matchedBaseInfo.State;
            driveId.controllerVendor = vendors[_.parseInt(controllerId)];
            driveId.physicalDisks = [{
                protocol: matchedBaseInfo.Intf,
                model: matchedBaseInfo.Model,
                deviceId: matchedBaseInfo.DID,
                slotId: match[3],
                size: matchedBaseInfo.Size,
                type: matchedBaseInfo.Med,
                enclosureId: match[2]
            }];
        }
        return driveId;
    }
function _getJbodExtDriveIdCatalog ( nodeId , driveId , physicalDiskData , vendors ) { //Devide ID in SCSI ID is used to match megaraid DID //This feature is only qualified on servers with one RAID card //An alternative method is to use logic wwid //to find "OS Device Name" in smart catalog and get megaraid DID var scsiIds = driveId . scsiId . split ( ':' ) ; var deviceId = scsiIds [ 2 ] ; var controllerId = scsiIds [ 0 ] ; /**
        *physicalDiskCatalog.data example, not fully displayed:
        *    "Controllers": [
        *    {
        *        "Command Status": {
        *            "Controller": 0,
        *            "Description": "Show Drive Information Succeeded.",
        *            "Status": "Success"
        *        },
        *        "Response Data": {
        *            "Drive /c0/e252/s0": [
        *                {
        *                    "DG": 0,
        *                    "DID": 0,
        *                    "EID:Slt": "252:0",
        *                    "Intf": "SAS",
        *                    "Med": "HDD",
        *                    "Model": "ST1200MM0088    ",
        *                    "PI": "N",
        *                    "SED": "N",
        *                    "SeSz": "512B",
        *                    "Size": "1.091 TB",
        *                    "Sp": "U",
        *                    "State": "Onln"
        *                }
        */ var driveDataList , driveBaseInfoList = { } , matchedBaseInfo , matchedBaseInfoKey ; _ . forEach ( physicalDiskData . Controllers , function ( controller ) { if ( controller [ 'Command Status' ] . Controller . toString ( ) === controllerId ) { driveDataList = controller [ 'Response Data' ] ; return false ; } } ) ; //Filter Drive Basic information from Response Data //Drive Basic information is the only one has array as element _ . forEach ( driveDataList , function ( driveInfo , key ) { if ( _ . isArray ( driveInfo ) ) { driveBaseInfoList [ key ] = driveInfo [ 0 ] ; } } ) ; _ . forEach ( driveBaseInfoList , function ( info , key ) { if ( info . DID . toString ( ) === deviceId ) { matchedBaseInfoKey = key ; return false ; } } ) ; if ( matchedBaseInfoKey ) { // Base info key example: //  "Drive /c0/e252/s0" var match = matchedBaseInfoKey . match ( / .*\/c(\d+)\/e(\d+)\/s(\d+) / ) ; matchedBaseInfo = driveBaseInfoList [ matchedBaseInfoKey ] ; driveId . controllerId = controllerId ; driveId . deviceIds = [ matchedBaseInfo . DID ] ; driveId . slotIds = matchedBaseInfoKey . split ( ' ' ) . slice ( - 1 ) ; driveId . size = matchedBaseInfo . Size ; driveId . type = matchedBaseInfo . State ; driveId . controllerVendor = vendors [ _ . parseInt ( controllerId ) ] ; driveId . physicalDisks = [ { protocol : matchedBaseInfo . Intf , model : matchedBaseInfo . Model , deviceId : matchedBaseInfo . DID , slotId : match [ 3 ] , size : matchedBaseInfo . Size , type : matchedBaseInfo . Med , enclosureId : match [ 2 ] } ] ; } return driveId ; }
Get extended driveId catalog data for JBOD disk from megaraid-physical-drives
@param {String} nodeId - node identifier
@param {Object} driveId - driveId catalog
@param {Object} physicalDiskData - Megaraid physical disk catalogs
@param {Array} vendors - Drive vendor controller list
@return {Promise} driveId catalogs extended
Get extended driveId catalog data for JBOD disk from megaraid - physical - drives