File Coverage

blib/lib/StorageDisplay/Data/Root.pm
Criterion Covered Total %
statement 39 41 95.1
branch 8 8 100.0
condition 1 2 50.0
subroutine 6 7 85.7
pod 0 3 0.0
total 54 61 88.5


line stmt bran cond sub pod time code
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     9   191 use strict;
  9         23  
  9         415  
10 9     9   58 use warnings;
  9         20  
  9         1010  
11              
12             package StorageDisplay::Data::Root;
13             # ABSTRACT: Handle machine data for StorageDisplay
14              
15             our $VERSION = '2.06'; # VERSION
16              
17 9     9   59 use Moose;
  9         67  
  9         74  
18 9     9   74814 use namespace::sweep;
  9         22  
  9         102  
19             extends 'StorageDisplay::Data::Elem';
20              
21             with (
22             'StorageDisplay::Role::Style::IsSubGraph',
23             'StorageDisplay::Role::Style::Machine',
24             'StorageDisplay::Role::Elem::Kind'
25             => { kind => "machine" }
26             );
27              
28             has 'host' => (
29             is => 'ro',
30             isa => 'Str',
31             required => 1,
32             );
33              
34             sub dotSubGraph {
35 7     7 0 17 my $self = shift;
36 7   50     32 my $t = shift // "\t";
37              
38 7         17 my @text;
39 7         102 my @subnodes=$self->dotSubNodes($t);
40 7         1206 $self->pushDotText(\@text, $t,
41             $self->dotSubNodes($t));
42              
43 7         324 my $it = $self->iterator(recurse => 1);
44 7         10938 while (defined(my $e=$it->next)) {
45 550         5438 my @links = $e->dotLinks($t, @_);
46 550 100       2004 if (scalar(@links)>0) {
47 114         632 $self->pushDotText(
48             \@text, $t,
49             '// Links from '.$e->dname,
50             @links,
51             );
52             }
53             }
54 7         87 $it = $self->iterator(recurse => 1);
55 7         11674 while (defined(my $e=$it->next)) {
56             my @blocks = grep {
57 550         35350 $_->provided
  176         1083  
58             } $e->consumedBlocks;
59              
60 550 100       1624 if (scalar(@blocks)>0) {
61             $self->pushDotText(
62             \@text, $t,
63             '// Links for '.$e->dname,
64 147         838 (map { $_->elem->linkname.' -> '.$e->linkname } @blocks),
  147         5173  
65             );
66             }
67             {
68             # No consumed block. Perhaps, we come from a VM provisionning
69 550         987 my @blocks = grep {
70 550 100       28426 (!$_->provided)
  176         797  
71             && $_->isa('StorageDisplay::Block::System')
72             } $e->consumedBlocks;
73 550 100       3814 if ($e->isa('StorageDisplay::Data::Partition::None')) {
74 3         170 push @blocks, $e->allProvidedBlocks;
75             }
76             $self->pushDotText(
77             \@text, $t,
78             '// Links for '.$e->dname,
79             (map {
80 550         3127 "// TARGET LINK: ".$self->host." ".
  17         587  
81             $_->size." ".
82             $_->kname." ".$e->linkname} @blocks));
83              
84             }
85             }
86 7         1294 return @text;
87             }
88              
89             around BUILDARGS => sub {
90             my $orig = shift;
91             my $class = shift;
92             my $host = shift // 'machine';
93              
94             return $class->$orig(
95             'name' => $host,
96             'host' => $host,
97             @_
98             );
99             };
100              
101             sub label {
102 0     0 0 0 my $self = shift;
103 0         0 return "COUCOU1".$self->host;
104             }
105              
106             sub dotLabel {
107 7     7 0 26 my $self = shift;
108 7         359 return $self->host;
109             }
110              
111             1;
112              
113             __END__
114              
115             =pod
116              
117             =encoding UTF-8
118              
119             =head1 NAME
120              
121             StorageDisplay::Data::Root - Handle machine data for StorageDisplay
122              
123             =head1 VERSION
124              
125             version 2.06
126              
127             =head1 AUTHOR
128              
129             Vincent Danjean <Vincent.Danjean@ens-lyon.org>
130              
131             =head1 COPYRIGHT AND LICENSE
132              
133             This software is copyright (c) 2014-2023 by Vincent Danjean.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =cut