Commit daacc1c7 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Unify batch experiment create with regular experiment. They were

already 99 percent the same, so no need for a different form and a
processing page. Just add a checkbox and footnote on regular page.
parent 9c4b544e
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Creating a Batch Mode Experiment");
$mydebug = 0;
#
# First off, sanity check the form to make sure all the required fields
# were provided. I do this on a per field basis so that we can be
# informative. Be sure to correlate these checks with any changes made to
# the project form.
#
if (!isset($exp_pid) ||
strcmp($exp_pid, "") == 0) {
FORMERROR("Select Project");
}
if (!isset($exp_id) ||
strcmp($exp_id, "") == 0) {
FORMERROR("Experiment Name");
}
if (!isset($exp_name) ||
strcmp($exp_name, "") == 0) {
FORMERROR("Experiment Description");
}
if (isset($exp_swappable)) {
if (strcmp($exp_swappable, "")) {
unset($exp_swappable);
}
elseif (strcmp($exp_swappable, "Yep")) {
USERERROR("Invalid argument for Swappable.", 1);
}
}
if (isset($exp_priority) &&
strcmp($exp_priority, "low") && strcmp($exp_priority, "high")) {
USERERROR("Invalid argument for Priority.", 1);
}
#
# Only known and logged in users can begin experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Database limits
#
if (strlen($exp_id) > $TBDB_EIDLEN) {
USERERROR("The experiment name \"$exp_id\" is too long! ".
"Please select another.", 1);
}
#
# Certain of these values must be escaped or otherwise sanitized.
#
$exp_name = addslashes($exp_name);
#
# Not allowed to specify both a local and an upload!
#
$speclocal = 0;
$specupload = 0;
if (isset($exp_localnsfile) && strcmp($exp_localnsfile, "")) {
$speclocal = 1;
}
if (isset($exp_nsfile) && strcmp($exp_nsfile, "") &&
strcmp($exp_nsfile, "none")) {
$specupload = 1;
}
if (!$speclocal && !$specupload) {
USERERROR("You must supply either NS file name (local or remote)", 1);
}
if ($speclocal && $specupload) {
USERERROR("You may not specify both an uploaded NS file and an ".
"NS file that is located on the Emulab server", 1);
}
if (!$specupload && strcmp($exp_nsfile_name, "")) {
#
# Catch an invalid filename.
#
USERERROR("The NS file '$exp_nsfile_name' does not appear to be a ".
"valid filename. Please go back and try again.", 1);
}
if ($speclocal) {
#
# No way to tell from here if this file actually exists, since
# the web server runs as user nobody. The startexp script checks
# for the file before going to ground, so the user will get immediate
# feedback if the filename is bogus.
#
# Do not allow anything outside of /users or /proj. I do not think there
# is a security worry, but good to enforce it anyway.
#
if (! ereg("^$TBPROJ_DIR/.*" ,$exp_localnsfile) &&
! ereg("^$TBUSER_DIR/.*" ,$exp_localnsfile)) {
USERERROR("You must specify a server resident in file in either ".
"$TBUSER_DIR/ or $TBPROJ_DIR/", 1);
}
$nsfile = $exp_localnsfile;
}
elseif ($specupload) {
#
# XXX
# Set the permissions on the NS file so that the scripts can get to it.
# It is owned by nobody, and most likely protected. This leaves the
# script open for a short time. A potential security hazard we should
# deal with at some point.
#
chmod($exp_nsfile, 0666);
$nsfile = $exp_nsfile;
}
#
# Make sure the PID/EID tuple does not already exist in the database.
#
$query_result =
DBQueryFatal("SELECT eid FROM experiments ".
"WHERE eid='$exp_id' and pid='$exp_pid'");
if (mysql_num_rows($query_result)) {
USERERROR("The experiment name '$exp_id' you have chosen is already ".
"in use in project $exp_pid. Please select another.", 1);
}
#
# Check group. If none specified, then use default group.
#
if (!isset($exp_gid) ||
strcmp($exp_gid, "") == 0) {
$exp_gid = $exp_pid;
}
if (!TBValidGroup($exp_pid, $exp_gid)) {
USERERROR("No such group $exp_gid in project $exp_gid!", 1);
}
#
# Convert Priority and Swappable params to arguments to script.
#
if (isset($exp_swappable)) {
$exp_swappable = "-s";
}
else {
$exp_swappable = "";
}
if (!isset($exp_priority) || strcmp($exp_priority, "high") == 0) {
$exp_priority = "-n high";
}
else {
$exp_priority = "-n low";
}
#
# Verify permissions.
#
if (! TBProjAccessCheck($uid, $exp_pid, $exp_gid, $TB_PROJECT_CREATEEXPT)) {
USERERROR("You do not have permission to begin a batch experiment in ".
"in Project/Group $exp_pid/$exp_gid!", 1);
}
#
# We need the unix gid for the group for running the scripts below.
#
TBGroupUnixInfo($exp_pid, $exp_gid, $unix_gid, $unix_name);
echo "<center><br>";
echo "<h2>Starting batch experiment setup. Please wait a moment ...
</h2></center>";
flush();
#
# Run the scripts. We use a script wrapper to deal with changing
# to the proper directory and to keep most of these details out
# of this.
#
$output = array();
$retval = 0;
$last = time();
$result = exec("$TBSUEXEC_PATH $uid $unix_gid ".
"webbatchexp -x \"$exp_expires\" -E \"$exp_name\" ".
"$exp_priority $exp_swappable ".
"-p $exp_pid -g $exp_gid -e $exp_id $nsfile",
$output, $retval);
if ($retval) {
echo "<br><br><h2>
Setup Failure($retval): Output as follows:
</h2>
<br>
<XMP>\n";
for ($i = 0; $i < count($output); $i++) {
echo "$output[$i]\n";
}
echo "</XMP>\n";
PAGEFOOTER();
die("");
}
echo "<br><br>";
echo "<h2>
Experiment `$exp_id' in project `$exp_pid' has been batched!<br><br>
Your experiment will be run when enough resources become available.
This might happen immediately, or it may take hours or days.
You will be notified via email when the experiment has been run.
If you do not receive email notification within a reasonable amount
of time, please contact $TBMAILADDR.
</h2>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Create a Batch Experiment");
#
# Only known and logged in users can begin experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# See what projects the uid can create experiments in. Must be at least one.
#
$projlist = TBProjList($uid, $TB_PROJECT_CREATEEXPT);
if (! count($projlist)) {
USERERROR("You do not appear to be a member of any Projects in which ".
"you have permission to create new experiments.", 1);
}
?>
<center>
<h2>For information on <i>Batch Mode</i>, please take a look at the
<a href="tutorial/tutorial.php3#BatchMode">Emulab Tutorial</a></h2>
</center>
<table align="center" border="1">
<tr>
<td align="center" colspan="3">
<em>(Fields marked with * are required)</em>
</td>
</tr>
<?php
echo "<form enctype=\"multipart/form-data\"
action=\"batchexp.php3\" method=\"post\">\n";
#
# Select Project
#
echo "<tr>
<td colspan=2>*Select Project:</td>";
echo " <td><select name=\"exp_pid\">";
for ($i = 0; $i < count($projlist); $i++) {
$project = $projlist[$i];
echo "<option value=\"$project\">$project</option>\n";
}
echo " </select>";
echo " </td>
</tr>\n";
#
# Experiment ID and Long Name:
#
# Note DB max length.
#
echo "<tr>
<td colspan=2>*Name (no blanks):</td>
<td><input type=\"text\" name=\"exp_id\"
size=$TBDB_EIDLEN maxlength=$TBDB_EIDLEN>
</td>
</tr>\n";
echo "<tr>
<td colspan=2>*Description:</td>
<td><input type=\"text\" name=\"exp_name\" size=\"40\">
</td>
</tr>\n";
#
# NS file upload.
#
echo "<tr>
<td rowspan>*Your NS file: &nbsp</td>
<td rowspan><center>Upload (20K max)<br>
<br>
Or<br>
<br>
On Server (/proj or /users)
</center></td>
<td rowspan>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"20000\">
<input type=\"file\" name=\"exp_nsfile\" size=\"30\">
<br>
<br>
<input type=\"text\" name=\"exp_localnsfile\" size=\"40\">
</td>
</tr>\n";
#
# Expires.
#
$utime = time();
$year = date("Y", $utime);
$month = date("m", $utime);
$thismonth = $month++;
if ($month > 12) {
$month -= 12;
$month = "0".$month;
}
$rest = date("d H:i:s", $utime);
echo "<tr>
<td colspan=2>Expiration date:</td>
<td><input type=\"text\" value=\"$year:$month:$rest\"
name=\"exp_expires\"></td>
</tr>\n";
echo "<tr>
<td colspan=2>Swappable?[<b>1</b>]:</td>
<td><input type=checkbox name=exp_swappable value=Yep> Yes</td>
</tr>\n";
echo "<tr>
<td colspan=2>Priority[<b>2</b>]:</td>
<td><input type=radio name=exp_priority value=low checked> <b>Low</b>
&nbsp &nbsp &nbsp
<input type=radio name=exp_priority value=high> High</td>
</tr>\n";
#
# Select a group
#
echo "<tr>
<td colspan=2>Group[<b>3</b>]:</td>
<td><input type=\"text\" name=\"exp_gid\"
size=$TBDB_GIDLEN maxlength=$TBDB_GIDLEN>
</td>
</tr>\n";
?>
<tr>
<td align="center" colspan="3">
<b><input type="submit" value="Submit"></b></td>
</tr>
</form>
</table>
<h4><blockquote><blockquote><blockquote>
<dl COMPACT>
<dt>[1]
<dd>Check if your experiment can be swapped out and swapped back in
without harm to your experiment. Useful for scheduling when
resources are tight.
<dt>[2]
<dd>You get brownie points for marking your experiments as Low
Priority, which indicates that we can swap you out before high
priority experiments.
<dt>[3]
<dd>Leave blank to use the default group for the project.
</dl>
</blockquote></blockquote></blockquote></h4>
<p>
<center>
<img alt="*" src="redball.gif">
Please <a href="nscheck_form.php3">syntax check</a> your NS file first!
</center>
<?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -80,10 +80,10 @@ echo "<tr>
<td rowspan>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"20000\">
<input type=\"file\" name=\"exp_nsfile\" size=\"30\">
<input type=\"file\" name=\"exp_nsfile\" size=\"40\">
<br>
<br>
<input type=\"text\" name=\"exp_localnsfile\" size=\"40\">
<input type=\"text\" name=\"exp_localnsfile\" size=\"50\">
</td>
</tr>\n";
......@@ -129,8 +129,8 @@ echo "<tr>
</tr>\n";
echo "<tr>
<td colspan=2>Pool Experiment?[<b>4</b>]:</td>
<td><input type=checkbox name=exp_shared value=Yep>&nbsp Yes</td>
<td colspan=2>Batch Experiment?[<b>4</b>]:</td>
<td><input type=checkbox name=exp_batched value=Yep>&nbsp Yes</td>
</tr>\n";
echo "<tr>
......@@ -155,7 +155,9 @@ echo "<h4><blockquote><blockquote><blockquote>
<dt>[3]
<dd>Leave blank to use the default group for the project.
<dt>[4]
<dd>Leave unchecked unless you know what this means!
<dd>Check this if you want to create a
<a href='$TBDOCBASE/tutorial/tutorial.php3#BatchMode'>
batch mode</a> experiment.
</dl>
</blockquote></blockquote></blockquote></h4>\n";
......
......@@ -36,6 +36,15 @@ if (isset($exp_swappable)) {
}
}
if (isset($exp_batched)) {
if (strcmp($exp_batched, "")) {
unset($exp_batched);
}
elseif (strcmp($exp_batched, "Yep")) {
USERERROR("Invalid argument for Batched", 1);
}
}
if (isset($exp_priority) &&
strcmp($exp_priority, "low") && strcmp($exp_priority, "high")) {
USERERROR("Invalid argument for Priority.", 1);
......@@ -191,7 +200,7 @@ TBUserInfo($uid, $user_name, $user_email);
#
$expt_state = "new";
# Shared experiments.
# Shared experiments. (Deprecated for now!)
if (isset($exp_shared) && strcmp($exp_shared, "Yep") == 0) {
$exp_shared = 1;
}
......@@ -278,6 +287,10 @@ flush();
$output = array();
$retval = 0;
$last = time();
$batch = "-i";
if (isset($exp_batched)) {
$batch = "";
}
#
# Avoid SIGPROF in child.
......@@ -285,7 +298,7 @@ $last = time();
set_time_limit(0);
$result = exec("$TBSUEXEC_PATH $uid $unix_gid ".
"webbatchexp -i -x \"$exp_expires\" -E \"$exp_name\" ".
"webbatchexp $batch -x \"$exp_expires\" -E \"$exp_name\" ".
"$exp_priority $exp_swappable ".
"-p $exp_pid -g $exp_gid -e $exp_id $nsfile",
$output, $retval);
......@@ -310,13 +323,23 @@ echo "<h3>
Experiment
<a href='showexp.php3?pid=$exp_pid&eid=$exp_id'>$exp_id</a>
in project <A href='showproject.php3?pid=$exp_pid'>$exp_pid</A>
is configuring!<br><br>
You will be notified via email when the experiment has been fully
configured and you are able to proceed. This typically takes less
than 10 minutes, depending on the number of nodes you have requested.
If you do not receive email notification within a reasonable amount
of time, please contact $TBMAILADDR.
<br>
is configuring!<br><br>\n";
if (isset($exp_batched)) {
echo "Batch Mode experiments will be run when enough resources become
available. This might happen immediately, or it may take hours
or days. You will be notified via email when the experiment has
been run. If you do not receive email notification within a
reasonable amount of time, please contact $TBMAILADDR.\n";
}
else {
echo "You will be notified via email when the experiment has been fully
configured and you are able to proceed. This typically takes less
than 10 minutes, depending on the number of nodes you have requested.
If you do not receive email notification within a reasonable amount
of time, please contact $TBMAILADDR.\n";
}
echo "<br>
</h3>\n";
#
......
......@@ -160,8 +160,6 @@ function WRITESIDEBAR() {
$TBBASE, "beginexp_form.php3");
WRITESIDEBARBUTTON("Experiment Information",
$TBBASE, "showexp_list.php3");
WRITESIDEBARBUTTON("Create a Batch Experiment",
$TBBASE, "batchexp_form.php3");
WRITESIDEBARBUTTON("Update user information",
$TBBASE, "modusr_form.php3");
WRITESIDEBARBUTTON("Node Reservation Status",
......
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