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

Add support for "shared" experiments to the web pages. The begin

experiment form sports a new checkbox. When shared, the experiment
information page will include a link (Shared) to a page where you can
add and subtract projects that can share the nodes in the experiment.
Only TBadmins and experiment creator and project leader get to mess
with this stuff. A backed script called webnodeupdate is called to
fire off updates on the nodes (accounts and mounts).
parent 8ae0fc4a
......@@ -68,7 +68,7 @@ echo "<tr>
</tr>\n";
echo "<tr>
<td colspan=2>*Long Name:</td>
<td colspan=2>*Long Name (description):</td>
<td><input type=\"text\" name=\"exp_name\" size=\"40\">
</td>
</tr>\n";
......@@ -129,6 +129,13 @@ echo "<tr>
<td><input type=\"text\" value=\"$year:$month:$rest\"
name=\"exp_end\"></td>
</tr>\n";
echo "<tr>
<td colspan=2>Pool Experiment?:<br>
(Leave unchecked unless you know what this means!)</td>
<td><input type=checkbox name=exp_shared value=Yep>&nbsp</td>
</tr>\n";
?>
<tr>
......
......@@ -183,6 +183,14 @@ $user_email = $row[1];
#
$expt_state = "new";
# Shared experiments.
if (isset($exp_shared) && strcmp($exp_shared, "Yep") == 0) {
$exp_shared = 1;
}
else {
$exp_shared = 0;
}
#
# At this point enter the exp_id into the database so that it shows up as
# valid when the tb scripts run. We need to remove the entry if any of
......@@ -191,9 +199,10 @@ $expt_state = "new";
$query_result = mysql_db_query($TBDBNAME,
"INSERT INTO experiments ".
"(eid, pid, expt_created, expt_expires, expt_name, ".
"expt_head_uid, expt_start, expt_end, state) ".
"expt_head_uid, expt_start, expt_end, state, shared) ".
"VALUES ('$exp_id', '$exp_pid', '$exp_created', '$exp_expires', ".
"'$exp_name', '$uid', '$exp_start', '$exp_end', '$expt_state')");
"'$exp_name', '$uid', '$exp_start', '$exp_end', ".
"'$expt_state', $exp_shared)");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error adding new experiment $exp_id: $err\n", 1);
......
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Manage Shared Access to your Experiment");
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# We must get a valid PID/EID.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a valid project ID!", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide a valid Experiment ID!", 1);
}
$query_result = mysql_db_query($TBDBNAME,
"select e.shared,e.expt_head_uid,p.head_uid from experiments as e, ".
"projects as p ".
"where e.eid='$eid' and e.pid='$pid' and p.pid='$pid'");
if (!$query_result) {
TBERROR("DB error getting experiment record $pid/$eid", 1);
}
if (($row = mysql_fetch_array($query_result)) == 0) {
USERERROR("No such experiment $eid in project $pid!", 1);
}
if (!$row[0]) {
USERERROR("Experiment $eid in project $pid is not shared", 1);
}
#
# Admin users get to do anything they want, of course. Otherwise, only
# the experiment creator or the project leader has permission to mess
# with this.
#
if (! ($isadmin = ISADMIN($uid))) {
#
# One of them better be you!
#
if (strcmp($row[1], $uid) && strcmp($row[2], $uid)) {
USERERROR("You must be either the experiment creator or the project ".
"leader under which the experiment was created, to change ".
"experiment/project access permissions!", 1);
}
}
#
# Get the current set of projects that have been granted share access to
# this experiment.
#
$query_result = mysql_db_query($TBDBNAME,
"select pid from exppid_access ".
"where exp_eid='$eid' and exp_pid='$pid'");
if (mysql_num_rows($query_result)) {
#
# For each one, make sure the checkbox was checked. If not, delete
# it from the table.
#
while ($row = mysql_fetch_array($query_result)) {
$foo = "access_$row[0]";
if (! isset($$foo)) {
$update_result = mysql_db_query($TBDBNAME,
"delete from exppid_access ".
"where exp_eid='$eid' and exp_pid='$pid' and pid='$row[0]'");
if (! $update_result) {
TBERROR("DB Error deleting $row[0] from experiment access ".
"for eid=$eid and pid=$pid!", 1);
}
}
}
}
#
# Add the new PID (if provided), but only if not already a member.
#
if (isset($addpid) && strcmp($addpid, "")) {
#
# Make sure a valid PID.
#
$query_result = mysql_db_query($TBDBNAME,
"select pid from projects where pid='$addpid'");
if (! $query_result) {
TBERROR("DB Error getting project info for $addpid!", 1);
}
if (! mysql_num_rows($query_result)) {
USERERROR("No such project $addpid!", 1);
}
$query_result = mysql_db_query($TBDBNAME,
"replace into exppid_access (exp_pid, exp_eid, pid) ".
"VALUES ('$pid', '$eid', '$addpid')");
if (! $query_result) {
TBERROR("DB Error adding experiment access for project $addpid ".
"to eid=$eid and pid=$pid!", 1);
}
}
SUEXEC($uid, $pid, "webnodeupdate -b $pid $eid", 1);
echo "<center>
<h3>Access Permissions Changed.</h3>
</center>\n";
echo "<p>
You will be notified via email when the update has completed on
all of the nodes in your experiment. Since this involves rebuilding
the accounts database on each node, it should be just a few minutes
before you receive notification.\n";
#
# Back links for convenience.
#
echo "<p>
<a href='expaccess_form.php3?pid=$pid&eid=$eid'>
Back to access management page</a>\n";
echo "<p>
<a href='showexp.php3?exp_pideid=$pid\$\$$eid'>
Back to experiment information page</a>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Manage Shared Access to your Experiment");
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# We must get a valid PID/EID.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a valid project ID!", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide a valid Experiment ID!", 1);
}
$query_result = mysql_db_query($TBDBNAME,
"select e.shared,e.expt_head_uid,p.head_uid from experiments as e, ".
"projects as p ".
"where e.eid='$eid' and e.pid='$pid' and p.pid='$pid'");
if (!$query_result) {
TBERROR("DB error getting experiment record $pid/$eid", 1);
}
if (($row = mysql_fetch_array($query_result)) == 0) {
USERERROR("No such experiment $eid in project $pid!", 1);
}
if (!$row[0]) {
USERERROR("Experiment $eid in project $pid is not shared", 1);
}
#
# Admin users get to do anything they want, of course. Otherwise, only
# the experiment creator or the project leader has permission to mess
# with this.
#
if (! ($isadmin = ISADMIN($uid))) {
#
# One of them better be you!
#
if (strcmp($row[1], $uid) && strcmp($row[2], $uid)) {
USERERROR("You must be either the experiment creator or the project ".
"leader under which the experiment was created, to change ".
"experiment/project access permissions!", 1);
}
}
echo "This page allows you to grant members of other projects 'read-only'
access to the nodes in your experiment. By read-only, we mean that
non-root accounts will be build on your nodes for all of the members
of the projects you grant access to. Those people will also be able
to view some aspects of the experiment's information via the web
interface, but they will not be able terminate or modify the
experiment in any way.
<br>\n";
echo "<table align=center border=0>
<form action='expaccess.php3?pid=$pid&eid=$eid' method=post>\n";
#
# Get the current set of projects that have been granted share access to
# this experiment.
#
$query_result = mysql_db_query($TBDBNAME,
"select pid from exppid_access ".
"where exp_eid='$eid' and exp_pid='$pid'");
if (mysql_num_rows($query_result)) {
echo "<tr><td align=center>
<b>These are the Projects currently granted access to your
experimental nodes. <br>
Deselect the ones you would like to remove.</b>
</td></tr>\n";
echo "<tr><td align=center>\n";
while ($row = mysql_fetch_array($query_result)) {
echo "<input checked type=checkbox value=permit name='access_$row[0]'>
$row[0] &nbsp\n";
}
echo "</td></tr>\n";
}
echo "<tr>
<td align=center>
<br><b>Enter in the PID of a project you wish to add.</b>
</td>
</tr>\n";
echo "<tr>
<td align=center>
<input type=text name='addpid'
size=$TBDB_PIDLEN maxlength=$TBDB_PIDLEN>
</td>
</tr>\n";
echo "<tr>
<td align=center>
<b><input type=submit value=Submit></b>
</td>
</tr>\n";
echo "</form>
</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -236,6 +236,7 @@ function SHOWEXP($pid, $eid) {
$exp_created = $exprow[expt_created];
$exp_head = $exprow[expt_head_uid];
$exp_status = $exprow[state];
$exp_shared = $exprow[shared];
#
# Generate the table.
......@@ -286,6 +287,18 @@ function SHOWEXP($pid, $eid) {
<td class=\"left\">$exp_expires</td>
</tr>\n";
echo "<tr>
<td>Shared: </td>
<td class=\"left\">";
if ($exp_shared) {
echo "<A href='expaccess_form.php3?pid=$pid&eid=$eid'>Yes</a>";
}
else {
echo "No";
}
echo " </td>
</tr>\n";
echo "<tr>
<td>Status: </td>
<td class=\"left\">$exp_status</td>
......
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