Commit 25ca9681 authored by Timothy Stack's avatar Timothy Stack
Browse files

Add some checks for 'free' nodes that are not allocatable.

	* db/audit.in: Include the list of nodes that are not reserved but
	have an eventstate that makes them unallocatable.

	* www/dbdefs.php3.in: Add POWEROFF and ALWAYSUP node states.

	* www/nodecontrol_list.php3: Add an asterisk next to the free
	count for type(s) that have free, but unallocatable nodes.

	* www/shownodetype.php3: If a node is free, but unallocatable, put
	a yellow ball next to its name instead of a green one.
parent b60583f5
......@@ -151,6 +151,33 @@ if ($today == 7) {
}
}
#
# Look for free nodes in odd states.
#
if (! ($query_result =
DBQueryWarn("select n.node_id from nodes as n ".
"left join reserved as r on r.node_id=n.node_id ".
"where (n.eventstate!='". TBDB_NODESTATE_ISUP ."' and ".
" n.eventstate!='". TBDB_NODESTATE_PXEWAIT ."' and ".
" n.eventstate!='". TBDB_NODESTATE_ALWAYSUP ."' and ".
" n.eventstate!='". TBDB_NODESTATE_POWEROFF ."') ".
" and r.pid is null and n.role='testnode'"))) {
fatal("Error accessing the database.");
}
if ($query_result->numrows) {
print "\n";
print "----------------------------------------------------------------\n";
print "\n";
print "'Free' nodes in an unknown state:\n";
while (my ($node_id) = $query_result->fetchrow()) {
print "$node_id ";
}
print "\n";
}
#
# Look for real nodes in hwdown.
#
......
......@@ -147,6 +147,8 @@ define("TBDB_IFACEROLE_OUTER_CONTROL", "outer_ctrl");
# Node states that the web page cares about.
define("TBDB_NODESTATE_ISUP", "ISUP");
define("TBDB_NODESTATE_PXEWAIT", "PXEWAIT");
define("TBDB_NODESTATE_POWEROFF", "POWEROFF");
define("TBDB_NODESTATE_ALWAYSUP", "ALWAYSUP");
# User Interface types
define("TBDB_USER_INTERFACE_EMULAB", "emulab");
......
......@@ -193,8 +193,10 @@ if (! strcmp($showtype, "summary")) {
$alltotal = 0;
$allfree = 0;
$allunknown = 0;
$totals = array();
$freecount = array();
$freecounts = array();
$unknowncounts = array();
while ($row = mysql_fetch_array($query_result)) {
$type = $row[0];
......@@ -202,24 +204,33 @@ if (! strcmp($showtype, "summary")) {
$totals[$type] = $count;
$freecounts[$type] = 0;
$unknowncounts[$type] = 0;
}
# Get free totals by type.
$query_result =
DBQueryFatal("select n.type,count(*) from nodes as n ".
DBQueryFatal("select n.eventstate,n.type,count(*) from nodes as n ".
"left join node_types as nt on n.type=nt.type ".
"left join reserved as r on r.node_id=n.node_id ".
"where (role='testnode') and ".
" (nt.class!='shark' and nt.class!='pcRemote' ".
" and nt.class!='pcplabphys') ".
" and r.pid is null ".
"group BY n.type");
"group BY n.eventstate,n.type");
while ($row = mysql_fetch_array($query_result)) {
$type = $row[0];
$count = $row[1];
$freecounts[$type] = $count;
$type = $row[1];
$count = $row[2];
# XXX Yeah, I'm a doofus and can't figure out how to do this in SQL.
if (($row[0] == TBDB_NODESTATE_ISUP) ||
($row[0] == TBDB_NODESTATE_PXEWAIT) ||
($row[0] == TBDB_NODESTATE_ALWAYSUP) ||
($row[0] == TBDB_NODESTATE_POWEROFF)) {
$freecounts[$type] += $count;
}
else {
$unknowncounts[$type] += $count;
}
}
$projlist = TBProjList($target_uid, $TB_PROJECT_CREATEEXPT);
......@@ -255,7 +266,13 @@ if (! strcmp($showtype, "summary")) {
continue;
$allfree += $freecount;
$allunknown += $unknowncounts[$key];
$alltotal += $value;
if ($unknowncounts[$key])
$ast = "*";
else
$ast = "";
echo "<tr>\n";
if ($isadmin)
......@@ -263,7 +280,7 @@ if (! strcmp($showtype, "summary")) {
else
echo "<td><a href=shownodetype.php3?node_type=$key>\n";
echo " $key</a></td>
<td align=center>$freecount</td>
<td align=center>${freecount}${ast}</td>
<td align=center>$value</td>
</tr>\n";
}
......@@ -273,6 +290,7 @@ if (! strcmp($showtype, "summary")) {
<td align=center>$allfree</td>
<td align=center>$alltotal</td>
</tr>\n";
if ($isadmin) {
# Give admins the option to create a new type
echo "<tr></tr>\n";
......@@ -281,6 +299,10 @@ if (! strcmp($showtype, "summary")) {
</th>\n";
}
echo "</table>\n";
if ($allunknown > 0) {
echo "<br><font size=-1><b>*</b> - Some nodes ($allunknown) are ".
"free, but currently in an unallocatable state.</font>";
}
PAGEFOOTER();
exit();
}
......
......@@ -165,7 +165,7 @@ echo "</table>\n";
# just a list of dots, in two color mode.
#
$query_result =
DBQueryFatal("select n.node_id,r.pid ".
DBQueryFatal("select n.node_id,n.eventstate,r.pid ".
"from nodes as n ".
"left join node_types as nt on n.type=nt.type ".
"left join reserved as r on n.node_id=r.node_id ".
......@@ -184,6 +184,7 @@ if (mysql_num_rows($query_result)) {
while ($row = mysql_fetch_array($query_result)) {
$node_id = $row["node_id"];
$es = $row["eventstate"];
$pid = $row["pid"];
if ($column == 0) {
......@@ -194,7 +195,15 @@ if (mysql_num_rows($query_result)) {
echo "<td align=left><nobr>\n";
if (!$pid) {
echo "<img src=\"/autostatus-icons/greenball.gif\" alt=free>\n";
if (($es == TBDB_NODESTATE_ISUP) ||
($es == TBDB_NODESTATE_ALWAYSUP) ||
($es == TBDB_NODESTATE_POWEROFF) ||
($es == TBDB_NODESTATE_PXEWAIT)) {
echo "<img src=\"/autostatus-icons/greenball.gif\" alt=free>\n";
}
else {
echo "<img src=\"/autostatus-icons/yellowball.gif\" alt='unusable free'>\n";
}
}
else {
echo "<img src=\"/autostatus-icons/redball.gif\" alt=reserved>\n";
......
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