updateaccounts.php3 4.67 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
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/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include_once("node_defs.php");
26 27

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

#
35 36 37 38 39 40
# Verify page arguments.
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("node",       PAGEARG_NODE,
				 "canceled",   PAGEARG_BOOLEAN,
				 "confirmed",  PAGEARG_BOOLEAN);
41 42

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

48 49 50 51 52
# Need these below
$pid = $experiment->pid();
$eid = $experiment->eid();
$unix_gid = $experiment->UnixGID();
$node_id  = (isset($node) ? $node->node_id() : "");
53 54
$project  = $experiment->Project();
$unix_pid = $project->unix_gid();
55

56 57 58 59
#
# Standard Testbed Header
#
PAGEHEADER("Update Experimental Nodes");
60 61 62 63

#
# Verify permissions.
#
64
if (!$experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
65
    USERERROR("You do not have permission to initiate node updates!", 1);
66
}
67

68
echo $experiment->PageHeader();
69 70 71 72

#
# 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
73
# set. Or, the user can hit the cancel button (see above).
74
#
75
if (!isset($confirmed)) {
76 77 78 79 80 81
    echo "<br><br><b>
          Confirming this operation will initiate various updates to be
          performed, including updating the password and group files,
          adding new mounts, and installing (or updating if modified) tarballs
          and rpms.
          This is sometimes quicker and easier than rebooting nodes.</b>\n";
82

83 84 85
    echo "<center><h2><br>
          Are you sure you want to perform an update on ";

86 87
    if (isset($node)) {
	echo "node $node_id in experiment '$eid?'\n";
88 89 90 91 92 93
    }
    else {
	echo "all of the nodes in experiment '$eid?'\n";
    }
    echo "</h2>\n";

94 95 96
    if (isset($node)) {
	$node->Show(SHOWNODE_SHORT);
	$url = CreateURL("updateaccounts", $experiment, $node);
97 98
    }
    else {
99 100
	$experiment->Show(1);
	$url = CreateURL("updateaccounts", $experiment);
101
    }
102
    
103
    echo "<form action='$url' method=post>";
104 105 106 107 108 109
    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";
    echo "</center>\n";

    echo "<br>
110 111
          <b>NOTE</b> that this operation will consume a small number of CPU
          cycles on
112
          each node. If this would disturb an experiment in progress, you
Jay Lepreau's avatar
Jay Lepreau committed
113
          should cancel this operation until later.
114 115 116 117 118 119 120
          Please note that accounts are automatically updated whenever a node
          reboots, or when an experiment is swapped back in.\n";

    PAGEFOOTER();
    return;
}

121
STARTBUSY("Starting node update");
122
$retval = SUEXEC($uid, "$unix_pid,$unix_gid",
123
		 "webnode_update -b $pid $eid $node_id",
124
		 SUEXEC_ACTION_IGNORE);
125
CLEARBUSY();
126

127 128 129 130 131 132 133 134 135 136 137
#
# 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("");
}
138 139

#
140
# Exit status 0 means the operation is proceeding in the background.
141
#
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
echo "<br>\n";
if ($retval) {
    echo "<h3>Node update could not proceed</h3>";
    echo "<blockquote><pre>$suexec_output<pre></blockquote>";
}
else {
    echo "You will be notified via email when the update has completed on
          all of the nodes in your experiment. This might take a just a
          few minutes (if updating only accounts) or it might take longer
          if new tar/rpm files need to be installed. In the meantime, the
          experiment is locked it may not be swapped or modified.\n";

    echo "<br><br>
         If you do not receive
         email notification within a reasonable amount of time,
         please contact $TBMAILADDR.\n";
}
159 160 161 162 163 164

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