generic host information report for systems overview pages
Robert 'phaylon' Sedlacek [Tue, 18 Sep 2012 00:44:51 +0000 (00:44 +0000)]
lib/System/Introspector/Report/Builder/HostInfo.pm [new file with mode: 0644]

diff --git a/lib/System/Introspector/Report/Builder/HostInfo.pm b/lib/System/Introspector/Report/Builder/HostInfo.pm
new file mode 100644 (file)
index 0000000..8c293da
--- /dev/null
@@ -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;