Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
e0a72dc6
Commit
e0a72dc6
authored
Jun 29, 2004
by
Leigh B. Stoller
Browse files
Minor change to "Run Linktest" menu option; when the is a non-zero pid
in the DB, change that to Stop Linktest instead.
parent
159076bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
www/linktest.php3
View file @
e0a72dc6
...
...
@@ -31,6 +31,9 @@ if (isset($pid) && strcmp($pid, "") &&
if
(
!
TBValidExperiment
(
$pid
,
$eid
))
{
USERERROR
(
"
$pid
/
$eid
is not a valid experiment!"
,
1
);
}
if
(
TBExptState
(
$pid
,
$eid
)
!=
$TB_EXPTSTATE_ACTIVE
)
{
USERERROR
(
"
$pid
/
$eid
is not currently swapped in!"
,
1
);
}
if
(
!
TBExptAccessCheck
(
$uid
,
$pid
,
$eid
,
$TB_EXPT_MODIFY
))
{
USERERROR
(
"You do not have permission to run linktest on
$pid
/
$eid
!"
,
1
);
...
...
@@ -40,16 +43,61 @@ else {
PAGEARGERROR
(
"Must specify pid and eid!"
);
}
$query_result
=
DBQueryFatal
(
"select gid,linktest_level from experiments "
.
"where pid='
$pid
' and eid='
$eid
'"
);
# Need the GID, plus current level and the pid.
$query_result
=
DBQueryFatal
(
"select gid,linktest_level,linktest_pid from experiments "
.
"where pid='
$pid
' and eid='
$eid
'"
);
$row
=
mysql_fetch_array
(
$query_result
);
$gid
=
$row
[
0
];
$gid
=
$row
[
0
];
$linktest_level
=
$row
[
1
];
$linktest_pid
=
$row
[
2
];
# For backend script calls below!
TBGroupUnixInfo
(
$pid
,
$gid
,
$unix_gid
,
$unix_name
);
#
# If we already have a linktest pid, then do not want to start another
# one. This is going to happen if someone loads this page directly; if
# we come in from the frameset below, then $frame will be set and we do
# not want put up this menu.
#
if
(
$linktest_pid
&&
!
isset
(
$frame
))
{
if
(
isset
(
$killit
)
&&
$killit
==
"Stop Linktest"
)
{
#
# Form submitted. Kill running linktest and zap back to the initial
# page to redisplay the menu.
#
SUEXEC
(
$uid
,
$unix_gid
,
"weblinktest -k
$pid
$eid
"
,
SUEXEC_ACTION_DIE
);
header
(
"Location: linktest.php3?pid=
$pid
&eid=
$eid
"
);
return
;
}
PAGEHEADER
(
"Kill running Linktest"
);
echo
"<font size=+2>Experiment <b>"
.
"<a href='showproject.php3?pid=
$pid
'>
$pid
</a>/"
.
"<a href='showexp.php3?pid=
$pid
&eid=
$eid
'>
$eid
</a></b></font>
\n
"
;
echo
"<center><font size=+2><br>
A Linktest is already running; click to stop it!
</font><br><br>
\n
"
;
echo
"<form action=linktest.php3 method=post>"
;
echo
"<input type=hidden name=pid value=
$pid
>
\n
"
;
echo
"<input type=hidden name=eid value=
$eid
>
\n
"
;
echo
"<b><input type=submit name=killit value='Stop Linktest'></b>
\n
"
;
echo
"</form>
\n
"
;
echo
"</center>
\n
"
;
PAGEFOOTER
();
return
;
}
#
# See if a level came in. If not, then get the default from the DB.
#
if
(
!
isset
(
$level
)
||
$level
==
""
)
{
$level
=
$
row
[
1
]
;
$level
=
$
linktest_level
;
}
elseif
(
!
TBvalid_tinyint
(
$level
)
||
$level
<
0
||
$level
>
TBDB_LINKTEST_MAX
)
{
...
...
@@ -57,6 +105,95 @@ elseif (! TBvalid_tinyint($level) ||
TBDB_LINKTEST_MAX
);
}
#
# If user hits stop button in the output side, stop linktest.
#
$fp
=
0
;
function
SPEWCLEANUP
()
{
global
$fp
;
if
(
connection_aborted
()
&&
$fp
)
{
SUEXEC
(
$uid
,
$unix_gid
,
"weblinktest -k
$pid
$eid
"
,
SUEXEC_ACTION_IGNORE
);
pclose
(
$fp
);
exit
();
}
}
#
# Respond to the frame requests that are set up below.
#
if
(
isset
(
$frame
))
{
if
(
$frame
==
"stopbutton"
)
{
if
(
isset
(
$submit
)
&&
$submit
==
"Stop"
)
{
SUEXEC
(
$uid
,
$unix_gid
,
"weblinktest -k
$pid
$eid
"
,
SUEXEC_ACTION_IGNORE
);
echo
"<html>
<center>
<font size=+1><b>Linktest is shutting down</b></font>
</center>
</html>
\n
"
;
return
;
}
#
# Throw up a simple form to stop the linktest run.
#
echo
"<html>
<center>
<font size=+1><b>Click to stop linktest run</b></font>
<br>
<form action=linktest.php3 method=post target=stopbutton>
\n
"
;
echo
" <input type=hidden name=pid value=
$pid
>
\n
"
;
echo
" <input type=hidden name=eid value=
$eid
>
\n
"
;
echo
" <input type=hidden name=frame value=stopbutton>
\n
"
;
echo
"<b><input type=submit name=submit value='Stop'></b>
\n
"
;
echo
"</form>
</center>
</html>
\n
"
;
return
;
}
# Else must be the content side.
register_shutdown_function
(
"SPEWCLEANUP"
);
ignore_user_abort
(
1
);
set_time_limit
(
0
);
$fp
=
popen
(
"
$TBSUEXEC_PATH
"
.
"
$uid
$unix_gid
weblinktest -l
$level
$pid
$eid
"
,
"r"
);
if
(
!
$fp
)
{
USERERROR
(
"Linktest failed!"
,
1
);
}
header
(
"Content-Type: text/plain"
);
header
(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT"
);
header
(
"Cache-Control: no-cache, must-revalidate"
);
header
(
"Pragma: no-cache"
);
flush
();
# See if we can get the browser to say something.
echo
date
(
"D M d G:i:s T"
);
echo
"
\n
"
;
echo
"Starting linktest run at level
$level
\n
"
;
flush
();
while
(
!
feof
(
$fp
))
{
$string
=
fgets
(
$fp
,
1024
);
echo
"
$string
"
;
flush
();
}
$retval
=
pclose
(
$fp
);
$fp
=
0
;
if
(
$retval
==
0
)
echo
"Linktest run was successful!
\n
"
;
echo
date
(
"D M d G:i:s T"
);
echo
"
\n
"
;
return
;
}
#
# 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
...
...
@@ -84,11 +221,12 @@ if (!$confirmed) {
echo
"<center><font size=+2><br>
Are you <b>REALLY</b>
sure you want to run linktest at level
$level
?
</font>
\n
"
;
</font>
<br><br>
\n
"
;
SHOWEXP
(
$pid
,
$eid
,
1
);
echo
"<form action=linktest.php3 method=post>"
;
echo
"<br>
\n
"
;
echo
"<form action=linktest.php3 method=post target=_linktest>"
;
echo
"<input type=hidden name=pid value=
$pid
>
\n
"
;
echo
"<input type=hidden name=eid value=
$eid
>
\n
"
;
...
...
@@ -123,52 +261,31 @@ if (!$confirmed) {
}
#
# A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
# Throw up a simple frameset.
#
$fp
=
0
;
function
SPEWCLEANUP
()
{
global
$fp
;
echo
"<html>
<script language=JavaScript>
<!--
function LinktestDone() {
var html = '<html><center>' +
'<font size=+1><b>Linktest has finished</b></font>' +
'</center></html>';
if
(
connection_aborted
()
&&
$fp
)
{
pclose
(
$fp
);
}
exit
();
}
register_shutdown_function
(
"SPEWCLEANUP"
);
ignore_user_abort
(
1
);
# For backend.
TBGroupUnixInfo
(
$pid
,
$gid
,
$unix_gid
,
$unix_name
);
$fp
=
popen
(
"
$TBSUEXEC_PATH
$uid
$unix_gid
weblinktest -l
$level
-e
$pid
/
$eid
"
,
"r"
);
if
(
!
$fp
)
{
USERERROR
(
"Linktest failed!"
,
1
);
}
header
(
"Content-Type: text/plain"
);
header
(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT"
);
header
(
"Cache-Control: no-cache, must-revalidate"
);
header
(
"Pragma: no-cache"
);
flush
();
echo
date
(
"D M d G:i:s T"
);
echo
"
\n
"
;
echo
"Starting linktest run at level
$level
\n
"
;
flush
();
while
(
!
feof
(
$fp
))
{
$string
=
fgets
(
$fp
,
1024
);
echo
"
$string
"
;
flush
();
}
$retval
=
pclose
(
$fp
);
$fp
=
0
;
if
(
$retval
==
0
)
echo
"Linktest run was successful!
\n
"
;
echo
date
(
"D M d G:i:s T"
);
echo
"
\n
"
;
parent.stopbutton.document.close();
parent.stopbutton.document.open();
parent.stopbutton.document.write(html);
}
//-->
</script>
\n
"
;
echo
" <frameset cols=
\"
10%,*
\"
border=5 onLoad=
\"
LinktestDone()
\"
>
<frame src=
\"
linktest.php3?pid=
$pid
&eid=
$eid
&frame=stopbutton
\"
name=stopbutton>
<frame src=
\"
linktest.php3?"
.
"pid=
$pid
&eid=
$eid
&level=
$level
&frame=output
\"
name=output>
<noframes>You must use a browser that can display frames
to see this page.
</noframes>
</frameset>
\n
"
;
?>
www/showexp.php3
View file @
e0a72dc6
...
...
@@ -58,7 +58,8 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
# Need some DB info.
#
$query_result
=
DBQueryFatal
(
"select e.idx,e.state,e.batchmode,s.rsrcidx,r.wirelesslans "
.
DBQueryFatal
(
"select e.idx,e.state,e.batchmode,e.linktest_pid,"
.
" s.rsrcidx,r.wirelesslans "
.
" from experiments as e "
.
"left join experiment_stats as s on s.exptidx=e.idx "
.
"left join experiment_resources as r on s.rsrcidx=r.idx "
.
...
...
@@ -69,6 +70,7 @@ $expstate = $row["state"];
$rsrcidx
=
$row
[
"rsrcidx"
];
$isbatch
=
$row
[
"batchmode"
];
$wireless
=
$row
[
"wirelesslans"
];
$linktest_running
=
$row
[
"linktest_pid"
];
echo
"<font size=+2>Experiment <b>"
.
"<a href='showproject.php3?pid=
$pid
'>
$pid
</a>/"
.
...
...
@@ -161,7 +163,8 @@ if ($expstate == $TB_EXPTSTATE_ACTIVE) {
}
if
(
STUDLY
())
{
WRITESUBMENUBUTTON
(
"Run Linktest"
,
WRITESUBMENUBUTTON
((
$linktest_running
?
"Stop LinkTest"
:
"Run LinkTest"
),
"linktest.php3?pid=
$exp_pid
&eid=
$exp_eid
"
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment