UCS/Blade.pm

filter: Statementstmt 40.4% 38 / 94 Branchbran 6.6% 2 / 30 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 42.8% 9 / 21 Podpod 90.0% 9 / 10 totaltotal 34.1% 58 / 170 CC 18 SCAR 24.8
CC
18
Cov
30%
led
30.0
new
20.0
get_cpus
20.0
CRAP 11.9
« UCS/Common/Fan.pm ↑ Summary UCS/Interconnect.pm »
1 package Cisco::UCS::Blade;
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 2 ▶use Cisco::UCS::Blade::Adaptor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Cisco::UCS::Blade::CPU;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Cisco::UCS::Blade::PowerBudget;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Cisco::UCS::Common::PowerStats;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = '0.51';
14  
15 2 our @ATTRIBUTES = qw(association availability discovery dn model name
16 operability presence revision serial uuid vendor);
17  
18 2 our %ATTRIBUTES = (
19 admin_state => 'adminState',
20 assignment => 'assignedToDn',
21 conn_path => 'connPath',
22 conn_status => 'connStatus',
23 cores_enabled => 'numOfCoresEnabled',
24 chassis => 'chassisId',
25 checkpoint => 'checkPoint',
26 description => 'descr',
27 id => 'slotId',
28 managing_instance => 'managingInst',
29 memory_speed => 'memorySpeed',
30 memory_available => 'availableMemory',
31 memory_total => 'totalMemory',
32 num_adaptors => 'numOfAdaptors',
33 num_cores => 'numOfCores',
34 num_cpus => 'numOfCpus',
35 num_eth_ifs => 'numOfEthHostIfs',
36 num_fc_ifs => 'numOfFcHostIfs',
37 num_threads => 'numOfThreads',
38 oper_power => 'operPower',
39 oper_state => 'operState',
40 server_id => 'serverId',
41 slot_id => 'slotId',
42 user_label => 'usrLbl',
43 uuid_original => 'originalUuid'
44 );
45  
46 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
47 0 my ($class, %args) = @_;
48 0 my $self = {};
49 0 bless $self, $class;
50  
51 defined $args{dn}
52 ? $self->{dn} = $args{dn}
53 0 ▶ : croak 'dn not defined';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'dn'} ? : 0 0 0
54  
55 defined $args{ucs}
56 ? weaken($self->{ucs} = $args{ucs})
57 0 ▶ : croak 'dn not defined';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'ucs'} ? : 0 0 0
58  
59 0 my %attr = %{ $self->{ucs}->resolve_dn(
60 dn => $self->{dn})->{outConfig}->{computeBlade}
61 0 };
62
63 0 ▶ while ( my ($k, $v) = each %attr ) { $self->{$k} = $v }
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %attr) 0 0 0
64  
65 0 return $self
66 }
67  
68 {
69 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 2 ▶ while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Cisco::UCS::Blade::ATTRIBUTES) 50 2 52
72 50 ▶ *{ __PACKAGE__ . '::' . $pseudo } = sub {
Subroutine __ANON__: not called CC=1 SCAR=2.6
73 0 my $self = shift;
74 0 return $self->{$attribute}
75 }
76 50 }
77  
78 2 foreach my $attribute ( @ATTRIBUTES ) {
79 24 ▶ *{ __PACKAGE__ . '::' . $attribute } = sub {
Subroutine __ANON__: not called CC=1 SCAR=2.6
80 0 my $self = shift;
81 0 return $self->{$attribute}
82 }
83 24 }
84 }
85  
86 0 ▶sub led {
Subroutine led: not called CC=5 SCAR=34.0
Pod documented
87 0 my ( $self, $state ) = @_;
88  
89 0 $state = lc $state;
90 0 ▶ $state eq 'on' || $state eq 'off' or return;
Branch: 1 branch
BranchTrueFalseTotal
$state eq "on" or $state eq "off" or return 0 0 0
Condition0%0/3
$state eq "on" or $state eq "off"
l!l&&r!l&&!r
000
MC/DC0%0/2
$state eq "on" or $state eq "off"
$state eq "on" $state eq "off"
Truth table0%0/3
A or B
A= $state eq "on"B= $state eq "off"
ABresult
1X1
011
000
91 0 my $req = <<XML;
92 <configConfMos cookie="$self->{ucs}->{cookie}" inHierarchical="false">
93 <inConfigs>
94 <pair key="sys/chassis-$self->{chassisId}/blade-$self->{slotId}/locator-led">
95 <equipmentLocatorLed adminState="$state"
96 dn="sys/chassis-$self->{chassisId}/blade-$self->{slotId}/locator-led"
97 id="1" name="" >
98 </equipmentLocatorLed>
99 </pair>
100 </inConfigs>
101 </configConfMos>
102 XML
103  
104 0 my $xml = $self->{ucs}->_ucsm_request( $req );
105
106 0 ▶ if ( defined $xml->{'errorCode'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xml->{"errorCode"}) 0 0 0
107 my $self->{error} =
108 ( defined $xml->{'errorDescr'}
109 0 ▶ ? $xml->{'errorDescr'}
Branch: 1 branch
BranchTrueFalseTotal
defined $xml->{'errorDescr'} ? : 0 0 0
110 : "Unspecified error"
111 );
112  
113 0 print "got error: $self->{error}\n";
114 return
115 0 }
116
117 0 return 1
118 }
119  
120 0 ▶sub power_stats {
Subroutine power_stats: not called CC=1 SCAR=6.9
Pod documented
121 0 my $self = shift;
122  
123 return Cisco::UCS::Common::PowerStats->new(
124 $self->{ucs}->resolve_dn(
125 dn => "$self->{dn}/board/power-stats"
126 )->{outConfig}->{computeMbPowerStats}
127 )
128 0 }
129  
130 0 ▶sub power_budget {
Subroutine power_budget: not called CC=1 SCAR=6.9
Pod documented
131 0 my $self = shift;
132  
133 return Cisco::UCS::Blade::PowerBudget->new(
134 $self->{ucs}->resolve_dn(
135 dn => "$self->{dn}/budget"
136 )->{outConfig}->{powerBudget}
137 )
138 0 }
139  
140 0 ▶sub cpu {
Subroutine cpu: not called CC=2 SCAR=17.9
Pod documented
141 0 my ( $self, $id ) = @_;
142  
143 return (
144 defined $self->{cpu}->{$id}
145 0 ▶ ? $self->{cpu}->{$id}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'cpu'}{$id} ? : 0 0 0
146 : $self->get_cpus( $id )
147 )
148 }
149  
150 0 ▶sub get_cpu {
Subroutine get_cpu: not called CC=2 SCAR=17.9
Pod documented
151 0 my ( $self, $id ) = @_;
152  
153 return (
154 0 ▶ $id ? $self->get_cpus( $id )
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 0 0
155 : undef
156 )
157 }
158  
159 0 ▶sub get_cpus {
Subroutine get_cpus: not called CC=4 SCAR=30.0
Pod documented
160 0 my ( $self, $id ) = @_;
161  
162 my $cpus = $self->{ucs}->resolve_children(
163 dn => "$self->{dn}/board"
164 0 )->{outConfigs}->{processorUnit};
165 0 my @cpus;
166  
167 0 ▶ while ( my ( $cid, $cpu ) = each %$cpus ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$cpus) 0 0 0
168 0 $cpu->{id} = $cid;
169 0 $cpu = Cisco::UCS::Blade::CPU->new( $self->{ucs}, $cpu );
170 0 push @cpus, $cpu;
171 0 $self->{cpu}->{$cid} = $cpu;
172 0 ▶ return $cpu if ( defined $id and $cid == $id )
Branch: 1 branch
BranchTrueFalseTotal
if defined $id and $cid == $id 0 0 0
Condition0%0/3
defined $id and $cid == $id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and $cid == $id
defined $id $cid == $id
Truth table0%0/3
A and B
A= defined $idB= $cid == $id
ABresult
0X0
100
111
173 }
174  
175 0 return @cpus;
176 }
177  
178 0 ▶sub adaptor {
Subroutine adaptor: not called CC=2 SCAR=17.9
Pod documented
179 0 my ( $self, $id ) = @_;
180  
181 return (
182 defined $self->{adaptor}->{$id}
183 0 ▶ ? $self->{adaptor}->{$id}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'adaptor'}{$id} ? : 0 0 0
184 : $self->get_adaptors( $id )
185 )
186 }
187  
188 0 ▶sub get_adaptor {
Subroutine get_adaptor: not called CC=2 SCAR=17.9
Pod documented
189 0 my ( $self, $id ) = @_;
190  
191 return (
192 0 ▶ $id ? $self->get_adaptors( $id )
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 0 0
193 : undef
194 )
195 }
196  
197  
198 0 ▶sub get_adaptors {
Subroutine get_adaptors: not called CC=4 SCAR=30.0
Pod documented
199 0 my ( $self, $id ) = @_;
200  
201 my $adaptors = $self->{ucs}->resolve_children(
202 dn => "$self->{dn}"
203 0 )->{outConfigs}->{adaptorUnit};
204 0 my @adaptors;
205  
206 0 ▶ while ( my ( $aid, $adaptor ) = each %$adaptors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$adaptors) 0 0 0
207 0 $adaptor->{id} = $aid;
208 0 $adaptor = Cisco::UCS::Blade::Adaptor->new( $self->{ucs}, $adaptor );
209 0 push @adaptors, $adaptor;
210 0 $self->{adaptor}->{$aid} = $adaptor;
211 0 ▶ return $adaptor if ( defined $id and $aid == $id )
Branch: 1 branch
BranchTrueFalseTotal
if defined $id and $aid == $id 0 0 0
Condition0%0/3
defined $id and $aid == $id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and $aid == $id
defined $id $aid == $id
Truth table0%0/3
A and B
A= defined $idB= $aid == $id
ABresult
0X0
100
111
212 }
213  
214 0 return @adaptors;
215 }
216  
217 2 1;
218 __END__
« UCS/Common/Fan.pm ↑ Summary UCS/Interconnect.pm »