Commit 39b1477e authored by Mike Hibler's avatar Mike Hibler

Mike's yearly PHP hacking:

 * Add a "showclass" param to shownodes so that the
   node listing will include only nodes of the indicated class.
   Prepend "no-" to exclude nodes of a particular class.  So:
        showclass=pc,mote
   would show just pcs and motes.

 * Now the real reason I added the above: change the hwdown experiment
   node list to include "showclass=no-pcplabphys" by default so I don't have
   to flip through 600+ dead plab nodes.  Change the URL to "showclass=all"
   if you want to see plab nodes in hwdown.
parent 9b2ae033
......@@ -327,7 +327,7 @@ SUBPAGEEND();
#
# Dump the node information.
#
SHOWNODES($exp_pid, $exp_eid, $sortby);
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
if ($isadmin) {
echo "<center>
......
......@@ -1132,7 +1132,7 @@ function SHOWEXPLIST($type,$fromuid,$id,$gid = "") {
#
# Show Node information for an experiment.
#
function SHOWNODES($pid, $eid, $sortby) {
function SHOWNODES($pid, $eid, $sortby, $showclass) {
global $SCRIPT_NAME;
global $TBOPSPID;
......@@ -1165,11 +1165,42 @@ function SHOWNODES($pid, $eid, $sortby) {
# XXX
if ($pid == "emulab-ops" && $eid == "hwdown") {
$showlastlog = 1;
if (empty($showclass)) {
$showclass = "no-pcplabphys";
}
}
else {
$showlastlog = 0;
}
if (!empty($showclass)) {
$classclause = "";
$noclassclause = "";
$opts = explode(",", $showclass);
foreach ($opts as $opt) {
if (preg_match("/^no-([-\w]+)$/", $opt, $matches)) {
if (!empty($noclassclause)) {
$noclassclause .= ",";
}
$noclassclause .= "'$matches[1]'";
} elseif ($opt == "all") {
$classclause = "";
$noclassclause = "";
} else {
if (!empty($classclause)) {
$classclause .= ",";
}
$classclause .= "'$opt'";
}
}
if (!empty($classclause)) {
$classclause = "and nt.class in (" . $classclause . ")";
}
if (!empty($noclassclause)) {
$noclassclause = "and nt.class not in (" . $noclassclause . ")";
}
}
if ($showlastlog) {
#
# We need to extract, for each node, just the latest nodelog message.
......@@ -1205,6 +1236,7 @@ function SHOWNODES($pid, $eid, $sortby) {
"left join nodelog as nl on nl.node_id=r.node_id and nl.reported=t.reported ".
"WHERE r.eid='$eid' and r.pid='$pid' ".
"$classclause $noclassclause".
"ORDER BY $sortclause");
DBQueryFatal("DROP table nodelogtemp");
}
......@@ -1220,6 +1252,7 @@ function SHOWNODES($pid, $eid, $sortby) {
"left join os_info as oi on n.def_boot_osid=oi.osid ".
"left join tiplines as tip on tip.node_id=r.node_id ".
"WHERE r.eid='$eid' and r.pid='$pid' ".
"$classclause $noclassclause".
"ORDER BY $sortclause");
}
......@@ -1230,15 +1263,17 @@ function SHOWNODES($pid, $eid, $sortby) {
<table align=center border=1>
<tr>
<th><a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
"&sortby=nodeid\">Node ID</a></th>
"&sortby=nodeid&showclass=$showclass\">
Node ID</a></th>
<th><a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
"&sortby=vname\">Name</a></th>\n";
"&sortby=vname&showclass=$showclass\">
Name</a></th>\n";
if ($pid == $TBOPSPID) {
echo "<th>Reserved<br>
<a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
"&sortby=rsrvtime-up\">Up</a> or
"&sortby=rsrvtime-up&showclass=$showclass\">Up</a> or
<a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
"&sortby=rsrvtime-down\">Down</a>
"&sortby=rsrvtime-down&showclass=$showclass\">Down</a>
</th>\n";
}
echo " <th>Type</th>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment