import torrus 1.0.9
[freeside.git] / torrus / perllib / Torrus / DevDiscover / Paradyne.pm
1 #  Copyright (C) 2002  Stanislav Sinyagin
2 #
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.
7 #
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.
12 #
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.
16
17 # $Id: Paradyne.pm,v 1.1 2010-12-27 00:03:48 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
19
20 # Paradyne devices discovery
21 # A typical Paradyne device has several slots, and all slots are managed
22 # through the same IP address, with different community strings.
23 # That's why you have to configure "Paradyne::slot-name" parameter
24 # in your discovery file, uniquely for each slot. A slot name should
25 # not contain special characters.
26
27
28 # Tested with:
29 #
30 #   - Paradyne GranDSLAM 2.0 DSLAM - Hotwire DSL;
31 #     Model: 8000-B2-211; S/W Release : M04.02.27
32 #
33 #   - Paradyne Hotwire ATM ADSL Line Card;
34 #     Model: 8365-B1-000; S/W Release: 02.03.54
35 #
36 #   - Paradyne Hotwire ATM G.SHDSL Line Card;
37 #     Model: 8385-B1-000; S/W Release: 02.03.45
38 #
39 #   - Hotwire IP ReachDSL Line Card;
40 #     Model: 8314-B3-000; S/W Release: 04.03.10
41
42
43 package Torrus::DevDiscover::Paradyne;
44
45 use strict;
46 use Torrus::Log;
47
48
49 $Torrus::DevDiscover::registry{'Paradyne'} = {
50     'sequence'     => 500,
51     'checkdevtype' => \&checkdevtype,
52     'discover'     => \&discover,
53     'buildConfig'  => \&buildConfig
54     };
55
56
57 our %oiddef =
58     (
59      # PDN-HEADER-MIB
60      'paradyne-products'                    => '1.3.6.1.4.1.1795.1.14',
61      'xdslDevIfStatsElapsedTimeLinkUp'      =>
62      '1.3.6.1.4.1.1795.2.24.2.6.8.1.1.1.1.4'
63      );
64
65 our $statsInterval;
66 if( not defined $statsInterval )
67 {
68     $statsInterval = 6; # current15Minutes (GORD)
69 }
70
71
72 sub checkdevtype
73 {
74     my $dd = shift;
75     my $devdetails = shift;
76
77     if( not $dd->oidBaseMatch
78         ( 'paradyne-products',
79           $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
80     {
81         return 0;
82     }
83
84     if( length( $devdetails->param('Paradyne::slot-name') ) == 0 )
85     {
86         Error('Mandatory discovery parameter "Paradyne::slot-number" ' .
87               'is not defined for a Paradyne device: ' .
88               $devdetails->param('snmp-host') . ':' .
89               $devdetails->param('snmp-port') . ':' .
90               $devdetails->param('snmp-community'));
91         return 0;
92     }
93     
94     $devdetails->setCap('interfaceIndexingManaged');
95
96     return 1;
97 }
98
99
100 sub discover
101 {
102     my $dd = shift;
103     my $devdetails = shift;
104
105     my $data = $devdetails->data();
106     my $session = $dd->session();
107
108     $data->{'nameref'}{'ifReferenceName'} = 'ifName';
109     $data->{'nameref'}{'ifSubtreeName'} = 'ifNameT';
110     $data->{'param'}{'ifindex-table'} = '$ifName';
111     $data->{'nameref'}{'ifNick'} = 'ParadyneIfNick';
112
113     $data->{'nameref'}{'ifComment'} = 'ifDescr';
114
115     if( not defined( $data->{'param'}{'snmp-oids-per-pdu'} ) )
116     {
117         $data->{'param'}{'snmp-oids-per-pdu'} = '10';
118     }
119     
120     my $slot = $devdetails->param('Paradyne::slot-name');    
121     foreach my $ifIndex ( keys %{$data->{'interfaces'}} )
122     {
123         my $interface = $data->{'interfaces'}{$ifIndex};
124         $interface->{'ParadyneIfNick'} =
125             $slot . '_' . $interface->{'ifNameT'};
126     }
127     
128     my $xdslOID = $dd->oiddef('xdslDevIfStatsElapsedTimeLinkUp');
129
130     my $xdslTable = $session->get_table( -baseoid => $xdslOID );
131     if( defined $xdslTable )
132     {
133         $devdetails->storeSnmpVars( $xdslTable );
134         $devdetails->setCap('paradyneXDSL');
135
136         foreach my $ifIndex ( keys %{$data->{'interfaces'}} )
137         {
138             if( $devdetails->hasOID( $xdslOID .'.'. $ifIndex .'.'.
139                                      $statsInterval ) )
140             {
141                 push( @{$data->{'paradyneXDSLInterfaces'}}, $ifIndex );
142             }
143         }
144     }
145
146     return 1;
147 }
148
149
150 # Nothing really to do yet
151 sub buildConfig
152 {
153     my $devdetails = shift;
154     my $cb = shift;
155     my $devNode = shift;
156
157     if( $devdetails->hasCap('paradyneXDSL') )
158     {
159         my $subtreeName = 'XDSL_Line_Stats';
160
161         my $param = {
162             'precedence'           => '-600',
163             'comment'              => 'Paradyne XDSL line statistics',
164             'xdsl-stats-interval'  => $statsInterval
165             };
166         my $subtreeNode = $cb->addSubtree( $devNode, $subtreeName, $param );
167
168         my $data = $devdetails->data();
169
170         foreach my $ifIndex
171             ( sort {$a<=>$b} @{$data->{'paradyneXDSLInterfaces'}} )
172         {
173             my $interface = $data->{'interfaces'}{$ifIndex};
174
175             my $ifSubtreeName =
176                 $interface->{$data->{'nameref'}{'ifSubtreeName'}};
177
178             my $templates = ['Paradyne::paradyne-xdsl-interface'];
179
180             my $param = {
181                 'interface-name' => $interface->{'param'}{'interface-name'},
182                 'interface-nick' => $interface->{'param'}{'interface-nick'},
183                 'comment'        => $interface->{'param'}{'comment'}
184             };
185
186             $cb->addSubtree( $subtreeNode, $ifSubtreeName,
187                              $param, $templates );
188         }
189     }
190 }
191
192
193 1;
194
195
196 # Local Variables:
197 # mode: perl
198 # indent-tabs-mode: nil
199 # perl-indent-level: 4
200 # End: