Commit a34a1dd4 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Merge reserved.php3 functionality into nodecontrol_list.php3,

conditionalized on isadmin() status. These pages were mostly
overlapping anyway, and the nodecontrol_list.php3 page was done more
cleanly. No point in all the duplication. Dropped the Node Control
menu item from the list.
Add explicit "widearea" view to get remote nodes in their own page,
instead of listed after all the PCs. Also some minor formatting
changes.
parent 0a4b876a
......@@ -131,8 +131,6 @@ function WRITESIDEBAR() {
if ($login_status & CHECKLOGIN_ISADMIN) {
WRITESIDEBARBUTTON("User List",
$TBBASE, "showuser_list.php3");
WRITESIDEBARBUTTON("Node Control",
$TBBASE, "nodecontrol_list.php3");
}
WRITESIDEBARBUTTON("Begin an Experiment",
......@@ -142,7 +140,7 @@ function WRITESIDEBAR() {
WRITESIDEBARBUTTON("Update user information",
$TBBASE, "moduserinfo.php3");
WRITESIDEBARBUTTON("Node Reservation Status",
$TBBASE, "reserved.php3");
$TBBASE, "nodecontrol_list.php3");
WRITESIDEBARBUTTON("Node Up/Down Status",
$TBDOCBASE, "updown.php3");
......
<?php
include("defs.php3");
#
# This page is used for both admin node control, and for mere user
# information purposes. Be careful about what you do outside of
# $isadmin tests.
#
#
# Standard Testbed Header
#
......@@ -16,13 +22,11 @@ LOGGEDINORDIE($uid);
# Admin users can control nodes.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
USERERROR("You do not have admin privledges!", 1);
}
echo "<b>Show: <a href='nodecontrol_list.php3?showtype=pcs'>pcs</a>,
<a href='nodecontrol_list.php3?showtype=dnards'>dnards</a>,
<a href='nodecontrol_list.php3?showtype=widearea'>widearea</a>,
<a href='nodecontrol_list.php3?showtype=virtnodes'>virtual</a>,
<a href='nodecontrol_list.php3?showtype=sharks'>sharks</a>,
<a href='nodecontrol_list.php3?showtype=all'>all</a>.
</b><br><br>\n";
......@@ -31,76 +35,137 @@ if (!isset($showtype)) {
}
if (! strcmp($showtype, "all")) {
$clause = "role='testnode' or role='virtnode'";
$role = "(role='testnode' or role='virtnode')";
$clause = "";
$view = "All";
}
elseif (! strcmp($showtype, "pcs")) {
$clause = "role='testnode' and type!='dnard'";
$role = "(role='testnode')";
$clause = "and (nt.class='pc')";
$view = "PCs";
}
elseif (! strcmp($showtype, "dnards")) {
$clause = "role='testnode' and type='dnard'";
elseif (! strcmp($showtype, "sharks")) {
$role = "(role='testnode')";
$clause = "and (nt.class='shark')";
$view = "Sharks";
}
elseif (! strcmp($showtype, "virtnodes")) {
$clause = "role='virtnode'";
$role = "(role='virtnode')";
$clause = "";
$view = "Virtual Nodes";
}
elseif (! strcmp($showtype, "widearea")) {
$role = "(role='testnode')";
$clause = "and (nt.isremotenode=1)";
$view = "Widearea";
}
else {
$clause = "role='testnode' and type!='dnard'";
$role = "(role='testnode')";
$clause = "and (nt.class='pc')";
$view = "PCs";
}
#
# Suck out info for all the nodes.
#
$query_result =
DBQueryFatal("SELECT nodes.*,reserved.pid,reserved.eid FROM nodes ".
"left join reserved on nodes.node_id=reserved.node_id ".
"WHERE $clause ORDER BY priority");
DBQueryFatal("select n.node_id,n.phys_nodeid,n.type,n.status, ".
" n.def_boot_osid,r.pid,r.eid,nt.class,r.vname ".
" 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 ".
"where $role $clause ".
"ORDER BY priority");
if (mysql_num_rows($query_result) == 0) {
echo "<center>Oops, no nodes to show you!</center>";
PAGEFOOTER();
}
echo "<center><b>
View: $view
</b></center><br>\n";
echo "<table border=2 cellpadding=2 cellspacing=1
align='center'>\n";
echo "<tr>
<td align=center>ID</td>
<td align=center>Type</td>
<td align=center>Up?</td>
<td align=center>PID</td>
<td align=center>Type (Class)</td>
<td align=center>Up?</td>\n";
if ($isadmin) {
echo "<td align=center>PID</td>
<td align=center>EID</td>
<td align=center>Default<br>OSID</td>
</tr>\n";
<td align=center>Name</td>
<td align=center>Default<br>OSID</td>\n";
}
else {
echo "<td align=center>Free?</td>\n";
}
echo "</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$node_id = $row[node_id];
$phys_nodeid = $row[phys_nodeid];
$type = $row[type];
$class = $row["class"];
$def_boot_osid = $row[def_boot_osid];
$pid = $row[pid];
$eid = $row[eid];
$vname = $row[vname];
$status = $row[status];
echo "<tr>
<td><A href='shownode.php3?node_id=$node_id'>$node_id</a></td>\n
<td>$type</td>\n";
echo "<tr>";
if ($status == "up")
echo "<td><img src='/autostatus-icons/greenball.gif' alt=up></td>\n";
else
echo "<td><img src='/autostatus-icons/redball.gif' alt=down></td>\n";
if ($pid) {
echo "<td>$pid</td>
<td>$eid</td>\n";
# Admins get a link to expand the node.
if ($isadmin) {
echo "<td><A href='shownode.php3?node_id=$node_id'>$node_id</a> " .
(!strcmp($node_id, $phys_nodeid) ? "" :
"(<A href='shownode.php3?node_id=$phys_nodeid'>$phys_nodeid</a>)")
. "</td>\n";
}
else {
echo "<td>--</td>
<td>--</td>\n";
echo "<td>$node_id " .
(!strcmp($node_id, $phys_nodeid) ? "" : "($phys_nodeid)") .
"</td>\n";
}
if ($def_boot_osid && TBOSInfo($def_boot_osid, $osname, $ospid))
echo "<td>$osname</td>\n";
echo " <td>$type ($class)</td>\n";
if ($status == "up")
echo "<td align=center>
<img src='/autostatus-icons/greenball.gif' alt=up></td>\n";
else
echo "<td>&nbsp</td>\n";
echo "<td align=center>
<img src='/autostatus-icons/redball.gif' alt=down></td>\n";
# Admins get pid/eid/vname, but mere users yes/no.
if ($isadmin) {
if ($pid) {
echo "<td>$pid</td>
<td>$eid</td>\n";
if ($vname)
echo "<td>$vname</td>\n";
else
echo "<td>--</td>\n";
}
else {
echo "<td>--</td>
<td>--</td>
<td>--</td>\n";
}
if ($def_boot_osid && TBOSInfo($def_boot_osid, $osname, $ospid))
echo "<td>$osname</td>\n";
else
echo "<td>&nbsp</td>\n";
}
else {
if ($pid)
echo "<td>&nbsp</td>\n";
else
echo "<td>Yes</td>\n";
}
echo "</tr>\n";
}
......
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Utah Testbed Machine Status");
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
$query_result =
DBQueryFatal("SELECT n.node_id, n.phys_nodeid, n.type, nt.class, ".
" nt.isvirtnode, j.pid, j.eid, j.vname from nodes AS n ".
"LEFT JOIN reserved AS j ON n.node_id = j.node_id ".
"LEFT JOIN node_types AS nt ON n.type=nt.type ".
"WHERE (role='testnode' or role='virtnode') and ".
" nt.class!='shark' " .
"ORDER BY priority,type");
#
# Count the types up.
#
$numpcs = 0;
$numsharks = 0;
$freepcs = 0;
$freesharks= 0;
while ($r = mysql_fetch_array($query_result)) {
$type = $r["class"];
$eid = $r["eid"];
if ($type == "pc") {
$numpcs++;
}
if ($type == "shark") {
$numsharks++;
}
if ($eid && $eid != "NULL") {
continue;
}
if ($type == "pc") {
$freepcs++;
}
if ($type == "shark") {
$freesharks++;
}
}
echo "<center><h3>
$freepcs of $numpcs PCs Free <br>
$freesharks of $numsharks Sharks Free.
</h3></center>\n";
echo "<table border=1 align=center padding=1>\n";
echo "<tr>
<td width=10%><b>ID</b></td>
<td width=10%><b>Type</b></td>\n";
if ($isadmin) {
echo "<td width=25%><b>Project</b></td>
<td width=25%><b>Experiment</b></td>
<td width=25%><b>Virtual Nickname</b></td>\n";
} else {
echo "<td width=20%><b>Reservation Status</b></td>\n";
}
echo "</tr>\n";
mysql_data_seek($query_result, 0);
while ($r = mysql_fetch_array($query_result)) {
$id = $r["node_id"]; $type = $r["type"]; $class = $r["class"];
$res1 = $r["pid"];
$res2 = $r["eid"];
$res3 = $r["vname"];
$isvirt = $r["isvirtnode"];
$phys = $r["phys_nodeid"];
if (!$res1 || $res1 == "NULL") {
$res1 = "--";
}
if (!$res2 || $res2 == "NULL") {
$res2 = "--";
}
if (!$res3 || $res3 == "NULL") {
$res3 = "--";
}
if ($isvirt)
echo "<tr><td>$id ($phys)</td> ";
else
echo "<tr><td>$id</td> ";
echo "<td>$type ($class)</td> ";
# If I'm an admin, I can see pid/eid/vname, but if not, I only see eid
if ($isadmin) { echo "<td>$res1</td> "; }
echo "<td>$res2</td> ";
if ($isadmin) { echo "<td>$res3</td>"; }
echo "</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
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