File: Root.pm

package info (click to toggle)
libstoragedisplay-perl 2.06-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,828 kB
  • sloc: perl: 7,947; sh: 95; makefile: 5
file content (138 lines) | stat: -rw-r--r-- 2,980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# This file is part of StorageDisplay
#
# This software is copyright (c) 2014-2023 by Vincent Danjean.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use strict;
use warnings;

package StorageDisplay::Data::Root;
# ABSTRACT: Handle machine data for StorageDisplay

our $VERSION = '2.06'; # VERSION

use Moose;
use namespace::sweep;
extends 'StorageDisplay::Data::Elem';

with (
    'StorageDisplay::Role::Style::IsSubGraph',
    'StorageDisplay::Role::Style::Machine',
    'StorageDisplay::Role::Elem::Kind'
    => { kind => "machine" }
);

has 'host' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    );

sub dotSubGraph {
    my $self = shift;
    my $t = shift // "\t";

    my @text;
    my @subnodes=$self->dotSubNodes($t);
    $self->pushDotText(\@text, $t,
                       $self->dotSubNodes($t));

    my $it = $self->iterator(recurse => 1);
    while (defined(my $e=$it->next)) {
        my @links = $e->dotLinks($t, @_);
        if (scalar(@links)>0) {
            $self->pushDotText(
                \@text, $t,
                '// Links from '.$e->dname,
                @links,
                );
        }
    }
    $it = $self->iterator(recurse => 1);
    while (defined(my $e=$it->next)) {
        my @blocks = grep {
            $_->provided
        } $e->consumedBlocks;

        if (scalar(@blocks)>0) {
            $self->pushDotText(
                \@text, $t,
                '// Links for '.$e->dname,
                (map { $_->elem->linkname.' -> '.$e->linkname } @blocks),
                );
        }
	{
	    # No consumed block. Perhaps, we come from a VM provisionning
	    my @blocks = grep {
		(!$_->provided)
		    && $_->isa('StorageDisplay::Block::System')
	    } $e->consumedBlocks;
	    if ($e->isa('StorageDisplay::Data::Partition::None')) {
		push @blocks, $e->allProvidedBlocks;
	    }
	    $self->pushDotText(
                \@text, $t,
                '// Links for '.$e->dname,
		(map {
		    "// TARGET LINK: ".$self->host." ".
			$_->size." ".
			$_->kname." ".$e->linkname} @blocks));

	}
    }
    return @text;
}

around BUILDARGS => sub {
    my $orig  = shift;
    my $class = shift;
    my $host = shift // 'machine';

    return $class->$orig(
        'name' => $host,
        'host' => $host,
        @_
        );
};

sub label {
    my $self = shift;
    return "COUCOU1".$self->host;
}

sub dotLabel {
    my $self = shift;
    return $self->host;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

StorageDisplay::Data::Root - Handle machine data for StorageDisplay

=head1 VERSION

version 2.06

=head1 AUTHOR

Vincent Danjean <Vincent.Danjean@ens-lyon.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014-2023 by Vincent Danjean.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut