Commit 3f3c7f40 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Allow experiments to be created without an NS file. Deleted as well.

This just adds and deletes the database field entries (experiments table)
so that other things will work correctly.
parent d656b7e5
......@@ -33,8 +33,6 @@ if (mysql_num_rows($query_result) == 0) {
}
?>
<br><br><center><h3>Still under Construction!</h3></center>
<table align="center" border="1">
<tr>
<td align="center" colspan="2">
......@@ -81,7 +79,7 @@ echo " </td>
# XXX Note CONSTANT in expression!
#
echo "<tr>
<td>*Name<br>(will be prefixed by project name):</td>
<td>*Name (no blanks):</td>
<td><input type=\"text\" name=\"exp_id\"
size=\"19\" maxlength=\"19\">
</td>
......
......@@ -38,11 +38,6 @@ if (!isset($exp_created) ||
strcmp($exp_created, "") == 0) {
$formerror = "Experiment Created";
}
if (!isset($exp_nsfile) ||
strcmp($exp_nsfile, "") == 0 ||
strcmp($exp_nsfile, "none") == 0) {
$formerror = "Your NS file";
}
if ($formerror != "No Error") {
USERERROR("Missing field; Please go back and fill out ".
"the \"$formerror\" field!", 1);
......@@ -66,6 +61,16 @@ if (strlen($exp_id) > 19) {
"Please select another.", 1);
}
#
# I'm going to allow shell experiments to be created (No NS file).
#
$nonsfile = 0;
if (!isset($exp_nsfile) ||
strcmp($exp_nsfile, "") == 0 ||
strcmp($exp_nsfile, "none") == 0) {
$nonsfile = 1;
}
#
# Make sure the PID/EID tuple does not already exist in the database.
#
......@@ -96,6 +101,42 @@ if (strcmp($trust, "group_root") && strcmp($trust, "local_root")) {
"cannot begin an experiment in that project.", 1);
}
#
# At this point enter the exp_id into the database so that it shows up as
# valid when the tb scripts run. We need to remove the entry if any of
# this fails!
#
$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_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_id: $err\n", 1);
}
#
# If an experiment "shell" give some warm fuzzies and be done with it.
# The user us responsible for running the tb scripts on his/her own!
# The user will need to come back and terminate the experiment though
# to clear it out of the database.
#
if ($nonsfile) {
echo "<center><br>
<h2>Experiment Configured!<br>
The ID for your experiment in project $exp_pid is $exp_id<br>
Since you did not provide an NS script, no nodes have been
allocated.<br> You must log in and run the tbsetup scripts
yourself.
</h2></center><br>\n";
echo "</body>
</html>\n";
die("");
}
#
# We are going to write out the NS file to a subdir of the testbed
# directory. The name of this directory is <pid>-<eid>, and we stash
......@@ -125,27 +166,6 @@ if (! copy($exp_nsfile, "$nsname")) {
TBERROR("Copying NS file for experiment into $dirname.", 1);
}
#
# So, that went okay. At this point enter the exp_id into the database
# so that it shows up as valid when the tb scripts run. We need to remove
# the entry if any of this fails!
#
$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_id', '$exp_pid', '$exp_created', '$exp_expires', ".
"'$exp_name', '$uid', '$exp_start', '$exp_end')");
if (! $query_result) {
if (! $mydebug) {
unlink("$nsname");
rmdir("$dirname");
}
$err = mysql_error();
TBERROR("Database Error adding new experiment $exp_id: $err\n", 1);
}
echo "<center><br>";
echo "<h3>Setting up experiment. This may take a few minutes ...</h3>";
echo "</center>";
......
......@@ -74,7 +74,33 @@ $logname = "$dirname" . "/" . "$exp_eid" . ".log";
$assname = "$dirname" . "/" . "assign" . ".log";
#
# Make sure the experiment directory exists before continuing.
# Check to see if the experiment directory exists before continuing.
# We will allow experiments to be deleted even without the files
# describing it, since in some cases the user is handling that part on
# his/her own.
#
if (! file_exists($dirname)) {
$query_result = mysql_db_query($TBDBNAME,
"DELETE FROM experiments WHERE eid='$exp_eid' and pid=\"$exp_pid\"");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error deleting experiment $exp_eid ".
"in project $exp_pid: $err\n", 1);
}
echo "<center><br><h2>
Experiment $exp_pid Terminated!<br>
Since there was no IR file to work from, the EID has been removed,
<br>but you will need to make sure the nodes are released yourself.
</h2></center><br>";
echo "</body>
</html>\n";
die("");
}
#
# By this point, the IR file must exist to go on.
#
if (! file_exists($irname)) {
TBERROR("IR file $irname for experiment $exp_eid does not exist!\n", 1);
......@@ -135,7 +161,7 @@ if (! $query_result) {
}
echo "<center><br>";
echo "<h2>Experiment Terminated! Thanks!<br>";
echo "<h2>Experiment $exp_pid Terminated!<br>";
echo "</h2></center><br>";
?>
......
......@@ -99,9 +99,8 @@ if (isset($uid)) {
Begin an Experiment</A>\n";
echo "<p><A href='endexp_form.php3?$uid'>
End an Experiment</A>\n";
# Every active user can do these options.
echo "<p><A href='showexp_form.php3?$uid'>
Show experiment information</A>\n";
Experiment Information</A>\n";
echo "<p><A href='modusr_form.php3?$uid'>
Update user information</A>\n";
echo "<p><A href='reserved.php3'>
......
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