Commit b4648c4e authored by Robert Ricci's avatar Robert Ricci
Browse files

Add a function to showstuff.php3 to display all experiments using a

given OSID, and include this view on the image and osinfo pages.
parent e95dfe4d
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -64,6 +64,42 @@ SUBMENUEND();
#
SHOWIMAGEID($imageid, 0);
echo "<br>\n";
#
# Show experiments using this image - we have to handle all four partitions.
# Also we don't put OSIDs directly into the virt_nodes table, so we have to
# get the pid and osname for the image, and use that to look into the virt_nodes
# table.
#
$query_result = DBQueryFatal("select part1_osid, part2_osid, " .
"part3_osid, part4_osid from images where imageid='$imageid'");
if (mysql_num_rows($query_result) != 1) {
USERERROR("Error getting partition information for $imageid.", 1);
}
$row = mysql_fetch_array($query_result);
$parts = array($row["part1_osid"], $row["part2_osid"],
$row["part3_osid"], $row["part4_osid"]);
foreach ($parts as $osid) {
if ($osid) {
echo "<h3 align='center'>Experiments using OS ";
SPITOSINFOLINK($osid);
echo "</h3>\n";
$query_result =
DBQueryFatal("select pid, osname from os_info where osid='$osid'");
if (mysql_num_rows($query_result) != 1) {
echo "<h4>Error getting os_info for $osid!</h4>\n";
continue;
}
$row = mysql_fetch_array($query_result);
SHOWOSIDEXPTS($row["pid"],$row["osname"],$uid);
}
}
SUBPAGEEND();
#
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -59,6 +59,16 @@ SUBMENUEND();
#
SHOWOSINFO($osid);
#
# Show experiments using this OS
#
$query_result =
DBQueryFatal("select pid, osname from os_info where osid='$osid'");
$row = mysql_fetch_array($query_result);
echo "<h3 align='center'>Experiments using this OS</h3>\n";
SHOWOSIDEXPTS($row["pid"],$row["osname"],$uid);
SUBPAGEEND();
#
......
......@@ -1510,6 +1510,72 @@ function SHOWIMAGEID($imageid, $edit, $isadmin = 0) {
echo "</table>\n";
}
#
# Show all experiments using a particular OSID
#
function SHOWOSIDEXPTS($pid, $osname, $uid) {
global $TBOPSPID;
global $TB_EXPT_READINFO;
#
# Due to the funny way we handle 'global' images in the emulab-ops project,
# we have to treat its images specially - namely, we have to make sure
# there is not an osname in that project, which takes priority over the
# global ones
#
if ($pid == $TBOPSPID) {
$query_result = DBQueryFatal("select distinct v.pid, v.eid, e.state " .
"from virt_nodes as v left join os_info as o on " .
" v.osname=o.osname and v.pid=o.pid ".
"left join experiments as e on v.pid=e.pid and v.eid=e.eid " .
"where v.osname='$osname' and o.osname is NULL " .
"order by v.pid, v.eid, e.state");
} else {
$query_result = DBQueryFatal("select distinct v.pid, v.eid, e.state " .
"from virt_nodes as v left join experiments as e " .
"on v.pid=e.pid and v.eid=e.eid " .
"where v.pid='$pid' and v.osname='$osname' " .
"order by v.pid, v.eid, e.state");
}
if (mysql_num_rows($query_result) == 0) {
echo "<h4 align='center'>No experiments are using this OS</h3>";
} else {
echo "<table align=center border=1>\n";
echo " <tr>
<th>PID</th>
<th>EID</th>
<th>State</th>
</tr>\n";
while($row = mysql_fetch_array($query_result)) {
$pid = $row[0];
$eid = $row[1];
$state = $row[2];
#
# Gotta make sure that the user actually has the right to see this
# experiment - summarize all the experiments that he/she can't see
# at the bottom
#
if (!TBExptAccessCheck($uid,$pid,$eid,$TB_EXPT_READINFO)) {
$other_exps++;
continue;
echo "Not supposed to read!\n";
}
echo "<tr>\n";
echo " <td><a href='showproject.php3?pid=$pid'>$pid</td>\n";
echo " <td><a href='showexp.php3?pid=$pid&eid=$eid'>$eid</td>\n";
echo " <td>$state</td>\n";
echo "</tr>\n";
}
if ($other_exps) {
echo "<tr><td colspan=3>$other_exps experiments in other projects</td></tr>\n";
}
echo "</table>\n";
}
}
#
# Show node record.
#
......
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