function Show($short = 0, $sortby = "")
 {
     global $TBDBNAME, $TBDOCBASE, $WIKIDOCURL;
     $pid = $this->pid();
     $eid = $this->eid();
     $nodecounts = array();
     # Node counts, by class.
     $query_result = DBQueryFatal("select nt.class,count(*) from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join node_types as nt on n.type=nt.type " . "where pid='{$pid}' and eid='{$eid}' group by nt.class");
     while ($row = mysql_fetch_array($query_result)) {
         $class = $row[0];
         $count = $row[1];
         $nodecounts[$class] = $count;
     }
     $query_result = DBQueryFatal("select e.*, s.archive_idx, pl.slicename, " . "round(e.minimum_nodes+.1,0) as min_nodes, " . "round(e.maximum_nodes+.1,0) as max_nodes " . " from experiments as e " . "left join experiment_stats as s on s.exptidx=e.idx " . "left join plab_slices as pl" . " on e.pid = pl.pid and e.eid = pl.eid " . "where e.pid='{$pid}' and e.eid='{$eid}'");
     if (($exprow = mysql_fetch_array($query_result)) == 0) {
         TBERROR("Experiment {$eid} in project {$pid} is gone!\n", 1);
     }
     $exp_gid = $exprow["gid"];
     $exp_name = $exprow["expt_name"];
     $exp_swapped = $exprow["expt_swapped"];
     $exp_swapuid = $exprow["expt_swap_uid"];
     $exp_end = $exprow["expt_end"];
     $exp_created = $exprow["expt_created"];
     $exp_head = $exprow["expt_head_uid"];
     $exp_swapper = $exprow["swapper_idx"];
     $exp_state = $exprow["state"];
     $exp_shared = $exprow["shared"];
     $exp_path = $exprow["path"];
     $batchmode = $exprow["batchmode"];
     $canceled = $exprow["canceled"];
     $attempts = $exprow["attempts"];
     $expt_locked = $exprow["expt_locked"];
     $priority = $exprow["priority"];
     $swappable = $exprow["swappable"];
     $noswap_reason = $exprow["noswap_reason"];
     $idleswap = $exprow["idleswap"];
     $idleswap_timeout = $exprow["idleswap_timeout"];
     $noidleswap_reason = $exprow["noidleswap_reason"];
     $autoswap = $exprow["autoswap"];
     $autoswap_timeout = $exprow["autoswap_timeout"];
     $idle_ignore = $exprow["idle_ignore"];
     $savedisk = $exprow["savedisk"];
     $swapreqs = $exprow["swap_requests"];
     $lastswapreq = $exprow["last_swap_req"];
     $minnodes = $exprow["min_nodes"];
     $maxnodes = $exprow["max_nodes"];
     $virtnodes = $exprow["virtnode_count"];
     $syncserver = $exprow["sync_server"];
     $mem_usage = $exprow["mem_usage"];
     $cpu_usage = $exprow["cpu_usage"];
     $exp_slice = $exprow["slicename"];
     $linktest_level = $exprow["linktest_level"];
     $linktest_pid = $exprow["linktest_pid"];
     $usemodelnet = $exprow["usemodelnet"];
     $mnet_cores = $exprow["modelnet_cores"];
     $mnet_edges = $exprow["modelnet_edges"];
     $lockdown = $exprow["lockdown"];
     $skipvlans = $exprow["skipvlans"];
     $exptidx = $exprow["idx"];
     $archive_idx = $exprow["archive_idx"];
     $dpdb = $exprow["dpdb"];
     $dpdbname = $exprow["dpdbname"];
     $dpdbpassword = $exprow["dpdbpassword"];
     $uuid = $exprow["eid_uuid"];
     $paniced = $exprow["paniced"];
     $panic_date = $exprow["panic_date"];
     $autoswap_hrs = $autoswap_timeout / 60.0;
     $idleswap_hrs = $idleswap_timeout / 60.0;
     $noswap = "({$noswap_reason})";
     $noidleswap = "({$noidleswap_reason})";
     $autoswap_str = $autoswap_hrs . " hour" . ($autoswap_hrs == 1 ? "" : "s");
     $idleswap_str = $idleswap_hrs . " hour" . ($idleswap_hrs == 1 ? "" : "s");
     if (!($head_user = User::Lookup($exp_head))) {
         TBERROR("Error getting object for user {$exp_head}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     if (!($swapper = User::Lookup($exp_swapper))) {
         TBERROR("Error getting object for user {$exp_swapper}", 1);
     }
     $swapper_uid = $swapper->uid();
     $swapper_url = CreateURL("showuser", $swapper);
     if ($swappable) {
         $swappable = "Yes";
     } else {
         $swappable = "<b>No</b> {$noswap}";
     }
     if ($idleswap) {
         $idleswap = "Yes (after {$idleswap_str})";
     } else {
         $idleswap = "<b>No</b> {$noidleswap}";
     }
     if ($autoswap) {
         $autoswap = "<b>Yes</b> (after {$autoswap_str})";
     } else {
         $autoswap = "No";
     }
     if ($idle_ignore) {
         $idle_ignore = "<b>Yes</b>";
     } else {
         $idle_ignore = "No";
     }
     if ($savedisk) {
         $savedisk = "<b>Yes</b>";
     } else {
         $savedisk = "No";
     }
     if ($expt_locked) {
         $expt_locked = "({$expt_locked})";
     } else {
         $expt_locked = "";
     }
     $query_result = DBQueryFatal("select cause_desc " . "from experiment_stats as s,errors,causes " . "where s.exptidx = {$exptidx} " . "and errors.cause = causes.cause " . "and s.last_error = errors.session");
     if ($row = mysql_fetch_array($query_result)) {
         $err_cause = $row[0];
     } else {
         $err_cause = '';
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     if (!$short) {
         $thisurl = CreateURL("showexp", $this);
         echo "<tr>\n                <td>Name: </td>\n                <td class=left><a href='{$thisurl}'>{$eid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$exp_name}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Group: </td>\n                <td class=\"left\">\n                  <a href='showgroup.php3?pid={$pid}&gid={$exp_gid}'>{$exp_gid}</a>\n                </td>\n              </tr>\n";
         if (isset($exp_slice)) {
             echo "<tr>\n                  <td>Planetlab Slice: </td>\n                  <td class=\"left\">{$exp_slice}</td>\n                </tr>\n";
         }
     }
     echo "<tr>\n            <td>Creator: </td>\n            <td class=\"left\">\n              <a href='{$showuser_url}'>{$exp_head}</a></td>\n          </tr>\n";
     if (!$swapper->SameUser($head_user)) {
         echo "<tr>\n                      <td>Swapper: </td>\n                      <td class=\"left\">\n                          <a href='{$swapper_url}'>{$swapper_uid}</a></td>\n                  </tr>\n";
     }
     if (!$short) {
         $instance = TemplateInstance::LookupByExptidx($exptidx);
         if (!is_null($instance)) {
             $guid = $instance->guid();
             $vers = $instance->vers();
             echo "<tr>\n                    <td>Template: </td>\n                    <td class=\"left\">\n                       <a href='template_show.php?guid={$guid}&version={$vers}'>\n                          {$guid}/{$vers}</a>";
             if ($instance->runidx()) {
                 $runidx = $instance->runidx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Current Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             } else {
                 $runidx = $instance->LastRunIdx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Last Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             }
             echo "</tr>\n";
         }
         echo "<tr>\n                <td>Created: </td>\n                <td class=\"left\">{$exp_created}</td>\n              </tr>\n";
         if ($exp_swapped) {
             echo "<tr>\n                    <td>Last Swap/Modify: </td>\n                    <td class=\"left\">{$exp_swapped}\n                        (<a href='{$swapper_url}'>{$swapper_uid}</a>)</td>\n                  </tr>\n";
         }
         if (ISADMIN()) {
             echo "<tr>\n                    <td><a href='{$WIKIDOCURL}/Swapping#swapping'>Swappable:</a></td>\n                    <td class=\"left\">{$swappable}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td><a href='{$WIKIDOCURL}/Swapping#idleswap'>Idle-Swap:</a></td>\n                  <td class=\"left\">{$idleswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#autoswap'>Max. Duration:</a></td>\n                <td class=\"left\">{$autoswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#swapstatesave'>Save State:</a></td>\n                <td class=\"left\">{$savedisk}</td>\n              </tr>\n";
         if (ISADMIN()) {
             echo "<tr>\n                    <td>Idle Ignore:</td>\n                    <td class=\"left\">{$idle_ignore}</td>\n                 </tr>\n";
         }
         echo "<tr>\n                <td>Path: </td>\n                <td class=left>{$exp_path}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Status: </td>\n                <td id=exp_state class=\"left\">{$exp_state} {$expt_locked}</td>\n              </tr>\n";
         if ($err_cause) {
             echo "<tr>\n                    <td>Last Error: </td>\n                    <td class=\"left\"><a href=\"showlasterror.php3?pid={$pid}&eid={$eid}\">{$err_cause}</a></td>\n                  </tr>\n";
         }
         if ($paniced) {
             echo "<tr>\n                    <td>Paniced on: </td>\n                    <td class=left>{$panic_date}</td>\n                  </tr>\n";
         }
         if ($linktest_pid) {
             $linktest_running = "<b>(Linktest Running)</b>";
         } else {
             $linktest_running = "";
         }
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/linktest'>" . "Linktest Level</a>: </td>\n                <td class=\"left\">{$linktest_level} {$linktest_running}</td>\n              </tr>\n";
     }
     if (count($nodecounts)) {
         echo "<tr>\n                 <td>Reserved Nodes: </td>\n                 <td class=\"left\">\n";
         while (list($class, $count) = each($nodecounts)) {
             echo "{$count} ({$class}) &nbsp; ";
         }
         echo "   </td>\n              </tr>\n";
     } elseif (!$short) {
         if ($minnodes != "") {
             echo "<tr>\n                      <td>Min/Max Nodes: </td>\n                      <td class=\"left\"><font color=green>\n                          {$minnodes}/{$maxnodes} (estimates)</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Minumum Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
         if ($virtnodes) {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font>\n                          {$virtnodes}</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         if ($mem_usage || $cpu_usage) {
             echo "<tr>\n                      <td>Mem Usage Est: </td>\n                      <td class=\"left\">{$mem_usage}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>CPU Usage Est: </td>\n                      <td class=\"left\">{$cpu_usage}</td>\n                  </tr>\n";
         }
         $lastact = $this->LastAct();
         $idletime = $this->IdleTime();
         $stale = $this->IdleStale();
         if ($lastact != -1) {
             echo "<tr>\n                      <td>Last Activity: </td>\n                      <td class=\"left\">{$lastact}</td>\n                  </tr>\n";
             if ($stale) {
                 $str = "(stale)";
             } else {
                 $str = "";
             }
             echo "<tr>\n                      <td>Idle Time: </td>\n                      <td class=\"left\">{$idletime} hours {$str}</td>\n                  </tr>\n";
         }
         if (!($swapreqs == "" || $swapreqs == 0)) {
             echo "<tr>\n                      <td>Swap Requests: </td>\n                      <td class=\"left\">{$swapreqs}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Swap Req.: </td>\n                      <td class=\"left\">{$lastswapreq}</td>\n                  </tr>\n";
         }
         $lockflip = $lockdown ? 0 : 1;
         $lockval = $lockdown ? "Yes" : "No";
         echo "<tr>\n                   <td>Locked Down:</td>\n                   <td>{$lockval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=lockdown&value={$lockflip}>Toggle</a>)\n                   </td>\n              </tr>\n";
         if (ISADMIN() || STUDLY() || OPSGUY()) {
             $thisflip = $skipvlans ? 0 : 1;
             $flipval = $skipvlans ? "Yes" : "No";
             echo "<tr>\n                       <td>Skip Vlans:</td>\n                       <td>{$flipval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=skipvlans&value={$thisflip}>Toggle</a>)\n                       </td>\n                      </tr>\n";
         }
     }
     if ($batchmode) {
         echo "<tr>\n                    <td>Batch Mode: </td>\n                    <td class=\"left\">Yes</td>\n                  </tr>\n";
         echo "<tr>\n                    <td>Start Attempts: </td>\n                    <td class=\"left\">{$attempts}</td>\n                  </tr>\n";
     }
     if ($canceled) {
         echo "<tr>\n                 <td>Cancel Flag: </td>\n                 <td class=\"left\">{$canceled}</td>\n              </tr>\n";
     }
     if (!$short) {
         if (ISADMIN()) {
             echo "<tr>\n                        <td>UUID: </td>\n                        <td class=left>{$uuid}</td>\n                      </tr>\n";
         }
         if ($usemodelnet) {
             echo "<tr>\n                      <td>Use Modelnet: </td>\n                      <td class=\"left\">Yes</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Core Nodes: </td>\n                      <td class=\"left\">{$mnet_cores}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Edge Nodes: </td>\n                      <td class=\"left\">{$mnet_edges}</td>\n                  </tr>\n";
         }
         if (isset($syncserver)) {
             echo "<tr>\n                      <td>Sync Server: </td>\n                      <td class=\"left\">{$syncserver}</td>\n                  </tr>\n";
         }
         if ($dpdb && $dpdbname && $dpdbpassword) {
             echo "<tr>\n                      <td>DataBase Name: </td>\n                      <td class=\"left\">{$dpdbname}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase User: </td>\n                      <td class=\"left\">E{$exptidx}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase Password: </td>\n                      <td class=\"left\">{$dpdbpassword}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Index: </td>\n                  <td class=\"left\">{$exptidx}";
         if ($archive_idx) {
             echo " ({$archive_idx}) ";
         }
         echo " </td>\n              </tr>\n";
     }
     if (!$short) {
         if ($this->geniflags()) {
             $slice = GeniSlice::Lookup("geni-cm", $uuid);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">\n                                     <a href='{$url}'>{$slice_urn}</a></td>\n                              </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
             }
         } else {
             $slice = GeniSlice::LookupByExperiment("geni-sa", $this);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "sa");
                     echo "<tr>\n                                 <td>Geni Slice (SA): </td>\n                                 <td class=\"left\">\n                                      <a href='{$url}'>{$slice_urn}</a></td>\n                             </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (SA): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
                 $slice = GeniSlice::Lookup("geni-cm", $slice_hrn);
                 if ($slice) {
                     if (ISADMIN()) {
                         $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                         echo "<tr>\n                                     <td>Geni Slice (CM): </td>\n                                     <td class=\"left\">\n                                           <a href='{$url}'>{$slice_urn}</a></td>\n                                  </tr>\n";
                     } else {
                         echo "<tr>\n                                    <td>Geni Slice (SA): </td>\n                                    <td class=\"left\">{$slice_urn}</td>\n                                  </tr>\n";
                     }
                 }
             }
         }
     }
     echo "</table>\n";
 }
Example #2
0
 function Show($flags = 0)
 {
     $node_id = $this->node_id();
     $short = $flags & SHOWNODE_SHORT ? 1 : 0;
     $noperm = $flags & SHOWNODE_NOPERM ? 1 : 0;
     $query_result = DBQueryFatal("select n.*,na.*,r.vname,r.pid,r.eid,i.IP, " . "greatest(last_tty_act,last_net_act,last_cpu_act," . "last_ext_act) as last_act, " . "  t.isvirtnode,t.isremotenode,t.isplabdslice, " . "  r.erole as rsrvrole, pi.IP as phys_IP, loc.*, " . "  util.*,n.uuid as node_uuid, " . "  mi.IP as mngmnt_IP " . " from nodes as n " . "left join reserved as r on n.node_id=r.node_id " . "left join node_activity as na on " . "     n.node_id=na.node_id " . "left join node_types as t on t.type=n.type " . "left join interfaces as i on " . "     i.node_id=n.node_id and " . "     i.role='" . TBDB_IFACEROLE_CONTROL . "' " . "left join interfaces as pi on " . "     pi.node_id=n.phys_nodeid and " . "     pi.role='" . TBDB_IFACEROLE_CONTROL . "' " . "left join interfaces as mi on " . "     mi.node_id=n.node_id and " . "     mi.role='" . TBDB_IFACEROLE_MANAGEMENT . "' " . "left join location_info as loc on " . "     loc.node_id=n.node_id " . "left join node_utilization as util on " . "     util.node_id=n.node_id " . "where n.node_id='{$node_id}'");
     if (mysql_num_rows($query_result) == 0) {
         TBERROR("The node {$node_id} is not a valid nodeid!", 1);
     }
     $row = mysql_fetch_array($query_result);
     $phys_nodeid = $row["phys_nodeid"];
     $type = $row["type"];
     $vname = $row["vname"];
     $pid = $row["pid"];
     $eid = $row["eid"];
     $def_boot_osid = $row["def_boot_osid"];
     $def_boot_cmd_line = $row["def_boot_cmd_line"];
     $next_boot_osid = $row["next_boot_osid"];
     $temp_boot_osid = $row["temp_boot_osid"];
     $next_boot_cmd_line = $row["next_boot_cmd_line"];
     $rpms = $row["rpms"];
     $tarballs = $row["tarballs"];
     $startupcmd = $row["startupcmd"];
     $routertype = $row["routertype"];
     $eventstate = $row["eventstate"];
     $state_timestamp = $row["state_timestamp"];
     $allocstate = $row["allocstate"];
     $allocstate_timestamp = $row["allocstate_timestamp"];
     $op_mode = $row["op_mode"];
     $op_mode_timestamp = $row["op_mode_timestamp"];
     $IP = $row["IP"];
     $isvirtnode = $row["isvirtnode"];
     $isremotenode = $row["isremotenode"];
     $isplabdslice = $row["isplabdslice"];
     $ipport_low = $row["ipport_low"];
     $ipport_next = $row["ipport_next"];
     $ipport_high = $row["ipport_high"];
     $sshdport = $row["sshdport"];
     $last_act = $row["last_act"];
     $last_tty_act = $row["last_tty_act"];
     $last_net_act = $row["last_net_act"];
     $last_cpu_act = $row["last_cpu_act"];
     $last_ext_act = $row["last_ext_act"];
     $last_report = $row["last_report"];
     $rsrvrole = $row["rsrvrole"];
     $phys_IP = $row["phys_IP"];
     $mngmnt_IP = $row["mngmnt_IP"];
     $battery_voltage = $row["battery_voltage"];
     $battery_percentage = $row["battery_percentage"];
     $battery_timestamp = $row["battery_timestamp"];
     $boot_errno = $row["boot_errno"];
     $reserved_pid = $row["reserved_pid"];
     $inception = $row["inception"];
     $alloctime = $row["allocated"];
     $downtime = $row["down"];
     $uuid = $row["node_uuid"];
     if (!$def_boot_cmd_line) {
         $def_boot_cmd_line = "&nbsp;";
     }
     if (!$next_boot_cmd_line) {
         $next_boot_cmd_line = "&nbsp;";
     }
     if (!$rpms) {
         $rpms = "&nbsp;";
     }
     if (!$tarballs) {
         $tarballs = "&nbsp;";
     }
     if (!$startupcmd) {
         $startupcmd = "&nbsp;";
     } else {
         $startupcmd = CleanString($startupcmd);
     }
     if ($node_id != $phys_nodeid) {
         if (!($phys_this = Node::Lookup($phys_nodeid))) {
             TBERROR("Cannot map physical node {$phys_nodeid} to object", 1);
         }
     }
     if (!$short) {
         #
         # Location info.
         #
         if (isset($row["loc_x"]) && isset($row["loc_y"]) && isset($row["floor"]) && isset($row["building"])) {
             $floor = $row["floor"];
             $building = $row["building"];
             $room = $row["room"];
             $loc_x = $row["loc_x"];
             $loc_y = $row["loc_y"];
             $orient = $row["orientation"];
             $contact = $row["contact"];
             $email = $row["email"];
             $phone = $row["phone"];
             $query_result = DBQueryFatal("select * from floorimages " . "where scale=1 and " . "      floor='{$floor}' and " . "      building='{$building}'");
             if (mysql_num_rows($query_result)) {
                 $row = mysql_fetch_array($query_result);
                 if (isset($row["pixels_per_meter"]) && ($pixels_per_meter = $row["pixels_per_meter"]) != 0.0) {
                     $meters_x = sprintf("%.3f", $loc_x / $pixels_per_meter);
                     $meters_y = sprintf("%.3f", $loc_y / $pixels_per_meter);
                     if (isset($orient)) {
                         $orientation = sprintf("%.3f", $orient);
                     }
                 }
             }
         }
     }
     echo "<table border=2 cellpadding=0 cellspacing=2\n                 align=center>\n";
     echo "<tr>\n              <td>Node ID:</td>\n              <td class=left>{$node_id}</td>\n          </tr>\n";
     if ($isvirtnode) {
         if (strcmp($node_id, $phys_nodeid)) {
             echo "<tr>\n                      <td>Phys ID:</td>\n                      <td class=left>\n\t   \t          <a href='shownode.php3?node_id={$phys_nodeid}'>\n                             {$phys_nodeid}</a></td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         if ($vname) {
             echo "<tr>\n                      <td>Virtual Name:</td>\n                      <td class=left>{$vname}</td>\n                  </tr>\n";
         }
         if ($pid) {
             echo "<tr>\n                      <td>Project: </td>\n                      <td class=\"left\">\n                          <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Experiment:</td>\n                      <td><a href='showexp.php3?pid={$pid}&eid={$eid}'>\n                             {$eid}</a></td>\n                  </tr>\n";
         }
     }
     echo "<tr>\n              <td>Node Type:</td>\n              <td class=left>\n  \t          <a href='shownodetype.php3?node_type={$type}'>{$type}</td>\n          </tr>\n";
     $feat_result = DBQueryFatal("select * from node_features " . "where node_id='{$node_id}'");
     if (mysql_num_rows($feat_result) > 0) {
         $features = "";
         $count = 0;
         while ($row = mysql_fetch_array($feat_result)) {
             if ($count > 0 && $count % 2 == 0) {
                 $features .= "<br>";
             }
             $features .= " " . $row["feature"];
             $count += 1;
         }
         echo "<tr><td>Features:</td><td class=left>{$features}</td></tr>";
     }
     if (!$short && !$noperm) {
         echo "<tr>\n                  <td>Def Boot OS:</td>\n                  <td class=left>";
         SpitOSIDLink($def_boot_osid);
         echo "    </td>\n              </tr>\n";
         if ($eventstate) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $state_timestamp);
             echo "<tr>\n                     <td>EventState:</td>\n                     <td class=left>{$eventstate} ({$when})</td>\n                  </tr>\n";
         }
         if ($op_mode) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $op_mode_timestamp);
             echo "<tr>\n                     <td>Operating Mode:</td>\n                     <td class=left>{$op_mode} ({$when})</td>\n                  </tr>\n";
         }
         if ($allocstate) {
             $when = strftime("20%y-%m-%d %H:%M:%S", $allocstate_timestamp);
             echo "<tr>\n                     <td>AllocState:</td>\n                     <td class=left>{$allocstate} ({$when})</td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         #
         # Location info.
         #
         if (isset($building)) {
             echo "<tr>\n                      <td>Location (bldg/floor/room):</td>\n                      <td class=left>{$building}";
             if (isset($floor)) {
                 echo "/{$floor}";
             }
             if (isset($room)) {
                 echo "/{$room}";
             }
             echo "</td>\n                      </tr>\n";
         }
         if (isset($meters_x) && isset($meters_y)) {
             echo "<tr>\n                      <td>Location Coordinates:</td>\n                      <td class=left>x={$meters_x}, y={$meters_y} meters";
             if (isset($orientation)) {
                 echo " (o={$orientation} degrees)";
             }
             echo "</td>\n                  </tr>\n";
         }
         if (OPSGUY() && (isset($contact) || isset($email))) {
             $lcstr = "";
             if (isset($contact)) {
                 $lcstr .= "{$contact}:";
             }
             if (isset($email)) {
                 $lcstr .= " <a href='mailto:{$email}'>{$email}</a>";
             }
             if (isset($phone)) {
                 $lcstr .= " {$phone}";
             }
             echo "<tr>\n                      <td>Location Contact:</td>\n                      <td class=left>{$lcstr}\n                      </td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         #
         # We want the last login for this node, but only if its *after*
         # the experiment was created (or swapped in).
         #
         if ($lastnodeuidlogin = TBNodeUidLastLogin($node_id)) {
             $foo = $lastnodeuidlogin["date"] . " " . $lastnodeuidlogin["time"] . " " . "(" . $lastnodeuidlogin["uid"] . ")";
             echo "<tr>\n                      <td>Last Login:</td>\n                      <td class=left>{$foo}</td>\n                 </tr>\n";
         }
         if ($last_act) {
             echo "<tr>\n                      <td>Last Activity:</td>\n                      <td class=left>{$last_act}</td>\n                  </tr>\n";
             $idletime = $this->IdleTime();
             echo "<tr>\n                      <td>Idle Time:</td>\n                      <td class=left>{$idletime} hours</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Act. Report:</td>\n                      <td class=left>{$last_report}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last TTY Act.:</td>\n                      <td class=left>{$last_tty_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Net. Act.:</td>\n                      <td class=left>{$last_net_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last CPU Act.:</td>\n                      <td class=left>{$last_cpu_act}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Ext. Act.:</td>\n                      <td class=left>{$last_ext_act}</td>\n                  </tr>\n";
         }
     }
     if (!$short && !$noperm) {
         if (!$isvirtnode && !$isremotenode) {
             echo "<tr>\n                      <td>Def Boot Command&nbsp;Line:</td>\n                      <td class=left>{$def_boot_cmd_line}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Next Boot OS:</td>\n                      <td class=left>";
             if ($next_boot_osid) {
                 SpitOSIDLink($next_boot_osid);
             } else {
                 echo "&nbsp;";
             }
             echo "    </td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Next Boot Command Line:</td>\n                      <td class=left>{$next_boot_cmd_line}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Temp Boot OS:</td>\n                      <td class=left>";
             if ($temp_boot_osid) {
                 SpitOSIDLink($temp_boot_osid);
             } else {
                 echo "&nbsp;";
             }
             echo "    </td>\n                  </tr>\n";
         } elseif ($isvirtnode) {
             if (!$isplabdslice) {
                 echo "<tr>\n                          <td>IP Port Low:</td>\n                          <td class=left>{$ipport_low}</td>\n                      </tr>\n";
                 echo "<tr>\n                          <td>IP Port Next:</td>\n                          <td class=left>{$ipport_next}</td>\n                      </tr>\n";
                 echo "<tr>\n                          <td>IP Port High:</td>\n                          <td class=left>{$ipport_high}</td>\n                      </tr>\n";
             }
             echo "<tr>\n                      <td>SSHD Port:</td>\n                     <td class=left>{$sshdport}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Startup Command:</td>\n                  <td class=left>{$startupcmd}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>Tarballs:</td>\n                  <td class=left>{$tarballs}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>RPMs:</td>\n                  <td class=left>{$rpms}</td>\n              </tr>\n";
         echo "<tr>\n                  <td>Boot Errno:</td>\n                  <td class=left>{$boot_errno}</td>\n              </tr>\n";
         if (!$isvirtnode && !$isremotenode) {
             echo "<tr>\n                      <td>Router Type:</td>\n                      <td class=left>{$routertype}</td>\n                  </tr>\n";
         }
         if ($IP) {
             echo "<tr>\n                      <td>Control Net IP:</td>\n                      <td class=left>{$IP}</td>\n                  </tr>\n";
             if ($mngmnt_IP) {
                 echo "<tr>\n                          <td>Management IP:</td>\n                          <td class=left>{$mngmnt_IP}</td>\n                       </tr>\n";
             }
         } elseif ($phys_IP) {
             echo "<tr>\n                      <td>Physical IP:</td>\n                      <td class=left>{$phys_IP}</td>\n                  </tr>\n";
         }
         if ($rsrvrole) {
             echo "<tr>\n                      <td>Role:</td>\n                      <td class=left>{$rsrvrole}</td>\n                  </tr>\n";
         }
         if ($reserved_pid) {
             echo "<tr>\n                      <td>Reserved Pid:</td>\n                      <td class=left>\n                          <a href='showproject.php3?pid={$reserved_pid}'>\n                               {$reserved_pid}</a></td>\n                  </tr>\n";
         }
         if ($uuid) {
             echo "<tr>\n                      <td>UUID:</td>\n                      <td class=left>{$uuid}</td>\n                  </tr>\n";
         }
         #
         # Show battery stuff
         #
         if (isset($battery_voltage) && isset($battery_percentage)) {
             echo "<tr>\n    \t              <td>Battery Volts/Percent</td>\n\t\t      <td class=left>";
             printf("%.2f/%.2f ", $battery_voltage, $battery_percentage);
             if (isset($battery_timestamp)) {
                 echo "(" . date("m/d/y H:i:s", $battery_timestamp) . ")";
             }
             echo "    </td>\n\t\t  </tr>\n";
         }
         if ($isplabdslice) {
             $query_result = DBQueryFatal("select leaseend from plab_slice_nodes " . "where node_id='{$node_id}'");
             if (mysql_num_rows($query_result) != 0) {
                 $row = mysql_fetch_array($query_result);
                 $leaseend = $row["leaseend"];
                 echo "<tr>\n                     <td>Lease Expiration:</td>\n                     <td class=left>{$leaseend}</td>\n                 </tr>\n";
             }
         }
         if ($isremotenode) {
             if ($isvirtnode) {
                 $phys_this->ShowWideAreaNode(1);
             } else {
                 $this->ShowWideAreaNode(1);
             }
         }
         #
         # Show any auxtypes the node has
         #
         $query_result = DBQueryFatal("select type, count from node_auxtypes " . "where node_id='{$node_id}'");
         if (mysql_num_rows($query_result) != 0) {
             echo "<tr>\n                      <td align=center colspan=2>\n                      Auxiliary Types\n                      </td>\n                  </tr>\n";
             echo "<tr><th>Type</th><th>Count</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $type = $row["type"];
                 $count = $row["count"];
                 echo "<tr>\n    \t    \t          <td>{$type}</td>\n\t\t          <td class=left>{$count}</td>\n\t\t      </td>\n";
             }
         }
     }
     if (!$short) {
         #
         # Get interface info.
         #
         echo "<tr>\n                  <td align=center colspan=2>Interface Info</td>\n              </tr>\n";
         echo "<tr><th>Interface</th><th>Model; protocols</th>\n";
         $query_result = DBQueryFatal("select i.*,it.*,c.*,s.capval as channel " . "  from interfaces as i " . "left join interface_types as it on " . "     i.interface_type=it.type " . "left join interface_capabilities as c on " . "     i.interface_type=c.type and " . "     c.capkey='protocols' " . "left join interface_settings as s on " . "     s.node_id=i.node_id and s.iface=i.iface and " . "     s.capkey='channel' " . "where i.node_id='{$node_id}' and " . "      i.role='" . TBDB_IFACEROLE_EXPERIMENT . "'" . "order by iface");
         while ($row = mysql_fetch_array($query_result)) {
             $iface = $row["iface"];
             $type = $row["type"];
             $man = $row["manufacturer"];
             $model = $row["model"];
             $protocols = $row["capval"];
             $channel = $row["channel"];
             if (isset($channel)) {
                 $channel = " (channel {$channel})";
             } else {
                 $channel = "";
             }
             echo "<tr>\n                      <td>{$iface}:&nbsp; {$channel}</td>\n                      <td class=left>{$type} ({$man} {$model}; {$protocols})</td>\n                  </tr>\n";
         }
         #
         # Get subboss info.
         #
         echo "<tr>\n              <td align=center colspan=2>Subboss Info</td>\n            </tr>\n";
         echo "<tr><th>Service</th><th>Subboss Node ID</th>\n";
         $query_result = DBQueryFatal("select service,subboss_id from subbosses " . "where node_id ='{$node_id}' and disabled=0");
         while ($row = mysql_fetch_array($query_result)) {
             $service = $row["service"];
             $subboss = $row["subboss_id"];
             echo "<tr>\n                  <td>{$service}</td>\n                  <td class=left>{$subboss}</td>\n                 </tr>\n";
         }
         #
         # Switch info. Very useful for debugging.
         #
         if (!$noperm) {
             $query_result = DBQueryFatal("select i.*,w.* from interfaces as i " . "left join wires as w on i.node_id=w.node_id1 " . "   and i.card=w.card1 and i.port=w.port1 " . "where i.node_id='{$node_id}' and " . "      w.node_id1 is not null " . "order by iface");
             echo "<tr></tr><tr>\n                    <td align=center colspan=2>Switch Info</td>\n                  </tr>\n";
             echo "<tr><th>Iface:role &nbsp; card,port</th>\n                      <th>Switch &nbsp; card,port</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $iface = $row["iface"];
                 $role = $row["role"];
                 $card = $row["card1"];
                 $port = $row["port1"];
                 $switch = $row["node_id2"];
                 $switch_card = $row["card2"];
                 $switch_port = $row["port2"];
                 echo "<tr>\n                      <td>{$iface}:{$role} &nbsp; {$card},{$port}</td>\n                      <td class=left>" . "{$switch}: &nbsp; {$switch_card},{$switch_port}</td>\n                  </tr>\n";
             }
         }
     }
     #
     # Spit out node attributes
     #
     $query_result = DBQueryFatal("select attrkey,attrvalue from node_attributes " . "where node_id='{$node_id}' " . ($noperm ? "and attrkey!='root_password'" : ""));
     if (!$short && mysql_num_rows($query_result)) {
         echo "<tr>\n                    <td align=center colspan=2>Node Attributes</td>\n                  </tr>\n";
         echo "<tr><th>Attribute</th><th>Value</th>\n";
         while ($row = mysql_fetch_array($query_result)) {
             $attrkey = $row["attrkey"];
             $attrvalue = $row["attrvalue"];
             echo "<tr>\n                        <td>{$attrkey}</td>\n                        <td>{$attrvalue}</td>\n                      </td>\n";
         }
     }
     if (!($short || $noperm || $isvirtnode)) {
         $query_result = DBQueryFatal("select n.node_id,pid,eid,exptidx " . " from nodes as n " . "left join reserved as r on r.node_id=n.node_id " . "where n.phys_nodeid='{$node_id}' and " . "      n.node_id!=n.phys_nodeid");
         if (mysql_num_rows($query_result)) {
             echo "<tr>\n                       <td align=center colspan=2>Virtual/Sub Nodes</td>\n                      </tr>\n";
             echo "<tr><th>Node ID</th><th>Experiment</th>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $vnodeid = $row["node_id"];
                 $vpid = $row["pid"];
                 $veid = $row["eid"];
                 $vidx = $row["exptidx"];
                 $url1 = CreateURL("shownode", URLARG_NODEID, $vnodeid);
                 echo "<tr>\n                            <td><a href='{$url1}'>{$vnodeid}</a></td>\n";
                 if (isset($veid)) {
                     $url2 = CreateURL("showexp", URLARG_EID, $vidx);
                     echo "<td><a href='{$url2}'>{$vpid}/{$veid}</a></td>\n";
                 } else {
                     echo "<td>No Experiment</a></td>\n";
                 }
                 echo "</td>\n";
             }
         }
     }
     echo "</table>\n";
 }
include "defs.php3";
#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments
#
$optargs = OptionalPageArguments("sortby", PAGEARG_STRING);
#
# Standard Testbed Header
#
PAGEHEADER("Emulab Site List");
if (!($isadmin || OPSGUY() || STUDLY())) {
    USERERROR("Cannot view site list.", 1);
}
if (!isset($sortby)) {
    $sortby = "created";
}
$sortclause = "";
if ($sortby == "created") {
    $sortclause = "order by created";
} elseif ($sortby == "urn") {
    $sortclause = "order by urn";
} elseif ($sortby == "commonname") {
    $sortclause = "order by commonname";
} elseif ($sortby == "buildinfo") {
    $sortclause = "order by buildinfo";
} elseif ($sortby == "updated") {