nodecontrol_list.php3 4.33 KB
Newer Older
1 2 3
<?php
include("defs.php3");

4 5 6 7 8 9
#
# 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.
# 

10 11 12
#
# Standard Testbed Header
#
13
PAGEHEADER("Node Control Center");
14

15 16 17
#
# Only known and logged in users can do this.
#
18
$uid = GETLOGIN();
19 20 21 22 23 24 25
LOGGEDINORDIE($uid);

#
# Admin users can control nodes.
#
$isadmin = ISADMIN($uid);

26
echo "<b>Show: <a href='nodecontrol_list.php3?showtype=pcs'>pcs</a>,
27
               <a href='nodecontrol_list.php3?showtype=widearea'>widearea</a>,
28
               <a href='nodecontrol_list.php3?showtype=virtnodes'>virtual</a>,
29
               <a href='nodecontrol_list.php3?showtype=sharks'>sharks</a>,
30 31 32 33 34 35 36 37
               <a href='nodecontrol_list.php3?showtype=all'>all</a>.
      </b><br><br>\n";

if (!isset($showtype)) {
    $showtype='pcs';
}

if (! strcmp($showtype, "all")) {
38 39 40
    $role   = "(role='testnode' or role='virtnode')";
    $clause = "";
    $view   = "All";
41 42
}
elseif (! strcmp($showtype, "pcs")) {
43 44 45
    $role   = "(role='testnode')";
    $clause = "and (nt.class='pc')";
    $view   = "PCs";
46
}
47 48 49 50
elseif (! strcmp($showtype, "sharks")) {
    $role   = "(role='testnode')";
    $clause = "and (nt.class='shark')";
    $view   = "Sharks";
51 52
}
elseif (! strcmp($showtype, "virtnodes")) {
53 54 55 56 57 58 59 60
    $role   = "(role='virtnode')";
    $clause = "";
    $view   = "Virtual Nodes";
}
elseif (! strcmp($showtype, "widearea")) {
    $role   = "(role='testnode')";
    $clause = "and (nt.isremotenode=1)";
    $view   = "Widearea";
61 62
}
else {
63 64 65
    $role   = "(role='testnode')";
    $clause = "and (nt.class='pc')";
    $view   = "PCs";
66 67
}

68 69 70
#
# Suck out info for all the nodes.
# 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
71
$query_result =
72 73 74 75 76 77 78
    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");
79 80 81 82 83

if (mysql_num_rows($query_result) == 0) {
    echo "<center>Oops, no nodes to show you!</center>";
    PAGEFOOTER();
}
84

85 86 87 88
echo "<center><b>
       View: $view
      </b></center><br>\n";

89
echo "<table border=2 cellpadding=2 cellspacing=1
90 91 92
       align='center'>\n";

echo "<tr>
93
          <td align=center>ID</td>
94 95 96 97 98
          <td align=center>Type (Class)</td>
          <td align=center>Up?</td>\n";

if ($isadmin) {
    echo "<td align=center>PID</td>
99
          <td align=center>EID</td>
100 101 102 103 104 105 106
          <td align=center>Name</td>
          <td align=center>Default<br>OSID</td>\n";
}
else {
    echo "<td align=center>Free?</td>\n";
}    
echo "</tr>\n";
107 108 109
    
while ($row = mysql_fetch_array($query_result)) {
    $node_id            = $row[node_id]; 
110
    $phys_nodeid        = $row[phys_nodeid]; 
111
    $type               = $row[type];
112
    $class              = $row["class"];
113
    $def_boot_osid      = $row[def_boot_osid];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
114 115
    $pid                = $row[pid];
    $eid                = $row[eid];
116
    $vname              = $row[vname];
117
    $status             = $row[status];
118

119
    echo "<tr>";
120

121 122 123 124 125 126
    # 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";
127 128
    }
    else {
129 130 131
	echo "<td>$node_id " .
  	      (!strcmp($node_id, $phys_nodeid) ? "" : "($phys_nodeid)") .
	      "</td>\n";
132
    }
133
    
134 135 136 137 138
    echo "   <td>$type ($class)</td>\n";

    if ($status == "up")
	echo "<td align=center>
                  <img src='/autostatus-icons/greenball.gif' alt=up></td>\n";
139
    else
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
	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";
    }
169
    
170
    echo "</tr>\n";
171 172 173
}

echo "</table>\n";
174 175 176 177 178

#
# Standard Testbed Footer
# 
PAGEFOOTER();
179 180 181
?>