[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 25/26] sg-report-host-history: Show used power approach(es)



Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/sg-report-host-history b/sg-report-host-history
index 51814534..18b538e9 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -161,6 +161,7 @@ sub reporthost ($) {
     print H "<th>branch</th><th>intended</th><th>blessing</th>\n";
 
     print H "<th>job</th><th>failure</th>\n";
+    print H "<th>power</th>\n";
 
     print H "</tr>\n";
 
@@ -188,6 +189,16 @@ END
         LIMIT 1
 END
 
+    # the final AND is just to reduce the data flow
+    our $jrunvarq //= db_prepare(<<END);
+       SELECT name, val
+         FROM runvars
+        WHERE flight=? AND job=?
+           AND (
+               name LIKE (? || '_power_%')
+           )
+END
+
     my $inrows = $hosts{$hostname};
     print DEBUG "FOUND ", (scalar @$inrows), " ROWS for $hostname\n";
 
@@ -213,6 +224,12 @@ END
     foreach my $jr (@rows) {
        my $ir = jobquery($infoq, $jr);
        my $ar = jobquery($allocdq, $jr);
+       my $ident = $jr->{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 "<tr $altcolour>";
@@ -252,6 +269,45 @@ END
        my $ri = report_run_getinfo({ %$jr, %$ir });
        print H "<td $ri->{ColourAttr}>$ri->{Content}</td>\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, '</span>';
+            } else {
+                print H "<td bgcolor=\"$colour\">", $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 "<td>" if !$any_power;
+       print H "</td>\n";
+
        print H "</tr>\n\n";
        $alternate ^= 1;
     }
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.