File Coverage

blib/lib/Cisco/UCS/Common/PSU.pm
Criterion Covered Total %
statement 15 27 55.5
branch 0 4 0.0
condition n/a
subroutine 5 8 62.5
pod 0 1 0.0
total 20 40 50.0


line stmt bran cond sub pod time code
1             package Cisco::UCS::Common::PSU;
2              
3 1     1   3 use warnings;
  1         1  
  1         25  
4 1     1   3 use strict;
  1         1  
  1         15  
5              
6 1     1   3 use Carp qw(croak);
  1         1  
  1         41  
7 1     1   5 use Scalar::Util qw(weaken);
  1         1  
  1         240  
8              
9             our $VERSION = '0.51';
10              
11             our @ATTRIBUTES = qw(dn id model operability power presence revision serial
12             thermal vendor voltage);
13              
14             our %ATTRIBUTES = (
15             operational => 'operState',
16             performance => 'perf'
17             );
18              
19             #our
20             # 'outputCurrentMin' => '10.000000',
21             # 'input210vAvg' => '239.000000',
22             # 'outputPowerAvg' => '120.869995',
23             # 'outputCurrent' => '10.000000',
24             # 'ambientTemp' => '26.000000',
25             # 'psuTemp1' => '0.000000',
26             # 'output12vAvg' => '12.087000',
27             # 'output12vMin' => '12.087000',
28             # 'outputCurrentMax' => '10.000000',
29             # 'output12v' => '12.087000',
30             # 'timeCollected' => '2012-10-19T13:07:33.952',
31             # 'outputCurrentAvg' => '10.000000',
32             # 'psuTemp2' => '0.000000',
33             # 'suspect' => 'no',
34             # 'thresholded' => '',
35             # 'ambientTempMin' => '26.000000',
36             # 'ambientTempMax' => '26.000000',
37             # 'output3v3Max' => '3.048000',
38             # 'output12vMax' => '12.087000',
39             # 'outputPowerMin' => '120.869995',
40             # 'input210v' => '239.000000',
41             # 'outputPowerMax' => '120.869995',
42             # 'input210vMin' => '239.000000',
43             # 'ambientTempAvg' => '26.000000',
44             # 'outputPower' => '120.869995',
45             # 'output3v3Avg' => '3.048000',
46             # 'intervals' => '58982460',
47             # 'output3v3' => '3.048000',
48             # 'update' => '131073',
49             # 'dn' => 'sys/chassis-1/psu-1/stats',
50             # 'input210vMax' => '239.000000',
51             # 'output3v3Min' => '3.048000'
52              
53              
54              
55             sub new {
56 0     0 0   my ( $class, %args ) = @_;
57              
58 0           my $self = {};
59 0           bless $self, $class;
60              
61             defined $args{dn}
62             ? $self->{dn} = $args{dn}
63 0 0         : croak 'dn not defined';
64              
65             defined $args{ucs}
66             ? weaken($self->{ucs} = $args{ucs})
67 0 0         : croak 'ucs not defined';
68              
69 0           my %attr = %{ $self->{ucs}->resolve_dn(
70             dn => $self->{dn}
71 0           )->{outConfig}->{equipmentPsu} };
72            
73 0           while ( my ($k, $v) = each %attr ) { $self->{$k} = $v }
  0            
74            
75 0           return $self;
76             }
77              
78             {
79 1     1   3 no strict 'refs';
  1         1  
  1         113  
80              
81             while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) {
82             *{ __PACKAGE__ . '::' . $pseudo } = sub {
83 0     0     return $_[0]->{$attribute}
84             }
85             }
86              
87             foreach my $attribute (@ATTRIBUTES) {
88             *{ __PACKAGE__ . '::' . $attribute } = sub {
89 0     0     return $_[0]->{$attribute}
90             }
91             }
92             }
93              
94             1;
95              
96             __END__