torrus, RT#10574
[freeside.git] / torrus / perllib / Torrus / DevDiscover / Symmetricom.pm
1 #
2 #  Discovery module for Symmetricom
3 #
4 #  Copyright (C) 2007 Jon Nistor
5 #
6 #  This program is free software; you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation; either version 2 of the License, or
9 #  (at your option) any later version.
10 #
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
20 # $Id: Symmetricom.pm,v 1.1 2010-12-27 00:03:46 ivan Exp $
21 # Jon Nistor <nistor at snickers dot org>
22 #
23
24
25 # Symmetricom
26 package Torrus::DevDiscover::Symmetricom;
27
28 use strict;
29 use Torrus::Log;
30
31
32 $Torrus::DevDiscover::registry{'Symmetricom'} = {
33     'sequence'     => 500,
34     'checkdevtype' => \&checkdevtype,
35     'discover'     => \&discover,
36     'buildConfig'  => \&buildConfig
37     };
38
39 our %oiddef = (
40      # SYMM-SMI
41      'syncServer'           => '1.3.6.1.4.1.9070.1.2.3.1.5',
42      'sysDescr'             => '1.3.6.1.2.1.1.1.0',
43      'ntpSysSystem'         => '1.3.6.1.4.1.9070.1.2.3.1.5.1.1.14.0',
44      'etcSerialNbr'         => '1.3.6.1.4.1.9070.1.2.3.1.5.1.6.2.0',
45      'etcModel'             => '1.3.6.1.4.1.9070.1.2.3.1.5.1.6.3.0',
46      );
47
48 sub checkdevtype
49 {
50     my $dd = shift;
51     my $devdetails = shift;
52
53     if( not $dd->oidBaseMatch
54         ( 'syncServer',
55           $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
56     {
57         return 0;
58     }
59     
60     $devdetails->setCap('interfaceIndexingPersistent');
61     $devdetails->setDevType('UcdSnmp'); # Force load Ucd
62
63     return 1;
64 }
65
66 sub discover
67 {
68     my $dd = shift;
69     my $devdetails = shift;
70
71     my $session = $dd->session();
72     my $data = $devdetails->data();
73
74     # SNMP: Get the system info and display it in the comment
75     my $ntpComment = $dd->retrieveSnmpOIDs
76         ( 'sysDescr', 'ntpSysSystem', 'etcSerialNbr', 'etcModel' );
77
78     $data->{'ntp'} = $ntpComment;
79
80     $data->{'param'}{'comment'} =
81         $ntpComment->{'ntpSysSystem'} . " " . $ntpComment->{'etcModel'} . 
82         ", Hw Serial#: " . $ntpComment->{'etcSerialNbr'};
83   
84     return 1;
85 }
86
87
88 sub buildConfig
89 {
90     my $devdetails = shift;
91     my $cb = shift;
92     my $devNode = shift;
93     my $data = $devdetails->data();
94
95     $cb->addTemplateApplication($devNode, 'Symmetricom::ntp-stats');
96 }
97
98 1;
99
100 # Local Variables:
101 # mode: perl
102 # indent-tabs-mode: nil
103 # perl-indent-level: 4
104 # End: