nodecontrol.php3 2.4 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2002, 2004 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");
Leigh B. Stoller's avatar
Leigh B. 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 B. Stoller's avatar
Leigh B. Stoller committed
24
$query_result =
25
    DBQueryFatal("SELECT * FROM nodes WHERE node_id='$node_id'");
26
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
27
    USERERROR("The node $node_id is not a valid nodeid!", 1);
28
}
29
$row = mysql_fetch_array($query_result);
30

31 32 33 34 35 36
#
# 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
37
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
38 39 40 41
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

42
#
43 44
# Check each parameter. Also note that when setting/clearing values,
# send the argument to the backend script *only when changed*
45
#
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
$command_string = "";

if ($def_boot_osid != $row[def_boot_osid]) {
    $command_string .= "default_boot_osid='$def_boot_osid' ";
}
if ($def_boot_cmd_line != $row[def_boot_cmd_line]) {
    $command_string .= "default_boot_cmdline='$def_boot_cmd_line' ";
}
if ($startupcmd != $row[startupcmd]) {
    $command_string .= "startup_command='$startupcmd' ";
}
if ($tarballs != $row[tarballs]) {
    $command_string .= "tarfiles='$tarballs' ";
}
if ($rpms != $row[rpms]) {
    $command_string .= "rpms='$rpms' ";
}
63 64

if ($isadmin) {
65 66 67 68 69 70 71 72 73
    if ($next_boot_osid != $row[next_boot_osid]) {
	$command_string .= "next_boot_osid='$next_boot_osid' ";
    }
    if ($next_boot_cmd_line != $row[next_boot_cmd_line]) {
	$command_string .= "next_boot_cmdline='$next_boot_cmd_line' ";
    }
    if ($temp_boot_osid != $row[temp_boot_osid]) {
	$command_string .= "temp_boot_osid='$temp_boot_osid' ";
    }
74
}
75

76
#
77
# Pass it off to the script. It will check the arguments.
78
#
79 80
SUEXEC($uid, "nobody", "webnodecontrol $command_string $node_id",
       SUEXEC_ACTION_DIE);
81

82
echo "<center>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
83 84 85 86
      <br>
      <h3>Node parameters successfully modified!</h3><p>
      </center>\n";

87
SHOWNODE($node_id, SHOWNODE_NOFLAGS);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
88 89 90 91

#
# Edit option.
#
92 93 94
echo "<br><center>
           <A href='nodecontrol_form.php3?node_id=$node_id'>
           Edit this the node info?</a>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
95
         </center>\n";
96

97
#
98 99 100
# Standard Testbed Footer
# 
PAGEFOOTER();
101
?>