replayexp.php3 3.06 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28
#
include("defs.php3");

#
# Only known and logged in users can end experiments.
#
29 30 31
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
32 33

#
34 35 36 37 38
# Verify page arguments.
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("canceled",   PAGEARG_STRING,
				 "confirmed",  PAGEARG_STRING);
39 40

# Canceled operation redirects back to showexp page. See below.
41 42
if (isset($canceled) && $canceled) {
    header("Location: " . CreateURL("showexp", $experiment));
43 44 45 46 47 48 49 50 51
    return;
}

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

#
52
# Need these below
53
#
54 55 56
$pid = $experiment->pid();
$eid = $experiment->eid();
$unix_gid = $experiment->UnixGID();
57 58
$project  = $experiment->Project();
$unix_pid = $project->unix_gid();
59 60 61 62

#
# Verify permissions.
#
63 64
if (!$experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission for $eid!", 1);
65 66
}

67 68
echo $experiment->PageHeader();
echo "<br>\n";
69 70 71 72 73 74 75

#
# 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).
#
76
if (!isset($confirmed)) {
77
    echo "<center><h2><br>
78
          Are you sure you want to replay all events in experiment '$eid?'
79 80
          </h2>\n";
    
81
    $experiment->Show(1);
82

83 84 85
    $url = CreateURL("replayexp", $experiment);
    
    echo "<form action='$url' method=post>";
86 87 88 89 90 91 92 93 94 95 96 97 98
    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);

99
STARTBUSY("Starting event replay");
100
$retval = SUEXEC($uid, "$unix_pid,$unix_gid",
101
		 "webeventsys_control replay $pid,$eid",
102 103 104 105 106 107 108 109 110 111 112 113 114 115
		 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("");
}
116 117 118 119 120 121 122 123

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

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