Commit 22798878 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Fix up the no-nsfile path of begin experiment. Note, if you think you

can swapmod an experiment created this way, think again ...
parent b7d83943
......@@ -10,12 +10,15 @@ use English;
use Getopt::Std;
#
# Create a batch experiment.
# Create an experiment. The experiment is either run immediately, or
# placed into the batch system to be run later. If no NS file is
# supplied, an experiment shell is created (this is currently an admin
# only option).
#
sub usage()
{
die("Usage: batchexp [-i [-f]] [-x expires] [-E description] [-g gid] ".
"[-s] [-n low|high] -p <pid> -e <eid> <nsfile>\n");
"[-s] [-n low|high] -p <pid> -e <eid> [<nsfile>]\n");
}
my $optlist = "iE:d:g:x:e:p:sn:f";
......@@ -101,7 +104,10 @@ else {
if (! defined($expires)) {
$expires = DBDateTime(60 * 60 * 24 * 30);
}
if (!defined($tempnsfile) && !TBAdmin($dbuid)) {
die("*** $0:\n".
" Only admins can create experiments with no NS file\n");
}
$nsfile = "$eid.ns";
#
......@@ -112,12 +118,25 @@ if (! TBProjAccessCheck($dbuid, $pid, $gid, TB_PROJECT_CREATEEXPT)) {
" You do not have permission to create experiments in $pid/$gid\n");
}
#
# All this stuff should change when new web form approved.
#
my $idleswap = 1;
my $idleignore = 0;
# Must do this before lock tables!
# idleswap is in minutes, threshold is in hours
$idleswap_time = 60 * TBGetSiteVar("idle/threshold");
# XXX : Remove this and the idle parts of the insert below when we get
# the new form committed, and they get filled in according to what the
# expt creator requested.
my $idleswap_time = $idleswap_time = 60 * TBGetSiteVar("idle/threshold");
#
# If no NS file, then override swap/idle stuff. Again, might change
# when new forms installed
#
if (!defined($tempnsfile)) {
$swappable = 0;
$idleswap = 0;
$idleswap_time = 0;
$idleignore = 1;
}
#
# Create an experiment record. The pid/eid has to be unique, so lock the
......@@ -143,10 +162,10 @@ if ($query_result->numrows) {
if (! DBQueryWarn("INSERT INTO experiments ".
"(eid, pid, gid, expt_created, expt_expires, expt_name,".
" expt_head_uid,expt_swap_uid, state, priority, swappable,".
" idleswap, idleswap_timeout) ".
" idleswap, idleswap_timeout, idle_ignore) ".
"VALUES ('$eid', '$pid', '$gid', now(), '$expires', ".
"$description,'$dbuid', '$dbuid', 'new', $priority, ".
"$swappable, 1, '$idleswap_time')")) {
"$swappable, $idleswap, '$idleswap_time', $idleignore)")) {
DBQueryWarn("unlock tables");
die("*** $0:\n".
" Database error inserting record for $pid/$eid!\n");
......@@ -187,6 +206,12 @@ if (system("$mkexpdir $pid $gid $eid") != 0) {
fatal("$mkexpdir failed");
}
#
# If no NS file, we are done.
#
exit(0)
if (!defined($tempnsfile));
#
# Grab the working directory path, and thats where we work.
# The user's experiment directory is off in /proj space.
......@@ -307,11 +332,20 @@ sub ParseArgs()
usage();
}
if (@ARGV != 1) {
if (@ARGV > 1) {
usage();
}
if (@ARGV == 1) {
$tempnsfile = $ARGV[0];
$tempnsfile = $ARGV[0];
# Note different taint check (allow /).
if ($tempnsfile =~ /^([-\@\w.\/]+)$/) {
$tempnsfile = $1;
}
else {
fatal("Bad data in argument: $tempnsfile");
}
}
if (defined($options{"i"})) {
$immediate = 1;
......@@ -369,12 +403,4 @@ sub ParseArgs()
usage();
}
}
# Note different taint check (allow /).
if ($tempnsfile =~ /^([-\@\w.\/]+)$/) {
$tempnsfile = $1;
}
else {
fatal("Bad data in argument: $tempnsfile");
}
}
......@@ -663,7 +663,7 @@ if (isset($formfields[exp_preload]) &&
}
#
# I'm not spitting out a redirection yet.
# I am not spitting out a redirection yet.
#
PAGEHEADER("Begin a Testbed Experiment");
......@@ -672,14 +672,6 @@ PAGEHEADER("Begin a Testbed Experiment");
#
TBUserInfo($uid, $user_name, $user_email);
#
# Set the experiment state bit to "new".
#
$exp_state = "new";
# Shared experiments. (Deprecated for now!)
$exp_shared = 0;
# Expiration is hardwired for now.
$exp_expires = date("Y:m:d", time() + (86400 * 120));
......@@ -689,61 +681,8 @@ $exp_expires = date("Y:m:d", time() + (86400 * 120));
TBGroupUnixInfo($exp_pid, $exp_gid, $unix_gid, $unix_name);
#
# If an experiment "shell" give some warm fuzzies and be done with it.
# The user is 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) {
#
# Stub Experiment record. Should do this elsewhere?
#
DBQueryFatal("INSERT INTO experiments ".
"(eid, pid, gid, expt_created, expt_expires, expt_name, ".
"expt_head_uid, expt_swap_uid, state, shared) ".
"VALUES ('$exp_id', '$exp_pid', '$exp_gid', now(), ".
" '$exp_expires', '$exp_name', ".
" '$uid', '$uid', '$exp_state', $exp_shared)");
#
# This is where the experiment hierarchy is going to be created.
#
$dirname = "$TBPROJ_DIR/$exp_pid/exp/$exp_id";
SUEXEC($uid, $unix_gid, "mkexpdir $exp_pid $exp_gid $exp_id", 0);
echo "<center><br>
<h2>Experiment Configured!</h2>
</center><br><br>
<h3>
The ID for your experiment in project `$exp_pid' is `$exp_id.'
<br><br>
Since you did not provide an NS script, no nodes have been
allocated. You must log in and run the tbsetup scripts
yourself. For your convenience, we have created a directory
hierarchy on the control node: $dirname
</h3>\n";
if (1) {
TBMAIL("$user_name '$uid' <$user_email>",
"New Experiment Created: $exp_pid/$exp_id",
"User: $uid\n".
"EID: $exp_id\n".
"PID: $exp_pid\n".
"GID: $exp_gid\n".
"Name: $exp_name\n".
"Expires: $exp_expires\n",
"From: $TBMAIL_WWW\n".
"Bcc: $TBMAIL_LOGS\n".
"Errors-To: $TBMAIL_WWW");
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
die("");
}
# Okay, time to do it.
#
echo "<center><br>";
echo "<h2>Starting experiment configuration. Please wait a moment ...
</h2></center>";
......@@ -770,7 +709,8 @@ set_time_limit(0);
$result = exec("$TBSUEXEC_PATH $uid $unix_gid ".
"webbatchexp $batcharg -x \"$exp_expires\" -E \"$exp_name\" ".
"$exp_priority $exp_swappable ".
"-p $exp_pid -g $exp_gid -e $exp_id $nsfile",
"-p $exp_pid -g $exp_gid -e $exp_id ".
($nonsfile ? "" : "$nsfile"),
$output, $retval);
if ($delnsfile) {
......@@ -799,8 +739,14 @@ echo "<font size=+1>
in project <A href='showproject.php3?pid=$exp_pid'>$exp_pid</A>
is configuring!<br><br>\n";
if ($exp_preload) {
if ($nonsfile) {
echo "Since you did not provide an NS script, no nodes have been
allocated. You will not be able to modify or swap this experiment,
nor do most other neat things you can do with a real experiment.
<br><br>
If this bothers you, <b>SUPPLY AN NS FILE!</b>\n";
}
elseif ($exp_preload) {
echo "Since you are only pre-loading the experiment, this will typically
take less than one minute. If you do not receive email notification
within a reasonable amount of time, please contact $TBMAILADDR.<br>
......
Supports Markdown
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