Commit 97d056f0 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Updates to web pages to reflect changes to the experiements table;

EIDs no longer concatenate the PID into the string, but instead there
are independent PID/EID fields to make experiments unique. Also, there
were changes to the tb* scripts.
parent 802ecc9a
......@@ -54,24 +54,25 @@ LOGGEDINORDIE($uid);
#
# Current policy is to prefix the EID with the PID. Make sure it is not
# too long for the database. PID is 12, and the max is 32, so the user
# cannot have provided one more than 19, since we add a hyphen in there.
# cannot have provided one more than 19, since other parts of the system
# may concatenate them together with a hyphen.
#
# XXX Note CONSTANT in expression!
#
$exp_eid = $exp_pid . $exp_id;
if (strlen($exp_id) > 19) {
USERERROR("The experiment name \"$exp_id\" is too long! ".
"Please select another.", 1);
}
#
# Make sure the experiment ID does not already exist.
# Make sure the PID/EID tuple does not already exist in the database.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE eid=\"$exp_eid\"");
"SELECT eid FROM experiments ".
"WHERE eid=\"$exp_id\" and pid=\"$exp_pid\"");
if ($row = mysql_fetch_row($query_result)) {
USERERROR("The experiment name \"$exp_eid\" you have chosen is already ".
"in use. Please select another.", 1);
USERERROR("The experiment name \"$exp_id\" you have chosen is already ".
"in use in project $exp_pid. Please select another.", 1);
}
#
......@@ -95,24 +96,23 @@ if (strcmp($trust, "group_root") && strcmp($trust, "local_root")) {
#
# We are going to write out the NS file to a subdir of the testbed
# directory. We create a subdir in there, and stash the ns file for
# processing by tbrun. We generate a name from the experiment ID,
# which we know to be unique cause we tested that above. Later, when
# the experiment is ended, the directory will be deleted.
# directory. The name of this directory is <pid>-<eid>, and we stash
# the <eid>.ns file in there. We then run a wrapper script as:
#
# Note that the filenames are all wierd. The tbsetup scripts do very odd
# things with the name, prepending the "project" to the filename.
# tbdoit <path to directory> <pid> <eid> <eid>.ns
#
# Later, when the experiment is ended, the directory will be deleted.
#
# There is similar path stuff in endexp.php3. Be sure to sync that up
# if you change things here.
#
# No need to tell me how bogus this is.
#
$dirname = "$TBWWW_DIR"."$TBNSSUBDIR"."/"."$exp_eid";
$dirname = "$TBWWW_DIR"."$TBNSSUBDIR" . "/" . "$exp_pid" . "-" . "$exp_id";
$nsname = "$dirname" . "/" . "$exp_id" . ".ns";
$irname = "$dirname" . "/" . "$exp_eid" . ".ir";
$irname = "$dirname" . "/" . "$exp_id" . ".ir";
$repname = "$dirname" . "/" . "$exp_id" . ".report";
$logname = "$dirname" . "/" . "$exp_eid" . ".log";
$logname = "$dirname" . "/" . "$exp_id" . ".log";
$assname = "$dirname" . "/" . "assign" . ".log";
if (! mkdir($dirname, 0777)) {
......@@ -136,7 +136,7 @@ echo "</center>";
#
$output = array();
$retval = 0;
$result = exec("$TBBIN_DIR/tbdoit $dirname $exp_pid $exp_id.ns",
$result = exec("$TBBIN_DIR/tbdoit $dirname $exp_pid $exp_id $exp_id.ns",
$output, $retval);
if ($retval) {
echo "<br><br><h2>
......@@ -200,16 +200,16 @@ $query_result = mysql_db_query($TBDBNAME,
"INSERT INTO experiments ".
"(eid, pid, expt_created, expt_expires, expt_name, ".
"expt_head_uid, expt_start, expt_end) ".
"VALUES ('$exp_eid', '$exp_pid', '$exp_created', '$exp_expires', ".
"VALUES ('$exp_id', '$exp_pid', '$exp_created', '$exp_expires', ".
"'$exp_name', '$uid', '$exp_start', '$exp_end')");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error adding new experiment $exp_eid: $err\n", 1);
TBERROR("Database Error adding new experiment $exp_id: $err\n", 1);
}
echo "<center><br>";
echo "<h2>Experiment Configured!<br>";
echo "The ID for your experiment is $exp_eid<br>";
echo "The ID for your experiment in project $exp_pid is $exp_id<br>";
echo "Here is a summary of the nodes that were allocated<br>";
echo "</h2></center><br>";
......@@ -218,7 +218,7 @@ echo "</h2></center><br>";
#
$fp = fopen($repname, "r");
if (! $fp) {
TBERROR("Error opening report file for experiment: $exp_eid\n", 1);
TBERROR("Error opening report file for experiment: $exp_id\n", 1);
}
$summary = "";
echo "<XMP>";
......@@ -231,10 +231,10 @@ echo "</XMP>\n";
#
# Lets generate a mail message for now so that we can see whats happening.
#
if (1) {
if (0) {
mail($TBMAIL_WWW, "TESTBED: New Experiment Created",
"User: $uid\n".
"EID: $exp_eid\n".
"EID: $exp_id\n".
"PID: $exp_pid\n".
"Name: $exp_name\n".
"Created: $exp_created\n".
......
......@@ -22,29 +22,39 @@ LOGGEDINORDIE($uid);
#
# Must provide the EID!
#
if (!isset($exp_eid) ||
strcmp($exp_eid, "") == 0) {
if (!isset($exp_pideid) ||
strcmp($exp_pideid, "") == 0) {
USERERROR("The experiment ID was not provided!", 1);
}
#
# Verify that this uid is a member of the project for the experiment.
# First get the project (PID) from the form parameter, which came in
# as <pid>$$<eid>.
#
# First get the project (PID) for the experiment (EID) requested.
# Then check to see if the user (UID) is a member of that PID.
$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\"");
if (($exprow = mysql_fetch_array($query_result)) == 0) {
USERERROR("The experiment $exp_eid is not a valid experiment.", 1);
"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);
}
$pid = $exprow[pid];
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$pid\"");
"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 the Project for Experiment: $exp_eid.",
1);
USERERROR("You are not a member of Project $exp_pid for ".
"Experiment: $exp_eid.", 1);
}
#
......@@ -56,11 +66,10 @@ if (mysql_num_rows($query_result) == 0) {
#
# No need to tell me how bogus this is.
#
$exp_id = substr($exp_eid, strlen($pid));
$dirname = "$TBWWW_DIR"."$TBNSSUBDIR"."/"."$exp_eid";
$nsname = "$dirname" . "/" . "$exp_id" . ".ns";
$dirname = "$TBWWW_DIR"."$TBNSSUBDIR" . "/" . "$exp_pid" . "-" . "$exp_eid";
$nsname = "$dirname" . "/" . "$exp_eid" . ".ns";
$irname = "$dirname" . "/" . "$exp_eid" . ".ir";
$repname = "$dirname" . "/" . "$exp_id" . ".report";
$repname = "$dirname" . "/" . "$exp_eid" . ".report";
$logname = "$dirname" . "/" . "$exp_eid" . ".log";
$assname = "$dirname" . "/" . "assign" . ".log";
......@@ -82,7 +91,7 @@ echo "</center>";
#
$output = array();
$retval = 0;
$result = exec("$TBBIN_DIR/tbstopit $dirname $exp_eid.ir",
$result = exec("$TBBIN_DIR/tbstopit $dirname $exp_pid $exp_eid $exp_eid.ir",
$output, $retval);
if ($retval) {
echo "<br><br><h2>
......@@ -118,10 +127,11 @@ if (file_exists($dirname))
# From the database too!
#
$query_result = mysql_db_query($TBDBNAME,
"DELETE FROM experiments WHERE eid='$exp_eid'");
"DELETE FROM experiments WHERE eid='$exp_eid' and pid=\"$exp_pid\"");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error deleting experiment $exp_eid: $err\n", 1);
TBERROR("Database Error deleting experiment $exp_eid ".
"in project $exp_pid: $err\n", 1);
}
echo "<center><br>";
......
......@@ -33,6 +33,26 @@ if (mysql_num_rows($groupmemb_result) == 0) {
"show any experiment information", 1);
}
#
# Lets see if the user is even part of any experiements before
# presenting a bogus option list.
#
$experiments = "";
while ($grprow = mysql_fetch_array($groupmemb_result)) {
$pid = $grprow[gid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
$eid = $exprow[eid];
$experiments = "$experiments " .
"<option value=\"$pid\$\$$eid\">$pid/$eid</option>\n";
}
}
if (strcmp($experiments, "") == 0) {
USERERROR("There are no experiments running in any of the projects ".
"you are a member of.", 1);
}
?>
<center>
......@@ -44,23 +64,20 @@ you are a member of.</h2>
<?php
echo "<form action=\"endexp.php3?$uid\" method=\"post\">";
echo "<tr>
<td align='center'>Project/Experiment</td>
</tr>\n";
echo "<tr></tr>";
echo "<tr></tr>";
#
# Suck the current info out of the database and display a list of
# experiments as an option list.
#
echo "<tr>";
echo " <td><select name=\"exp_eid\">";
while ($grprow = mysql_fetch_array($groupmemb_result)) {
$pid = $grprow[gid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
$eid = $exprow[eid];
echo "<option value=\"$eid\">$eid</option>\n";
}
}
echo " </select>";
echo " <td><select name=\"exp_pideid\">";
echo " $experiments";
echo " </select>";
echo " </td>
</tr>\n";
......
......@@ -35,26 +35,41 @@ if (($row = mysql_fetch_row($query_result)) == 0) {
USERERROR("You do not appear to have an account!", 1);
}
if (!isset($exp_pideid) ||
strcmp($exp_pideid, "") == 0) {
USERERROR("You must provide an experiment ID.", 1);
}
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
# 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));
#
# First get the project (PID) for the experiment (EID) requested.
# Then check to see if the user (UID) is a member of that PID.
# 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\"");
if (($exprow = mysql_fetch_array($query_result)) == 0) {
USERERROR("The experiment $exp_eid is not a valid experiment.", 1);
"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);
}
$pid = $exprow[pid];
$exprow = mysql_fetch_array($query_result);
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$pid\"");
"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 the Project for Experiment: $exp_id.", 1);
USERERROR("You are not a member of Project $exp_pid for ".
"Experiment: $exp_eid.", 1);
}
?>
<center>
......@@ -63,13 +78,13 @@ if (mysql_num_rows($query_result) == 0) {
<?php
$exp_expires = $row[expt_expires];
$exp_name = $row[expt_name];
$exp_created = $row[expt_created];
$exp_start = $row[expt_start];
$exp_end = $row[expt_end];
$exp_created = $row[expt_created];
$exp_head = $row[expt_head_uid];
$exp_expires = $exprow[expt_expires];
$exp_name = $exprow[expt_name];
$exp_created = $exprow[expt_created];
$exp_start = $exprow[expt_start];
$exp_end = $exprow[expt_end];
$exp_created = $exprow[expt_created];
$exp_head = $exprow[expt_head_uid];
#
# Generate the table.
......@@ -86,7 +101,7 @@ echo "<tr>
echo "<tr>
<td>Project: </td>
<td class=\"left\">$pid</td>
<td class=\"left\">$exp_pid</td>
</tr>\n";
echo "<tr>
......
......@@ -62,7 +62,7 @@ while ($grprow = mysql_fetch_array($groupmemb_result)) {
while ($exprow = mysql_fetch_array($exp_result)) {
$eid = $exprow[eid];
$experiments = "$experiments " .
"<option value=\"$eid\">$eid</option>\n";
"<option value=\"$pid\$\$$eid\">$pid/$eid</option>\n";
}
}
if (strcmp($experiments, "") == 0) {
......@@ -81,13 +81,18 @@ you are a member of.</h2>
<?php
echo "<form action=\"showexp.php3?$uid\" method=\"post\">";
echo "<tr>
<td align='center'>Project/Experiment</td>
</tr>\n";
echo "<tr></tr>";
echo "<tr></tr>";
#
# Suck the current info out of the database and display a list of
# experiments as an option list.
#
echo "<tr>";
echo " <td><select name=\"exp_eid\">";
echo " <td><select name=\"exp_pideid\">";
echo " $experiments";
echo " </select>";
echo " </td>
......
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