nodecontrol.php3 3.34 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include_once("node_defs.php");
26

27 28 29
#
# Only known and logged in users can do this.
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33 34

#
35 36 37 38 39
# Verify page arguments.
#
$reqargs = RequiredPageArguments("node",	      PAGEARG_NODE,
				 "def_boot_osid",     PAGEARG_STRING,
				 "def_boot_cmd_line", PAGEARG_STRING,
40
				 "startupcmd",        PAGEARG_ANYTHING,
41 42 43 44 45 46 47 48
				 "tarballs",          PAGEARG_STRING,
				 "rpms",              PAGEARG_STRING);
$optargs = OptionalPageArguments("next_boot_osid",     PAGEARG_STRING,
				 "next_boot_cmd_line", PAGEARG_STRING,
				 "temp_boot_osid",     PAGEARG_STRING);

# Need these below.
$node_id = $node->node_id();
49

50 51 52 53
#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
54 55 56
if (!$isadmin &&
    !$node->AccessCheck($this_user, $TB_NODEACCESS_MODIFYINFO)) {
    USERERROR("You do not have permission to modify node parameters!", 1);
57 58
}

59 60 61 62 63
#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

64
#
65 66
# Check each parameter. Also note that when setting/clearing values,
# send the argument to the backend script *only when changed*
Leigh Stoller's avatar
Leigh Stoller committed
67
#
68 69
$command_string = "";

70
if ($def_boot_osid != $node->def_boot_osid()) {
71 72
    $command_string .=
	"default_boot_osid=" . escapeshellarg($def_boot_osid) . " ";
73
}
74
if ($def_boot_cmd_line != $node->def_boot_cmd_line()) {
75 76
    $command_string .=
	"default_boot_cmdline=" . escapeshellarg($def_boot_cmd_line) . " ";
77
}
78
if ($startupcmd != $node->startupcmd()) {
79
    $command_string .= "startup_command=" . escapeshellarg($startupcmd) . " ";
80
}
81
if ($tarballs != $node->tarballs()) {
82
    $command_string .= "tarfiles=" . escapeshellarg($tarballs) . " ";
83
}
84
if ($rpms != $node->rpms()) {
85
    $command_string .= "rpms=" . escapeshellarg($rpms) . " ";
86
}
87 88

if ($isadmin) {
89 90
    if (isset($next_boot_osid) &&
	$next_boot_osid != $node->next_boot_osid()) {
91 92
	$command_string .=
	    "next_boot_osid=" . escapeshellarg($next_boot_osid) . " ";
93
    }
94 95
    if (isset($next_boot_cmd_line) &&
	$next_boot_cmd_line != $node->next_boot_cmd_line()) {
96 97
	$command_string .=
	    "next_boot_cmdline=" . escapeshellarg($next_boot_cmd_line) . " ";
98
    }
99 100
    if (isset($temp_boot_osid) &&
	$temp_boot_osid != $node->temp_boot_osid()) {
101 102
	$command_string .=
	    "temp_boot_osid=" . escapeshellarg($temp_boot_osid) . " ";
103
    }
104
}
105

106
STARTBUSY("Making changes to $node_id");
107
SUEXEC($uid, "nobody", "webnode_control $command_string $node_id",
108
       SUEXEC_ACTION_DIE);
109
STOPBUSY();
110

111
PAGEREPLACE(CreateURL("shownode", $node));
112

113
#
114 115 116
# Standard Testbed Footer
# 
PAGEFOOTER();
117
?>