blib/lib/StorageDisplay/Data/RAID.pm

filter: Statementstmt 85.0% 493 / 580 Branchbran 51.3% 37 / 72 Conditioncond 48.0% 12 / 25 MC/DCmcdc 6.6% 1 / 15 Subroutinesub 86.0% 86 / 100 Podpod 0.0% 0 / 28 totaltotal 76.7% 629 / 820 CC 54 SCAR 16.5
CC
54
Cov
80%
BUILD
18.2
__ANON__
15.3
hwsize
12.0
CRAP 5.2
« blib/lib/StorageDisplay/Data/Elem.pm ↑ Summary blib/lib/StorageDisplay/Data/Root.pm »
1 #
2 # This file is part of StorageDisplay
3 #
4 # This software is copyright (c) 2014-2023 by Vincent Danjean.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 package StorageDisplay::Data::RAID;
13 # ABSTRACT: Handle RAID data for StorageDisplay
14  
15 9 our $VERSION = '2.06'; # VERSION
16  
17 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 extends 'StorageDisplay::Data::Elem';
20  
21 9 with (
22 'StorageDisplay::Role::Style::IsSubGraph',
23 'StorageDisplay::Role::Style::Grey',
24 );
25  
26 has '_devices' => (
27 traits => [ 'Array' ],
28 is => 'ro',
29 isa => 'ArrayRef[StorageDisplay::Data::RAID::Device]',
30 required => 1,
31 10 ▶ default => sub { return []; },
Subroutine __ANON__: called CC=1 SCAR=0.0
32 9 handles => {
33 '_add_device' => 'push',
34 'devices' => 'elements',
35 }
36 );
37  
38 has 'raid-devices' => (
39 traits => [ 'Array' ],
40 is => 'ro',
41 isa => 'ArrayRef[StorageDisplay::Data::RAID::RaidDevice]',
42 required => 1,
43 10 ▶ default => sub { return []; },
Subroutine __ANON__: called CC=1 SCAR=0.0
44 9 handles => {
45 '_add_raid_device' => 'push',
46 'raid_devices' => 'elements',
47 }
48 );
49  
50 12 ▶around '_add_raid_device' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
51 12 my $orig = shift;
52 12 my $self = shift;
53 12 my $raid_device = shift;
54 12 my $state = shift;
55 12 ▶ die "Invalid state" if $state->raid_device != $raid_device;
Branch: 1 branch
BranchTrueFalseTotal
if $state->raid_device != $raid_device 0 12 12
56 12 $raid_device->_state($state);
57 12 $self->addChild($state);
58 12 return $self->$orig($raid_device);
59 9 };
60  
61 9 1;
62  
63 ##################################################################
64 package StorageDisplay::Data::RAID::Container;
65 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 9 extends 'StorageDisplay::Data::RAID';
68  
69 has 'container-devices' => (
70 traits => [ 'Array' ],
71 is => 'ro',
72 isa => 'ArrayRef[StorageDisplay::Data::RAID::ContainerDevice]',
73 required => 1,
74 0 ▶ default => sub { return []; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
75 9 handles => {
76 '_add_container_device' => 'push',
77 'container_devices' => 'elements',
78 }
79 );
80  
81 0 ▶sub _add_raid_device {
Subroutine _add_raid_device: not called CC=1 SCAR=6.9
82 0 die "Internal error";
83 }
84  
85 0 ▶around '_add_container_device' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
86 0 my $orig = shift;
87 0 my $self = shift;
88 0 my $container_device = shift;
89 0 $self->addChild($container_device);
90 0 return $self->$orig($container_device);
91 9 };
92  
93 9 1;
94  
95 ###########################################################################
96 package StorageDisplay::Data::RAID::Elem;
97  
98 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 9 extends 'StorageDisplay::Data::Elem';
101  
102 9 has 'raid' => (
103 is => 'ro',
104 isa => 'StorageDisplay::Data::RAID',
105 required => 1,
106 );
107  
108 62 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
109 62 my $orig = shift;
110 62 my $class = shift;
111 62 my $raid = shift;
112 62 my $st = shift;
113  
114 62 return $class->$orig(
115 'raid' => $raid,
116 'st' => $st,
117 @_
118 );
119 9 };
120  
121 9 1;
122  
123 ###########################################################################
124 package StorageDisplay::Data::RAID::State;
125  
126 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
127 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 9 extends 'StorageDisplay::Data::RAID::Elem';
129  
130 9 with (
131 'StorageDisplay::Role::Style::Plain',
132 'StorageDisplay::Role::Style::IsSubGraph',
133 );
134  
135 9 has 'state' => (
136 is => 'ro',
137 isa => 'Str',
138 required => 1,
139 );
140  
141 9 has 'extra-info' => (
142 is => 'ro',
143 isa => 'Str',
144 required => 0,
145 predicate => 'has_extra_info',
146 reader => 'extra_info',
147 );
148  
149 9 has 'raid_device' => (
150 is => 'ro',
151 isa => 'StorageDisplay::Data::RAID::RaidDevice',
152 required => 1,
153 );
154  
155 12 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
156 12 my $orig = shift;
157 12 my $class = shift;
158 12 my $raid_device = shift;
159 12 my $st = shift;
160  
161 12 return $class->$orig(
162 $raid_device->raid, $st,
163 'consume' => [],
164 'raid_device' => $raid_device,
165 @_
166 );
167 9 };
168  
169 24 ▶sub dotStyleNode {
Subroutine dotStyleNode: called CC=4 SCAR=15.5
Pod undocumented
170 24 my $self = shift;
171 24 my $color = 'special';
172 24 my $state = $self->state;
173  
174 24 ▶ if ($state =~ /degraded|DGD/i) {
Branch: 3 branches
BranchTrueFalseTotal
if ($state =~ /degraded|DGD/i) { } 0 24 24
elsif ($state =~ /failed|offline/i) { } 0 24 24
elsif ($state =~ /clean|active|active-idle|optimal|OKY/i) { } 24 0 24
175 0 $color = 'warning';
176 } elsif ($state =~ /failed|offline/i) {
177 0 $color = 'error';
178 } elsif ($state =~ /clean|active|active-idle|optimal|OKY/i) {
179 24 $color = 'ok';
180 }
181  
182 return (
183 24 "shape=oval",
184 "fillcolor=".$self->statecolor($color),
185 );
186 }
187  
188 24 ▶sub dotLabel {
Subroutine dotLabel: called CC=2 SCAR=7.4
Pod undocumented
189 24 my $self = shift;
190 24 my @label=('state: '.$self->state);
191 24 ▶ if ($self->has_extra_info) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_extra_info) 0 24 24
192 0 push @label, $self->extra_info;
193 }
194  
195 24 return @label;
196 }
197  
198 9 1;
199  
200 ###########################################################################
201 package StorageDisplay::Data::RAID::ContainerDevice;
202  
203 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
204 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
205 9 extends 'StorageDisplay::Data::RAID::Elem';
206  
207 9 with (
208 'StorageDisplay::Role::HasBlock',
209 #'StorageDisplay::Role::Style::Plain',
210 );
211  
212 9 has 'container-type' => (
213 is => 'ro',
214 isa => 'Str',
215 reader => 'container_type',
216 required => 1,
217 );
218  
219 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
220 0 my $orig = shift;
221 0 my $class = shift;
222 0 my $raid = shift;
223 0 my $st = shift;
224 0 my $block = shift;
225  
226 0 return $class->$orig(
227 $raid, $st,
228 'block' => $block,
229 'name' => $block->name,
230 'consume' => [],
231 @_
232 );
233 9 };
234  
235 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
236 0 my $self = shift;
237 0 my $args = shift;
238  
239 #print STDERR "container device ", $self->name, " with providing block ", $self->block->dname,"\n";
240 0 $self->block->providedBy($self);
241 }
242  
243 0 ▶sub dotLabel {
Subroutine dotLabel: not called CC=1 SCAR=6.9
Pod undocumented
244 0 my $self = shift;
245  
246 return (
247 0 $self->block->dname,
248 #$self->container_type,
249 );
250 }
251  
252 0 ▶sub dotStyleNode {
Subroutine dotStyleNode: not called CC=1 SCAR=6.9
Pod undocumented
253 0 my $self = shift;
254 return (
255 0 "shape=oval;",
256 "fillcolor=".$self->statecolor('special').";",
257 );
258 };
259  
260 9 1;
261  
262 ###########################################################################
263 package StorageDisplay::Data::RAID::RaidDevice;
264  
265 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
266 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
267 9 extends 'StorageDisplay::Data::RAID::Elem';
268  
269 9 with (
270 'StorageDisplay::Role::HasBlock',
271 'StorageDisplay::Role::Style::FromBlockState',
272 'StorageDisplay::Role::Style::WithSize',
273 );
274  
275 9 has 'state' => (
276 is => 'ro',
277 isa => 'StorageDisplay::Data::RAID::State',
278 writer => '_state',
279 required => 0,
280 );
281  
282 9 has 'raid-level' => (
283 is => 'ro',
284 isa => 'Str',
285 reader => 'raid_level',
286 required => 1,
287 );
288  
289 12 ▶around '_state' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
290 12 my $orig = shift;
291 12 my $self = shift;
292 12 my $ret = $self->$orig(@_);
293 12 $self->state->addChild($self);
294 12 return $ret;
295 9 };
296  
297 12 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
298 12 my $orig = shift;
299 12 my $class = shift;
300 12 my $raid = shift;
301 12 my $st = shift;
302 12 my $block = shift;
303  
304 12 return $class->$orig(
305 $raid, $st,
306 'block' => $block,
307 'name' => $block->name,
308 'consume' => [],
309 @_
310 );
311 9 };
312  
313 12 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
314 12 my $self = shift;
315 12 my $args = shift;
316  
317 12 $self->block->providedBy($self);
318 }
319  
320 24 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
321 24 my $self = shift;
322  
323 return (
324 24 $self->block->dname,
325 $self->raid_level,
326 );
327 }
328  
329 9 1;
330  
331 ###########################################################################
332 package StorageDisplay::Data::RAID::Device;
333  
334 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
335 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
336 9 extends 'StorageDisplay::Data::RAID::Elem';
337  
338 9 with (
339 'StorageDisplay::Role::HasBlock',
340 'StorageDisplay::Role::Style::Plain',
341 );
342  
343 9 has 'state' => (
344 is => 'ro',
345 isa => 'Maybe[Str]',
346 required => 0,
347 );
348  
349 9 has 'raiddevice' => (
350 is => 'ro',
351 isa => 'Str',
352 required => 1,
353 );
354  
355 37 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
356 37 my $orig = shift;
357 37 my $class = shift;
358 37 my $raid = shift;
359 37 my $st = shift;
360 37 my $devname = shift;
361 37 my $info = shift;
362 37 my $args = { @_ };
363 37 my $container_block = $args->{'container-block'};
364  
365 37 my $block = $st->block($devname);
366  
367 #print STDERR "RAID::Device ", $block->dname, " container ", ($container_block // $block)->dname, "\n";
368  
369 return $class->$orig(
370 $raid, $st,
371 'block' => $block,
372 'name' => $block->name,
373 'consume' => [$container_block // $block],
374 'state' => $info->{state},
375 'raiddevice' => $info->{raiddevice},
376 @_
377 37 ▶ );
Condition33%1/3
$container_block // $block
l!l&&r!l&&!r
0370
MC/DC0%0/2
$container_block // $block
$container_block $block
Truth table33%1/3
A // B
A= $container_blockB= $block
ABresult
1X1
011
000
378 9 };
379  
380 74 ▶around 'dotStyleNode' => sub {
Subroutine __ANON__: called CC=8 SCAR=27.2
381 74 my $orig = shift;
382 74 my $self = shift;
383 74 my @text = $self->$orig(@_);
384  
385 74 my $state = $self->state;
386 74 my $s;
387  
388 74 ▶ if (not defined($state)) {
Branch: 7 branches
BranchTrueFalseTotal
if (not defined $state) { } 0 74 74
elsif ($state =~ /active|Online, Spun Up|OPT|RDY/i) { } 70 4 74
elsif ($state =~ /rebuild|RBLD/i) { } 0 4 4
elsif ($state =~ /spare|HSP/i) { } 4 0 4
elsif ($state =~ /faulty|error|FLD|MIS|bad|offline/i) { } 0 0 0
elsif ($state =~ /Unconfigured.*good|AVL/i) { } 0 0 0
elsif ($state =~ /JBOD/i) { } 0 0 0
389 # devices in RAID containers
390 0 $s = 'used';
391 } elsif ($state =~ /active|Online, Spun Up|OPT|RDY/i) {
392 70 $s = 'used';
393 } elsif ($state =~ /rebuild|RBLD/i) {
394 0 $s = 'warning';
395 } elsif ($state =~ /spare|HSP/i) {
396 4 $s = 'free';
397 } elsif ($state =~ /faulty|error|FLD|MIS|bad|offline/i) {
398 0 $s = 'error';
399 } elsif ($state =~ /Unconfigured.*good|AVL/i) {
400 0 $s = 'unused';
401 } elsif ($state =~ /JBOD/i) {
402 0 $s = $self->block->state;
403 } else {
404 0 $s = 'warning';
405 }
406 74 my $color = $self->statecolor($s);
407  
408 74 push @text, "fillcolor=$color";
409 74 return @text;
410 9 };
411  
412 46 ▶sub dotLabel {
Subroutine dotLabel: called CC=2 SCAR=7.0
Pod undocumented
413 46 my $self = shift;
414 46 my @label = ($self->raiddevice.': '.$self->block->dname);
415 46 ▶ if (defined($self->state)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->state) 46 0 46
416 46 push @label, $self->state;
417 }
418 46 return @label;
419 }
420  
421 9 1;
422  
423 ###########################################################################
424 package StorageDisplay::Data::RAID::RawDevice;
425  
426 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
427 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
428 9 extends 'StorageDisplay::Data::RAID::Device';
429 9 with(
430 'StorageDisplay::Role::Style::WithSize',
431 );
432  
433 9 has 'model' => (
434 is => 'ro',
435 isa => 'Str',
436 required => 1,
437 );
438  
439 9 has 'slot' => (
440 is => 'ro',
441 isa => 'Str',
442 required => 1,
443 );
444  
445 28 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
446 28 my $self = shift;
447  
448 return (
449 28 $self->model,
450 $self->raiddevice.': slot '.$self->slot,
451 $self->state,
452 );
453 }
454  
455 9 1;
456  
457 ##################################################################
458 package StorageDisplay::Data::RAID::MD::Container;
459  
460 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
461 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
462 9 extends 'StorageDisplay::Data::RAID::Container';
463  
464 9 with(
465 'StorageDisplay::Role::HasBlock',
466 );
467  
468 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
469 0 my $orig = shift;
470 0 my $class = shift;
471 0 my $devname = shift;
472 0 my $st = shift;
473  
474 #$st->get_infos
475 0 $st->log({level=>1}, 'MD Container managed by '.$devname);
476  
477 0 my $info = $st->get_info('md', $devname);
478 0 my $block = $st->block($devname);
479 #print STDERR "MD::Container $devname -> ", $block->dname, "\n";
480  
481 return $class->$orig(
482 'name' => $block->name,
483 'block' => $block,
484 'consume' => [],
485 'st' => $st,
486 'raid-name' => '', # in case $info has no name
487 0 %{$info},
488 @_
489 );
490 9 };
491  
492 0 ▶sub BUILD {
Subroutine BUILD: not called CC=2 SCAR=17.9
Pod undocumented
493 0 my $self=shift;
494 0 my $args=shift;
495 0 my $st = $args->{st};
496  
497 my $container_device = StorageDisplay::Data::RAID::ContainerDevice->new(
498 $self, $st,
499 $self->block,
500 0 'container-type' => $args->{'raid-version'},
501 );
502 0 $self->_add_container_device($container_device);
503  
504 0 foreach my $dev (sort keys %{$args->{'devices'}}) {
505 0 my $d = StorageDisplay::Data::RAID::Device->new($self, $st, $dev, $args->{'devices'}->{$dev});
506 0 $self->_add_device($d);
507 0 $self->addChild($d);
508 }
509  
510 0 return $self;
511 };
512  
513 9 has 'raid-version' => (
514 is => 'ro',
515 isa => 'Str',
516 required => 1,
517 reader => 'container_type',
518 );
519  
520 0 ▶sub dname {
Subroutine dname: not called CC=1 SCAR=6.9
Pod undocumented
521 0 my $self=shift;
522 0 return 'MD: '.$self->block->dname;
523 }
524  
525 0 ▶sub dotLabel {
Subroutine dotLabel: not called CC=1 SCAR=6.9
Pod undocumented
526 0 my $self = shift;
527 return (
528 0 'Software RAID container',
529 'Type: '.$self->container_type,
530 #$self->disp_size($self->used_dev_size).' used per device',
531 );
532 }
533  
534 0 ▶sub dotLinks {
Subroutine dotLinks: not called CC=1 SCAR=6.9
Pod undocumented
535 0 my $self = shift;
536 # Always one container device for MD RAID
537 0 my $raidlinkname = ($self->container_devices)[0]->linkname;
538 return (
539 map {
540 0 $_->linkname.' -> '.$raidlinkname
541 } $self->devices
542 );
543 }
544  
545 9 1;
546  
547 ##################################################################
548 package StorageDisplay::Data::RAID::MD;
549  
550 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
551 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
552 9 extends 'StorageDisplay::Data::RAID';
553  
554 9 with(
555 'StorageDisplay::Role::HasBlock',
556 );
557  
558 8 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
559 8 my $orig = shift;
560 8 my $class = shift;
561 8 my $devname = shift;
562 8 my $st = shift;
563  
564 #$st->get_infos
565 8 $st->log({level=>1}, 'MD Raid for device '.$devname);
566  
567 8 my $info = $st->get_info('md', $devname);
568 8 my $block = $st->block($devname);
569  
570 return $class->$orig(
571 'name' => $block->name,
572 'block' => $block,
573 'consume' => [],
574 'st' => $st,
575 'raid-name' => '', # in case $info has no name
576 8 %{$info},
577 @_
578 );
579 9 };
580  
581 8 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
582 8 my $self=shift;
583 8 my $args=shift;
584 8 my $st = $args->{st};
585  
586 my $raid_device = $self->newElem(
587 'RAID::MD::State::RaidDevice', $self, $st, $self->block,
588 'raid-level' => $args->{'raid-level'},
589 8 'size' => $args->{'array-size'});
590 my $state = $self->newElem(
591 'RAID::MD::State', $raid_device, $st,
592 8 'state' => $args->{'raid-state'},
593 'ignore_name' => 1,
594 );
595 8 $self->_add_raid_device($raid_device, $state);
596  
597 8 my $container_device_block = undef;
598 8 ▶ if (exists($args->{'raid-container-device'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"raid-container-device"}) 0 8 8
599 0 $container_device_block = $st->block($args->{'raid-container-device'});
600 #print STDERR "RAID::MD Container ", $args->{'raid-container-device'}, " -> ",
601 # $container_device_block->dname, "\n";
602 }
603  
604 8 foreach my $dev (sort keys %{$args->{'devices'}}) {
605 my $d = $self->newChild(
606 'RAID::MD::Device',
607 23 $self, $st, $dev, $args->{'devices'}->{$dev},
608 'container-block' => $container_device_block);
609 23 $self->_add_device($d);
610 }
611  
612 8 return $self;
613 };
614  
615 9 has 'used-dev-size' => (
616 is => 'ro',
617 isa => 'Int',
618 required => 0, # not present with RAID0
619 predicate => 'has_used_dev_size',
620 reader => 'used_dev_size',
621 );
622  
623 9 has 'raid-name' => (
624 is => 'ro',
625 isa => 'Str',
626 required => 1,
627 reader => 'raid_name',
628 );
629  
630 16 ▶sub dname {
Subroutine dname: called CC=1 SCAR=0.0
Pod undocumented
631 16 my $self=shift;
632 16 return 'MD: '.$self->block->dname;
633 }
634  
635 16 ▶sub dotLabel {
Subroutine dotLabel: called CC=2 SCAR=6.9
Pod undocumented
636 16 my $self = shift;
637 16 my @label = ($self->raid_name);
638 16 ▶ if ($self->has_used_dev_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_used_dev_size) 14 2 16
639 14 push @label, $self->disp_size($self->used_dev_size).' used per device';
640 }
641 16 return @label;
642 }
643  
644 8 ▶sub dotLinks {
Subroutine dotLinks: called CC=1 SCAR=0.0
Pod undocumented
645 8 my $self = shift;
646 # Always one raid device for MD RAID
647 8 my $raidlinkname = ($self->raid_devices)[0]->linkname;
648 return (
649 map {
650 8 $_->linkname.' -> '.$raidlinkname
651 } $self->devices
652 );
653 }
654  
655 9 1;
656  
657 ##################################################################
658 package StorageDisplay::Data::RAID::MD::State;
659  
660 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
661 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
662 9 extends 'StorageDisplay::Data::RAID::State';
663  
664 9 1;
665  
666 ##################################################################
667 package StorageDisplay::Data::RAID::MD::State::RaidDevice;
668  
669 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
670 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
671 9 extends 'StorageDisplay::Data::RAID::RaidDevice';
672  
673 9 1;
674  
675 ##################################################################
676 package StorageDisplay::Data::RAID::MD::Device;
677  
678 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
679 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
680 9 extends 'StorageDisplay::Data::RAID::Device';
681  
682 9 1;
683  
684 ##################################################################
685 package StorageDisplay::Data::RAID::LSI::Megacli;
686  
687 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
688 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
689 9 extends 'StorageDisplay::Data::RAID';
690  
691 9 has 'controller' => (
692 is => 'ro',
693 isa => 'Num',
694 required => 1,
695 );
696  
697 9 has 'hw_model' => (
698 is => 'ro',
699 isa => 'Str',
700 init_arg => 'H/W Model',
701 required => 1,
702 );
703  
704 9 has 'ID' => (
705 is => 'ro',
706 isa => 'Str',
707 required => 1,
708 );
709  
710 has 'named-raid-devices' => (
711 traits => [ 'Hash' ],
712 is => 'ro',
713 isa => 'HashRef[StorageDisplay::Data::RAID::RaidDevice]',
714 required => 1,
715 1 ▶ default => sub { return {}; },
Subroutine __ANON__: called CC=1 SCAR=0.0
716 9 handles => {
717 '_add_named_raid_device' => 'set',
718 'raid_device' => 'get',
719 }
720 );
721  
722 1 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
723 1 my $orig = shift;
724 1 my $class = shift;
725 1 my $controller = shift;
726 1 my $st = shift;
727  
728 #$st->get_infos
729 1 $st->log({level=>1}, 'Megacli Raid controller '.$controller);
730  
731 1 my $info = $st->get_info('lsi-megacli', $controller);
732  
733 return $class->$orig(
734 'name' => $controller,
735 'controller' => $controller,
736 'consume' => [],
737 'st' => $st,
738 1 %{$info->{'Controller'}->{'c'.$controller}},
739 1 %{$info},
740 @_
741 );
742 9 };
743  
744 0 ▶sub hwsize {
Subroutine hwsize: not called CC=3 SCAR=24.8
Pod undocumented
745 0 my $self = shift;
746 0 my $hwsize = shift;
747  
748 0 ▶ if ($hwsize =~ /^[0-9]+$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hwsize =~ /^[0-9]+$/) { } 0 0 0
elsif ($hwsize =~ /^([0-9]+)([BKMGTP])$/) { } 0 0 0
749 0 return $hwsize;
750 } elsif ($hwsize =~ /^([0-9]+)([BKMGTP])$/) {
751 0 my %pow = (
752 'B' => 0,
753 'K' => 1,
754 'M' => 2,
755 'G' => 3,
756 'T' => 4,
757 'P' => 5,
758 );
759 0 return $1 * (1024 ** $pow{$2});
760 } else {
761 0 print STDERR "Warning: cannot interpret size $hwsize, using -1\n";
762 0 return -1;
763 }
764 }
765  
766 1 ▶sub BUILD {
Subroutine BUILD: called CC=11 SCAR=24.8
Pod undocumented
767 1 my $self=shift;
768 1 my $args=shift;
769 1 my $st = $args->{st};
770  
771 #my $state = StorageDisplay::Data::RAID::State->new($self, $st,
772 # 'state' => $args->{'raid-state'});
773 #$self->addChild($state);
774  
775 #$self->_add_raid_device(StorageDisplay::Data::RAID::RaidDevice->new($self, $st,
776 # $self->block,
777 # $state,
778 # 'size' => $args->{'array-size'}));
779 1 my $cid = $self->controller;
780  
781 #use Data::Dumper;
782 #print STDERR Dumper($st);
783 $self->newChild('RAID::LSI::Megacli::BBU::Status',
784 1 $self, $st, 'status' => $args->{'BBU'});
785  
786 9 ▶ use bignum qw/hex/;
Subroutine BEGIN: called CC=1 SCAR=0.0
787 1 foreach my $dev (sort { $a->{'LSI ID'} <=> $b->{'LSI ID'} }
788 1 (values %{$args->{'Disk'}})) {
789 10 ▶ my $devname = $dev->{'Path'} // '';
Condition100%2/2
$dev->{"Path"} // ""
l!l
28
MC/DC100%1/1
$dev->{"Path"} // ""
$dev->{"Path"}
Truth table100%2/2
A
A= $dev->{"Path"}
Aresult
11
00
790 10 my $devpath = 'LSI@'.$dev->{'Slot ID'};
791 10 ▶ if ($dev->{'ID'} !~ /^c[0-9]+uXpY$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dev->{"ID"} =~ /^c[0-9]+uXpY$/) 9 1 10
792 9 $devpath = 'LSI@'.$dev->{'ID'};
793 }
794 10 my $block;
795 my @block;
796 10 ▶ if ($devname ne '' && $devname ne 'N/A') {
Branch: 1 branch
BranchTrueFalseTotal
if ($devname ne "" and $devname ne "N/A") 0 10 10
Condition66%2/3
$devname ne "" and $devname ne "N/A"
!ll&&!rl&&r
820
MC/DC0%0/2
$devname ne "" and $devname ne "N/A"
$devname ne "" $devname ne "N/A"
Truth table66%2/3
A and B
A= $devname ne ""B= $devname ne "N/A"
ABresult
0X0
100
111
797 0 $block = $st->block($devname);
798 0 @block = ('block' => $block);
799 }
800 my $d = $self->newChild(
801 'RAID::LSI::Megacli::RawDevice',
802 $self, $st, $devpath, $dev,
803 'raiddevice' => $dev->{'ID'},
804 'state' => $dev->{'Status'},
805 'model' => $dev->{'Drive Model'},
806 'slot' => $dev->{'Slot ID'},
807 10 ▶ 'size' => (hex($dev->{'# sectors'}) * ($dev->{'sector size'} // 512))->numify(),
Condition50%1/2
$dev->{"sector size"} // bless( {"sign" => "+","value" => bless( [512], 'Math::BigInt::Calc' )}, 'Math::BigInt' )
l!l
100
MC/DC0%0/1
$dev->{"sector size"} // bless( {"sign" => "+","value" => bless( [512], 'Math::BigInt::Calc' )}, 'Math::BigInt' )
$dev->{"sector size"}
Truth table50%1/2
A
A= $dev->{"sector size"}
Aresult
11
00
808 @block,
809 );
810 10 $self->_add_device($d);
811 10 ▶ if ($block) {
Branch: 1 branch
BranchTrueFalseTotal
if ($block) 0 10 10
812 0 $d->provideBlock($block);
813 }
814 }
815 1 foreach my $dev (sort { $a->{'ID'} cmp $b->{'ID'} }
816 1 (values %{$args->{'Array'}})) {
817 #print STDERR Dumper($dev);
818 3 my $devname = $dev->{'OS Path'};
819 3 my $block = $st->block($devname);
820 #print STDERR Dumper($block->blk_info("SIZE")//$self->hwsize($dev->{'Size'}));
821 my $raid_device = $self->newElem(
822 'RAID::LSI::Megacli::State::RaidDevice',
823 $self, $st, $block,
824 # If the disk is not attached to linux (or have been 'deleted')
825 # the SIZE would be unknown from blk
826 'size' => $block->blk_info("SIZE")//$self->hwsize($dev->{'Size'}),
827 'raid-level' => $dev->{'Type'},
828 3 ▶ %{$dev},
Condition33%1/3
$block->blk_info("SIZE") // $self->hwsize($dev->{"Size"})
l!l&&r!l&&!r
300
MC/DC0%0/2
$block->blk_info("SIZE") // $self->hwsize($dev->{"Size"})
$block->blk_info("SIZE") $self->hwsize($dev->{"Size"})
Truth table33%1/3
A // B
A= $block->blk_info("SIZE")B= $self->hwsize($dev->{"Size"})
ABresult
1X1
011
000
829 );
830 3 my %inprogress=();
831 3 ▶ if ($dev->{'InProgress'} ne 'None') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dev->{"InProgress"} ne "None") 0 3 3
832 0 %inprogress=('extra-info' => $dev->{'InProgress'});
833 }
834 my $state = $self->newElem(
835 'RAID::LSI::Megacli::State', $raid_device, $st,
836 3 'state' => $dev->{'Status'},
837 'name' => $raid_device->block->name,
838 %inprogress);
839  
840 3 $self->_add_raid_device($raid_device, $state);
841 3 $self->_add_named_raid_device($dev->{'ID'}, $raid_device);
842 }
843  
844 1 return $self;
845 };
846  
847 2 ▶sub dname {
Subroutine dname: called CC=1 SCAR=0.0
Pod undocumented
848 2 my $self=shift;
849 2 return 'MegaCli: Controller '.$self->ID;
850 }
851  
852 2 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
853 2 my $self = shift;
854 return (
855 2 $self->hw_model,
856 "Controller: ".$self->ID,
857 #$self->raid_level.': '.$self->raid_name,
858 #$self->disp_size($self->used_dev_size).' used per device',
859 );
860 }
861  
862 1 ▶sub dotLinks {
Subroutine dotLinks: called CC=2 SCAR=6.9
Pod undocumented
863 1 my $self = shift;
864 return (
865 map {
866 1 ▶ if ($_->raiddevice =~ /^(c[0-9]+u[0-9]+)p([0-9]+|Y)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->raiddevice =~ /^(c[0-9]+u[0-9]+)p([0-9]+|Y)$/) 9 1 10
867 9 my $raid_device = $self->raid_device($1);
868 9 $_->linkname.' -> '.$raid_device->linkname;
869 }
870 } $self->devices
871 );
872 }
873  
874 9 1;
875  
876 ##################################################################
877 package StorageDisplay::Data::RAID::LSI::Megacli::BBU::Status;
878  
879 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
880 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
881 9 extends 'StorageDisplay::Data::RAID::Elem';
882  
883 9 has 'status' => (
884 is => 'ro',
885 isa => 'Str',
886 required => 1,
887 );
888  
889 1 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
890 1 my $orig = shift;
891 1 my $class = shift;
892 1 my $raid = shift;
893 1 my $st = shift;
894  
895 1 return $class->$orig(
896 $raid, $st,
897 'ignore_name' => 1,
898 'consume' => [],
899 @_
900 );
901 9 };
902  
903 2 ▶sub dotStyleNode {
Subroutine dotStyleNode: called CC=6 SCAR=22.3
Pod undocumented
904 2 my $self = shift;
905 2 my $color = 'special';
906 2 my $status = $self->status;
907  
908 2 ▶ if ($status =~ /REPL|error/i) {
Branch: 4 branches
BranchTrueFalseTotal
if ($status =~ /REPL|error/i) { } 0 2 2
elsif ($status =~ /missing/i or $status eq '') { } 0 2 2
elsif ($status =~ /absent/i) { } 0 2 2
elsif ($status =~ /good/i) { } 2 0 2
909 0 $color = 'red';
910 ▶ } elsif ($status =~ /missing/i || $status eq '') {
Condition33%1/3
$status =~ /missing/i or $status eq ""
l!l&&r!l&&!r
002
MC/DC0%0/2
$status =~ /missing/i or $status eq ""
$status =~ /missing/i $status eq ""
Truth table33%1/3
A or B
A= $status =~ /missing/iB= $status eq ""
ABresult
1X1
011
000
911 0 $color = 'warning';
912 } elsif ($status =~ /absent/i) {
913 0 $color = 'unused';
914 } elsif ($status =~ /good/i) {
915 2 $color = 'ok';
916 }
917  
918 return (
919 2 "shape=oval",
920 "fillcolor=".$self->statecolor($color),
921 );
922 }
923  
924 2 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
925 2 my $self = shift;
926  
927 return (
928 2 'BBU Status: '.$self->status,
929 );
930 }
931  
932 9 1;
933  
934 ##################################################################
935 package StorageDisplay::Data::RAID::LSI::Megacli::State;
936  
937 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
938 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
939 9 extends 'StorageDisplay::Data::RAID::State';
940  
941 9 1;
942  
943 ##################################################################
944 package StorageDisplay::Data::RAID::LSI::Megacli::RawDevice;
945  
946 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
947 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
948 9 extends 'StorageDisplay::Data::RAID::RawDevice';
949  
950 9 1;
951  
952 ##################################################################
953 package StorageDisplay::Data::RAID::LSI::Megacli::State::RaidDevice;
954  
955 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
956 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
957 9 extends 'StorageDisplay::Data::RAID::RaidDevice';
958  
959 9 has 'lsi-id' => (
960 is => 'ro',
961 isa => 'Str',
962 init_arg => 'ID',
963 reader=> 'lsi_id',
964 required => 1,
965 );
966  
967 6 ▶around 'dotLabel' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
968 6 my $orig = shift;
969 6 my $self = shift;
970 6 my @ret = $self->$orig(@_);
971 6 $ret[0] .= " (".$self->lsi_id.")";
972 6 return @ret;
973 9 };
974  
975 9 1;
976  
977 ##################################################################
978 package StorageDisplay::Data::RAID::LSI::SASIrcu;
979  
980 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
981 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
982 9 extends 'StorageDisplay::Data::RAID';
983  
984 9 my $missing_count=0;
985  
986 9 has 'controller' => (
987 is => 'ro',
988 isa => 'Num',
989 init_arg => 'controllerID',
990 required => 1,
991 );
992  
993 9 has 'hw_model' => (
994 is => 'ro',
995 isa => 'Str',
996 init_arg => 'controller-type',
997 required => 1,
998 );
999  
1000 has 'named-raw-devices' => (
1001 traits => [ 'Hash' ],
1002 is => 'ro',
1003 isa => 'HashRef[StorageDisplay::Data::RAID::RawDevice]',
1004 required => 1,
1005 1 ▶ default => sub { return {}; },
Subroutine __ANON__: called CC=1 SCAR=0.0
1006 9 handles => {
1007 '_add_named_raw_device' => 'set',
1008 'raw_device' => 'get',
1009 }
1010 );
1011  
1012 1 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1013 1 my $orig = shift;
1014 1 my $class = shift;
1015 1 my $controller = shift;
1016 1 my $st = shift;
1017  
1018 #$st->get_infos
1019 1 $st->log({level=>1}, 'LSI Raid controller (SAS2Ircu) '.$controller);
1020  
1021 1 my $info = $st->get_info('lsi-sas-ircu', $controller);
1022  
1023 return $class->$orig(
1024 'name' => $controller,
1025 'controllerID' => $controller,
1026 'consume' => [],
1027 'st' => $st,
1028 1 %{$info->{'controller'}},
1029 1 %{$info},
1030 @_
1031 );
1032 9 };
1033  
1034 1 ▶sub BUILD {
Subroutine BUILD: called CC=15 SCAR=29.0
Pod undocumented
1035 1 my $self=shift;
1036 1 my $args=shift;
1037 1 my $st = $args->{st};
1038  
1039 1 my $cid = $self->controller;
1040 1 my $cur_missing_count = $missing_count;
1041 1 foreach my $dev (sort { $a->{'enclosure'} <=> $b->{'enclosure'}
1042 4 ▶ or $a->{'slot'} <=> $b->{'slot'}
Condition33%1/3
$StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'enclosure'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'enclosure'} || $StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'slot'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'slot'}
l!l&&r!l&&!r
040
MC/DC0%0/2
$StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'enclosure'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'enclosure'} || $StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'slot'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'slot'}
$StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'enclosure'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'enclosure'} $StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'slot'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'slot'}
Truth table33%1/3
A || B
A= $StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'enclosure'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'enclosure'}B= $StorageDisplay::Data::RAID::LSI::SASIrcu::a->{'slot'} <=> $StorageDisplay::Data::RAID::LSI::SASIrcu::b->{'slot'}
ABresult
1X1
011
000
1043 }
1044 1 @{$args->{'devices'}}) {
1045 4 my ($id,$d);
1046 4 ▶ if ($dev->{'state'} =~ /MIS/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dev->{'state'} =~ /MIS/) { } 0 4 4
1047 # disk missing
1048 0 $id = $dev->{'enclosure'}.":".$dev->{'slot'}." (".($missing_count++).")";
1049 0 my $devpath = 'LSISASIrcu@'.$id;
1050 $d = $self->newChild(
1051 'RAID::LSI::SASIrcu::MissingRawDevice',
1052 $self, $st, $devpath, $dev,
1053 'raiddevice' => $id,
1054 0 'state' => $dev->{'state'},
1055 'model' => 'Disk missing',
1056 'size' => 0,
1057 'slot' => 'none',
1058 );
1059 } else {
1060 4 $id=$dev->{'enclosure'}.":".$dev->{'slot'};
1061 4 ▶ if ($id eq '0:0') { # can be the case of FLD drives
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "0:0") 0 4 4
1062 0 $id .= ' ('.($cur_missing_count++).')';
1063 }
1064 #print STDERR "Adding $id\n";
1065 4 my $devpath = 'LSISASIrcu@'.$id;
1066 4 my $block;
1067 {
1068 4 ▶ my $serial = $dev->{'serial-no'}//'';
Condition50%1/2
$dev->{"serial-no"} // ""
l!l
40
MC/DC0%0/1
$dev->{"serial-no"} // ""
$dev->{"serial-no"}
Truth table50%1/2
A
A= $dev->{"serial-no"}
Aresult
11
00
1069 4 ▶ if ($serial ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($serial ne "") 4 0 4
1070 #print STDERR "Serial for $id is $serial\n";
1071 4 $block = $st->blockBySerial($serial);
1072 }# else { # GUID/WWN is not always unique
1073 # $serial = $dev->{'guid'}//'';
1074 # if ($serial ne '') {
1075 # print STDERR "Guid for $id is $serial\n";
1076 # $block = $st->blockBySerial($serial);
1077 # }
1078 #}
1079 }
1080 $d = $self->newChild(
1081 'RAID::LSI::SASIrcu::RawDevice',
1082 $self, $st, $devpath, $dev,
1083 'raiddevice' => $id,
1084 'state' => $dev->{'state'},
1085 'model' => join(' ', $dev->{'manufacturer'}, $dev->{'model-number'}, $dev->{'serial-no'}),
1086 4 ▶ 'size' => $dev->{'size'}//'0', # No size on some FLD devices
Condition50%1/2
$dev->{"size"} // 0
l!l
40
MC/DC0%0/1
$dev->{"size"} // 0
$dev->{"size"}
Truth table50%1/2
A
A= $dev->{"size"}
Aresult
11
00
1087 'slot' => $id,
1088 );
1089 4 ▶ if (defined($block)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $block) 2 2 4
1090 #print STDERR "$id provide ", $block->name,"\n";
1091 2 $d->provideBlock($block);
1092 }
1093 }
1094 4 $self->_add_device($d);
1095 4 $self->_add_named_raw_device($id, $d);
1096 }
1097 1 my $defined_missing_count = $cur_missing_count;
1098 1 $cur_missing_count = $missing_count;
1099 0 foreach my $dev (sort { $a->{'id'} cmp $b->{'id'} }
1100 1 @{$args->{'volumes'}}) {
1101 1 my $devname = $args->{'wwid'}->{$dev->{'wwid'}};
1102 1 my $block = $st->block($devname);
1103 my $raid_device = $self->newElem(
1104 'RAID::LSI::SASIrcu::State::RaidDevice',
1105 $self, $st, $block,
1106 'size' => $block->blk_info("SIZE"),
1107 'raid-level' => $dev->{'Type'},
1108 1 %{$dev},
1109 );
1110 my $state = $self->newElem(
1111 'RAID::LSI::SASIrcu::State', $raid_device, $st,
1112 1 'state' => $dev->{'status'},
1113 'name' => $raid_device->block->name
1114 );
1115  
1116 1 $self->_add_raid_device($raid_device, $state);
1117 1 ▶ foreach my $phyid (keys %{$dev->{'PHY'} // {}}) {
Condition50%1/2
$dev->{"PHY"} // {}
l!l
10
MC/DC0%0/1
$dev->{"PHY"} // {}
$dev->{"PHY"}
Truth table50%1/2
A
A= $dev->{"PHY"}
Aresult
11
00
1118 2 my $phy = $dev->{'PHY'}->{$phyid};
1119 2 my $id = $phy->{'enclosure'}.":".$phy->{'slot'};
1120 2 ▶ if ($id eq '0:0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "0:0") 0 2 2
1121 0 $id .= ' ('.($cur_missing_count++).')';
1122 }
1123 #print STDERR "Getting $id\n";
1124 2 my $rdsk = $self->raw_device($id);
1125 2 $rdsk->volume($raid_device);
1126 2 $rdsk->phyid($phyid);
1127 }
1128 }
1129 1 ▶ if ($cur_missing_count != $defined_missing_count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur_missing_count != $defined_missing_count) 0 1 1
1130 0 print STDERR "Internal warning: wrong total of missing drives: $cur_missing_count != $defined_missing_count\n";
1131 }
1132 1 ▶ $missing_count = ($cur_missing_count > $defined_missing_count)?$cur_missing_count:$defined_missing_count;
Branch: 1 branch
BranchTrueFalseTotal
$cur_missing_count > $defined_missing_count ? : 0 1 1
1133 1 return $self;
1134 };
1135  
1136 2 ▶sub dname {
Subroutine dname: called CC=1 SCAR=0.0
Pod undocumented
1137 2 my $self=shift;
1138 2 return 'MegaCli: Controller '.$self->controller;
1139 }
1140  
1141 2 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
1142 2 my $self = shift;
1143 return (
1144 2 $self->hw_model,
1145 #$self->ID,
1146 #$self->raid_level.': '.$self->raid_name,
1147 #$self->disp_size($self->used_dev_size).' used per device',
1148 );
1149 }
1150  
1151 1 ▶sub dotLinks {
Subroutine dotLinks: called CC=2 SCAR=6.9
Pod undocumented
1152 1 my $self = shift;
1153 return (
1154 map {
1155 1 ▶ if ($_->has_volume) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->has_volume) 2 2 4
1156 2 $_->linkname.' -> '.$_->volume->linkname;
1157 }
1158 } $self->devices
1159 );
1160 }
1161  
1162 9 1;
1163  
1164 ##################################################################
1165 package StorageDisplay::Data::RAID::LSI::SASIrcu::MissingRawDevice;
1166  
1167 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
1168 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
1169 9 extends 'StorageDisplay::Data::RAID::RawDevice';
1170  
1171 #with (
1172 # 'StorageDisplay::Role::Style::WithSize',
1173 # );
1174  
1175 9 has 'volume' => (
1176 is => 'rw',
1177 isa => 'StorageDisplay::Data::RAID::RaidDevice',
1178 required => 0,
1179 predicate => 'has_volume',
1180 );
1181  
1182 9 has 'phyid' => (
1183 is => 'rw',
1184 isa => 'Num',
1185 required => 0,
1186 predicate => 'has_phyid',
1187 );
1188  
1189 0 ▶around 'dotLabel' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1190 0 my $orig = shift;
1191 0 my $self = shift;
1192 0 my @ret = $self->$orig(@_);
1193 0 ▶ if ($self->has_phyid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_phyid) { } 0 0 0
1194 0 $ret[1] = $self->phyid.": enc/slot: ".$self->slot;
1195 } else {
1196 0 $ret[1] = "enc/slot: ".$self->slot;
1197 }
1198 0 return @ret;
1199 9 };
1200  
1201 9 1;
1202  
1203 ##################################################################
1204 package StorageDisplay::Data::RAID::LSI::SASIrcu::RawDevice;
1205  
1206 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
1207 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
1208 9 extends 'StorageDisplay::Data::RAID::RawDevice';
1209  
1210 9 has 'volume' => (
1211 is => 'rw',
1212 isa => 'StorageDisplay::Data::RAID::RaidDevice',
1213 required => 0,
1214 predicate => 'has_volume',
1215 );
1216  
1217 9 has 'phyid' => (
1218 is => 'rw',
1219 isa => 'Num',
1220 required => 0,
1221 predicate => 'has_phyid',
1222 );
1223  
1224 8 ▶around 'dotLabel' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1225 8 my $orig = shift;
1226 8 my $self = shift;
1227 8 my @ret = $self->$orig(@_);
1228 8 ▶ if ($self->has_phyid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_phyid) { } 4 4 8
1229 4 $ret[1] = $self->phyid.": enc/slot: ".$self->slot;
1230 } else {
1231 4 $ret[1] = "enc/slot: ".$self->slot;
1232 }
1233 8 return @ret;
1234 9 };
1235  
1236 9 1;
1237  
1238 ##################################################################
1239 package StorageDisplay::Data::RAID::LSI::SASIrcu::State;
1240  
1241 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
1242 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
1243 9 extends 'StorageDisplay::Data::RAID::State';
1244  
1245 9 1;
1246  
1247 ##################################################################
1248 package StorageDisplay::Data::RAID::LSI::SASIrcu::State::RaidDevice;
1249  
1250 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
1251 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
1252 9 extends 'StorageDisplay::Data::RAID::RaidDevice';
1253  
1254 9 1;
1255  
1256 __END__
« blib/lib/StorageDisplay/Data/Elem.pm ↑ Summary blib/lib/StorageDisplay/Data/Root.pm »