| 1 | package Cisco::UCS::Common::FanModule; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | our $VERSION = '0.51'; | |||||||||
| 10 | |||||||||||
| 11 | 2 | our @ATTRIBUTES = qw(dn id model operability power presence revision serial | |||||||||
| 12 | thermal tray vendor voltage); | ||||||||||
| 13 | |||||||||||
| 14 | 2 | our %ATTRIBUTES = ( | |||||||||
| 15 | performance => 'perf', | ||||||||||
| 16 | oper_state => 'operState' | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | { | ||||||||||
| 20 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 4 | ▶ | *{ __PACKAGE__ . '::' . $pseudo } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||
| 24 | 0 | my $self = shift; | |||||||||
| 25 | 0 | return $self->{$attribute} | |||||||||
| 26 | } | ||||||||||
| 27 | 4 | } | |||||||||
| 28 | |||||||||||
| 29 | 2 | foreach my $attribute ( @ATTRIBUTES ) { | |||||||||
| 30 | 24 | ▶ | *{ __PACKAGE__ . '::' . $attribute } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | 0 | return $self->{$attribute} | |||||||||
| 33 | } | ||||||||||
| 34 | 24 | } | |||||||||
| 35 | |||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 39 | 0 | my ( $class, %args ) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 0 | my $self = {}; | |||||||||
| 42 | 0 | bless $self, $class; | |||||||||
| 43 | |||||||||||
| 44 | defined $args{dn} | ||||||||||
| 45 | ? $self->{dn} = $args{dn} | ||||||||||
| 46 | 0 | ▶ | : croak 'dn not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | defined $args{ucs} | ||||||||||
| 49 | ? weaken($self->{ucs} = $args{ucs}) | ||||||||||
| 50 | 0 | ▶ | : croak 'ucs not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | my %attr = %{ $self->{ucs}->resolve_dn( | |||||||||
| 53 | dn => $self->{dn} | ||||||||||
| 54 | 0 | )->{outConfig}->{equipmentFanModule} }; | |||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | while ( my ( $k, $v ) = each %attr ) { $self->{$k} = $v } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | return $self; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub fan { | ||||||||
|
Subroutine
fan: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | my ( $self, $id ) = @_; | |||||||||
| 63 | |||||||||||
| 64 | return ( defined $self->{fan}->{$id} | ||||||||||
| 65 | 0 | ▶ | ? $self->{fan}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | : $self->get_fan($id) | ||||||||||
| 67 | ) | ||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub get_fan { | ||||||||
|
Subroutine
get_fan: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | 0 | my ( $self, $id ) = @_; | |||||||||
| 72 | |||||||||||
| 73 | 0 | return $self->get_fans( $id ) | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub get_fans { | ||||||||
|
Subroutine
get_fans: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | 0 | my ( $self, $id ) = @_; | |||||||||
| 78 | |||||||||||
| 79 | return $self->{ucs}->_get_child_objects( | ||||||||||
| 80 | 0 | id => $id, | |||||||||
| 81 | type => 'equipmentFan', | ||||||||||
| 82 | class => 'Cisco::UCS::Common::Fan', | ||||||||||
| 83 | attr => 'fan', | ||||||||||
| 84 | self => $self | ||||||||||
| 85 | ) | ||||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 2 | 1; | |||||||||
| 89 | |||||||||||
| 90 | __END__ | ||||||||||