Commit | Line | Data |
d636bbef |
1 | package System::Introspector::Report::Builder::HostInfo; |
2 | use Moo; |
3 | |
4 | extends 'System::Introspector::Report::Builder'; |
5 | |
6 | has _hostinfo => (is => 'ro', default => sub { {} }); |
7 | |
8 | sub required_data { |
9 | return qw( host ); |
10 | } |
11 | |
12 | sub collect_from { |
13 | my ($self, $id, $data) = @_; |
14 | $self->_hostinfo->{$id}{hostname} = $data->{host}{hostname}; |
15 | return 1; |
16 | } |
17 | |
18 | sub render_reports { |
19 | my ($self) = @_; |
20 | my @columns = ( |
21 | { key => 'info-field', label => 'Info' }, |
22 | { key => 'info-value', label => 'Value' }, |
23 | ); |
24 | return map { |
25 | my $remote = $_; |
26 | +{ |
27 | columns => [@columns], |
28 | title => "Host Information for $remote", |
29 | id => ['host-info-by-remote', $remote], |
30 | rowid => [qw( info-field )], |
31 | meta => { remote => $remote }, |
32 | rows => [ |
33 | +{ |
34 | 'info-field' => 'Hostname', |
35 | 'info-value' => $self->_hostinfo->{$remote}{hostname}, |
36 | }, |
37 | ], |
38 | }; |
39 | } keys %{$self->_hostinfo}; |
40 | } |
41 | |
42 | 1; |