lib/jobs/switch-node-relations.js
function _findMatchingMac(nodeLldpData, lldpMacList) {
        var relationsList = {};
        return Promise.all(
        _.forEach(_.keys(nodeLldpData.data), function (ethPort) {
            //validate mac first
            var lldpMac = catalogSearch.getPath(nodeLldpData.data[ethPort], 'chassis.mac');
            if (!lldpMac) {
                throw new Error('cant find mac address in lldp data for node ' +
                    nodeLldpData.node + ' port ' + ethPort);
            }
            if (_validateMacStrFormat(lldpMac)) {
                lldpMac = _adjustMacStrFormat(lldpMac);
                if (lldpMacList.indexOf(lldpMac) >= 0) {
                    var singleEntry = {
                        destMac: nodeLldpData.data[ethPort].chassis.mac,
                        destPort: nodeLldpData.data[ethPort].port.ifname
                    };
                    relationsList[ethPort] = singleEntry;
                }
            } else {
                throw new Error('mac: ' + lldpMac + ' bad format',
                    +nodeLldpData.node + ' port ' + ethPort);
            }
        }))
        .then(function () {
            return Promise.resolve(relationsList);
        });
    }
function _findMatchingMac(nodeLldpData, lldpMacList) {
        var relationsList = {};
        return Promise.all(
        _.forEach(_.keys(nodeLldpData.data), function (ethPort) {
            //validate mac first
            var lldpMac = catalogSearch.getPath(nodeLldpData.data[ethPort], 'chassis.mac');
            if (!lldpMac) {
                throw new Error('cant find mac address in lldp data for node ' +
                    nodeLldpData.node + ' port ' + ethPort);
            }
            if (_validateMacStrFormat(lldpMac)) {
                lldpMac = _adjustMacStrFormat(lldpMac);
                if (lldpMacList.indexOf(lldpMac) >= 0) {
                    var singleEntry = {
                        destMac: nodeLldpData.data[ethPort].chassis.mac,
                        destPort: nodeLldpData.data[ethPort].port.ifname
                    };
                    relationsList[ethPort] = singleEntry;
                }
            } else {
                throw new Error('mac: ' + lldpMac + ' bad format',
                    +nodeLldpData.node + ' port ' + ethPort);
            }
        }))
        .then(function () {
            return Promise.resolve(relationsList);
        });
    }
function _findMatchingMac ( nodeLldpData , lldpMacList ) { var relationsList = { } ; return Promise . all ( _ . forEach ( _ . keys ( nodeLldpData . data ) , function ( ethPort ) { //validate mac first var lldpMac = catalogSearch . getPath ( nodeLldpData . data [ ethPort ] , 'chassis.mac' ) ; if ( ! lldpMac ) { throw new Error ( 'cant find mac address in lldp data for node ' + nodeLldpData . node + ' port ' + ethPort ) ; } if ( _validateMacStrFormat ( lldpMac ) ) { lldpMac = _adjustMacStrFormat ( lldpMac ) ; if ( lldpMacList . indexOf ( lldpMac ) >= 0 ) { var singleEntry = { destMac : nodeLldpData . data [ ethPort ] . chassis . mac , destPort : nodeLldpData . data [ ethPort ] . port . ifname } ; relationsList [ ethPort ] = singleEntry ; } } else { throw new Error ( 'mac: ' + lldpMac + ' bad format' , + nodeLldpData . node + ' port ' + ethPort ) ; } } ) ) . then ( function ( ) { return Promise . resolve ( relationsList ) ; } ) ; }
Iterate through switch mac addresses list
for a match in nodes lldp catalog
return a promise
Iterate through switch mac addresses list for a match in nodes lldp catalog return a promise