replayexp.php3 2.3 KB
Newer Older
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
5 6 7 8 9 10 11
# All rights reserved.
#
include("defs.php3");

#
# Only known and logged in users can end experiments.
#
12 13 14
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
15 16

#
17 18 19 20 21
# Verify page arguments.
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("canceled",   PAGEARG_STRING,
				 "confirmed",  PAGEARG_STRING);
22 23

# Canceled operation redirects back to showexp page. See below.
24 25
if (isset($canceled) && $canceled) {
    header("Location: " . CreateURL("showexp", $experiment));
26 27 28 29 30 31 32 33 34
    return;
}

#
# Standard Testbed Header, after cancel above.
#
PAGEHEADER("Replay Control");

#
35
# Need these below
36
#
37 38 39
$pid = $experiment->pid();
$eid = $experiment->eid();
$unix_gid = $experiment->UnixGID();
40 41 42 43

#
# Verify permissions.
#
44 45
if (!$experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission for $eid!", 1);
46 47
}

48 49
echo $experiment->PageHeader();
echo "<br>\n";
50 51 52 53 54 55 56

#
# 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 
# redirect the browser back to the experiment page (see above).
#
57
if (!isset($confirmed)) {
58
    echo "<center><h2><br>
59
          Are you sure you want to replay all events in experiment '$eid?'
60 61
          </h2>\n";
    
62
    $experiment->Show(1);
63

64 65 66
    $url = CreateURL("replayexp", $experiment);
    
    echo "<form action='$url' method=post>";
67 68 69 70 71 72 73 74 75 76 77 78 79
    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";

    PAGEFOOTER();
    return;
}

#
# Avoid SIGPROF in child.
# 
set_time_limit(0);

80 81
STARTBUSY("Starting event replay");
$retval = SUEXEC($uid, "$pid,$unix_gid",
82
		 "webeventsys_control replay $pid,$eid",
83 84 85 86 87 88 89 90 91 92 93 94 95 96
		 SUEXEC_ACTION_IGNORE);
CLEARBUSY();

#
# Fatal Error. Report to the user, even though there is not much he can
# do with the error. Also reports to tbops.
# 
if ($retval < 0) {
    SUEXECERROR(SUEXEC_ACTION_DIE);
    #
    # Never returns ...
    #
    die("");
}
97 98 99 100 101 102 103 104

echo "Events for your experiment are now being replayed.\n";

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>