123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- <?php
- /**
- * OLT V-Solution 1600D hardware abstraction layer
- */
- class PONVsol extends PONProto {
- /**
- * Receives, preprocess and stores all required data from V-Solution 1600D
- *
- * @return void
- */
- public function collect() {
- $oltModelId = $this->oltParameters['MODELID'];
- $oltid = $this->oltParameters['ID'];
- $oltIp = $this->oltParameters['IP'];
- $oltCommunity = $this->oltParameters['COMMUNITY'];
- $oltNoFDBQ = $this->oltParameters['NOFDB'];
- $oltIPPORT = $oltIp . ':' . self::SNMPPORT;
- $deviceType = $this->snmpTemplates[$oltModelId]['define']['DEVICE'];
- $sigIndexOID = $this->snmpTemplates[$oltModelId]['signal']['SIGINDEX'];
- $sigIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $sigIndexOID, self::SNMPCACHE);
- $sigIndex = str_replace($sigIndexOID . '.', '', $sigIndex);
- $sigIndex = str_replace($this->snmpTemplates[$oltModelId]['signal']['SIGVALUE'], '', $sigIndex);
- $sigIndex = explodeRows($sigIndex);
- $macIndexOID = $this->snmpTemplates[$oltModelId]['signal']['MACINDEX'];
- $macIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $macIndexOID, self::SNMPCACHE);
- $macIndex = str_replace($macIndexOID . '.', '', $macIndex);
- $macIndex = str_replace($this->snmpTemplates[$oltModelId]['signal']['MACVALUE'], '', $macIndex);
- $macIndex = explodeRows($macIndex);
- $VSOLMACsProcessed = $this->macParseVSOL($macIndex, $this->snmpTemplates[$oltModelId]);
- if (!empty($VSOLMACsProcessed)) {
- $this->signalParseVSOL($oltid, $sigIndex, $VSOLMACsProcessed);
- $distIndexOID = $this->snmpTemplates[$oltModelId]['misc']['DISTINDEX'];
- $distIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $distIndexOID, self::SNMPCACHE);
- $distIndex = str_replace($distIndexOID . '.', '', $distIndex);
- $distIndex = str_replace($this->snmpTemplates[$oltModelId]['misc']['DISTVALUE'], '', $distIndex);
- $distIndex = explodeRows($distIndex);
- $this->distanceParseVSOL($oltid, $distIndex, $VSOLMACsProcessed);
- $ifaceIndexOID = $this->snmpTemplates[$oltModelId]['misc']['IFACEDESCR'];
- $ifaceIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $ifaceIndexOID, self::SNMPCACHE);
- $ifaceIndex = str_replace($ifaceIndexOID . '.', '', $ifaceIndex);
- $ifaceIndex = str_replace(array($this->snmpTemplates[$oltModelId]['misc']['IFACEVALUE'], '"'), '', $ifaceIndex);
- $ifaceIndex = explodeRows($ifaceIndex);
- $ifaceCustDescrIndex = array();
- if (isset($this->snmpTemplates[$oltModelId]['misc']['IFACECUSTOMDESCR'])) {
- $ifaceCustDescrIndexOID = $this->snmpTemplates[$oltModelId]['misc']['IFACECUSTOMDESCR'];
- $ifaceCustDescrIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $ifaceCustDescrIndexOID, self::SNMPCACHE);
- $ifaceCustDescrIndex = str_replace($ifaceCustDescrIndexOID . '.', '', $ifaceCustDescrIndex);
- $ifaceCustDescrIndex = str_replace(array($this->snmpTemplates[$oltModelId]['misc']['IFACEVALUE'], '"'), '', $ifaceCustDescrIndex);
- $ifaceCustDescrIndex = explodeRows($ifaceCustDescrIndex);
- }
- $this->interfaceParseVSOL($oltid, $ifaceIndex, $VSOLMACsProcessed, $ifaceCustDescrIndex);
- $lastDeregIndexOID = $this->snmpTemplates[$oltModelId]['misc']['DEREGREASON'];
- $lastDeregIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $lastDeregIndexOID, self::SNMPCACHE);
- $lastDeregIndex = str_replace($lastDeregIndexOID . '.', '', $lastDeregIndex);
- $lastDeregIndex = str_replace($this->snmpTemplates[$oltModelId]['misc']['DEREGVALUE'], '', $lastDeregIndex);
- $lastDeregIndex = explodeRows($lastDeregIndex);
- $this->lastDeregParseVSOL($oltid, $lastDeregIndex, $VSOLMACsProcessed);
- if (!$oltNoFDBQ) {
- $fdbIndex = $this->walkCleared($oltIPPORT, $oltCommunity,
- $this->snmpTemplates[$oltModelId]['misc']['FDBINDEX'],
- '',
- $this->snmpTemplates[$oltModelId]['misc']['FDBVALUE'],
- self::SNMPCACHE);
- /* $fdbIndexOID = $this->snmpTemplates[$oltModelId]['misc']['FDBINDEX'];
- $fdbIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $fdbIndexOID, self::SNMPCACHE);
- $fdbIndex = str_replace($fdbIndexOID . '.', '', $fdbIndex);
- $fdbIndex = str_replace($this->snmpTemplates[$oltModelId]['misc']['FDBVALUE'], '', $fdbIndex);
- $fdbIndex = explodeRows($fdbIndex);*/
- $fdbVLANIndex = $this->walkCleared($oltIPPORT, $oltCommunity,
- $this->snmpTemplates[$oltModelId]['misc']['FDBVLANINDEX'],
- '',
- $this->snmpTemplates[$oltModelId]['misc']['FDBVLANVALUE'],
- self::SNMPCACHE);
- /* $fdbMACVLANOID = $this->snmpTemplates[$oltModelId]['misc']['FDBVLANINDEX'];
- $fdbVLANIndex = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $fdbMACVLANOID, self::SNMPCACHE);
- $fdbVLANIndex = str_replace($fdbMACVLANOID . '.', '', $fdbVLANIndex);
- $fdbVLANIndex = str_replace($this->snmpTemplates[$oltModelId]['misc']['FDBVLANVALUE'], '', $fdbVLANIndex);
- $fdbVLANIndex = explodeRows($fdbVLANIndex);*/
- if ($deviceType == 'V-Solution OLT V1600D_L') {
- $fdbMACIndex = $this->walkCleared($oltIPPORT, $oltCommunity,
- $this->snmpTemplates[$oltModelId]['misc']['FDBMACINDEX'],
- '',
- array($this->snmpTemplates[$oltModelId]['misc']['FDBMACVALUE'], '"'),
- self::SNMPCACHE);
- $this->fdbParseVSOL_L($VSOLMACsProcessed, $fdbIndex, $fdbMACIndex, $fdbVLANIndex);
- } else {
- $this->fdbParseVSOL($oltid, $VSOLMACsProcessed, $fdbIndex, $fdbVLANIndex);
- }
- }
- }
- //getting others system data from OLT
- if (isset($this->snmpTemplates[$oltModelId]['system'])) {
- //OLT uptime
- if (isset($this->snmpTemplates[$oltModelId]['system']['UPTIME'])) {
- $uptimeIndexOid = $this->snmpTemplates[$oltModelId]['system']['UPTIME'];
- $oltSystemUptimeRaw = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $uptimeIndexOid, self::SNMPCACHE);
- $this->uptimeParse($oltid, $oltSystemUptimeRaw);
- }
- //OLT temperature
- if (isset($this->snmpTemplates[$oltModelId]['system']['TEMPERATURE'])) {
- $temperatureIndexOid = $this->snmpTemplates[$oltModelId]['system']['TEMPERATURE'];
- $oltTemperatureRaw = $this->snmp->walk($oltIp . ':' . self::SNMPPORT, $oltCommunity, $temperatureIndexOid, self::SNMPCACHE);
- $this->temperatureParse($oltid, $oltTemperatureRaw);
- }
- }
- }
- /**
- * Processes V-SOLUTION OLT MAC adresses and returns them in array: LLID=>MAC
- *
- * @param $macIndex
- * @param $snmpTemplate
- *
- * @return array
- */
- protected function macParseVSOL($macIndex, $snmpTemplate) {
- $ONUsMACs = array();
- if (!empty($macIndex)) {
- //mac index preprocessing
- foreach ($macIndex as $io => $eachmac) {
- $line = explode('=', $eachmac);
- if (empty($line[0]) || empty($line[1])) {
- continue;
- }
- $tmpONUPortLLID = trim($line[0]);
- if ($snmpTemplate['misc']['GETACTIVEONUMACONLY']) {
- $tmpONUMAC = rtrim(chunk_split(str_replace(array('"', "0x"), '', trim($line[1])), 2, ':'), ':'); //mac address
- } else {
- $tmpONUMAC = str_replace('"', '', trim($line[1])); //mac address
- }
- //mac is present
- if (!empty($tmpONUPortLLID) and ! empty($tmpONUMAC)) {
- $ONUsMACs[$tmpONUPortLLID] = $tmpONUMAC;
- }
- }
- }
- return ($ONUsMACs);
- }
- /**
- * Performs signal preprocessing for sig/mac index arrays and stores it into cache
- *
- * @param int $oltid
- * @param array $sigIndex
- * @param array $macIndexProcessed
- *
- * @return void
- */
- protected function signalParseVSOL($oltid, $sigIndex, $macIndexProcessed) {
- $ONUsModulesTemps = array();
- $ONUsModulesVoltages = array();
- $ONUsModulesCurrents = array();
- $ONUsSignals = array();
- $result = array();
- $macDevID = array();
- $curDate = curdatetime();
- $oltid = vf($oltid, 3);
- //signal index preprocessing
- if ((!empty($sigIndex)) and ( !empty($macIndexProcessed))) {
- foreach ($sigIndex as $io => $eachsig) {
- $line = explode('=', $eachsig);
- //signal is present
- if (isset($line[0])) {
- $tmpOIDParamaterPiece = substr(trim($line[0]), 0, 1);
- $tmpONUPortLLID = substr(trim($line[0]), 2);
- // just because we can't(I dunno why - honestly) just query the
- // .1.3.6.1.4.1.37950.1.1.5.12.2.1.8.1.6 and .1.3.6.1.4.1.37950.1.1.5.12.2.1.8.1.7 OIDs
- // cause it's simply returns NOTHING - we need to take a start from the higher tree point - .1.3.6.1.4.1.37950.1.1.5.12.2.1.8.1
- // and then we can extract all necessary values
- switch ($tmpOIDParamaterPiece) {
- case '3':
- $ONUsModulesTemps[$tmpONUPortLLID] = trim($line[1]); // may be we'll show this somewhere in future
- break;
- case '4':
- $ONUsModulesVoltages[$tmpONUPortLLID] = trim($line[1]); // may be we'll show this somewhere in future
- break;
- case '5':
- $ONUsModulesCurrents[$tmpONUPortLLID] = trim($line[1]); // may be we'll show this somewhere in future
- break;
- // may be we'll show this somewhere in future
- case '6':
- $SignalRaw = trim($line[1]);
- $ONUsSignals[$tmpONUPortLLID]['SignalTXRaw'] = $SignalRaw;
- $ONUsSignals[$tmpONUPortLLID]['SignalTXdBm'] = trim(substr(stristr(stristr(stristr($SignalRaw, '('), ')', true), 'dBm', true), 1));
- break;
- case '7':
- $SignalRaw = trim($line[1]);
- $ONUsSignals[$tmpONUPortLLID]['SignalRXRaw'] = $SignalRaw;
- $ONUsSignals[$tmpONUPortLLID]['SignalRXdBm'] = trim(substr(stristr(stristr(stristr($SignalRaw, '('), ')', true), 'dBm', true), 1));
- break;
- }
- }
- }
- //storing results
- foreach ($macIndexProcessed as $devId => $eachMac) {
- if (isset($ONUsSignals[$devId])) {
- //signal history filling
- $signal = (isset($ONUsSignals[$devId]['SignalRXdBm']) ? $ONUsSignals[$devId]['SignalRXdBm'] : '');
- if (!empty($signal)) {
- $result[$eachMac] = $signal;
- }
- if (empty($signal) or $signal == 'Offline') {
- $signal = $this->onuOfflineSignalLevel; //over 9000 offline signal level :P
- }
- //saving each ONU signal history
- $this->olt->writeSignalHistory($eachMac, $signal);
- }
- }
- $macDevID = array_flip($macIndexProcessed);
- //writing signals cache
- $this->olt->writeSignals($result);
- //saving ONU cache
- $this->olt->writeOnuCache($macIndexProcessed);
- // saving macindex as MAC => devID
- $this->olt->writeMacIndex($macDevID);
- }
- }
- /**
- * Performs distance preprocessing for distance/mac index arrays and stores it into cache
- *
- * @param $oltid
- * @param $DistIndex
- * @param $macIndexProcessed
- */
- protected function distanceParseVSOL($oltid, $DistIndex, $macIndexProcessed) {
- $ONUDistances = array();
- $result = array();
- if (!empty($macIndexProcessed) and ! empty($DistIndex)) {
- //last dereg index preprocessing
- foreach ($DistIndex as $io => $eachRow) {
- $line = explode('=', $eachRow);
- if (empty($line[0]) || empty($line[1])) {
- continue;
- }
- $tmpONUPortLLID = trim($line[0]);
- $tmpONUDistance = trim($line[1]);
- $ONUDistances[$tmpONUPortLLID] = $tmpONUDistance;
- }
- //storing results
- foreach ($macIndexProcessed as $devId => $eachMac) {
- if (isset($ONUDistances[$devId])) {
- $result[$eachMac] = $ONUDistances[$devId];
- }
- }
- //saving distances
- $this->olt->writeDistances($result);
- }
- }
- /**
- * Performs interface preprocessing for interface/mac index arrays and stores it into cache
- *
- * @param $oltid
- * @param $IfaceIndex
- * @param $macIndexProcessed
- * @param $ifaceCustDescrRaw
- */
- protected function interfaceParseVSOL($oltid, $IfaceIndex, $macIndexProcessed, $ifaceCustDescrRaw = array()) {
- $ONUIfaces = array();
- $result = array();
- $processIfaceCustDescr = !empty($ifaceCustDescrRaw);
- $ifaceCustDescrIdx = array();
- $ifaceCustDescrArr = array();
- // olt iface descr extraction
- if ($processIfaceCustDescr) {
- foreach ($ifaceCustDescrRaw as $io => $each) {
- if (empty($each)) {
- continue;
- }
- $ifDescr = explode('=', str_replace(array(" ", "\t", "\n", "\r", "\0", "\x0B"), '', $each));
- if (empty($ifDescr[0]) && empty($ifDescr[1])) {
- continue;
- }
- $ifaceCustDescrIdx[$ifDescr[0]] = $ifDescr[1];
- }
- }
- if (!empty($macIndexProcessed) and ! empty($IfaceIndex)) {
- //OLT iface index preprocessing
- foreach ($IfaceIndex as $io => $eachRow) {
- if (empty($eachRow)) {
- continue;
- }
- $line = explode('=', str_replace(array(" ", "\t", "\n", "\r", "\0", "\x0B"), '', $eachRow));
- if (empty($line[0]) || empty($line[1])) {
- continue;
- }
- $tmpONUPortLLID = trim($line[0]);
- $tmpONUIface = trim($line[1]);
- $ONUIfaces[$tmpONUPortLLID] = $tmpONUIface;
- }
- //storing results
- foreach ($macIndexProcessed as $devId => $eachMac) {
- $tPONIfaceNum = substr($devId, 0, 1);
- if (array_key_exists($tPONIfaceNum, $ONUIfaces)) {
- $tPONIfaceName = $ONUIfaces[$tPONIfaceNum];
- $tPONIfaceStr = $tPONIfaceName . ' / ' . str_replace('.', ':', $devId);
- $cleanIface = strstr($tPONIfaceStr, ':', true);
- if ($processIfaceCustDescr && !isset($ifaceCustDescrArr[$cleanIface]) && array_key_exists($tPONIfaceNum, $ifaceCustDescrIdx)) {
- $ifaceCustDescrArr[$cleanIface] = $ifaceCustDescrIdx[$tPONIfaceNum];
- }
- } else {
- $tPONIfaceStr = str_replace('.', ':', $devId);
- }
- $result[$eachMac] = $tPONIfaceStr;
- }
- //saving ONU interfaces and interfaces descriptions
- $this->olt->writeInterfaces($result);
- $this->olt->writeInterfacesDescriptions($ifaceCustDescrArr);
- }
- }
- /**
- * Parses & stores to cache ONUs FDB cache (MACs behind ONU)
- *
- * @param $oltID
- * @param $onuMACIndex
- * @param $fdbIndex
- * @param $fdbVLANIndex
- */
- protected function fdbParseVSOL($oltID, $onuMACIndex, $fdbIndex, $fdbVLANIndex) {
- $fdbIdxMAC = array();
- $fdbIdxVLAN = array();
- $fdbCahce = array();
- if (!empty($fdbIndex)) {
- // processing FDBIndex array to get FDB MAC => pon port number + ONU LLID mapping
- foreach ($fdbIndex as $each => $eachIdx) {
- $line = explode('=', $eachIdx);
- // ONU LLID is present
- if (isset($line[1])) {
- $portLLID = trim(str_replace(array('"', 'EPON0/'), '', $line[1])); // pon port number + ONU LLID
- $portLLID = str_replace(':', '.', $portLLID);
- $fdbMAC = trim(convertMACDec2Hex($line[0])); // FDB MAC in dotted DEC format
- $fdbIdxMAC[$fdbMAC] = $portLLID; // FDB MAC => pon port number + ONU LLID
- }
- }
- }
- if (!empty($fdbVLANIndex)) {
- // processing $fdbVLANIndex array to get FDB MAC => FDB VLAN mapping
- foreach ($fdbVLANIndex as $each => $eachIdx) {
- $line = explode('=', $eachIdx);
- // FDB VLAN is present
- if (isset($line[1])) {
- $fdbVLAN = trim($line[1]); // pon port number + ONU LLID
- $fdbMAC = trim(convertMACDec2Hex($line[0])); // FDB MAC in dotted DEC format
- $fdbIdxVLAN[$fdbMAC] = $fdbVLAN; // FDB MAC => FDB VLAN
- }
- }
- }
- if (!empty($onuMACIndex) and ! empty($fdbIdxMAC)) {
- foreach ($onuMACIndex as $eachLLID => $eachONUMAC) {
- $onuFDBIdxs = array_keys($fdbIdxMAC, $eachLLID);
- if (!empty($onuFDBIdxs)) {
- $tmpFDBArr = array();
- foreach ($onuFDBIdxs as $io => $eachFDBMAC) {
- if (empty($eachFDBMAC) or $eachFDBMAC == $eachONUMAC) {
- continue;
- } else {
- $tmpFDBVLAN = empty($fdbIdxVLAN[$eachFDBMAC]) ? '' : $fdbIdxVLAN[$eachFDBMAC];
- // not applicable with PON HAL now
- // i dont know nahooya this was here
- //$tmpONUID = $this->getONUIDByMAC($eachONUMAC);
- //$tmpONUID = (empty($tmpONUID)) ? $io : $tmpONUID;
- $tmpONUID = $io;
- $tmpFDBArr[$tmpONUID] = array('mac' => $eachFDBMAC, 'vlan' => $tmpFDBVLAN);
- }
- }
- $fdbCahce[$eachONUMAC] = $tmpFDBArr;
- }
- }
- }
- //saving OLT FDB
- $this->olt->writeFdb($fdbCahce);
- }
- /**
- * Parses & stores to cache ONUs FDB cache (MACs behind ONU) for "L" series VSOL OLTs
- *
- * @param $onuMACIndex
- * @param $fdbIndex
- * @param $fdbMACIndex
- * @param $fdbVLANIndex
- *
- * @return void
- */
- protected function fdbParseVSOL_L($onuMACIndex, $fdbIndex, $fdbMACIndex, $fdbVLANIndex) {
- $fdbIdxPosLLID = array();
- $fdbIdxMAC = array();
- $fdbIdxVLAN = array();
- $fdbCahce = array();
- if (!empty($fdbIndex)) {
- // processing FDBIndex array to get FDB MAC => pon port number + ONU LLID mapping
- foreach ($fdbIndex as $each => $eachIdx) {
- $line = explode('=', $eachIdx);
- // ONU LLID is present
- if (isset($line[1])) {
- $portLLID = trim(str_replace(array('"', 'EPON0/'), '', $line[1])); // pon port number + ONU LLID
- $portLLID = str_replace(':', '.', $portLLID);
- $fdbIdxPos = trim($line[0]); // FDB index position (integer) to look for in $fdbMACIndex & $fdbVLANIndex
- $fdbIdxPosLLID[$fdbIdxPos] = $portLLID; // FDB index position => pon port number + ONU LLID
- }
- }
- }
- if (!empty($fdbMACIndex)) {
- // processing $fdbVLANIndex array to get FDB MAC => FDB VLAN mapping
- foreach ($fdbMACIndex as $each => $eachIdx) {
- $line = explode('=', $eachIdx);
- // FDB VLAN is present
- if (isset($line[1])) {
- $fdbMAC = strtolower(str_replace(' ', ':', trim($line[1]))); // FDB MAC
- $fdbIdxPos = trim($line[0]); // FDB index position (integer)
- $fdbIdxMAC[$fdbIdxPos] = $fdbMAC; // FDB MAC => FDB VLAN
- }
- }
- }
- if (!empty($fdbVLANIndex)) {
- // processing $fdbVLANIndex array to get FDB MAC => FDB VLAN mapping
- foreach ($fdbVLANIndex as $each => $eachIdx) {
- $line = explode('=', $eachIdx);
- // FDB VLAN is present
- if (isset($line[1])) {
- $fdbVLAN = trim($line[1]); // FDB VLAN ID (integer)
- $fdbIdxPos = trim($line[0]); // FDB index position (integer)
- $fdbIdxVLAN[$fdbIdxPos] = $fdbVLAN; // FDB MAC => FDB VLAN
- }
- }
- }
- if (!empty($onuMACIndex) and !empty($fdbIdxPosLLID)) {
- foreach ($onuMACIndex as $eachLLID => $eachONUMAC) {
- $onuFDBIdxs = array_keys($fdbIdxPosLLID, $eachLLID);
- if (!empty($onuFDBIdxs)) {
- $tmpFDBArr = array();
- foreach ($onuFDBIdxs as $io => $eachFDBIdx) {
- if (empty($eachFDBIdx)) {
- continue;
- } else {
- $tmpFDBVLAN = (empty($fdbIdxVLAN[$eachFDBIdx]) ? '' : $fdbIdxVLAN[$eachFDBIdx]);
- $tmpFDBMAC = (empty($fdbIdxMAC[$eachFDBIdx]) ? '' : $fdbIdxMAC[$eachFDBIdx]);
- $tmpONUID = $io;
- $tmpFDBArr[$tmpONUID] = array('mac' => $tmpFDBMAC, 'vlan' => $tmpFDBVLAN);
- }
- }
- $fdbCahce[$eachONUMAC] = $tmpFDBArr;
- }
- }
- }
- //saving OLT FDB
- $this->olt->writeFdb($fdbCahce);
- }
- /**
- * Performs last dereg reason preprocessing for dereg reason/mac index arrays and stores it into cache
- *
- * @param $oltid
- * @param $LastDeregIndex
- * @param $macIndex
- * @param $snmpTemplate
- */
- protected function lastDeregParseVSOL($oltid, $LastDeregIndex, $macIndexProcessed) {
- $ONUDeRegs = array();
- $result = array();
- if (!empty($macIndexProcessed) and ! empty($LastDeregIndex)) {
- //last dereg index preprocessing
- foreach ($LastDeregIndex as $io => $eachRow) {
- $line = explode('=', $eachRow);
- if (empty($line[0]) || empty($line[1])) {
- continue;
- }
- $tmpONUPortLLID = trim($line[0]);
- $tmpONULastDeregReason = intval(trim($line[1]));
- switch ($tmpONULastDeregReason) {
- case 0:
- $TxtColor = '"#F80000"';
- $tmpONULastDeregReasonStr = 'Wire down';
- break;
- case 1:
- $TxtColor = '"#FF4400"';
- $tmpONULastDeregReasonStr = 'Power off';
- break;
- default:
- $TxtColor = '"#000000"';
- $tmpONULastDeregReasonStr = 'Unknown';
- break;
- }
- if (!empty($tmpONUPortLLID)) {
- $tmpONULastDeregReasonStr = wf_tag('font', false, '', 'color=' . $TxtColor . '') .
- $tmpONULastDeregReasonStr .
- wf_tag('font', true);
- $ONUDeRegs[$tmpONUPortLLID] = $tmpONULastDeregReasonStr;
- }
- }
- //storing results
- foreach ($macIndexProcessed as $devId => $eachMac) {
- if (isset($ONUDeRegs[$devId])) {
- $result[$eachMac] = $ONUDeRegs[$devId];
- }
- }
- //saving ONUs deregs reasons
- $this->olt->writeDeregs($result);
- }
- }
- }
|