Commit 080feb1b authored by Mac Newbold's avatar Mac Newbold

Wow. Mountain of changes for the new begin experiment form.

Lots of changes to the form, both functional and aesthetic. See the
testbed ops mail logs for a list of all of them, and the rationale.

Corresponding updates to the showexp "edit meta-data" stuff, so that it
gets all the same error checks as the real form.

Also some backend changes in batchexp to pass through all the new form
values.
parent 36db5e6e
......@@ -18,9 +18,11 @@ use Getopt::Std;
sub usage()
{
die("Usage: batchexp [-i [-f]] [-x expires] [-E description] [-g gid] ".
"[-s] [-n low|high] -p <pid> -e <eid> [<nsfile>]\n");
"[-s] [-a <autotime>] [-l <idletime>]] [-n low|high] ".
"-p <pid> -e <eid> [<nsfile>]\n");
}
my $optlist = "iE:d:g:x:e:p:sn:fgq";
my $optlist = "iE:d:g:x:e:p:sa:l:n:fq";
#
# Configure variables
......@@ -60,7 +62,7 @@ umask(0002);
#
# Untaint the path
#
#
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
......@@ -72,6 +74,11 @@ my $description;
my $expires;
my $tempnsfile;
my $swappable = 0;
my $idleswap = 0;
my $idleswaptime = 60 * TBGetSiteVar("idle/threshold");
my $autoswap = 0;
my $autoswaptime = 10 * 60;
my $idleignore = 0;
my $priority = TB_EXPTPRIORITY_LOW;
#
......@@ -89,7 +96,7 @@ ParseArgs();
#
# Sanity check them.
#
#
if (!defined($pid) || !defined($eid)) {
usage();
}
......@@ -119,15 +126,6 @@ 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
my $idleswap_time = 60 * TBGetSiteVar("idle/threshold");
#
# If no NS file, then override swap/idle stuff. Again, might change
# when new forms installed
......@@ -135,8 +133,6 @@ my $idleswap_time = 60 * TBGetSiteVar("idle/threshold");
if (!defined($tempnsfile)) {
$swappable = 0;
$idleswap = 0;
$idleswap_time = 0;
$idleignore = 1;
}
#
......@@ -158,15 +154,17 @@ if ($query_result->numrows) {
#
# Insert the record. This reserves the pid/eid for us. If its a batchmode
# experiment, we will update the record later so that the batch daemon
# will recognize it.
# will recognize it.
#
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, idle_ignore) ".
" idleswap, idleswap_timeout, autoswap, autoswap_timeout,".
" idle_ignore) ".
"VALUES ('$eid', '$pid', '$gid', now(), '$expires', ".
"$description,'$dbuid', '$dbuid', 'new', $priority, ".
"$swappable, $idleswap, '$idleswap_time', $idleignore)")) {
"$swappable, $idleswap, '$idleswaptime', $autoswap, ".
"'$autoswaptime', $idleignore)")) {
DBQueryWarn("unlock tables");
die("*** $0:\n".
" Database error inserting record for $pid/$eid!\n");
......@@ -177,7 +175,7 @@ if (! DBQueryWarn("unlock tables")) {
}
#
# Create an experiment_resources record for the above record.
# Create an experiment_resources record for the above record.
#
if (! DBQueryWarn("insert into experiment_resources (idx, tstamp, exptidx) ".
"select 0, now(), idx from experiments ".
......@@ -188,7 +186,7 @@ if (! DBQueryWarn("insert into experiment_resources (idx, tstamp, exptidx) ".
#
# Now create an experiment_stats record to match.
#
#
if (! DBQueryWarn("insert into experiment_stats ".
"(eid, pid, creator, gid, created, batch, exptidx,rsrcidx) ".
"select '$eid', '$pid', '$dbuid', '$gid', now(), ".
......@@ -208,7 +206,7 @@ if (system("$mkexpdir $pid $gid $eid") != 0) {
}
#
# If no NS file, we are done.
# If no NS file, we are done.
#
exit(0)
if (!defined($tempnsfile));
......@@ -223,7 +221,7 @@ chdir("$workdir") or
fatal("Could not chdir to $workdir: $!");
#
# Now we can get the NS file!
# Now we can get the NS file!
#
if (system("/bin/cp", "$tempnsfile", "$nsfile")) {
fatal("Could not copy $tempnsfile to $workdir/$nsfile");
......@@ -251,8 +249,8 @@ if ($nsfile_string) {
#
# 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.
#
# would be a third (call it redundant) check.
#
DBQueryWarn("insert into nsfiles (pid, eid, nsfile) ".
"VALUES('$pid', '$eid', $nsfile_string)");
}
......@@ -262,14 +260,14 @@ if ($nsfile_string) {
# the startexp script to do the rest. It exits and so do we; user gets
# email later. If its a batch experiment, update the experiment record
# so that the batch daemon will see it and act.
#
#
if ($immediate) {
my $optargs = "";
$optargs .= " -f"
if ($frontend);
$optargs .= " -b"
if ($quiet);
if (system("$startexp $optargs -g $gid $pid $eid $nsfile")) {
fatal("Failed to start experiment $pid/$eid!");
}
......@@ -279,7 +277,7 @@ else {
# Preload the experiment in the foreground. User sees parse errors
# right away, and the experiment is now in the system so we can look
# at it.
#
#
if (system("$startexp -f -b -g $gid $pid $eid $nsfile")) {
fatal("Failed to preload batch experiment $pid/$eid!");
}
......@@ -304,7 +302,7 @@ sub fatal($)
# waste of space since the testbed_stats log indicates there was a
# failure and why (sorta, via the exit code).
#
if (($query_result =
if (($query_result =
DBQueryWarn("select idx from experiments ".
"where pid='$pid' and eid='$eid'"))) {
......@@ -317,12 +315,12 @@ sub fatal($)
"WHERE exptidx=$idx");
}
}
#
# Clear the record and cleanup.
#
#
TBExptDestroy($pid, $eid);
exit(-1);
}
......@@ -336,7 +334,7 @@ sub ParseArgs()
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV > 1) {
usage();
}
......@@ -351,7 +349,7 @@ sub ParseArgs()
fatal("Bad data in argument: $tempnsfile");
}
}
if (defined($options{"i"})) {
$immediate = 1;
}
......@@ -397,6 +395,18 @@ sub ParseArgs()
if (defined($options{"s"})) {
$swappable = 1;
}
if (defined($options{"l"})) {
$idleswap = 1;
$idleswaptime = $options{"l"};
(($idleswaptime =~ /^\d+$/) &&
($idleswaptime > 0)) or die("Bad idleswap time: '$idleswaptime'");
}
if (defined($options{"a"})) {
$autoswap = 1;
$autoswaptime = $options{"a"};
(($autoswaptime =~ /^\d+$/) &&
($autoswaptime > 0)) or die("Bad autoswap time: '$autoswaptime'");
}
if (defined($options{"q"})) {
$quiet = 1;
}
......
This diff is collapsed.
......@@ -154,29 +154,73 @@ SUBMENUEND_2B();
# if we got a submission of changes, update the db now...
if ($submit) {
# Find out our limit
$idlethresh = TBGetSiteVar("idle/threshold");
$exp_name = addslashes(str_replace('"',"",$exp_name));
$noswap = addslashes(str_replace('"',"",$noswap));
$noidleswap = addslashes(str_replace('"',"",$noidleswap));
# exp name is always sent...
$str = "expt_name=\"$exp_name\"";
$mail=0;
$strs = array();
$errors = array();
if (isset($exp_name)) {
if ($exp_name!="") {
$strs[] = "expt_name=\"$exp_name\"";
} else {
$errors['Expt. Name'] = "Missing/Blank Field";
}
}
if (isset($noswap)) {
$str .= ",noswap_reason=\"$noswap\"";
$strs[] = "noswap_reason=\"$noswap\"";
$mail=1;
}
if (isset($noidleswap)) {
$str .= ",noidleswap_reason=\"$noidleswap\"";
$strs[].= "noidleswap_reason=\"$noidleswap\"";
$mail=1;
}
if (isset($idleswap) && $idleswap !="" && $idleswap>0 && ISADMIN()) {
$str .= ",idleswap_timeout=\"".(60*$idleswap)."\"";
$mail=1;
if (isset($idleswap)) {
if ($idleswap>0 && $idleswap <= $idlethresh && $idleswap !="") {
$strs[] = "idleswap_timeout=\"".(60*$idleswap)."\"";
$mail=1;
} else {
$errors['Idle-Swap'] ="Time must be non-zero and <= $idlethresh";
}
}
if (isset($autoswap) && $autoswap !="" && $autoswap>0) {
$str .= ",autoswap_timeout=\"".(60*$autoswap)."\"";
$mail=1;
if (isset($autoswap)) {
if ($autoswap>=0 && $autoswap !="") {
$strs[] = "autoswap_timeout=\"".(60*$autoswap)."\"";
$mail=1;
} else {
$errors['Max Duration'] = "Time must be non-zero";
}
}
if (count($strs)>0) {
$str = implode(",",$strs);
DBQueryWarn("update experiments set $str ".
"where pid='$pid' and eid='$eid'");
}
if ($errors) {
echo "<table class=nogrid
align=center border=0 cellpadding=6 cellspacing=0>
<tr>
<th align=center colspan=2>
<font size=+1 color=red>
&nbsp;Oops, please fix the following errors!&nbsp;
</font>
</td>
</tr>\n";
while (list ($name, $message) = each ($errors)) {
echo "<tr>
<td align=right>
<font color=red>$name:&nbsp;</font></td>
<td align=left>
<font color=red>$message</font></td>
</tr>\n";
}
echo "</table><br>\n";
# Jump back into edit mode
$edit=1;
}
DBQueryWarn("update experiments set $str where pid='$pid' and eid='$eid'");
if ($mail) {
$q = DBQueryFatal("select * from experiments ".
"where pid='$pid' and eid='$eid'");
......@@ -193,22 +237,28 @@ if ($submit) {
TBUserInfo($uid, $user_name, $user_email);
TBUserInfo($cuid, $cname, $cemail);
TBUserInfo($suid, $sname, $semail);
TBMAIL($TBMAIL_OPS,"$pid/$eid swap settings changed",
"\nThe swap settings for $pid/$eid have changed.\n".
"\nThe reasons and/or timeouts have changed.\n".
"\nThe new settings are:\n".
"Swappable:\t$s\t($sr)\n".
"Idleswap:\t$i\t(after $it hrs)\t($ir)\n".
"Autoswap:\t$a\t(after $at hrs)\n".
"\nCreator:\t$cuid ($cname <$cemail>)\n".
"Swapper:\t$suid ($sname <$semail>)\n".
"\nIf it is necessary to change these settings, ".
"please reply to this message \nto notify the user, ".
"then change the settings here:\n\n".
"$TBBASE/showexp.php3?pid=$pid&eid=$eid\n\n".
"Thanks,\nTestbed WWW\n",
"From: $user_name <$user_email>\n".
"Errors-To: $TBMAIL_WWW");
# Do not send this email if the user is an administrator
# (adminmode does not matter), and is changing an expt
# he created or swapped in. Pointless email.
if (! (ISADMINISTRATOR() &&
(!strcmp($uid, $cuid) || !strcmp($uid, $suid)))) {
TBMAIL($TBMAIL_OPS,"$pid/$eid swap settings changed",
"\nThe swap settings for $pid/$eid have changed.\n".
"\nThe reasons and/or timeouts have changed.\n".
"\nThe new settings are:\n".
#"Swappable:\t$s\t($sr)\n".
"Idleswap:\t$i\t(after $it hrs)\t($ir)\n".
"Autoswap:\t$a\t(after $at hrs)\n".
"\nCreator:\t$cuid ($cname <$cemail>)\n".
"Swapper:\t$suid ($sname <$semail>)\n".
"\nIf it is necessary to change these settings, ".
"please reply to this message \nto notify the user, ".
"then change the settings here:\n\n".
"$TBBASE/showexp.php3?pid=$pid&eid=$eid\n\n".
"Thanks,\nTestbed WWW\n",
"From: $user_name <$user_email>\n".
"Errors-To: $TBMAIL_WWW");
}
}
}
......
......@@ -19,6 +19,7 @@ table.stealth { border: 0px; background-color:#FFF; }
td.stealth { background-color:#FFF; }
img.stealth { background-color:#FFF; }
td.pad4 { padding: 4px; }
td.paddedcell { padding-left: 0.5em; padding-right: 0.5em; padding-top: 0.75em; }
td.paddedcell2 { padding: 0.5em; }
......
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