Commit b26d4a93 authored by Leigh Stoller's avatar Leigh Stoller

Add a link to send an email request to swap/terminate an experiment.

parent 8ca3dbfb
......@@ -741,6 +741,28 @@ function TBProjLeader($pid, &$projleader)
return 1;
}
#
# Return Experiment Leader.
#
# usage TBExpLeader($pid, &$expleader)
# returns 1 if valid
# returns 0 if not valid
#
function TBExpLeader($pid, $eid, &$expleader)
{
$query_result =
DBQueryFatal("select expt_head_uid from experiments ".
"where pid='$pid' and eid='$eid'");
if (mysql_num_rows($query_result) == 0) {
return 0;
}
$row = mysql_fetch_array($query_result);
$expleader = $row[expt_head_uid];
return 1;
}
#
# Return a list of projects for which the uid is allowed to perform the
# requested operation. Only a couple of access options are supported since
......
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Request a Swap/Terminate");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($pid, $eid)) {
USERERROR("The experiment $eid is not a valid experiment ".
"in project $pid.", 1);
}
#
# Only admins can do this!
#
if (! ISADMIN($uid)) {
USERERROR("Only TB admins can do this!", 1);
}
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
if ($canceled) {
echo "<center><h2><br>
Swap/Termination request canceled!
</h2></center>\n";
PAGEFOOTER();
return;
}
if (!$confirmed) {
echo "<center><h2><br>
Are you sure you want to send an email message requesting that<br>
experiment '$eid' be swapped or terminated?
</h2>\n";
#
# Dump experiment record.
#
SHOWEXP($pid, $eid);
echo "<form action='request_swapexp.php3?pid=$pid&eid=$eid' method=post>";
echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
echo "<b><input type=submit name=canceled value=Cancel></b>\n";
echo "</form>\n";
echo "</center>\n";
PAGEFOOTER();
return;
}
#
# Grab experiment/project leaders and email info.
#
$expleader = 0;
$projleader = 0;
if (! TBExpLeader($pid, $eid, $expleader)) {
TBERROR("Could not determine experiment leader!", 1);
}
TBUserInfo($expleader, $expleader_name, $expleader_email);
if (! TBProjLeader($pid, $projleader)) {
TBERROR("Could not determine experiment leader!", 1);
}
TBUserInfo($projleader, $projleader_name, $projleader_email);
mail("$expleader_name <$expleader_email>",
"TESTBED: Please Swap or Terminate Experiment: $pid/$eid",
"Hi, this is an automated message from Emulab.Net.\n".
"\n".
"It appears that your experiment '$eid' in project '$pid' is inactive.\n".
"We would appreciate it if you could either terminate or swap this\n".
"this experiment out so that the nodes will be available for use by\n".
"other experimentors. You can do this by logging into the Emulab Web\n".
"Interface, and using the swap or terminate links on this page:\n".
"\n".
" $TBBASE/showexp.php3?pid=$pid&eid=$eid\n".
"\n".
"If you feel this message is in error then please contact\n".
"$TBMAILADDR_OPS.\n".
"\n".
"Thanks!\n".
"Utah Network Testbed\n",
"From: $TBMAIL_OPS\n".
"Cc: $projleader_name <$projleader_email>\n".
"Bcc: $TBMAIL_OPS\n".
"Errors-To: $TBMAIL_WWW");
echo "<p><center>
Message successfully sent!
</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -81,6 +81,16 @@ if ($expstate) {
# Dump the node information.
#
SHOWNODES($exp_pid, $exp_eid);
#
# Admin folks get a swap request link to send email.
#
if (ISADMIN($uid)) {
echo "<p><center>
<A href='request_swapexp.php3?&pid=$exp_pid&eid=$exp_eid'>
Send a swap/terminate request</a>
</center>\n";
}
#
# Standard Testbed Footer
......
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