updateaccounts.php3 3.92 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2004, 2006, 2007 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7
include("defs.php3");
8
include_once("node_defs.php");
9 10

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

#
18 19 20 21 22 23
# Verify page arguments.
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("node",       PAGEARG_NODE,
				 "canceled",   PAGEARG_BOOLEAN,
				 "confirmed",  PAGEARG_BOOLEAN);
24 25

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

31 32 33 34 35 36
# Need these below
$pid = $experiment->pid();
$eid = $experiment->eid();
$unix_gid = $experiment->UnixGID();
$node_id  = (isset($node) ? $node->node_id() : "");

37 38 39 40
#
# Standard Testbed Header
#
PAGEHEADER("Update Experimental Nodes");
41 42 43 44

#
# Verify permissions.
#
45
if (!$experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
46
    USERERROR("You do not have permission to initiate node updates!", 1);
47
}
48

49
echo $experiment->PageHeader();
50 51 52 53

#
# 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
54
# set. Or, the user can hit the cancel button (see above).
55
#
56
if (!isset($confirmed)) {
57 58 59 60 61 62
    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";
63

64 65 66
    echo "<center><h2><br>
          Are you sure you want to perform an update on ";

67 68
    if (isset($node)) {
	echo "node $node_id in experiment '$eid?'\n";
69 70 71 72 73 74
    }
    else {
	echo "all of the nodes in experiment '$eid?'\n";
    }
    echo "</h2>\n";

75 76 77
    if (isset($node)) {
	$node->Show(SHOWNODE_SHORT);
	$url = CreateURL("updateaccounts", $experiment, $node);
78 79
    }
    else {
80 81
	$experiment->Show(1);
	$url = CreateURL("updateaccounts", $experiment);
82
    }
83
    
84
    echo "<form action='$url' method=post>";
85 86 87 88 89 90
    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>
91 92
          <b>NOTE</b> that this operation will consume a small number of CPU
          cycles on
93
          each node. If this would disturb an experiment in progress, you
Jay Lepreau's avatar
typo  
Jay Lepreau committed
94
          should cancel this operation until later.
95 96 97 98 99 100 101
          Please note that accounts are automatically updated whenever a node
          reboots, or when an experiment is swapped back in.\n";

    PAGEFOOTER();
    return;
}

102
STARTBUSY("Starting node update");
103
$retval = SUEXEC($uid, "$pid,$unix_gid",
104
		 "webnode_update -b $pid $eid $node_id",
105
		 SUEXEC_ACTION_IGNORE);
106
CLEARBUSY();
107

108 109 110 111 112 113 114 115 116 117 118
#
# 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("");
}
119 120

#
121
# Exit status 0 means the operation is proceeding in the background.
122
#
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
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";
}
140 141 142 143 144 145

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