Info/Layer1/Allied.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 100 CC 6 SCAR 17.2
CC
6
Cov
0%
i_up
12.0
os_ver
6.0
model
6.0
CRAP 5.6
1 # SNMP::Info::Layer1::Allied
2 #
3 # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
4 #
5 # Copyright (c) 2002,2003 Regents of the University of California
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # * Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of the University of California, Santa Cruz nor the
17 # names of its contributors may be used to endorse or promote products
18 # derived from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE.
31  
32 package SNMP::Info::Layer1::Allied;
33  
34 use strict;
35 use warnings;
36 use Exporter;
37 use SNMP::Info::Layer1;
38  
39 @SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/;
40 @SNMP::Info::Layer1::Allied::EXPORT_OK = qw//;
41  
42 our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE);
43  
44 $VERSION = '3.985003';
45  
46 # Set for No CDP
47 %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', );
48  
49 %FUNCS = (
50 %SNMP::Info::Layer1::FUNCS,
51 'ati_p_name' => 'portName',
52 'ati_up' => 'linkTestLED',
53 );
54  
55 %MIBS = (
56 %SNMP::Info::Layer1::MIBS,
57 'ATI-MIB' => 'atiPortGroupIndex',
58 );
59  
60 %MUNGE = (
61 %SNMP::Info::Layer1::MUNGE,
62 );
63  
64 sub vendor {
65 return 'allied';
66 }
67  
68 sub os {
69 return 'allied';
70 }
71  
72 sub os_ver {
73 my $allied = shift;
74 my $descr = $allied->description();
75  
76 if ( defined ($descr) && $descr =~ m/version (\d+\.\d+)/ ) {
77 return $1;
78 }
79 return;
80 }
81  
82 sub model {
83 my $allied = shift;
84  
85 my $desc = $allied->description();
86  
87 if ( defined ($desc) && $desc =~ /(AT-\d{4}\S{1})/ ) {
88 return $1;
89 }
90 return;
91 }
92  
93 sub i_name {
94 my $allied = shift;
95 my $partial = shift;
96  
97 my $i_name = $allied->orig_i_name($partial) || {};
98 my $ati_p_name = $allied->ati_p_name($partial) || {};
99  
100 foreach my $port ( keys %$ati_p_name ) {
101 my $name = $ati_p_name->{$port};
102 $i_name->{$port} = $name if ( defined $name and $name !~ /^\s*$/ );
103 }
104  
105 return $i_name;
106 }
107  
108 sub i_up {
109 my $allied = shift;
110 my $partial = shift;
111  
112 my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
113 my $ati_up = $allied->ati_up($partial) || {};
114  
115 foreach my $port ( keys %$ati_up ) {
116 my $up = $ati_up->{$port};
117 $i_up->{$port} = 'down' if $up eq 'linktesterror';
118 $i_up->{$port} = 'up' if $up eq 'nolinktesterror';
119 }
120  
121 return $i_up;
122 }
123 1;
124 __END__