Commit 3f56ba9b authored by Leigh Stoller's avatar Leigh Stoller

Redo the Edit Experiment Metadata page; turned it into a standard form

based page that looks like the original Begin Experiment page. Be sure
to look at the page in both admin mode and non-admin mode since I had
some trouble determining how swappable is treated these days.

Oh, added the ability to convert non-batch experiments into batch, and
back. The experiment must be unlocked and in the swapped state to go
in either direction.

Also added the cpu_usage and mem_usage slots for editing. I added a
comment about planetlab only, since otherwise we would just confuse
normal users who have no idea what they mean. I could conditionalize
them on having plab nodes, but thats difficult to figure out in the
web page when the experiment is swapped out, so lets not worry about
it.
parent 4bc8c274
......@@ -1849,4 +1849,16 @@ function DBFatal($message)
"Unexpected Error. Could not continue. ".
"Please contact $TBMAILADDR\n");
}
#
# Return the number of affected rows, for the last query. Why is this
# not stored in the query result?
#
function DBAffectedRows()
{
global $DBlinkid;
return mysql_affected_rows($DBlinkid);
}
?>
This diff is collapsed.
......@@ -122,9 +122,8 @@ if ($expstate) {
}
}
$editflip = ($edit ? 0 : 1);
WRITESUBMENUBUTTON("Edit Experiment Metadata",
"showexp.php3?pid=$exp_pid&eid=$exp_eid&edit=$editflip");
"editexp.php3?pid=$exp_pid&eid=$exp_eid");
#
# Admin and project/experiment leader get this option.
......@@ -179,135 +178,7 @@ echo "<br>
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));
$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)) {
$strs[] = "noswap_reason=\"$noswap\"";
$mail=1;
}
if (isset($noidleswap)) {
$strs[].= "noidleswap_reason=\"$noidleswap\"";
$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)) {
if ($autoswap>=0 && $autoswap !="") {
$strs[] = "autoswap_timeout=\"".(60*$autoswap)."\"";
$mail=1;
} else {
$errors['Max Duration'] = "Time must be non-zero";
}
}
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;
$mail=0;
} else {
$q = DBQueryFatal("select * from experiments ".
"where pid='$pid' and eid='$eid'");
$r = mysql_fetch_array($q);
$olds = ($r[swappable] ? "Yes" : "No");
$oldsr= $r[noswap_reason];
$oldi = ($r[idleswap] ? "Yes" : "No");
$oldit= $r[idleswap_timeout] / 60.0;
$oldir= $r[noidleswap_reason];
$olda = ($r[autoswap] ? "Yes" : "No");
$oldat= $r[autoswap_timeout] / 60.0;
if (count($strs)>0) {
$str = implode(",",$strs);
DBQueryWarn("update experiments set $str ".
"where pid='$pid' and eid='$eid'");
}
}
if ($mail) {
$q = DBQueryFatal("select * from experiments ".
"where pid='$pid' and eid='$eid'");
$r = mysql_fetch_array($q);
$s = ($r[swappable] ? "Yes" : "No");
$sr= $r[noswap_reason];
$i = ($r[idleswap] ? "Yes" : "No");
$it= $r[idleswap_timeout] / 60.0;
$ir= $r[noidleswap_reason];
$a = ($r[autoswap] ? "Yes" : "No");
$at= $r[autoswap_timeout] / 60.0;
$cuid = $r[expt_head_uid];
$suid= $r[expt_swap_uid];
TBUserInfo($uid, $user_name, $user_email);
TBUserInfo($cuid, $cname, $cemail);
TBUserInfo($suid, $sname, $semail);
# 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 old settings were:\n".
#"Swappable:\t$olds\t($oldsr)\n".
"Idleswap:\t$oldi\t(after $oldit hrs)\t($oldir)\n".
"MaxDuration:\t$olda\t(after $oldat hrs)\n".
"\nThe new settings are:\n".
#"Swappable:\t$s\t($sr)\n".
"Idleswap:\t$i\t(after $it hrs)\t($ir)\n".
"MaxDuration:\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");
}
}
}
# Dump (possibly updated) experiment record.
if (!isset($edit)) { $edit=0; }
SHOWEXP($exp_pid, $exp_eid, $edit);
SHOWEXP($exp_pid, $exp_eid);
SUBPAGEEND();
......
......@@ -537,7 +537,7 @@ function SHOWUSER($uid) {
#
# Show an experiment.
#
function SHOWEXP($pid, $eid, $edit=0) {
function SHOWEXP($pid, $eid) {
global $TBDBNAME, $TBDOCBASE;
$nodecounts = array();
......@@ -565,10 +565,7 @@ function SHOWEXP($pid, $eid, $edit=0) {
}
$exp_gid = $exprow[gid];
#$exp_expires = $exprow[expt_expires];
$exp_name_safe= htmlspecialchars(stripslashes($exprow[expt_name]));
$exp_name = stripslashes($exprow[expt_name]);
$exp_created = $exprow[expt_created];
$exp_swapped = $exprow[expt_swapped];
$exp_swapuid = $exprow[expt_swap_uid];
$exp_end = $exprow[expt_end];
......@@ -582,16 +579,12 @@ function SHOWEXP($pid, $eid, $edit=0) {
$batchstate = $exprow[batchstate];
$priority = $exprow[priority];
$swappable = $exprow[swappable];
$noswap_reason_safe =
htmlspecialchars(stripslashes($exprow[noswap_reason]));
$noswap_reason = stripslashes($exprow[noswap_reason]);
$idleswap = $exprow[idleswap];
$idleswap_timeout = $exprow[idleswap_timeout];
$noidleswap_reason_safe =
htmlspecialchars(stripslashes($exprow[noidleswap_reason]));
$idleswap_timeout = $exprow[idleswap_timeout];
$noidleswap_reason = stripslashes($exprow[noidleswap_reason]);
$autoswap = $exprow[autoswap];
$autoswap_timeout = $exprow[autoswap_timeout];
$autoswap_timeout = $exprow[autoswap_timeout];
$idle_ignore = $exprow[idle_ignore];
$swapreqs = $exprow[swap_requests];
$lastswapreq = $exprow[last_swap_req];
......@@ -602,84 +595,31 @@ function SHOWEXP($pid, $eid, $edit=0) {
$autoswap_hrs= ($autoswap_timeout/60.0);
$idleswap_hrs= ($idleswap_timeout/60.0);
if ($edit) {
# make this a form too
echo "<form action=\"showexp.php3?pid=$pid&eid=$eid\" method=POST>\n";
$noswap_form = "Why: <input type=text ".
"name=noswap value=\"$noswap_reason\" size=30>";
$noidleswap_form = "Why: <input type=text ".
"name=noidleswap value=\"$noidleswap_reason\" size=30>";
$autoswap_form= "<input type=text size=3 name=autoswap ".
"value=\"$autoswap_hrs\"> hour".($autoswap_hrs==1 ? "" : "s");
$toggle = "<font size=-2 face=\"Verdana,Arial,sans-serif\">Toggle</font>";
$expttag = "pid=$pid&eid=$eid&edit=1";
if ($swappable)
$swappable = "Yes
<a href=\"toggle.php?type=swappable&value=0&$expttag\">$toggle</a>
$noswap_form";
else
$swappable = "<b>No</b>
<a href=\"toggle.php?type=swappable&value=1&$expttag\">$toggle</a>
$noswap_form";
$idleswap_form= "<input type=text size=3 name=idleswap ".
"value=\"$idleswap_hrs\"> hour".($idleswap_hrs==1 ? "" : "s");
if ($idleswap)
$idleswap = "Yes
<a href=\"toggle.php?type=idleswap&value=0&$expttag\">$toggle</a>
(after $idleswap_form) <br> $noidleswap_form";
else
$idleswap = "<b>No</b>
<a href=\"toggle.php?type=idleswap&value=1&$expttag\">$toggle</a>
(after $idleswap_form) <br> $noidleswap_form";
if ($autoswap)
$autoswap = "<b>Yes</b>
<a href=\"toggle.php?type=autoswap&value=0&$expttag\">$toggle</a>
(after $autoswap_form)";
else
$autoswap = "No
<a href=\"toggle.php?type=autoswap&value=1&$expttag\">$toggle</a>
(after $autoswap_form)";
if ($idle_ignore)
$idle_ignore = "<b>Yes</b>
<a href=\"toggle.php?type=idle_ignore&value=0&$expttag\">$toggle</a>";
else
$idle_ignore = "No
<a href=\"toggle.php?type=idle_ignore&value=1&$expttag\">$toggle</a>";
} else {
$noswap = "($noswap_reason)";
$noidleswap = "($noidleswap_reason)";
$autoswap_str= $autoswap_hrs." hour".($autoswap_hrs==1 ? "" : "s");
$idleswap_str= $idleswap_hrs." hour".($idleswap_hrs==1 ? "":"s");
$noswap = "($noswap_reason)";
$noidleswap = "($noidleswap_reason)";
$autoswap_str= $autoswap_hrs." hour".($autoswap_hrs==1 ? "" : "s");
$idleswap_str= $idleswap_hrs." hour".($idleswap_hrs==1 ? "":"s");
if ($swappable)
$swappable = "Yes";
else
$swappable = "<b>No</b> $noswap";
if ($swappable)
$swappable = "Yes";
else
$swappable = "<b>No</b> $noswap";
if ($idleswap)
$idleswap = "Yes (after $idleswap_str)";
else
$idleswap = "<b>No</b> $noidleswap";
if ($idleswap)
$idleswap = "Yes (after $idleswap_str)";
else
$idleswap = "<b>No</b> $noidleswap";
if ($autoswap)
$autoswap = "<b>Yes</b> (after $autoswap_str)";
else
$autoswap = "No";
if ($autoswap)
$autoswap = "<b>Yes</b> (after $autoswap_str)";
else
$autoswap = "No";
if ($idle_ignore)
$idle_ignore = "<b>Yes</b>";
else
$idle_ignore = "No";
if ($idle_ignore)
$idle_ignore = "<b>Yes</b>";
else
$idle_ignore = "No";
}
#
# Generate the table.
#
......@@ -690,15 +630,9 @@ $noswap_form";
<td class=left>$eid</td>
</tr>\n";
if ($edit) {
$exp_name_str =
"<input type=text name=exp_name size=30 value=\"$exp_name_safe\">";
} else {
$exp_name_str = $exp_name;
}
echo "<tr>
<td>Long Name: </td>
<td class=\"left\">$exp_name_str</td>
<td class=\"left\">$exp_name</td>
</tr>\n";
echo "<tr>
......@@ -873,16 +807,7 @@ $noswap_form";
</tr>\n";
}
if ($edit) {
echo "<tr><td colspan=2 align=center>
<input type=submit name=submit value=\"Submit Changes\">
<input type=submit name=reset value=\"Reset\">
</td></tr>\n";
}
echo "</table>\n";
if ($edit) { echo "</form>\n"; }
}
#
......
......@@ -29,15 +29,11 @@ LOGGEDINORDIE($uid);
# (type & value are required, others are optional and vary by type)
# List of valid toggles
$toggles = array("adminoff", "swappable", "idleswap", "autoswap",
"idle_ignore");
$toggles = array("adminoff", "idle_ignore");
# list of valid values for each toggle
$values = array("adminoff" => array(0,1),
"swappable" => array(0,1),
"idleswap" => array(0,1),
"autoswap" => array(0,1),
"idle_ignore" => array(0,1) );
"idle_ignore" => array(0,1));
if (! in_array($type, $toggles)) {
USERERROR("There is no toggle for $type!", 1);
......@@ -61,73 +57,6 @@ if ($type=="adminoff") {
DBQueryFatal("update users set adminoff=$value where uid='$target_uid'");
}
elseif ($type=="swappable" || $type=="idleswap" || $type=="autoswap") {
# must be admin OR must have permission to modify the expt...
if (! ISADMIN() && !TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) {
USERERROR("You do not have permission to toggle $type!", 1);
}
# require pid/eid
if (!isset($pid) || !isset($eid) ||
!TBValidExperiment($pid, $eid)) {
USERERROR("Experiment '$pid/$eid' is not valid!", 1);
}
DBQueryFatal("update experiments set $type=$value ".
"where pid='$pid' and eid='$eid'");
# Send mail on these changes...
if ($type!="autoswap" && $value=="0") {
$q = DBQueryFatal("select * from experiments ".
"where pid='$pid' and eid='$eid'");
$r = mysql_fetch_array($q);
$cuid = $r[expt_head_uid];
$suid = $r[expt_swap_uid];
#
# Do not send this email if the user is an administrator
# (adminmode does not matter), and is changing an experiment
# he created or swapped in. Pointless email.
#
if (! (ISADMINISTRATOR() &&
(!strcmp($uid, $cuid) || !strcmp($uid, $suid)))) {
$s = ($r[swappable] ? "Yes" : "No");
$sr= $r[noswap_reason];
$i = ($r[idleswap] ? "Yes" : "No");
$it= $r[idleswap_timeout] / 60.0;
$ir= $r[noidleswap_reason];
$a = ($r[autoswap] ? "Yes" : "No");
$at= $r[autoswap_timeout] / 60.0;
$olds = ($type=="swappable"? "Yes" : $s);
$oldi = ($type=="idleswap" ? "Yes" : $i);
$olda = ($type=="autoswap" ? "Yes" : $a);
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 $type bit has been cleared.\n".
"\nThe old settings were:\n".
#"Swappable:\t$olds\t('$sr')\n".
"Idleswap:\t$oldi\t(after $it hrs)\t('$ir')\n".
"MaxDuration:\t$olda\t(after $at hrs)\n".
"\nThe new settings are:\n".
#"Swappable:\t$s\t('$sr')\n".
"Idleswap:\t$i\t(after $it hrs)\t('$ir')\n".
"MaxDuration:\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");
}
}
}
elseif ($type=="idle_ignore") {
# must be admin
if (! ISADMIN() ) {
......
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