Commit 169b0c65 authored by Leigh Stoller's avatar Leigh Stoller

Add "Show Me the NS File" stuff as per Mike's request.

parent fc17b22a
......@@ -9,12 +9,16 @@ package libdb;
use Exporter;
@ISA = "Exporter";
@EXPORT =
qw ( NODERELOADING_PID NODERELOADING_EID NODEDEAD_PID NODEDEAD_EID
NODEBOOTSTATUS_OKAY NODEBOOTSTATUS_FAILED NODEBOOTSTATUS_UNKNOWN
NODESTARTSTATUS_NOSTATUS PROJMEMBERTRUST_NONE PROJMEMBERTRUST_USER
PROJMEMBERTRUST_TRUSTED TBAdmin NodeAccessCheck ProjMember ExpLeader
MarkNodeDown SetNodeBootStatus OSFeatureSupported IsShelved
NodeidToExp UIDInfo DBQuery DBQueryFatal DBQueryWarn DBWarn DBFatal );
qw ( NODERELOADING_PID NODERELOADING_EID NODEDEAD_PID NODEDEAD_EID
NODEBOOTSTATUS_OKAY NODEBOOTSTATUS_FAILED NODEBOOTSTATUS_UNKNOWN
NODESTARTSTATUS_NOSTATUS PROJMEMBERTRUST_NONE PROJMEMBERTRUST_USER
PROJMEMBERTRUST_TRUSTED DBLIMIT_NSFILESIZE
TBAdmin NodeAccessCheck ProjMember ExpLeader MarkNodeDown
SetNodeBootStatus OSFeatureSupported IsShelved NodeidToExp
UIDInfo DBQuery DBQueryFatal DBQueryWarn DBWarn DBFatal DBQuoteSpecial
);
# Configure variables
my $TB = "@prefix@";
......@@ -55,6 +59,11 @@ sub PROJMEMBERTRUST_NONE() { 0; }
sub PROJMEMBERTRUST_USER() { 1; }
sub PROJMEMBERTRUST_TRUSTED() { 2; }
#
# We should list all of the DB limits.
#
sub DBLIMIT_NSFILESIZE() { (1024 * 16); }
#
# Test admin status. Optional argument is the UID or Name to test. If not
# provided, then test the current UID.
......@@ -453,7 +462,7 @@ sub DBWarn($)
#
# Same as above, but die after the warning.
#
# usage: DBFatal(char *message)
# usage: DBFatal(char *message);
#
sub DBFatal($)
{
......@@ -464,5 +473,19 @@ sub DBFatal($)
exit(1);
}
#
# Quote a string for DB insertion.
#
# usage: DBQuoteSpecial(char *string);
#
sub DBQuoteSpecial($)
{
my($string) = $_[0];
$string = $DB->quote($string);
return $string;
}
1;
......@@ -256,8 +256,11 @@ else {
#
# Done! Remove all trace from the DB.
#
DBQueryFatal("DELETE from experiments ".
"WHERE eid='$eid' and pid='$pid'");
DBQueryWarn("DELETE from experiments ".
"WHERE eid='$eid' and pid='$pid'");
DBQueryWarn("DELETE from nsfiles ".
"WHERE eid='$eid' and pid='$pid'");
print STDOUT "Termination Success\n";
......
......@@ -303,6 +303,25 @@ if ($infodir =~ /^([-\@\w.]+)$/) {
}
}
#
# Shove a copy of the NS file into the DB to make Mike happy.
#
$nsfile_string = `cat $nsfile`;
if ($nsfile_string) {
$nsfile_string = $DB->quote($nsfile_string);
$DB->query("delete from nsfiles WHERE eid='$eid' and pid='$pid'");
#
# I could strlen check the string, but the webserver has a limit,
# plus the DB is going to truncate it if its longer. Doing it here
# would be a third (call it redundant) check.
#
$DB->query("insert into nsfiles (pid, eid, nsfile) ".
"VALUES('$pid', '$eid', $nsfile_string)");
}
#
# In batch mode, just exit without sending email. Remove tempns file!
#
......
......@@ -55,16 +55,22 @@ if (!$isadmin) {
}
}
# Terminate option.
echo "<p><center>
Do you want to terminate this experiment?
<A href='endexp.php3?exp_pideid=$exp_pid\$\$$exp_eid'>Yes</a>
</center><br>\n";
#
# Dump experiment record.
#
SHOWEXP($exp_pid, $exp_eid);
# Terminate option.
# NS File option
echo "<p><center>
Do you want to terminate this experiment?
<A href='endexp.php3?exp_pideid=$exp_pid\$\$$exp_eid'>Yes</a>
</center>\n";
Do you want to see the
<A href='shownsfile.php3?exp_pideid=$exp_pid\$\$$exp_eid'>NS file?</a>
</center>\n";
#
# Dump the node information.
......
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Show me the NS File");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($exp_pideid) ||
strcmp($exp_pideid, "") == 0) {
USERERROR("You must provide an experiment ID.", 1);
}
#
# First get the project (PID) from the form parameter, which came in
# as <pid>$$<eid>.
#
$exp_eid = strstr($exp_pideid, "$$");
$exp_eid = substr($exp_eid, 2);
$exp_pid = substr($exp_pideid, 0, strpos($exp_pideid, "$$", 0));
#
# Check to make sure thats this is a valid PID/EID tuple.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM experiments WHERE ".
"eid=\"$exp_eid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The experiment $exp_eid is not a valid experiment ".
"in project $exp_pid.", 1);
}
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
if (!$isadmin) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("You are not a member of Project $exp_pid for ".
"Experiment: $exp_eid.", 1);
}
}
$query_result = mysql_db_query($TBDBNAME,
"SELECT nsfile from nsfiles where pid='$exp_pid' and eid='$exp_eid'");
if (!$query_result ||
mysql_num_rows($query_result) == 0) {
USERERROR("There is no stored NS file for $exp_pid/$exp_eid", 1);
}
$row = mysql_fetch_array($query_result);
$nsfile = $row[nsfile];
echo "<XMP>$nsfile</XMP>\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