vrpReadLLDPStatus: vrp85 was not working
authorAlexey Andriyanov <alan@al-an.info>
Fri, 14 Feb 2014 15:19:12 +0000 (19:19 +0400)
committerAlexey Andriyanov <alan@al-an.info>
Fri, 14 Feb 2014 15:19:12 +0000 (19:19 +0400)
Huawei VRP 8.5 has different Port ID type values. Extend the $valid_subtypes
array and also the extracting regexp.

Do trim of every extracted string, because the values have spaces in trail.

ChangeLog
wwwroot/inc/deviceconfig.php

index bcc9854f50c5abbc5a4f685e06d0e70da5b71308..6a8abacd0f04400344fbfb3bf0933828875a9dd0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
        bugfix: system functions for translating IPs were not used even being available
        bugfix: Zero-U-mounted objects were not counted in rack summary
        bugfix: fix of sorting issue with national characters by Thomas Uhde (#837)
+       bugfix: LLDP parser fixed for Huawei VRP 8.5
        update: enable IP addressing for all object types unless specifically excluded
        update: SNMP support for 3Com 4510G-24, Cisco SF302-08MP, 
                Linksys SRW248G4 by Rafael Driutti,
index 088db57eb7b863819c86e31d1f96b3c9603c6aa1..8e763160f03c3472d55ff69aef2f60af573b7985 100644 (file)
@@ -106,8 +106,11 @@ function vrpReadLLDPStatus ($input)
        $valid_subtypes = array
        (
                'interfaceName',
+               'Interface Name',
                'interfaceAlias',
+               'Interface Alias',
                'local',
+               'Local',
        );
        foreach (explode ("\n", $input) as $line)
        {
@@ -115,16 +118,16 @@ function vrpReadLLDPStatus ($input)
                switch (TRUE)
                {
                case preg_match ('/^(.+) has \d+ neighbor(\(s\)|s):$/', $line, $matches):
-                       $ret['current']['local_port'] = shortenIfName ($matches[1]);
+                       $ret['current']['local_port'] = shortenIfName (trim ($matches[1]));
                        break;
-               case preg_match ('/^Port ?ID ?(?:sub)?type\s*:\s*([^ ]+)/i', $line, $matches):
-                       $ret['current']['PortIdSubtype'] = $matches[1];
+               case preg_match ('/^Port ?ID ?(?:sub)?type\s*:\s*(.*)$/i', $line, $matches):
+                       $ret['current']['PortIdSubtype'] = trim ($matches[1]);
                        break;
                case preg_match ('/^Port ?ID\s*:\s*(.+)$/i', $line, $matches):
-                       $ret['current']['PortId'] = $matches[1];
+                       $ret['current']['PortId'] = trim ($matches[1]);
                        break;
                case preg_match ('/^Port description\s*:\s*(.*)$/i', $line, $matches):
-                       $ret['current']['PortDescription'] = $matches[1];
+                       $ret['current']['PortDescription'] = trim ($matches[1]);
                        break;
                case preg_match ('/^Sys(?:tem)? ?name\s*:\s*(.+)$/i', $line, $matches):
                        if
@@ -142,7 +145,7 @@ function vrpReadLLDPStatus ($input)
                                if (isset ($port))
                                        $ret[$ret['current']['local_port']][] = array
                                        (
-                                               'device' => $matches[1],
+                                               'device' => trim ($matches[1]),
                                                'port' => $port,
                                        );
                        }