shownsfile.php3 5.76 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2007 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 25 26
include("defs.php3");

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

#
Leigh Stoller's avatar
Leigh Stoller committed
34
# Verify page arguments.
35 36 37 38 39 40
#
$reqargs = RequiredPageArguments("experiment",   PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("zoom",         PAGEARG_NUMERIC,
				 "detail",       PAGEARG_BOOLEAN,
				 "showevents",   PAGEARG_BOOLEAN,
				 "justns",       PAGEARG_BOOLEAN);
41

42 43 44 45 46 47 48 49 50 51 52
#
# Standard Testbed Header
#
if (!isset($justns)) {
    $justns = 0;
}

if (!$justns) {
    PAGEHEADER("Visualization, NS File, and Details");
}

53
#
54
# Need these below
55
#
56 57 58 59 60
$pid = $experiment->pid();
$eid = $experiment->eid();
$shownsfile_url = CreateURL("shownsfile", $experiment);
$top2image_url  = CreateURL("top2image", $experiment);
$spitnsdata_url = CreateURL("spitnsdata", $experiment);
61

62 63 64 65 66 67
# if they dont exist, or are non-numeric, use defaults.
if (!isset($zoom))       { $zoom   = 1; }
if (!isset($detail))     { $detail = 0; }
if (!isset($justns))     { $justns = 0; }
if (!isset($showevents)) { $showevents = 0; }
 
68
#
69
# Must have permission to view experiment details.
70
#
71 72 73
if (!$isadmin &&
    !$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment details!", 1);
74 75
}

Chad Barb's avatar
Chad Barb committed
76 77 78 79 80
#
# if it is netbuild wanting an NS to modify, send that along
# (For now, as a disgusting hack, send node positioning along, too.)
#
if ($justns) {
81
    if (($nsfile = $experiment->NSFile())) {
Chad Barb's avatar
Chad Barb committed
82 83 84
	echo "$nsfile\n";

	$query_result = 
85 86
	    DBQueryFatal("SELECT vname, x, y FROM vis_nodes ".
			 "where pid='$pid' and eid='$eid'");
Chad Barb's avatar
Chad Barb committed
87 88

	while ($row = mysql_fetch_array($query_result)) {
89 90 91
	    $name = $row["vname"];
	    $x = $row["x"];
	    $y = $row["y"];
Chad Barb's avatar
Chad Barb committed
92 93 94 95 96 97 98 99 100 101
	    echo "tb-set-vis-position \$$name $x $y\n";
	}
	flush();
    }
    else {
	echo "No stored NS file for $pid/$eid\n";
    }    
    return;
}

102
echo $experiment->PageHeader();
103 104
echo "<br />\n";

105
if ($showevents) {
106
    echo "<b><a href='$shownsfile_url'>Hide Event List</a>
107 108
          </b><br><br>\n";
}
109 110
elseif ($experiment->EventCount()) {
    echo "<b><a href='${shownsfile_url}&showevents=1'>Show Event List</a>
111 112 113
          </b><br><br>\n";
}

114 115 116 117
#
# Spit out an image that refers to a php script. That script will run and
# send back the GIF image contents.
#
118 119
if (strcmp($experiment->state(), $TB_EXPTSTATE_NEW) &&
    strcmp($experiment->state(), $TB_EXPTSTATE_PRERUN)) {
120 121 122
    echo "<table cellpadding='0' cellspacing='0' border='0' class='stealth'>
	    <tr><td class='stealth' width='32'>&nbsp;</td>
            <td class='stealth'><center>
123 124
		<img src='${top2image_url}&zoom=$zoom&detail=$detail'
                     align=center>
Chad Barb's avatar
Chad Barb committed
125
	    <h5>
126 127 128 129
	      zoom: ";
    if ($zoom == 1.00) { 
	echo "<b>100%</b> "; 
    } else { 
130
	echo "<a href='${shownsfile_url}&zoom=1.00&detail=$detail'>100%</a> ";
131 132 133 134
    }
    if ($zoom == 1.12) { 
	echo "<b>112%</b> "; 
    } else { 
135
	echo "<a href='${shownsfile_url}&zoom=1.12&detail=$detail'>112%</a> ";
136 137 138 139
    }
    if ($zoom == 1.25) { 
	echo "<b>125%</b> "; 
    } else { 
140
	echo "<a href='${shownsfile_url}&zoom=1.25&detail=$detail'>125%</a> ";
141 142 143 144
    }
    if ($zoom == 1.50) { 
	echo "<b>150%</b> "; 
    } else { 
145
	echo "<a href='${shownsfile_url}&zoom=1.50&detail=$detail'>150%</a> ";
146 147 148 149
    }
    if ($zoom == 1.75) { 
	echo "<b>175%</b> "; 
    } else { 
150
	echo "<a href='${shownsfile_url}&zoom=1.75&detail=$detail'>175%</a> ";
151 152 153 154
    }
    if ($zoom == 2.00) { 
	echo "<b>200%</b> "; 
    } else { 
155
	echo "<a href='${shownsfile_url}&zoom=2.00&detail=$detail'>200%</a> ";
156 157 158 159
    }
    if ($zoom == 2.50) { 
	echo "<b>250%</b> "; 
    } else { 
160
	echo "<a href='${shownsfile_url}&zoom=2.50&detail=$detail'>250%</a> ";
161 162 163 164
    }
    if ($zoom == 3.00) { 
	echo "<b>300%</b> "; 
    } else { 
165
	echo "<a href='${shownsfile_url}&zoom=3.00&detail=$detail'>300%</a> ";
166 167 168 169
    }
    if ($zoom == 4.00) { 
	echo "<b>400%</b> "; 
    } else { 
170
	echo "<a href='${shownsfile_url}&zoom=4.00&detail=$detail'>400%</a> ";
171 172
    }
    echo "<br>detail: ";
Chad Barb's avatar
Chad Barb committed
173
    if ($detail == 0) {
174
	if ($zoom < 1.75) {
175
      	    echo "<a href='${shownsfile_url}&zoom=1.75&detail=1'>high</a> <b>low</b>";
Chad Barb's avatar
Chad Barb committed
176
	} else {
177
    	    echo "<a href='${shownsfile_url}&zoom=$zoom&detail=1'>high</a> <b>low</b>";
Chad Barb's avatar
Chad Barb committed
178 179
	}
    } else {
180
    	echo "<b>high</b> <a href='${shownsfile_url}&zoom=$zoom&detail=0'>low</a>";
Chad Barb's avatar
Chad Barb committed
181
    }
182
    echo "  </h5></center></td></tr></table>";
183 184
}

185
echo "<br>
186
      <a href='$spitnsdata_url'><h3>NS File:</h3></a>\n";
187

188 189
# Dump the NS file.
if (($nsfile = $experiment->NSFile())) {
190 191 192 193 194 195
    echo "<XMP>$nsfile</XMP>\n";
    flush();
}
else {
    echo "There is no stored NS file for $pid/$eid\n";
}
196

197
echo "<br>
198
      <h3>
199
         Experiment Details:
200
      </h3>\n";
201 202 203 204

$output = array();
$retval = 0;

205
if ($showevents) {
206 207 208
    $flags = "-v";
}
else {
Mike Hibler's avatar
Mike Hibler committed
209 210
    # Show event summary and firewall info.
    $flags = "-b -e -f";
211 212
}

213 214 215
$result =
    exec("$TBSUEXEC_PATH $uid $TBADMINGROUP webtbreport $flags $pid $eid",
	 $output, $retval);
216 217

echo "<XMP>\n";
Leigh Stoller's avatar
Leigh Stoller committed
218
for ($i = 0; $i < count($output); $i++) {
219 220 221 222
    echo "$output[$i]\n";
}
echo "</XMP>\n";

223 224 225 226 227
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>