nodecontrol.php3 2.49 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
7
include("defs.php3");
8
include_once("node_defs.php");
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 19 20
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
21 22

#
23 24 25 26 27
# Verify page arguments.
#
$reqargs = RequiredPageArguments("node",	      PAGEARG_NODE,
				 "def_boot_osid",     PAGEARG_STRING,
				 "def_boot_cmd_line", PAGEARG_STRING,
28
				 "startupcmd",        PAGEARG_ANYTHING,
29 30 31 32 33 34 35 36
				 "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();
37

38 39 40 41
#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
42 43 44
if (!$isadmin &&
    !$node->AccessCheck($this_user, $TB_NODEACCESS_MODIFYINFO)) {
    USERERROR("You do not have permission to modify node parameters!", 1);
45 46
}

47
#
48 49
# Check each parameter. Also note that when setting/clearing values,
# send the argument to the backend script *only when changed*
50
#
51 52
$command_string = "";

53
if ($def_boot_osid != $node->def_boot_osid()) {
54 55
    $command_string .= "default_boot_osid='$def_boot_osid' ";
}
56
if ($def_boot_cmd_line != $node->def_boot_cmd_line()) {
57 58
    $command_string .= "default_boot_cmdline='$def_boot_cmd_line' ";
}
59
if ($startupcmd != $node->startupcmd()) {
60
    $command_string .= "startup_command=" . escapeshellarg($startupcmd) . " ";
61
}
62
if ($tarballs != $node->tarballs()) {
63 64
    $command_string .= "tarfiles='$tarballs' ";
}
65
if ($rpms != $node->rpms()) {
66 67
    $command_string .= "rpms='$rpms' ";
}
68 69

if ($isadmin) {
70 71
    if (isset($next_boot_osid) &&
	$next_boot_osid != $node->next_boot_osid()) {
72 73
	$command_string .= "next_boot_osid='$next_boot_osid' ";
    }
74 75
    if (isset($next_boot_cmd_line) &&
	$next_boot_cmd_line != $node->next_boot_cmd_line()) {
76 77
	$command_string .= "next_boot_cmdline='$next_boot_cmd_line' ";
    }
78 79
    if (isset($temp_boot_osid) &&
	$temp_boot_osid != $node->temp_boot_osid()) {
80 81
	$command_string .= "temp_boot_osid='$temp_boot_osid' ";
    }
82
}
83

84
STARTBUSY("Making changes to $node_id");
85
SUEXEC($uid, "nobody", "webnode_control $command_string $node_id",
86
       SUEXEC_ACTION_DIE);
87
STOPBUSY();
88

89
PAGEREPLACE(CreateURL("shownode", $node));
90

91
#
92 93 94
# Standard Testbed Footer
# 
PAGEFOOTER();
95
?>