Commit e72c90a8 authored by Leigh Stoller's avatar Leigh Stoller

Checkpoint the visualization stuff. Rework Chad's stuff to match

current testbed software practices. Add a wrapper script to go from
a pid/eid to the top file in the experiment directory. This means we
cannot visualize experiments that are not active, but until we have a
topfile generator that is independent of assign_wrapper, there is
nothing to do about that. A makefile to install new tools. Also add a
couple of web pages. The first web page spits out a page with an img
tag which refers to another php script that generates the gif file
with the backend tools, and stuff is out with an appropriate content
header line. Very nifty.
parent 202d5b88
......@@ -9,7 +9,8 @@ DISTCLEAN_FILES = @DISTCLEAN_FILES@
include Makeconf
SUBDIRS = lib assign discvr tbsetup db os security pxe tmcd utils www tip capture ipod
SUBDIRS = lib assign discvr tbsetup db os security pxe tmcd utils www \
tip capture ipod vis
all: all-subdirs
......
......@@ -1057,6 +1057,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tmcd/tmcd.restart \
utils/GNUmakefile utils/vlandiff utils/vlansync utils/delay_config \
utils/sshtb utils/create_image utils/node_admin \
vis/GNUmakefile vis/vistopology vis/webvistopology vis/top2gif \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
rc.d/GNUmakefile rc.d/2.mysql-server.sh rc.d/3.testbed.sh \
rc.d/cvsupd.sh"
......
......@@ -180,6 +180,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/GNUmakefile utils/vlandiff utils/vlansync utils/delay_config \
utils/sshtb utils/create_image utils/node_admin \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
vis/GNUmakefile vis/vistopology vis/webvistopology vis/top2gif \
rc.d/GNUmakefile rc.d/2.mysql-server.sh rc.d/3.testbed.sh \
rc.d/cvsupd.sh"
......
#
# Insert Copyright Here.
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ..
SUBDIR = vis
include $(OBJDIR)/Makeconf
BIN_SCRIPTS = vistopology
LIBEXEC_SCRIPTS = webvistopology
LIBEXEC_VIS = topper top2gif
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(LIBEXEC_SCRIPTS) $(LIBEXEC_VIS) $(BIN_SCRIPTS)
include $(TESTBED_SRCDIR)/GNUmakerules
install: \
$(addprefix $(INSTALL_BINDIR)/, $(BIN_SCRIPTS)) \
$(addprefix $(INSTALL_LIBEXECDIR)/, $(LIBEXEC_SCRIPTS)) \
$(addprefix $(INSTALL_LIBEXECDIR)/vis/, $(LIBEXEC_VIS))
$(INSTALL_LIBEXECDIR)/vis/%: %
@echo "Installing $<"
-mkdir -p $(INSTALL_LIBEXECDIR)/vis
$(INSTALL) $< $@
clean:
#!/usr/local/bin/perl -w
$TOPPER = "~barb/bin/topper";
$NEATO = "/usr/local/bin/neato";
while ($_ = shift) {
if (/\-o(.*)/) {
$outfile = $1 || shift || die "Bad arguments! '-o' must be followed by output
file name.\n";
} else {
if (defined $infile) {
warn "Specifying second infile \"$_\" ignores previous infile \"$infile\".\n";
}
$infile = $_;
}
}
defined $outfile or die "Must define output file with -o parameter.\n";
defined $infile or die "Must specify input file.\n";
(-r $infile) or die "Input file \"$infile\" not readable.\n";
# (-w $outfile) or die "Output file \"$infile\" not writeable.\n";
exit (system( "cat $infile | $TOPPER | $NEATO -Tgif -o $outfile" ) / 256);
#!/usr/local/bin/perl -w
use English;
use Getopt::Std;
#
# Convert a top file into a GIF image.
#
sub usage()
{
print STDOUT "Usage: top2gif [-o <outputfile>] <inputfile>\n".
"Use -o to specify output file. Default to stdout.\n";
exit(-1);
}
my $optlist = "o:";
#
# Configure variables
#
my $TB = "@prefix@";
my $TOPPER = "$TB/libexec/vis/topper";
my $NEATO = "neato";
my $output;
#
# Turn off line buffering on output.
#
$| = 1;
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"o"})) {
$output = $options{"o"};
}
if (@ARGV != 1) {
usage();
}
my $input = $ARGV[0];
if (! -e $input) {
die("*** $0:\n".
" $input does not exist!\n");
}
my $cmd = "cat $input | $TOPPER | $NEATO -Tgif";
if (defined($output)) {
$cmd = "$cmd -o $output";
}
if (system($cmd)) {
exit(1);
}
exit(0);
#!/usr/bin/perl -wT
use English;
use Getopt::Std;
#
# Generate a GIF image of the topology for an experiment.
#
sub usage()
{
print STDOUT
"Usage: vistoplogy [-o <outputfile>] <pid> <eid>\n";
exit(-1);
}
my $optlist = "o:";
#
# Configure variables
#
my $TB = "@prefix@";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
my $top2gif = "$TB/libexec/vis/top2gif";
my $tbdata = "tbdata";
my $output;
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Parse command arguments. Once we return from getopts, all that should
# be left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV != 2) {
usage();
}
my $pid = $ARGV[0];
my $eid = $ARGV[1];
if (defined($options{"o"})) {
$output = $options{"o"};
if ($output =~ /^([-\@\w.\/]+)$/) {
$output = $1;
}
else {
die("Bad data in output name: $output");
}
}
#
# Untaint the arguments.
#
if ($pid =~ /^([-\@\w]+)$/) {
$pid = $1;
}
else {
die("Tainted argument $pid!\n");
}
if ($eid =~ /^([-\@\w]+)$/) {
$eid = $1;
}
else {
die("Tainted argument $eid!\n");
}
#
# Verify existing experiment.
#
if (! ExpState($pid, $eid)) {
die("*** $0:\n".
" No such experiment $pid/$eid\n");
}
#
# Verify that this person is allowed to look at experiment.
#
if (! TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_READINFO)) {
die("*** $0:\n".
" You do not have permission to view experiment $pid/$eid\n");
}
#
# Find out where the experiment directory is.
#
$query_result =
DBQueryFatal("SELECT * FROM experiments WHERE eid='$eid' and pid='$pid'");
if (! $query_result->numrows) {
die("*** $0:\n".
" No experiment record for $pid/$eid exists!\n");
}
my %row = $query_result->fetchhash();
my $estate = $row{'state'};
my $expt_path = $row{'path'};
if ($estate ne EXPTSTATE_ACTIVE) {
die("*** $0:\n".
" Experiment $pid/$eid is not active!\n");
}
if (! chdir("$expt_path/$tbdata")) {
die("*** $0:\n".
" Could not chdir to $expt_path/$tbdata: $!\n");
}
#
# Run the vis script and be done with it.
#
my $args = "$eid.top";
if (defined($output)) {
$args = "-o $output $args";
}
if (system("$top2gif $args") != 0) {
exit(1);
}
exit(0);
#!/usr/bin/perl -w
use English;
#
# This gets invoked from the Web interface. Simply a wrapper ...
#
# usage: webvistopology arguments ...
#
#
# Configure variables
#
my $TB = "@prefix@";
#
# Run the real thing, and never return.
#
exec "$TB/bin/vistopology", @ARGV;
die("webvistopology: Could not exec vistopology: $!");
<?php
include("defs.php3");
#
# This script generates the contents of an image. No headers or footers,
# just spit back an image.
#
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
$exp_eid = $eid;
$exp_pid = $pid;
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($exp_pid, $exp_eid)) {
USERERROR("The experiment $exp_eid is not a valid experiment ".
"in project $exp_pid.", 1);
}
#
# Verify Permission.
#
if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1);
}
#
# Spit out the image with a content header.
#
if ($fp = popen("$TBSUEXEC_PATH $uid nobody webvistopology $pid $eid", "r")) {
header("Content-type: image/jpeg");
fpassthru($fp);
}
#
# No Footer!
#
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Graphic Visualization of Topology");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
$exp_eid = $eid;
$exp_pid = $pid;
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($exp_pid, $exp_eid)) {
USERERROR("The experiment $exp_eid is not a valid experiment ".
"in project $exp_pid.", 1);
}
#
# Verify Permission.
#
if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1);
}
#
# Dump the NS file so that the user can cross reference the visualization
# against the NS file that created it.
#
$query_result =
DBQueryFatal("SELECT nsfile from nsfiles where pid='$pid' and eid='$eid'");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$nsfile = $row[nsfile];
echo "<XMP>$nsfile</XMP>\n";
flush();
}
#
# Spit out an image that refers to a php script. That script will run and
# send back the GIF image contents.
#
echo "<br>
<center>
<img src='top2gif.php3?pid=$exp_pid&eid=$exp_eid' align=center>
</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
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