r5057 fix two EOS parsing functions for the new port naming pattern
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 17 Apr 2012 21:27:33 +0000 (21:27 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 17 Apr 2012 21:27:33 +0000 (21:27 +0000)
ios12ShortenIfName(): add EOS's special "Et" form
eos4ReadInterfaceStatus(): use ios12ShortenIfName()
eos4ReadMacList(): idem

wwwroot/inc/deviceconfig.php
wwwroot/inc/functions.php

index a49015a9bced25af2540308da07e6fe7dfd75e5a..dfdd3612bc82bb33e4407c01a723c7da84c5c9ec 100644 (file)
@@ -2173,7 +2173,7 @@ function eos4ReadInterfaceStatus ($text)
                                        $status = 'down';
                                else
                                        $status = 'disabled';
-                               $result[$fields['Port']] = array
+                               $result[ios12ShortenIfName ($fields['Port'])] = array
                                (
                                        'status' => $status,
                                        'speed' => $fields['Speed'],
@@ -2347,7 +2347,7 @@ function eos4ReadMacList ($text)
                        if (substr ($line, 0, 19) == 'Total Mac Addresses') # end of table
                                break;
                        if (preg_match ('/^(\d+)\s+(\S+)\s+DYNAMIC\s+(\S+)\s/', $line, $m))
-                               $result[$m[3]][] = array
+                               $result[ios12ShortenIfName ($m[3])][] = array
                                (
                                        'mac' => $m[2],
                                        'vid' => $m[1],
index 4562187729683c12f7053c54cdcccddb2d8dbadc..88876a93ea4821bde2851009e8aafc9ed6875ee3 100644 (file)
@@ -3123,6 +3123,7 @@ function ios12ShortenIfName ($ifname)
        $ifname = preg_replace ('@^port-channel(.+)$@i', 'po\\1', $ifname);
        $ifname = preg_replace ('@^(?:XGigabitEthernet|XGE)(.+)$@', 'xg\\1', $ifname);
        $ifname = preg_replace ('@^Management(.+)$@', 'ma\\1', $ifname);
+       $ifname = preg_replace ('@^Et(\d.*)$@', 'e\\1', $ifname);
        $ifname = strtolower ($ifname);
        return $ifname;
 }