nodecontrol.php3 2.02 KB
Newer Older
1 2
<?php
include("defs.php3");
3

4
#
5 6 7
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");
8 9 10 11

#
# Only known and logged in users can do this.
#
12
$uid = GETLOGIN();
13 14 15 16 17 18 19 20
LOGGEDINORDIE($uid);

#
# Check to make sure that this is a valid nodeid
#
$query_result = mysql_db_query($TBDBNAME,
	"SELECT node_id FROM nodes WHERE node_id=\"$node_id\"");
if (mysql_num_rows($query_result) == 0) {
21
    USERERROR("The node $node_id is not a valid nodeid", 1);
22 23
}

24 25 26 27 28 29 30
#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    $query_result = mysql_db_query($TBDBNAME,
31 32 33
	"select proj_memb.* from proj_memb left join reserved ".
	"on proj_memb.pid=reserved.pid and proj_memb.uid='$uid' ".
	"where reserved.node_id='$node_id'");
34
    if (mysql_num_rows($query_result) == 0) {
35 36
        USERERROR("The node $node_id is not in an experiment ".
		  "or not in the same project as you", 1);
37 38
    }
    $foorow = mysql_fetch_array($query_result);
39 40
    $trust = $foorow[trust];
    if ($trust != "local_root" && $trust != "group_root") {
41 42 43 44
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

45 46 47 48
if (isset($def_boot_osid) && strcmp($def_boot_osid, "None") == 0) {
    $def_boot_osid = "";
}

49 50 51 52 53
#
# Now change the information.
#
$insert_result = mysql_db_query($TBDBNAME, 
	"UPDATE nodes SET ".
54
	"def_boot_osid=\"$def_boot_osid\",             ".
55
	"def_boot_path=\"$def_boot_path\",             ".
56
	"def_boot_cmd_line=\"$def_boot_cmd_line\",     ".
57
	"next_boot_osid=\"$next_boot_osid\",           ".
58
	"next_boot_path=\"$next_boot_path\",           ".
59
	"next_boot_cmd_line=\"$next_boot_cmd_line\",   ".
60 61
	"startupcmd='$startupcmd',                     ".
	"rpms='$rpms'                                  ".
62 63 64 65 66 67 68
	"WHERE node_id=\"$node_id\"");

if (! $insert_result) {
    $err = mysql_error();
    TBERROR("Database Error changing node setup for $node_id: $err", 1);
}

69 70 71
echo "<center>
      <h3>Node Parameters Changed!</h3>
      </center>";
72

73
#
74 75 76
# Standard Testbed Footer
# 
PAGEFOOTER();
77
?>