Commit 251c1dd5 authored by Leigh Stoller's avatar Leigh Stoller

Add web page for entering node log entries. Might make it easier to

use.
parent 28c1968f
......@@ -1025,7 +1025,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog \
db/dhcpd_makeconf db/nodelog db/webnodelog \
ipod/GNUmakefile \
lib/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......
......@@ -147,7 +147,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog \
db/dhcpd_makeconf db/nodelog db/webnodelog \
ipod/GNUmakefile \
lib/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......
......@@ -11,7 +11,7 @@ include $(OBJDIR)/Makeconf
BIN_SCRIPTS = nalloc nfree nodeip
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists genelists.proxy dhcpd_makeconf nodelog
LIBEXEC_SCRIPTS =
LIBEXEC_SCRIPTS = webnodelog
LIB_SCRIPTS = libdb.pm
# Stuff installed on plastic.
......
#!/usr/bin/perl -w
use English;
#
# This gets invoked from the Web interface. Simply a wrapper ...
#
# usage: webnodelog arguments ...
#
#
# Configure variables
#
my $TB = "@prefix@";
#
# Run the real thing, and never return.
#
exec "$TB/sbin/nodelog", @ARGV;
die("webnodelog: Could not exec nodelog: $!");
......@@ -8,6 +8,7 @@ $TBDB_UIDLEN = 8;
$TBDB_PIDLEN = 12;
$TBDB_GIDLEN = 12;
$TBDB_UNIXGLEN = 16;
$TBDB_NODEIDLEN = 10;
#
# Current policy is to prefix the EID with the PID. Make sure it is not
......
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Enter Node Log Entry");
#
# Only known and logged in users can create an OSID.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# First off, sanity check the form to make sure all the required fields
# were provided. I do this on a per field basis so that we can be
# informative. Be sure to correlate these checks with any changes made to
# the project form.
#
if (!isset($node_id) ||
strcmp($node_id, "") == 0) {
FORMERROR("Node ID");
}
if (!isset($log_type) ||
strcmp($log_type, "") == 0) {
FORMERROR("Log Type");
}
if (!isset($log_entry) ||
strcmp($log_entry, "") == 0) {
FORMERROR("Log Entry");
}
#
# Only Admins can enter log entries.
#
if (! $isadmin) {
USERERROR("You do not have permission to enter log entries!", 1);
}
#
# Check to make sure that this is a valid nodeid
#
if (! TBValidNodeName($node_id)) {
USERERROR("The node $node_id is not a valid nodeid!", 1);
}
#
# Check log type. Strictly letters, not too long.
#
if (! ereg("^[a-zA-Z]+$", $log_type) || strlen($log_type) > 32) {
USERERROR("The log type you gave looks funky!", 1);
}
$log_entry = addslashes($log_entry);
#
# Run the external script.
#
SUEXEC($uid, "flux", "webnodelog -t $log_type -m \"$log_entry\" $node_id", 1);
#
# Show result.
#
SHOWNODELOG($node_id);
#
# New Entry option.
#
echo "<p><center>
Do you want to enter a log entry?
<A href='newnodelog_form.php3?node_id=$node_id'>Yes</a>
</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Enter Node Log Entry");
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($node_id) || strcmp($node_id, "") == 0) {
unset($node_id);
}
else {
#
# Check to make sure that this is a valid nodeid
#
if (! TBValidNodeName($node_id)) {
USERERROR("The node $node_id is not a valid nodeid!", 1);
}
}
#
# Only Admins can enter log entries.
#
if (! $isadmin) {
USERERROR("You do not have permission to enter log entries!", 1);
}
echo "<table align=center border=1>
<tr>
<td align=center colspan=2>
<em>(Fields marked with * are required)</em>
</td>
</tr>
<form action='newnodelog.php3' method=post>\n";
#
# Node ID:
#
# Note DB max length.
#
if (isset($node_id)) {
echo "<tr>
<td>*Node ID:</td>
<td><input type=text name=node_id value=$node_id
size=$TBDB_NODEIDLEN maxlength=$TBDB_NODEIDLEN>
</tr>\n";
}
else {
echo "<tr>
<td>*Node ID:</td>
<td><input type=text name=node_id size=$TBDB_NODEIDLEN
maxlength=$TBDB_NODEIDLEN>
</td>
</tr>\n";
}
#
# Log Type.
#
echo "<tr>
<td>*Log Type:</td>
<td><select name=log_type>
<option selected value='misc'>Misc</option>
</select>
</td>
</tr>\n";
#
# Log Entry.
#
echo "<tr>
<td>*Log Entry:</td>
<td><input type=text name=log_entry size=50 maxlength=128></td>
</tr>\n";
echo "<tr>
<td align=center colspan=2>
<b><input type=submit value=Submit></b>
</td>
</tr>\n";
echo "</form>
</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -39,49 +39,15 @@ if (! $isadmin) {
USERERROR("You do not have permission to view log for node $node_id!", 1);
}
$query_result =
DBQueryFatal("select * from nodelog where node_id='$node_id'".
"order by reported");
SHOWNODELOG($node_id);
if (! mysql_num_rows($query_result)) {
echo "<br>
<center>
There are no entries in the log for node $node_id.
#
# New Entry option.
#
echo "<p><center>
Do you want to enter a log entry?
<A href='newnodelog_form.php3?node_id=$node_id'>Yes</a>
</center>\n";
}
else {
echo "<br>
<center>
Log for node $node_id.
</center><br>\n";
echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";
echo "<tr>
<td align=center>Date</td>
<td align=center>ID</td>
<td align=center>Type</td>
<td align=center>Reporter</td>
<td align=center>Entry</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$type = $row[type];
$log_id = $row[log_id];
$reporter = $row[reporting_uid];
$date = $row[reported];
$entry = $row[entry];
echo "<tr>
<td>$date</td>
<td>$log_id</td>
<td>$type</td>
<td>$reporter</td>
<td>$entry</td>
</tr>\n";
}
echo "</table>\n";
}
#
# Standard Testbed Footer
......
......@@ -953,6 +953,57 @@ function SHOWNODE($node_id) {
echo "</table>\n";
}
#
# Show log
#
function SHOWNODELOG($node_id)
{
$query_result =
DBQueryFatal("select * from nodelog where node_id='$node_id'".
"order by reported");
if (! mysql_num_rows($query_result)) {
echo "<br>
<center>
There are no entries in the log for node $node_id.
</center>\n";
return;
}
echo "<br>
<center>
Log for node $node_id.
</center><br>\n";
echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";
echo "<tr>
<td align=center>Date</td>
<td align=center>ID</td>
<td align=center>Type</td>
<td align=center>Reporter</td>
<td align=center>Entry</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$type = $row[type];
$log_id = $row[log_id];
$reporter = $row[reporting_uid];
$date = $row[reported];
$entry = $row[entry];
echo "<tr>
<td>$date</td>
<td>$log_id</td>
<td>$type</td>
<td>$reporter</td>
<td>$entry</td>
</tr>\n";
}
echo "</table>\n";
}
#
# This is an included file.
#
......
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