1 # Copyright (C) 2002 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: AxxessIT.pm,v 1.1 2010-12-27 00:03:55 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # AxxessIT Ethernet over SDH switches, also known as
21 # Cisco ONS 15305 and 15302 (by January 2005)
22 # Probably later Cisco will update the software and it will need
23 # another Torrus discovery module.
24 # Company website: http://www.axxessit.no/
28 # Cisco ONS 15305 software release 1.1.1
34 package Torrus::DevDiscover::AxxessIT;
40 $Torrus::DevDiscover::registry{'AxxessIT'} = {
42 'checkdevtype' => \&checkdevtype,
43 'discover' => \&discover,
44 'buildConfig' => \&buildConfig
51 'axxEdgeTypes' => '1.3.6.1.4.1.7546.1.4.1.1',
53 'axxEdgeWanPortMapTable' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.2',
54 'axxEdgeWanPortMapSlotNumber' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.2.1.1',
55 'axxEdgeWanPortMapPortNumber' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.2.1.2',
57 'axxEdgeWanXPortMapTable' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.11',
58 'axxEdgeWanXPortMapSlotNumber' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.11.1.1',
59 'axxEdgeWanXPortMapPortNumber' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.11.1.2',
61 'axxEdgeWanPortDescription' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.3.1.4',
62 'axxEdgeWanXPortDescription' => '1.3.6.1.4.1.7546.1.4.1.2.5.1.12.1.4',
64 'axxEdgeEthPortMapTable' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.2',
65 'axxEdgeEthPortMapSlotNumber' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.2.1.1',
66 'axxEdgeEthPortMapPortNumber' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.2.1.2',
68 'axxEdgeEthLanXPortMapTable' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.4',
69 'axxEdgeEthLanXPortMapSlotNumber' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.4.1.1',
70 'axxEdgeEthLanXPortMapPortNumber' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.4.1.2',
72 'axxEdgeEthPortDescription' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.3.1.4',
73 'axxEdgeEthLanXPortDescription' => '1.3.6.1.4.1.7546.1.4.1.2.6.1.5.1.4',
75 'axxEdgeDcnManagementPortMode' => '1.3.6.1.4.1.7546.1.4.1.2.3.2.1.0',
76 'axxEdgeDcnManagementPortIfIndex' => '1.3.6.1.4.1.7546.1.4.1.2.3.2.2.0',
78 # AXX155E-MIB (ONS 15302)
79 'axx155EDevices' => '1.3.6.1.4.1.7546.1.5.1.1',
81 'axx155EEthPortTable' => '1.3.6.1.4.1.7546.1.5.1.2.6.1.2',
82 'axx155EEthPortIfIndex' => '1.3.6.1.4.1.7546.1.5.1.2.6.1.2.1.2',
83 'axx155EEthPortName' => '1.3.6.1.4.1.7546.1.5.1.2.6.1.2.1.3',
84 'axx155EEthPortType' => '1.3.6.1.4.1.7546.1.5.1.2.6.1.2.1.4',
86 'axx155EDcnManagementPortMode' => '1.3.6.1.4.1.7546.1.5.1.2.2.2.2.0',
87 'axx155EDcnManagementPortIfIndex' => '1.3.6.1.4.1.7546.1.5.1.2.2.2.3.0'
94 my $devdetails = shift;
96 my $sysObjID = $devdetails->snmpVar( $dd->oiddef('sysObjectID') );
97 if( index( $sysObjID, $dd->oiddef('axxEdgeTypes') ) == 0 )
99 $devdetails->setCap('axxEdge');
101 elsif( index( $sysObjID, $dd->oiddef('axx155EDevices') ) == 0 )
103 $devdetails->setCap('axx155E');
110 $devdetails->setCap('interfaceIndexingManaged');
119 my $devdetails = shift;
121 my $data = $devdetails->data();
122 my $session = $dd->session();
124 $data->{'param'}{'ifindex-map'} = '$IFIDX_IFINDEX';
126 $data->{'nameref'}{'ifNick'} = 'axxInterfaceNick';
127 $data->{'nameref'}{'ifSubtreeName'} = 'axxInterfaceNick';
128 $data->{'nameref'}{'ifComment'} = 'axxInterfaceComment';
129 $data->{'nameref'}{'ifReferenceName'} = 'axxInterfaceHumanName';
131 if( $devdetails->hasCap('axxEdge') )
135 'MapTable' => 'axxEdgeWanPortMapTable',
136 'MapSlotNumber' => 'axxEdgeWanPortMapSlotNumber',
137 'MapPortNumber' => 'axxEdgeWanPortMapPortNumber',
138 'Description' => 'axxEdgeWanPortDescription',
139 'ifNick' => 'Wan_%d_%d',
140 'ifHuman' => 'WAN %d/%d',
141 'ifComment' => 'WAN slot %d, port %d' },
144 'MapTable' => 'axxEdgeWanXPortMapTable',
145 'MapSlotNumber' => 'axxEdgeWanXPortMapSlotNumber',
146 'MapPortNumber' => 'axxEdgeWanXPortMapPortNumber',
147 'Description' => 'axxEdgeWanXPortDescription',
148 'ifNick' => 'WanX_%d_%d',
149 'ifHuman' => 'WANX %d/%d',
150 'ifComment' => 'WANX slot %d, port %d' },
153 'MapTable' => 'axxEdgeEthPortMapTable',
154 'MapSlotNumber' => 'axxEdgeEthPortMapSlotNumber',
155 'MapPortNumber' => 'axxEdgeEthPortMapPortNumber',
156 'Description' => 'axxEdgeEthPortDescription',
157 'ifNick' => 'Eth_%d_%d',
158 'ifHuman' => 'Ethernet %d/%d',
159 'ifComment' => 'Ethernet interface: slot %d, port %d' },
162 'MapTable' => 'axxEdgeEthLanXPortMapTable',
163 'MapSlotNumber' => 'axxEdgeEthLanXPortMapSlotNumber',
164 'MapPortNumber' => 'axxEdgeEthLanXPortMapPortNumber',
165 'Description' => 'axxEdgeEthLanXPortDescription',
166 'ifNick' => 'EthLanX_%d_%d',
167 'ifHuman' => 'Ethernet LANX %d/%d',
168 'ifComment' => 'Ethernet LANX interface: slot %d, port %d' }
171 foreach my $type ( keys %map )
174 $session->get_table( -baseoid =>
175 $dd->oiddef($map{$type}{'MapTable'}) );
176 $devdetails->storeSnmpVars( $mapTable );
179 $session->get_table( -baseoid =>
180 $dd->oiddef($map{$type}{'Description'}) );
181 $devdetails->storeSnmpVars( $descTable );
185 getSnmpIndices($dd->oiddef($map{$type}{'MapSlotNumber'})) )
187 my $interface = $data->{'interfaces'}{$ifIndex};
188 next if not defined( $interface );
192 ($dd->oiddef($map{$type}{'MapSlotNumber'}) .'.'. $ifIndex);
195 ($dd->oiddef($map{$type}{'MapPortNumber'}) .'.'. $ifIndex);
199 ($dd->oiddef($map{$type}{'Description'}) .'.'.
202 $interface->{'param'}{'interface-index'} = $ifIndex;
204 $interface->{'axxInterfaceNick'} =
205 sprintf( $map{$type}{'ifNick'}, $slot, $port );
207 $interface->{'axxInterfaceHumanName'} =
208 sprintf( $map{$type}{'ifHuman'}, $slot, $port );
210 $interface->{'axxInterfaceComment'} =
211 sprintf( $map{$type}{'ifComment'}, $slot, $port );
212 if( length( $desc ) > 0 )
214 $interface->{'axxInterfaceComment'} .= ' (' . $desc . ')';
219 # Management interface
221 my $result = $dd->retrieveSnmpOIDs
222 ( 'axxEdgeDcnManagementPortMode',
223 'axxEdgeDcnManagementPortIfIndex');
225 if( defined( $result ) )
227 if( $result->{'axxEdgeDcnManagementPortMode'} != 2 )
229 Warning('Non-IP mode of Management port is not supported');
233 my $ifIndex = $result->{'axxEdgeDcnManagementPortIfIndex'};
235 my $interface = $data->{'interfaces'}{$ifIndex};
237 $interface->{'param'}{'interface-index'} = $ifIndex;
239 $interface->{'axxInterfaceNick'} = 'Management';
241 $interface->{'axxInterfaceHumanName'} = 'Management';
243 $interface->{'axxInterfaceComment'} = 'Management port';
249 if( $devdetails->hasCap('axx155E') )
252 $session->get_table( -baseoid =>
253 $dd->oiddef('axx155EEthPortTable') );
254 $devdetails->storeSnmpVars( $ethTable );
258 getSnmpIndices($dd->oiddef('axx155EEthPortIfIndex')) )
262 ($dd->oiddef('axx155EEthPortIfIndex') .'.'. $port);
264 my $interface = $data->{'interfaces'}{$ifIndex};
265 next if not defined( $interface );
269 ($dd->oiddef('axx155EEthPortName') .'.'. $port);
273 ($dd->oiddef('axx155EEthPortType') .'.'. $port);
275 $interface->{'param'}{'interface-index'} = $ifIndex;
277 my $type = $portType == 1 ? 'Eth':'Wan';
279 $interface->{'axxInterfaceNick'} =
280 sprintf( '%s_%d', $type, $port );
282 $interface->{'axxInterfaceHumanName'} =
283 sprintf( '%s %d', $type, $port );
285 $interface->{'axxInterfaceComment'} = '';
286 if( length( $portName ) > 0 )
288 $interface->{'axxInterfaceComment'} = $portName;
292 # Management interface
294 my $result = $dd->retrieveSnmpOIDs
295 ( 'axx155EDcnManagementPortMode',
296 'axx155EDcnManagementPortIfIndex');
298 if( defined( $result ) )
300 if( $result->{'axx155EDcnManagementPortMode'} != 2 )
302 Warning('Non-IP mode of Management port is not supported');
306 my $ifIndex = $result->{'axx155EDcnManagementPortIfIndex'};
308 my $interface = $data->{'interfaces'}{$ifIndex};
310 $interface->{'param'}{'interface-index'} = $ifIndex;
312 $interface->{'axxInterfaceNick'} = 'Management';
314 $interface->{'axxInterfaceHumanName'} = 'Management';
316 $interface->{'axxInterfaceComment'} = 'Management port';
322 foreach my $ifIndex ( keys %{$data->{'interfaces'}} )
324 if( not defined( $data->{'interfaces'}{$ifIndex}->
325 {'param'}{'interface-index'} ) )
327 delete $data->{'interfaces'}{$ifIndex};
337 my $devdetails = shift;
349 # indent-tabs-mode: nil
350 # perl-indent-level: 4