From: Ian Jackson Date: Thu, 24 Jan 2019 16:52:47 +0000 (+0000) Subject: sg-report-host-history: Show used power approach(es) X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e847a88a27d8a1bcc05a590a96858ab6a92f5b19;p=osstest.git sg-report-host-history: Show used power approach(es) Signed-off-by: Ian Jackson --- diff --git a/sg-report-host-history b/sg-report-host-history index 5181453..18b538e 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -161,6 +161,7 @@ sub reporthost ($) { print H "branchintendedblessing\n"; print H "jobfailure\n"; + print H "power\n"; print H "\n"; @@ -188,6 +189,16 @@ END LIMIT 1 END + # the final AND is just to reduce the data flow + our $jrunvarq //= db_prepare(<{name}; + $jrunvarq->execute($jr->{flight}, $jr->{job}, $ident); + my %runvars; + while (my ($n, $v) = $jrunvarq->fetchrow_array()) { + $runvars{$n} = $v; + } my $altcolour = report_altcolour($alternate); print H ""; @@ -252,6 +269,45 @@ END my $ri = report_run_getinfo({ %$jr, %$ir }); print H "{ColourAttr}>$ri->{Content}\n"; + my %powers; + foreach my $r (sort keys %runvars) { + next unless $r =~ m{^\Q${ident}\E_power_}; + $powers{$'} = $runvars{$r}; + } + my $skipped = 0; + my $any_power = 0; + my $pr_power_colour = sub { + my ($colour, $contents) = @_; + if ($any_power++) { + print H span_colour($colour), $contents, ''; + } else { + print H "", $contents; + } + }; + my $pr_power = sub { + my ($wh) = @_; + for (; $skipped; $skipped--) { + $pr_power_colour->($grey_mid, " - "); + } + my $how = $powers{$wh}; + my $colour = + $how =~ /PDU/ ? $yellow : + $how =~ /Combined/ ? $yellow : + $how eq 'SSH' ? $green : + $grey_pale ; + $pr_power_colour->($colour, " $how "); + }; + foreach my $wh (qw(install recover)) { + $skipped++, next unless exists $powers{$wh}; + $pr_power->($wh); + delete $powers{$wh}; + } + foreach my $wh (sort keys %powers) { + $pr_power->($wh); + } + print H "" if !$any_power; + print H "\n"; + print H "\n\n"; $alternate ^= 1; }