From: Robert 'phaylon' Sedlacek Date: Tue, 18 Sep 2012 00:44:51 +0000 (+0000) Subject: generic host information report for systems overview pages X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d636bbefc8890517e8f567297e5e567eeb6e1cb8;p=scpubgit%2FSystem-Introspector-Report.git generic host information report for systems overview pages --- diff --git a/lib/System/Introspector/Report/Builder/HostInfo.pm b/lib/System/Introspector/Report/Builder/HostInfo.pm new file mode 100644 index 0000000..8c293da --- /dev/null +++ b/lib/System/Introspector/Report/Builder/HostInfo.pm @@ -0,0 +1,42 @@ +package System::Introspector::Report::Builder::HostInfo; +use Moo; + +extends 'System::Introspector::Report::Builder'; + +has _hostinfo => (is => 'ro', default => sub { {} }); + +sub required_data { + return qw( host ); +} + +sub collect_from { + my ($self, $id, $data) = @_; + $self->_hostinfo->{$id}{hostname} = $data->{host}{hostname}; + return 1; +} + +sub render_reports { + my ($self) = @_; + my @columns = ( + { key => 'info-field', label => 'Info' }, + { key => 'info-value', label => 'Value' }, + ); + return map { + my $remote = $_; + +{ + columns => [@columns], + title => "Host Information for $remote", + id => ['host-info-by-remote', $remote], + rowid => [qw( info-field )], + meta => { remote => $remote }, + rows => [ + +{ + 'info-field' => 'Hostname', + 'info-value' => $self->_hostinfo->{$remote}{hostname}, + }, + ], + }; + } keys %{$self->_hostinfo}; +} + +1;