nodecontrol.php3 1.99 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3 4 5 6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
7
include("defs.php3");
Leigh Stoller's avatar
Leigh Stoller committed
8
include("showstuff.php3");
9

10
#
11 12 13
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");
14 15 16 17

#
# Only known and logged in users can do this.
#
18
$uid = GETLOGIN();
19 20 21 22 23
LOGGEDINORDIE($uid);

#
# Check to make sure that this is a valid nodeid
#
Leigh Stoller's avatar
Leigh Stoller committed
24 25
$query_result =
    DBQueryFatal("SELECT node_id FROM nodes WHERE node_id='$node_id'");
26
if (mysql_num_rows($query_result) == 0) {
Leigh Stoller's avatar
Leigh Stoller committed
27
    USERERROR("The node $node_id is not a valid nodeid!", 1);
28 29
}

30 31 32 33 34 35
#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
Leigh Stoller's avatar
Leigh Stoller committed
36
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
37 38 39 40
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

41 42 43 44
if (isset($def_boot_osid) && strcmp($def_boot_osid, "None") == 0) {
    $def_boot_osid = "";
}

45
#
46
# Create a command string, that is slightly different if an admin; we allow
47
# admin people to set next_boot parameters. Ordinary folks cannot.
48
#
49 50 51 52 53 54 55
$command_string =
	"default_boot_osid='$def_boot_osid'		".
	"default_boot_path='$def_boot_path'		".
	"default_boot_cmdline='$def_boot_cmd_line'	".
	"startup_command='$startupcmd'			".
	"tarfiles='$tarballs'                           ".
	"rpms='$rpms'                                   ";
56 57

if ($isadmin) {
58 59 60 61
    $command_string = "$command_string			".
	"next_boot_osid='$next_boot_osid'		".
	"next_boot_path='$next_boot_path'		".
	"next_boot_cmdline='$next_boot_cmd_line'	";
62
}
63

64 65 66 67
#
# Pass it off to the script.
#
SUEXEC($uid, "nobody", "webnodecontrol $command_string $node_id", 1);
68

69
echo "<center>
Leigh Stoller's avatar
Leigh Stoller committed
70 71 72 73 74 75 76 77 78
      <br>
      <h3>Node parameters successfully modified!</h3><p>
      </center>\n";

SHOWNODE($node_id);

#
# Edit option.
#
79 80 81
echo "<br><center>
           <A href='nodecontrol_form.php3?node_id=$node_id'>
           Edit this the node info?</a>
Leigh Stoller's avatar
Leigh Stoller committed
82
         </center>\n";
83

84
#
85 86 87
# Standard Testbed Footer
# 
PAGEFOOTER();
88
?>