Commit d0b5885d authored by Leigh B. Stoller's avatar Leigh B. Stoller

The rest of the node selector support.

parent 51fe60fc
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");
#
# Only known and logged in users can watch LEDs
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# When called from the applet, the variable "fromapplet" will be set.
# In that case, spit back simple text based errors that can go into
# a dialog box.
#
if (isset($fromapplet)) {
$session_interactive = 0;
$session_errorhandler = 'handle_error';
}
else {
PAGEHEADER("Set Robot Destination");
}
#
# Capture script errors in non-interactive case.
#
function handle_error($message, $death)
{
header("Content-Type: text/plain");
echo "$message";
if ($death)
exit(1);
}
#
# Verify page arguments. Allow user to optionally specify building/floor.
#
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
PAGEARGERROR("You must provide a Project ID.");
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
PAGEARGERROR("You must provide an Experiment ID.");
}
if (!preg_match("/^[-\w]+$/", $pid)) {
PAGEARGERROR("Invalid pid argument.");
}
if (!preg_match("/^[-\w]+$/", $eid)) {
PAGEARGERROR("Invalid eid argument.");
}
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($pid, $eid)) {
USERERROR("Experiment $pid/$eid is not a valid experiment.", 1);
}
#
# Verify Permission.
#
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to access experiment $pid/$eid!", 1);
}
if (!isset($nodelist)) {
#
# We expect an array of node ids otherwise.
#
USERERROR("Must specify a nodelist!", 1);
}
#
# Go through the list and check the args. Bail if any are bad.
#
while (list ($vname, $pname) = each ($nodelist)) {
if (!TBvalid_node_id($pname)) {
USERERROR("Illegal characters in node ID.", 1);
}
if (!TBvalid_node_id($vname)) {
USERERROR("Illegal characters in vname.", 1);
}
if (!TBValidNodeName($pname)) {
USERERROR("$node_id is not a valid node name!", 1);
}
}
#
# Okay, now do it for real ...
#
reset($nodelist);
while (list ($vname, $pname) = each ($nodelist)) {
DBQueryFatal("update virt_nodes set fixed='$pname' ".
"where pid='$pid' and eid='$eid' and vname='$vname'");
}
#
# Standard testbed footer
#
if (!isset($fromapplet)) {
PAGEFOOTER();
}
?>
......@@ -49,7 +49,8 @@ register_shutdown_function("SPEWCLEANUP");
# Get the robot information. Actually, this includes motes.
$query_result =
DBQueryFatal("select loc.node_id,r.pid,r.eid,r.vname,n.type,nt.class ".
DBQueryFatal("select loc.node_id,r.pid,r.eid,r.vname,n.type,nt.class, ".
" loc.loc_x,loc.loc_y,loc.loc_z,loc.orientation ".
" from location_info as loc ".
"left join reserved as r on r.node_id=loc.node_id ".
"left join nodes as n on n.node_id=loc.node_id ".
......@@ -65,6 +66,10 @@ while ($row = mysql_fetch_array($query_result)) {
$eid = $row["eid"];
$type = $row["type"];
$class = $row["class"];
$loc_x = $row["loc_x"];
$loc_y = $row["loc_y"];
$loc_z = $row["loc_z"];
$or = $row["orientation"];
$mobile = ($class == "robot" ? 1 : 0);
# In meters.
$size = ($class == "robot" ? 0.27 : 0.07);
......@@ -73,8 +78,21 @@ while ($row = mysql_fetch_array($query_result)) {
if (!isset($vname))
$vname = $pname;
if (!isset($loc_z))
$loc_z = "";
if (!isset($or))
$or = "";
echo "$pname, $vname, $type, $alloc, $mobile, $size, $radius\n";
echo "$pname, ";
if (!isset($selector)) {
echo "$vname, ";
}
echo "$type, $alloc, $mobile, $size, $radius";
if (isset($selector)) {
echo ", $loc_x, $loc_y, $loc_z, $or";
}
echo "\n";
}
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
PAGEHEADER("Node Selector Applet");
#
# Verify page arguments. Allow user to optionally specify building/floor.
#
if (isset($building) && $building != "") {
# Sanitize for the shell.
if (!preg_match("/^[-\w]+$/", $building)) {
PAGEARGERROR("Invalid building argument.");
}
# Optional floor argument. Sanitize for the shell.
if (isset($floor) && !preg_match("/^[-\w]+$/", $floor)) {
PAGEARGERROR("Invalid floor argument.");
}
}
else {
$building = "MEB-ROBOTS";
$floor = 4;
}
if (!isset($pid) ||
strcmp($pid, "") == 0) {
PAGEARGERROR("You must provide a Project ID.");
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
PAGEARGERROR("You must provide an Experiment ID.");
}
if (!preg_match("/^[-\w]+$/", $pid)) {
PAGEARGERROR("Invalid pid argument.");
}
if (!preg_match("/^[-\w]+$/", $eid)) {
PAGEARGERROR("Invalid eid argument.");
}
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($pid, $eid)) {
USERERROR("Experiment $pid/$eid is not a valid experiment.", 1);
}
$ppm = 1;
#
# Grab pixel_per_meters for above map.
#
$query_result =
DBQueryFatal("select pixels_per_meter from floorimages ".
"where building='$building' and floor='$floor'");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$ppm = $row["pixels_per_meter"];
}
else {
USERERROR("No such building/floor $building/$floor", 1);
}
#
# Draw the legend and some explanatory text.
#
echo "<table cellspacing=5 cellpadding=5 border=0 class=\"stealth\">
<tr>
<td align=\"left\" valign=\"top\" class=\"stealth\">
<table>
<tr><th colspan=2>Legend</th></tr>
<tr>
<td><img src='/autostatus-icons/redball.gif' alt=down></td>
<td nowrap=1>Dead Node</td>
</tr>
<tr>
<td><img src='/autostatus-icons/greenball.gif' alt=down></td>
<td nowrap=1>Unassigned Node</td>
</tr>
<tr>
<td><img src='/autostatus-icons/yellowball.gif' alt=down></td>
<td nowrap=1>Assigned Node</td>
</tr>
</table>
</td>
<td class=stealth>This applet allows you to assign your virual nodes
to physical nodes. See below for instructions.
</td>
</tr>
</table><hr>\n";
#
# Create a tempfile to use as a unique prefix; it is not actually used but
# serves the same purpose (The script uses ${prefix}.jpg and ${prefix}.map .)
#
$prefix = tempnam("/tmp", "floormap");
#
# Get the unique part to send back.
#
if (!preg_match("/^\/tmp\/([-\w]+)$/", $prefix, $matches)) {
TBERROR("Bad tempnam: $prefix", 1);
}
$uniqueid = $matches[1];
$perl_args = "-o $prefix -t -z -n -x -v -y -f $floor $building";
$retval = SUEXEC($uid, "nobody", "webfloormap $perl_args",
SUEXEC_ACTION_IGNORE);
if ($retval) {
SUEXECERROR(SUEXEC_ACTION_USERERROR);
# Never returns.
die("");
}
$auth = $HTTP_COOKIE_VARS[$TBAUTHCOOKIE];
$baseurl = "../floormap_aux.php3?prefix=$uniqueid";
echo "<applet name='selector' code='NodeSelect.class'
archive='selector.jar'
width='1025' height='1050'
alt='You need java to run this applet'>
<param name='floorurl' value='$baseurl'>
<param name='uid' value='$uid'>
<param name='auth' value='$auth'>
<param name='ppm' value='$ppm'>
<param name='building' value='$building'>
<param name='floor' value='$floor'>
<param name='pid' value='$pid'>
<param name='eid' value='$eid'>
</applet>\n";
echo "<br>
<blockquote><blockquote>
<center>
<h3>Using the Node Selector Applet</h3>
</center>
<ul>
<li> Left click over a node brings up a menu of virtual nodes. Select a
virtual node from the menu to assign to the physical node.
<li> Right click over a node brings up a menu that allows you to get
information about the physical node, or cancel the current
assignment.
<li> Left click over the background image brings up a menu to submit your
assignments.
</ul>
<blockquote><blockquote>\n";
PAGEFOOTER();
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");
#
# Only known and logged in users can watch LEDs
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify page arguments. Allow user to optionally specify building/floor.
#
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
PAGEARGERROR("You must provide a Project ID.");
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
PAGEARGERROR("You must provide an Experiment ID.");
}
if (!preg_match("/^[-\w]+$/", $pid)) {
PAGEARGERROR("Invalid pid argument.");
}
if (!preg_match("/^[-\w]+$/", $eid)) {
PAGEARGERROR("Invalid eid argument.");
}
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($pid, $eid)) {
USERERROR("Experiment $pid/$eid is not a valid experiment.", 1);
}
#
# Verify Permission.
#
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to access experiment $pid/$eid!", 1);
}
# Initial goo.
header("Content-Type: text/plain");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
#
# Clean up when the remote user disconnects
#
function SPEWCLEANUP()
{
exit(0);
}
register_shutdown_function("SPEWCLEANUP");
# Get the virtual node info
$query_result =
DBQueryFatal("select vname,fixed from virt_nodes ".
"where pid='$pid' and eid='$eid' ".
"order by vname");
while ($row = mysql_fetch_array($query_result)) {
$vname = $row["vname"];
$fixed = $row["fixed"];
if (!isset($fixed))
$fixed = "";
echo "$vname, $fixed\n";
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment