| 1 | package Cisco::UCS::Chassis; | ||||||||||
| 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 Cisco::UCS::FEX; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Cisco::UCS::Common::FanModule; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Cisco::UCS::Common::Fan; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Cisco::UCS::Chassis::PSU; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Cisco::UCS::Chassis::Stats; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | @ISA = qw(Cisco::UCS); | |||||||||
| 16 | |||||||||||
| 17 | 2 | our $VERSION = '0.51'; | |||||||||
| 18 | |||||||||||
| 19 | 2 | our %ATTRIBUTES = ( | |||||||||
| 20 | adminState => 'admin_state', | ||||||||||
| 21 | connPath => 'conn_path', | ||||||||||
| 22 | connStatus => 'conn_status', | ||||||||||
| 23 | dn => 'dn', | ||||||||||
| 24 | id => 'id', | ||||||||||
| 25 | managingInst => 'managing_instance', | ||||||||||
| 26 | model => 'model', | ||||||||||
| 27 | operState => 'oper_state', | ||||||||||
| 28 | operability => 'operability', | ||||||||||
| 29 | power => 'power', | ||||||||||
| 30 | presence => 'presence', | ||||||||||
| 31 | seepromOperState=> 'seeprom_oper_state', | ||||||||||
| 32 | serial => 'serial', | ||||||||||
| 33 | thermal => 'thermal', | ||||||||||
| 34 | usrLbl => 'label', | ||||||||||
| 35 | vendor => 'vendor', | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | { | ||||||||||
| 39 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | 2 | ▶ | while ( my ($attribute, $pseudo) = each %ATTRIBUTES ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 32 | ▶ | *{ __PACKAGE__ . '::' . $pseudo } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||
| 43 | 0 | my $self = shift; | |||||||||
| 44 | 0 | return $self->{$attribute} | |||||||||
| 45 | } | ||||||||||
| 46 | 32 | } | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 50 | 0 | my ( $class, %args ) = @_; | |||||||||
| 51 | |||||||||||
| 52 | 0 | my $self = {}; | |||||||||
| 53 | 0 | bless $self, $class; | |||||||||
| 54 | |||||||||||
| 55 | defined $args{dn} | ||||||||||
| 56 | ? $self->{dn} = $args{dn} | ||||||||||
| 57 | 0 | ▶ | : croak 'dn not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | defined $args{ucs} | ||||||||||
| 60 | ? weaken($self->{ucs} = $args{ucs} ) | ||||||||||
| 61 | 0 | ▶ | : croak 'ucs not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | |||||||||||
| 63 | 0 | my %attr = %{$self->{ucs}->resolve_dn( | |||||||||
| 64 | dn => $self->{dn} | ||||||||||
| 65 | 0 | )->{outConfig}->{equipmentChassis}}; | |||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | while ( my ($k, $v) = each %attr ) { $self->{$k} = $v } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | |||||||||||
| 69 | 0 | return $self; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub blade { | ||||||||
|
Subroutine
blade: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 73 | 0 | my ( $self, $id ) = @_; | |||||||||
| 74 | |||||||||||
| 75 | return ( | ||||||||||
| 76 | defined $self->{blade}->{$id} | ||||||||||
| 77 | 0 | ▶ | ? $self->{blade}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | : $self->get_blades( $id ) | ||||||||||
| 79 | ) | ||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 0 | ▶ | sub get_blade { | ||||||||
|
Subroutine
get_blade: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 83 | 0 | my ( $self, $id ) = @_; | |||||||||
| 84 | |||||||||||
| 85 | return ( | ||||||||||
| 86 | 0 | ▶ | $id ? $self->get_blades( $id ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | : undef | ||||||||||
| 88 | ) | ||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 0 | ▶ | sub get_blades { | ||||||||
|
Subroutine
get_blades: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 92 | 0 | my ( $self, $id ) = @_; | |||||||||
| 93 | |||||||||||
| 94 | return $self->_get_child_objects( | ||||||||||
| 95 | id => $id, | ||||||||||
| 96 | type => 'computeBlade', | ||||||||||
| 97 | class => 'Cisco::UCS::Blade', | ||||||||||
| 98 | attr => 'blade', | ||||||||||
| 99 | uid => 'slotId', | ||||||||||
| 100 | class_filter => { | ||||||||||
| 101 | classId => 'computeBlade', | ||||||||||
| 102 | chassisId => $self->{id} | ||||||||||
| 103 | } | ||||||||||
| 104 | ) | ||||||||||
| 105 | 0 | } | |||||||||
| 106 | |||||||||||
| 107 | 0 | ▶ | sub fex { | ||||||||
|
Subroutine
fex: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 108 | 0 | my ( $self, $id ) = @_; | |||||||||
| 109 | |||||||||||
| 110 | return ( | ||||||||||
| 111 | defined $self->{fex}->{$id} | ||||||||||
| 112 | 0 | ▶ | ? $self->{fex}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | : $self->get_fexs( $id ) | ||||||||||
| 114 | ) | ||||||||||
| 115 | } | ||||||||||
| 116 | |||||||||||
| 117 | 0 | ▶ | sub get_fex { | ||||||||
|
Subroutine
get_fex: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 118 | 0 | my ( $self, $id ) = @_; | |||||||||
| 119 | |||||||||||
| 120 | return ( | ||||||||||
| 121 | 0 | ▶ | $id ? $self->get_fexs( $id ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 122 | : undef | ||||||||||
| 123 | ) | ||||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 0 | ▶ | sub get_fexs { | ||||||||
|
Subroutine
get_fexs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 127 | 0 | my ( $self, $id ) = @_; | |||||||||
| 128 | |||||||||||
| 129 | 0 | return $self->_get_child_objects( | |||||||||
| 130 | id => $id, | ||||||||||
| 131 | type => 'equipmentIOCard', | ||||||||||
| 132 | class => 'Cisco::UCS::FEX', | ||||||||||
| 133 | attr => 'fex' | ||||||||||
| 134 | ) | ||||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 0 | ▶ | sub fan_module { | ||||||||
|
Subroutine
fan_module: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 138 | 0 | my ( $self, $id ) = @_; | |||||||||
| 139 | |||||||||||
| 140 | return ( | ||||||||||
| 141 | defined $self->{fan_module}->{$id} | ||||||||||
| 142 | 0 | ▶ | ? $self->{fan_module}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 143 | : $self->get_fan_module( $id ) | ||||||||||
| 144 | ) | ||||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 0 | ▶ | sub get_fan_module { | ||||||||
|
Subroutine
get_fan_module: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 148 | 0 | my ( $self, $id ) = @_; | |||||||||
| 149 | |||||||||||
| 150 | return ( | ||||||||||
| 151 | 0 | ▶ | $id ? $self->get_fan_modules( $id ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 152 | : undef | ||||||||||
| 153 | ) | ||||||||||
| 154 | } | ||||||||||
| 155 | |||||||||||
| 156 | 0 | ▶ | sub get_fan_modules { | ||||||||
|
Subroutine
get_fan_modules: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 157 | 0 | my ( $self, $id ) = @_; | |||||||||
| 158 | |||||||||||
| 159 | 0 | return $self->_get_child_objects( | |||||||||
| 160 | id => $id, | ||||||||||
| 161 | type => 'equipmentFanModule', | ||||||||||
| 162 | class => 'Cisco::UCS::Common::FanModule', | ||||||||||
| 163 | attr => 'fan_module' | ||||||||||
| 164 | ) | ||||||||||
| 165 | } | ||||||||||
| 166 | |||||||||||
| 167 | 0 | ▶ | sub psu { | ||||||||
|
Subroutine
psu: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 168 | 0 | my ( $self, $id ) = @_; | |||||||||
| 169 | |||||||||||
| 170 | return ( | ||||||||||
| 171 | defined $self->{psu}->{$id} | ||||||||||
| 172 | 0 | ▶ | ? $self->{psu}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 173 | : $self->get_psus( $id ) | ||||||||||
| 174 | ) | ||||||||||
| 175 | } | ||||||||||
| 176 | |||||||||||
| 177 | 0 | ▶ | sub get_psu { | ||||||||
|
Subroutine
get_psu: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 178 | 0 | my ( $self, $id ) = @_; | |||||||||
| 179 | |||||||||||
| 180 | 0 | return $self->get_psu( $id ) | |||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | 0 | ▶ | sub get_psus { | ||||||||
|
Subroutine
get_psus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 184 | 0 | my ( $self, $id ) = @_; | |||||||||
| 185 | |||||||||||
| 186 | 0 | return $self->_get_child_objects( | |||||||||
| 187 | id => $id, | ||||||||||
| 188 | type => 'equipmentPsu', | ||||||||||
| 189 | class => 'Cisco::UCS::Chassis::PSU', | ||||||||||
| 190 | attr => 'psu' | ||||||||||
| 191 | ) | ||||||||||
| 192 | } | ||||||||||
| 193 | |||||||||||
| 194 | 0 | ▶ | sub stats { | ||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 195 | 0 | my $self = shift; | |||||||||
| 196 | |||||||||||
| 197 | return Cisco::UCS::Chassis::Stats->new( | ||||||||||
| 198 | $self->{ucs}->resolve_dn( | ||||||||||
| 199 | dn => "$self->{dn}/stats" | ||||||||||
| 200 | )->{outConfig}->{equipmentChassisStats} | ||||||||||
| 201 | ) | ||||||||||
| 202 | 0 | } | |||||||||
| 203 | |||||||||||
| 204 | 2 | 1; | |||||||||
| 205 | |||||||||||
| 206 | __END__ | ||||||||||