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

Move the bulk of what was in showlogfile, into showlogfile_sup, so

that it can be "included" into other scripts; showlogfile, beginexp,
swapexp, modifyexp, endexp.

Each of these scripts now appends the showlog directly to the page,
instead of providing a link to a different page.

Also changed the showlog code to place the output into an inner iframe
so that it can be sized to fit in the window, without the outer stuff
(like the menus) getting scrolled away.
parent 01585b4b
...@@ -28,6 +28,9 @@ function EXPERROR() ...@@ -28,6 +28,9 @@ function EXPERROR()
$uid = GETLOGIN(); $uid = GETLOGIN();
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
# This will not return if its a sajax request.
include("showlogfile_sup.php3");
# #
# Handle pre-defined view styles # Handle pre-defined view styles
# #
...@@ -182,18 +185,12 @@ echo "<font size=+2>Experiment <b>". ...@@ -182,18 +185,12 @@ echo "<font size=+2>Experiment <b>".
"</font>\n"; "</font>\n";
echo "<br><br>\n"; echo "<br><br>\n";
echo "<center><br>"; echo "<b>Starting experiment configuration!</b> " . $results[message];
echo "<font size=+1>Starting experiment configuration.</font>
</center>";
echo "<br>\n";
echo $results[message];
echo "<br><br>\n"; echo "<br><br>\n";
echo "While you are waiting, you can watch the log echo "While you are waiting, you can watch the log
in <a href=showlogfile.php3?pid=$exp_pid&eid=$exp_id> in realtime:<br>\n";
realtime</a>.\n"; echo "</font>\n";
echo "<br> STARTLOG($exp_pid, $exp_id);
</font>\n";
# #
# Standard Testbed Footer # Standard Testbed Footer
......
...@@ -13,6 +13,9 @@ include("showstuff.php3"); ...@@ -13,6 +13,9 @@ include("showstuff.php3");
$uid = GETLOGIN(); $uid = GETLOGIN();
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
# This will not return if its a sajax request.
include("showlogfile_sup.php3");
# #
# Must provide the EID! # Must provide the EID!
# #
...@@ -38,7 +41,7 @@ if ($canceled) { ...@@ -38,7 +41,7 @@ if ($canceled) {
# #
# Standard Testbed Header, after checking for cancel above. # Standard Testbed Header, after checking for cancel above.
# #
PAGEHEADER("Terminate a Testbed Experiment"); PAGEHEADER("Terminate Experiment");
# #
# Check to make sure thats this is a valid PID/EID, while getting the # Check to make sure thats this is a valid PID/EID, while getting the
...@@ -65,7 +68,7 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_DESTROY)) { ...@@ -65,7 +68,7 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_DESTROY)) {
echo "<font size=+2>Experiment <b>". echo "<font size=+2>Experiment <b>".
"<a href='showproject.php3?pid=$exp_pid'>$exp_pid</a>/". "<a href='showproject.php3?pid=$exp_pid'>$exp_pid</a>/".
"<a href='showexp.php3?pid=$exp_pid&eid=$exp_eid'>$exp_eid</a>". "<a href='showexp.php3?pid=$exp_pid&eid=$exp_eid'>$exp_eid</a>".
"</b></font>\n"; "</b></font><br>\n";
# A locked down experiment means just that! # A locked down experiment means just that!
if ($lockdown) { if ($lockdown) {
...@@ -106,16 +109,6 @@ if (!$confirmed) { ...@@ -106,16 +109,6 @@ if (!$confirmed) {
# #
TBGroupUnixInfo($exp_pid, $exp_gid, $unix_gid, $unix_name); TBGroupUnixInfo($exp_pid, $exp_gid, $unix_gid, $unix_name);
#
# We run a wrapper script that does all the work of terminating the
# experiment.
#
# tbstopit <pid> <eid>
#
echo "<center><br>";
echo "<h2>Starting experiment termination. Please wait a moment ...
</h2></center>";
flush(); flush();
# #
...@@ -146,7 +139,7 @@ if ($retval) { ...@@ -146,7 +139,7 @@ if ($retval) {
echo "<blockquote><pre>$suexec_output<pre></blockquote>"; echo "<blockquote><pre>$suexec_output<pre></blockquote>";
} }
else { else {
echo "<h3>Your experiment is terminating!</h3><br> echo "<b>Your experiment is terminating!</b>
You will be notified via email when the experiment has been torn You will be notified via email when the experiment has been torn
down, and you can reuse the experiment name. down, and you can reuse the experiment name.
This typically takes less than two minutes, depending on the This typically takes less than two minutes, depending on the
...@@ -155,10 +148,8 @@ else { ...@@ -155,10 +148,8 @@ else {
of time, please contact $TBMAILADDR.\n"; of time, please contact $TBMAILADDR.\n";
echo "<br><br> echo "<br><br>
If you are the morbid type, you can watch the experiment die in Watch the experiment die in realtime:<br>\n";
<a href=showlogfile.php3?pid=$exp_pid&eid=$exp_eid> STARTLOG($exp_pid, $exp_eid);
realtime</a>.\n";
} }
# #
......
...@@ -9,40 +9,21 @@ include("showstuff.php3"); ...@@ -9,40 +9,21 @@ include("showstuff.php3");
$parser = "$TB/libexec/ns2ir/parse-ns"; $parser = "$TB/libexec/ns2ir/parse-ns";
#
# Standard Testbed Header
#
PAGEHEADER("Modify Experiment");
# the following hack is a page for Netbuild to
# point the users browser at after a successful modify.
# this does no error checking.
if ($justsuccess) {
echo "<br /><br />";
echo "<font size=+1>
<p>Experiment
<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>
in project <A href='showproject.php3?pid=$pid'>$pid</A>
is being modified!</p><br />
<p>You will be notified via email when the operation is complete.
This could take one to ten minutes, depending on
whether nodes were added to the experiments, and whether
disk images had to be loaded.</p>
<p>While you are waiting, you can watch the log
in <a href=showlogfile.php3?pid=$pid&eid=$eid>
realtime</a>.</p></font>\n";
PAGEFOOTER();
return;
}
# #
# Only known and logged in users can modify experiments. # Only known and logged in users can modify experiments.
# #
$uid = GETLOGIN(); $uid = GETLOGIN();
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid); $isadmin = ISADMIN($uid);
# This will not return if its a sajax request.
include("showlogfile_sup.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Modify Experiment");
# #
# Verify page arguments. # Verify page arguments.
# #
...@@ -65,21 +46,15 @@ $eid = addslashes($eid); ...@@ -65,21 +46,15 @@ $eid = addslashes($eid);
# Check to make sure this is a valid experiment. # Check to make sure this is a valid experiment.
# #
if (! TBValidExperiment($pid, $eid)) { if (! TBValidExperiment($pid, $eid)) {
# Netbuild requires the following line.
echo "\n\n<!-- NetBuild! Experiment does not exist -->\n\n";
USERERROR("The experiment $eid is not a valid experiment ". USERERROR("The experiment $eid is not a valid experiment ".
"in project $pid.", 1); "in project $pid.", 1);
} }
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) { if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) {
# Netbuild requires the following line.
echo "\n\n<!-- NetBuild! No permission to modify -->\n\n";
USERERROR("You do not have permission to modify this experiment.", 1); USERERROR("You do not have permission to modify this experiment.", 1);
} }
if (TBExptLockedDown($pid, $eid)) { if (TBExptLockedDown($pid, $eid)) {
# Netbuild requires the following line.
echo "\n\n<!-- NetBuild! No permission to modify -->\n\n";
USERERROR("Cannot proceed; experiment is locked down!", 1); USERERROR("Cannot proceed; experiment is locked down!", 1);
} }
...@@ -87,8 +62,6 @@ $expstate = TBExptState($pid, $eid); ...@@ -87,8 +62,6 @@ $expstate = TBExptState($pid, $eid);
if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) && if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) &&
strcmp($expstate, $TB_EXPTSTATE_SWAPPED)) { strcmp($expstate, $TB_EXPTSTATE_SWAPPED)) {
# Netbuild requires the following line.
echo "\n\n<!-- NetBuild! Experiment is in transition. -->\n\n";
USERERROR("You cannot modify an experiment in transition.", 1); USERERROR("You cannot modify an experiment in transition.", 1);
} }
...@@ -96,7 +69,8 @@ if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) && ...@@ -96,7 +69,8 @@ if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) &&
echo "<font size=+2>Experiment <b>". echo "<font size=+2>Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/". "<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n"; "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
echo "<br><br>\n"; echo "<br>\n";
flush();
# #
# Put up the modify form on first load. # Put up the modify form on first load.
...@@ -106,17 +80,6 @@ if (! isset($go)) { ...@@ -106,17 +80,6 @@ if (! isset($go)) {
"Modify Experiment Documentation (FAQ)</a></h3>"; "Modify Experiment Documentation (FAQ)</a></h3>";
echo "<br>"; echo "<br>";
#
# Unreleased option?
#
if ($isadmin) {
echo "<font size='+1'>You can ".
"<a href='buildui/bui.php3?action=modify&pid=$pid&eid=$eid'>".
"modify this experiment with NetBuild</a>, ".
"or edit the NS directly:</font>";
echo "<br>";
}
if (STUDLY()) { if (STUDLY()) {
echo "<font size='+1'>". echo "<font size='+1'>".
"<a href='clientui.php3?pid=$pid&eid=$eid'>GUI Editor</a>". "<a href='clientui.php3?pid=$pid&eid=$eid'>GUI Editor</a>".
...@@ -124,7 +87,7 @@ if (! isset($go)) { ...@@ -124,7 +87,7 @@ if (! isset($go)) {
echo "<br>"; echo "<br>";
} }
echo "<form action='modifyexp.php3' method='post'>"; echo "<form action='modifyexp.php3?pid=$pid&eid=$eid' method='post'>";
echo "<textarea cols='100' rows='40' name='nsdata'>"; echo "<textarea cols='100' rows='40' name='nsdata'>";
$query_result = $query_result =
...@@ -159,8 +122,6 @@ if (! isset($go)) { ...@@ -159,8 +122,6 @@ if (! isset($go)) {
Restart Event System in experiment (Highly Recommended)</input>"; Restart Event System in experiment (Highly Recommended)</input>";
} }
echo "<br>"; echo "<br>";
echo "<input type='hidden' name='pid' value='$pid'>";
echo "<input type='hidden' name='eid' value='$eid'>";
echo "<input type='submit' name='go' value='Modify'>"; echo "<input type='submit' name='go' value='Modify'>";
echo "</form>\n"; echo "</form>\n";
PAGEFOOTER(); PAGEFOOTER();
...@@ -211,9 +172,6 @@ if ($retval != 0) { ...@@ -211,9 +172,6 @@ if ($retval != 0) {
if ($retval < 0) { if ($retval < 0) {
SUEXECERROR(SUEXEC_ACTION_CONTINUE); SUEXECERROR(SUEXEC_ACTION_CONTINUE);
} }
# Netbuild requires the following line.
echo "\n\n<!-- NetBuild! Modifed NS file contains syntax errors -->\n\n";
echo "<br>"; echo "<br>";
echo "<h3>Modified NS file contains syntax errors</h3>"; echo "<h3>Modified NS file contains syntax errors</h3>";
echo "<blockquote><pre>$suexec_output<pre></blockquote>"; echo "<blockquote><pre>$suexec_output<pre></blockquote>";
...@@ -222,12 +180,6 @@ if ($retval != 0) { ...@@ -222,12 +180,6 @@ if ($retval != 0) {
exit(); exit();
} }
echo "<center>";
echo "<h2>Starting experiment modify. Please wait a moment ...
</h2></center>";
flush();
# #
# Avoid SIGPROF in child. # Avoid SIGPROF in child.
# #
...@@ -248,9 +200,6 @@ unlink($nsfile); ...@@ -248,9 +200,6 @@ unlink($nsfile);
# do with the error. Also reports to tbops. # do with the error. Also reports to tbops.
# #
if ($retval < 0) { if ($retval < 0) {
# the following line is required for Netbuild interaction.
echo "\n\n<!-- Netbuild! Modify failed -->\n\n";
SUEXECERROR(SUEXEC_ACTION_DIE); SUEXECERROR(SUEXEC_ACTION_DIE);
# #
# Never returns ... # Never returns ...
...@@ -265,16 +214,12 @@ echo "<br>\n"; ...@@ -265,16 +214,12 @@ echo "<br>\n";
if ($retval) { if ($retval) {
echo "<h3>Experiment modify could not proceed</h3>"; echo "<h3>Experiment modify could not proceed</h3>";
echo "<blockquote><pre>$suexec_output<pre></blockquote>"; echo "<blockquote><pre>$suexec_output<pre></blockquote>";
# the following line is required for Netbuild interaction.
echo "\n\n<!-- Netbuild! Modify failed -->\n\n";
} }
else { else {
# #
# Exit status 0 means the experiment is modifying. # Exit status 0 means the experiment is modifying.
# #
echo "<br>"; echo "<b>Your experiment is being modified!</b> ";
echo "Your experiment is being modified!<br><br>";
echo "You will be notified via email when the experiment has ". echo "You will be notified via email when the experiment has ".
"finished modifying and you are able to proceed. This ". "finished modifying and you are able to proceed. This ".
"typically takes less than 10 minutes, depending on the ". "typically takes less than 10 minutes, depending on the ".
...@@ -283,12 +228,8 @@ else { ...@@ -283,12 +228,8 @@ else {
"reasonable amount time, please contact $TBMAILADDR. ". "reasonable amount time, please contact $TBMAILADDR. ".
"<br><br>". "<br><br>".
"While you are waiting, you can watch the log of experiment ". "While you are waiting, you can watch the log of experiment ".
"modification in ". "modification in realtime:<br>\n";
"<a href=showlogfile.php3?pid=$pid&eid=$eid> ". STARTLOG($pid, $eid);
"realtime</a>.\n";
# the following line is required for Netbuild.
echo "\n\n<!-- Netbuild! success -->\n\n";
} }
# #
......
...@@ -110,14 +110,16 @@ function ml_getBodyText(ifr) { ...@@ -110,14 +110,16 @@ function ml_getBodyText(ifr) {
/* @return The innerHeight of the window. */ /* @return The innerHeight of the window. */
function ml_getInnerHeight() { function ml_getInnerHeight() {
var retval; var retval;
var win = document.getElementById('outputframe').contentWindow;
var doc = document.getElementById('outputframe').contentWindow.document;
if (self.innerHeight) // all except Explorer if (win.innerHeight) // all except Explorer
retval = self.innerHeight; retval = win.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight) else if (doc.documentElement && doc.documentElement.clientHeight)
// Explorer 6 Strict Mode // Explorer 6 Strict Mode
retval = document.documentElement.clientHeight; retval = doc.documentElement.clientHeight;
else if (document.body) // other Explorers else if (doc.body) // other Explorers
retval = document.body.clientHeight; retval = doc.body.clientHeight;
return retval; return retval;
} }
...@@ -125,9 +127,11 @@ function ml_getInnerHeight() { ...@@ -125,9 +127,11 @@ function ml_getInnerHeight() {
/* @return The scrollTop of the window. */ /* @return The scrollTop of the window. */
function ml_getScrollTop() { function ml_getScrollTop() {
var retval; var retval;
var win = document.getElementById('outputframe').contentWindow;
var doc = document.getElementById('outputframe').contentWindow.document;
if (self.pageYOffset) // all except Explorer if (win.pageYOffset) // all except Explorer
retval = self.pageYOffset; retval = win.pageYOffset;
else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
retval = document.documentElement.scrollTop; retval = document.documentElement.scrollTop;
else if (document.body) // all other Explorers else if (document.body) // all other Explorers
...@@ -139,14 +143,16 @@ function ml_getScrollTop() { ...@@ -139,14 +143,16 @@ function ml_getScrollTop() {
/* @return The height of the document. */ /* @return The height of the document. */
function ml_getScrollHeight() { function ml_getScrollHeight() {
var retval; var retval;
var test1 = document.body.scrollHeight; var win = document.getElementById('outputframe').contentWindow;
var test2 = document.body.offsetHeight; var doc = document.getElementById('outputframe').contentWindow.document;
var test1 = doc.body.scrollHeight;
var test2 = doc.body.offsetHeight;
if (test1 > test2) // all but Explorer Mac if (test1 > test2) // all but Explorer Mac
retval = document.body.scrollHeight; retval = doc.body.scrollHeight;
else // Explorer Mac; else // Explorer Mac;
//would also work in Explorer 6 Strict, Mozilla and Safari //would also work in Explorer 6 Strict, Mozilla and Safari
retval = document.body.offsetHeight; retval = doc.body.offsetHeight;
return retval; return retval;
} }
...@@ -158,7 +164,9 @@ function ml_getScrollHeight() { ...@@ -158,7 +164,9 @@ function ml_getScrollHeight() {
* @param state The state of the download. * @param state The state of the download.
*/ */
function ml_handleReadyState(state) { function ml_handleReadyState(state) {
var oa = document.getElementById('outputarea'); var Iframe = document.getElementById('outputframe');
var idoc = Iframe.contentWindow.document;
var oa = Iframe.contentWindow.document.getElementById('outputarea');
var dl = document.getElementById('downloader'); var dl = document.getElementById('downloader');
if ((rt = ml_getBodyText(dl)) == null) { if ((rt = ml_getBodyText(dl)) == null) {
...@@ -237,7 +245,7 @@ function ml_handleReadyState(state) { ...@@ -237,7 +245,7 @@ function ml_handleReadyState(state) {
if (line.indexOf('***') != -1 || if (line.indexOf('***') != -1 ||
(lastError == i - 1) && line.indexOf(' ') == 0) { (lastError == i - 1) && line.indexOf(' ') == 0) {
if (plain != "") { if (plain != "") {
tn = document.createTextNode(plain); tn = idoc.createTextNode(plain);
oa.appendChild(tn); oa.appendChild(tn);
} }
plain = ""; plain = "";
...@@ -281,9 +289,9 @@ function ml_handleReadyState(state) { ...@@ -281,9 +289,9 @@ function ml_handleReadyState(state) {
pnode = lengths[index]; pnode = lengths[index];
plain += line.substring(lastIndex, index); plain += line.substring(lastIndex, index);
tn = document.createTextNode(plain); tn = idoc.createTextNode(plain);
if (hasError) { if (hasError) {
fn = document.createElement("font"); fn = idoc.createElement("font");
fn.setAttribute("color", "red"); fn.setAttribute("color", "red");
fn.appendChild(tn); fn.appendChild(tn);
oa.appendChild(fn); oa.appendChild(fn);
...@@ -295,10 +303,11 @@ function ml_handleReadyState(state) { ...@@ -295,10 +303,11 @@ function ml_handleReadyState(state) {
/* Create the link. */ /* Create the link. */
var linktext = line.substring(index, index + pnode.length); var linktext = line.substring(index, index + pnode.length);
var nlink = document.createElement("A"); var nlink = idoc.createElement("A");
nlink.setAttribute('href', nlink.setAttribute('href',
'shownode.php3?node_id=' + pnode); 'shownode.php3?node_id=' + pnode);
tn = document.createTextNode(linktext); nlink.setAttribute('target', '_parent');
tn = idoc.createTextNode(linktext);
nlink.appendChild(tn); nlink.appendChild(tn);
oa.appendChild(nlink); oa.appendChild(nlink);
...@@ -307,8 +316,8 @@ function ml_handleReadyState(state) { ...@@ -307,8 +316,8 @@ function ml_handleReadyState(state) {
} }
if (hasError) { if (hasError) {
/* It is an error line, turn it red. */ /* It is an error line, turn it red. */
tn = document.createTextNode(line.substring(lastIndex)); tn = idoc.createTextNode(line.substring(lastIndex));
fn = document.createElement("font"); fn = idoc.createElement("font");
fn.setAttribute("color", "red"); fn.setAttribute("color", "red");
fn.appendChild(tn); fn.appendChild(tn);
oa.appendChild(fn); oa.appendChild(fn);
...@@ -329,15 +338,15 @@ function ml_handleReadyState(state) { ...@@ -329,15 +338,15 @@ function ml_handleReadyState(state) {
if (state == LOG_STATE_LOADED) if (state == LOG_STATE_LOADED)
plain += lastLine; plain += lastLine;
tn = document.createTextNode(plain); tn = idoc.createTextNode(plain);
oa.appendChild(tn); oa.appendChild(tn);
var nh = ml_getScrollHeight(); var nh = ml_getScrollHeight();
/* See if we should scroll the window down. */ /* See if we should scroll the window down. */
if ((h - (y + ih)) < (y == 0 ? 200 : 10)) { if ((h - (y + ih)) < (y == 0 ? 200 : 10)) {
document.documentElement.scrollTop = nh; Iframe.contentWindow.document.documentElement.scrollTop = nh;
document.body.scrollTop = nh; Iframe.contentWindow.document.body.scrollTop = nh;
} }
} }
} }
...@@ -7,17 +7,6 @@ ...@@ -7,17 +7,6 @@
include("defs.php3"); include("defs.php3");
include("showstuff.php3"); include("showstuff.php3");
require("Sajax.php");
sajax_init();
sajax_export("GetPNodes");
# If this call is to client request function, then turn off interactive mode.
# All errors will go to above function and get reported back through the
# Sajax interface.
if (sajax_client_request()) {
$session_interactive = 0;
}
# #
# Only known and logged in users can look at experiments. # Only known and logged in users can look at experiments.
# #
...@@ -25,63 +14,17 @@ $uid = GETLOGIN(); ...@@ -25,63 +14,17 @@ $uid = GETLOGIN();
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid); $isadmin = ISADMIN($uid);
function CHECKPAGEARGS($pid, $eid) { # This will not return if its a sajax request.
global $uid, $TB_EXPT_READINFO; include("showlogfile_sup.php3");
#
# 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)) {