nodecontrol.php3 1.97 KB
Newer Older
1
2
<?php
include("defs.php3");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
3
include("showstuff.php3");
4

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

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

#
# Check to make sure that this is a valid nodeid
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
19
20
$query_result =
    DBQueryFatal("SELECT node_id FROM nodes WHERE node_id='$node_id'");
21
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
22
    USERERROR("The node $node_id is not a valid nodeid!", 1);
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) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
31
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
32
33
34
35
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

36
37
38
39
if (isset($def_boot_osid) && strcmp($def_boot_osid, "None") == 0) {
    $def_boot_osid = "";
}

40
#
41
42
# Create an update string, that is slightly different if an admin; we allow
# admin people to set next_boot parameters. Ordinary folks cannot.
43
#
44
$query_string =
45
	"UPDATE nodes SET ".
46
	"def_boot_osid=\"$def_boot_osid\",             ".
47
	"def_boot_path=\"$def_boot_path\",             ".
48
	"def_boot_cmd_line=\"$def_boot_cmd_line\",     ".
49
	"startupcmd='$startupcmd',                     ".
50
	"tarballs='$tarballs',                         ".
51
52
53
54
	"rpms='$rpms'                                  ";

if ($isadmin) {
    $query_string = "$query_string, ".
55
	"next_boot_osid=\"$next_boot_osid\",           ".
56
	"next_boot_path=\"$next_boot_path\",           ".
57
58
59
	"next_boot_cmd_line=\"$next_boot_cmd_line\"    ";
}
$query_string = "$query_string WHERE node_id=\"$node_id\"";
60

Leigh B. Stoller's avatar
Leigh B. Stoller committed
61
DBQueryFatal($query_string);
62

63
echo "<center>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
64
65
66
67
68
69
70
71
72
73
74
75
76
      <br>
      <h3>Node parameters successfully modified!</h3><p>
      </center>\n";

SHOWNODE($node_id);

#
# Edit option.
#
echo "<p><center>
           Do you want to edit this the node info?
           <A href='nodecontrol_form.php3?node_id=$node_id'>Yes</a>
         </center>\n";
77

78
#
79
80
81
# Standard Testbed Footer
# 
PAGEFOOTER();
82
?>