import torrus 1.0.9
[freeside.git] / torrus / perllib / Torrus / DevDiscover / Arista.pm
1 #
2 #  Copyright (C) 2009  Jon Nistor
3 #
4 #  This program is free software; you can redistribute it and/or modify
5 #  it under the terms of the GNU General Public License as published by
6 #  the Free Software Foundation; either version 2 of the License, or
7 #  (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17
18 # $Id: Arista.pm,v 1.1 2010-12-27 00:03:49 ivan Exp $
19 # Jon Nistor <nistor at snickers.org>
20
21 # Force10 Networks Real Time Operating System Software
22 #
23 # NOTE: Arista::x
24
25 package Torrus::DevDiscover::Arista;
26
27 use strict;
28 use Torrus::Log;
29
30 $Torrus::DevDiscover::registry{'Arista'} = {
31     'sequence'     => 500,
32     'checkdevtype' => \&checkdevtype,
33     'discover'     => \&discover,
34     'buildConfig'  => \&buildConfig
35     };
36
37
38 our %oiddef =
39     (
40      'sysDescr'         => '1.3.6.1.2.1.1.1.0',
41      # Arista
42      'aristaProducts'   => '1.3.6.1.4.1.30065.1'
43
44      );
45
46
47 # Not all interfaces are normally needed to monitor.
48 # You may override the interface filtering in devdiscover-siteconfig.pl:
49 # redefine $Torrus::DevDiscover::Arista::interfaceFilter
50 # or define $Torrus::DevDiscover::Arista::interfaceFilterOverlay
51
52 our $interfaceFilter;
53 our $interfaceFilterOverlay;
54 my %aristaInterfaceFilter;
55
56 if( not defined( $interfaceFilter ) )
57 {
58     $interfaceFilter = \%aristaInterfaceFilter;
59 }
60
61
62 # Key is some unique symbolic name, does not mean anything
63 #  ifType is the number to match the interface type
64 # ifDescr is the regexp to match the interface description
65 %aristaInterfaceFilter =
66     (
67      'other' => {
68          'ifType'  => 1,                     # other
69      },
70      'lag'      => {
71          'ifType'  => 161,                   # ieee 802.3ad LAG groups
72                                              # added due to index too high
73      },
74      'loopback' => {
75          'ifType'  => 24,                    # softwareLoopback
76      },
77      'vlan' => {
78          'ifType'  => 136,                   # vlan
79                                              # added due to index too high
80      },
81
82     );
83
84
85 sub checkdevtype
86 {
87     my $dd = shift;
88     my $devdetails = shift;
89
90     if( not $dd->oidBaseMatch
91         ( 'aristaProducts',
92           $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
93     {
94         return 0;
95     }
96
97     &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
98         ($devdetails, $interfaceFilter);
99     
100     if( defined( $interfaceFilterOverlay ) )
101     {
102         &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
103             ($devdetails, $interfaceFilterOverlay);
104     }
105
106     $devdetails->setCap('interfaceIndexingPersistent');
107
108     return 1;
109 }
110
111
112 sub discover
113 {
114     my $dd = shift;
115     my $devdetails = shift;
116
117     my $session = $dd->session();
118     my $data = $devdetails->data();
119
120     # PROG: Add comment for sysDescr
121     my $desc    = $dd->retrieveSnmpOIDs('sysDescr');
122     $data->{'param'}{'comment'} = $desc->{'sysDescr'};
123     
124     return 1;
125 }
126
127
128 sub buildConfig
129 {
130     my $devdetails = shift;
131     my $cb = shift;
132     my $devNode = shift;
133     my $data = $devdetails->data();
134
135 }
136
137
138 1;
139
140 # Local Variables:
141 # mode: perl
142 # indent-tabs-mode: nil
143 # perl-indent-level: 4
144 # End: