showexp.php3 19.9 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
Leigh Stoller's avatar
Leigh Stoller committed
7
include("defs.php3");
8
require("Sajax.php");
9
include("showstuff.php3");
10
sajax_init();
11
sajax_export("GetExpState", "Show");
Leigh Stoller's avatar
Leigh Stoller committed
12

13
#
14
# Only known and logged in users can look at experiments.
15
#
16
$uid = GETLOGIN();
17
LOGGEDINORDIE($uid);
Leigh Stoller's avatar
Leigh Stoller committed
18
$isadmin = ISADMIN($uid);
19
$tag = "Experiment";
Leigh Stoller's avatar
Leigh Stoller committed
20 21

#
Leigh Stoller's avatar
Leigh Stoller committed
22
# Verify page arguments.
23
# 
Leigh Stoller's avatar
Leigh Stoller committed
24 25 26
if (!isset($pid) ||
    strcmp($pid, "") == 0) {
    USERERROR("You must provide a Project ID.", 1);
27 28
}

Leigh Stoller's avatar
Leigh Stoller committed
29 30 31 32
if (!isset($eid) ||
    strcmp($eid, "") == 0) {
    USERERROR("You must provide an Experiment ID.", 1);
}
33 34 35 36 37 38
if (!isset($sortby)) {
    if ($pid == $TBOPSPID)
	$sortby = "rsrvtime-down";
    else
	$sortby = "";
}
Leigh Stoller's avatar
Leigh Stoller committed
39 40
$exp_eid = $eid;
$exp_pid = $pid;
41

Leigh Stoller's avatar
Leigh Stoller committed
42
#
Leigh Stoller's avatar
Leigh Stoller committed
43
# Check to make sure this is a valid PID/EID tuple.
Leigh Stoller's avatar
Leigh Stoller committed
44
#
45
if (! TBValidExperiment($exp_pid, $exp_eid)) {
46 47
  USERERROR("The experiment $exp_eid is not a valid experiment ".
            "in project $exp_pid.", 1);
Leigh Stoller's avatar
Leigh Stoller committed
48 49
}

50
#
Leigh Stoller's avatar
Leigh Stoller committed
51
# Verify Permission.
52
#
Leigh Stoller's avatar
Leigh Stoller committed
53 54
if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment $exp_eid!", 1);
Leigh Stoller's avatar
Leigh Stoller committed
55 56
}

57 58 59 60 61 62 63 64 65 66 67
#
# For the Sajax Interface
#
function GetExpState($a, $b)
{
    global $pid, $eid;
    
    $expstate = TBExptState($pid, $eid);

    return $expstate;
}
68

69
function Show($which, $arg1, $arg2)
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
{
    global $pid, $eid, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
    $html = "";

    if ($which == "settings") {
	ob_start();
	SHOWEXP($pid, $eid);
	$html = ob_get_contents();
	ob_end_clean();
    }
    elseif ($which == "details") {
	$output = array();
	$retval = 0;
	$html   = "";

        # Show event summary and firewall info.
        $flags = "-b -e -f";

	$result = exec("$TBSUEXEC_PATH $uid $TBADMINGROUP ".
		       "webreport $flags $pid $eid",
		       $output, $retval);

92 93
	$html = "<pre><div align=left id=\"showexp_details\" ".
	    "class=\"showexp_codeblock\">";
94 95 96 97
	for ($i = 0; $i < count($output); $i++) {
	    $html .= htmlentities($output[$i]);
	    $html .= "\n";
	}
98 99 100 101 102
	$html .= "</div></pre>\n";

	$html .= "<button name=savedetails type=button value=1";
	$html .= " onclick=\"SaveDetails();\">";
	$html .= "Save</button>\n";
103
    }
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    elseif ($which == "graphs") {
	$graphtype = $arg1;

	if (!isset($graphtype) || !$graphtype)
	    $graphtype = "pps";
	
	$exptidx = TBExptIndex($pid, $eid);
	# Make the link unique to force reload on the client side.
	$now     = time();
	
	$html  = "";
	$html .= "<div style='display: block; overflow: auto; ".
	         "     position: relative; height: 450px; ".
	         "     width: 90%; border: 2px solid black;'>\n";
	$html .= "  <img border=0 ";
	$html .= "       src='linkgraph_image.php?exptidx=$exptidx";
	$html .= "&graphtype=$graphtype&now=$now'>\n";
	$html .= "</div>\n";

	$html .= "<button name=pps type=button value=1";
	$html .= " onclick=\"GraphChange('pps');\">";
	$html .= "Packets</button>\n";
	$html .= "<button name=bps type=button value=1";
	$html .= " onclick=\"GraphChange('bps');\">";
	$html .= "Bytes</button>\n";
    }
130
    elseif ($which == "vis") {
131 132 133
	$zoom   = $arg1;
	$detail = $arg2;
	
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
	if ($zoom == 0) {
            # Default is whatever we have; to avoid regen of the image.
	    $query_result =
		DBQueryFatal("select zoom,detail from vis_graphs ".
			     "where pid='$pid' and eid='$eid'");

	    if (mysql_num_rows($query_result)) {
		$row    = mysql_fetch_array($query_result);
		$zoom   = $row['zoom'];
		$detail = $row['detail'];
	    }
	    else {
		$zoom   = 1.15;
		$detail = 1;
	    }
	}
	else {
            # Sanity check but lets not worry about throwing an error.
	    if (!TBvalid_float($zoom))
		$zoom = 1.25;
	    if (!TBvalid_integer($detail))
		$detail = 1;
    	}

	$html = ShowVis($pid, $eid, $zoom, $detail);

	$zoomout = sprintf("%.2f", $zoom / 1.25);
	$zoomin  = sprintf("%.2f", $zoom * 1.25);

	$html .= "<button name=viszoomout type=button value=$zoomout";
	$html .= " onclick=\"VisChange('$zoomout', $detail);\">";
	$html .= "Zoom Out</button>\n";
	$html .= "<button name=viszoomin type=button value=$zoomin";
	$html .= " onclick=\"VisChange('$zoomin', $detail);\">";
	$html .= "Zoom In</button>\n";

	if ($detail) {
	    $html .= "<button name=hidedetail type=button value=0";
	    $html .= " onclick=\"VisChange('$zoom', 0);\">";
	    $html .= "Hide Details</button>\n";
	}
	else {
	    $html .= "<button name=showdetail type=button value=1";
	    $html .= " onclick=\"VisChange('$zoom', 1);\">";
	    $html .= "Show Details</button>\n";
	}
180 181 182 183
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";
	$html .= "<button name=fullscreenvis type=button value=1";
	$html .= " onclick=\"FullScreenVis();\">";
	$html .= "Full Screen</button>\n";
184 185 186 187 188 189 190 191 192 193 194
    }
    elseif ($which == "nsfile") {
	$nsdata = "";
	
	$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);
	    $nsdata = htmlentities($row["nsfile"]);
	}
195 196
	$html = "<pre><div align=left class=\"showexp_codeblock\">".
	    "$nsdata</div></pre>\n";
197 198 199 200 201 202 203 204 205 206 207 208 209

	$html .= "<button name=savens type=button value=1";
	$html .= " onclick=\"SaveNS();\">";
	$html .= "Save</button>\n";
    }
    return $html;
}

#
# Dump the visualization into its own iframe.
#
function ShowVis($pid, $eid, $zoom = 1.25, $detail = 1) {
    $html = "<div id=fee style='display: block; overflow: hidden; ".
210
	    "     position: relative; z-index:1010; height: 450px; ".
211
	    "     width: 90%; border: 2px solid black;'>\n".
212
            " <div id=myvisdiv style='position:relative;'>\n".
213
	    "   <img id=myvisimg border=0 style='cursor: move;' ".
214 215 216 217 218 219 220 221 222
	    "        onLoad=\"setTimeout('ShowVisInit();', 10);\" ".
	    "        src='top2image.php3?pid=$pid&eid=$eid".
	    "&zoom=$zoom&detail=$detail'>\n".
	    " </div>\n".
	    "</div>\n";

    return $html;
}

223 224 225 226 227 228 229
#
# See if this request is to the above function. Does not return
# if it is. Otherwise return and continue on.
#
sajax_handle_client_request();

# Faster to do this after the sajax stuff
230
include_once("template_defs.php");
231

232 233 234 235
#
# Need some DB info.
#
$query_result =
236
    DBQueryFatal("select e.idx,e.state,e.batchmode,e.linktest_pid,".
237 238
		 "       e.paniced,e.panic_date,s.rsrcidx,r.wirelesslans, ".
		 "       e.lockdown ".
239 240
		 "  from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
241
		 "left join experiment_resources as r on s.rsrcidx=r.idx ".
242
		 "where e.eid='$eid' and e.pid='$pid'");
243 244 245 246 247
$row        = mysql_fetch_array($query_result);
$expindex   = $row["idx"];
$expstate   = $row["state"];
$rsrcidx    = $row["rsrcidx"];
$isbatch    = $row["batchmode"];
248
$wireless   = $row["wirelesslans"];
249
$linktest_running = $row["linktest_pid"];
Leigh Stoller's avatar
Leigh Stoller committed
250 251
$paniced    = $row["paniced"];
$panic_date = $row["panic_date"];
252
$lockdown   = $row["lockdown"];
253

254
# Template Instance Experiments get special treatment in this page.
255 256 257 258 259 260 261 262 263
$instance = NULL;
if ($EXPOSETEMPLATES) {
     $instance = TemplateInstance::LookupByExptidx($expindex);

     if (! is_null($instance)) {
	 $tag = "Template Instance";
	 $guid = $instance->guid();
	 $vers = $instance->vers();
     }
264 265 266 267 268 269 270
}

#
# Standard Testbed Header.
#
PAGEHEADER("$tag ($pid/$eid)");

271 272 273 274 275 276 277
echo "<script type='text/javascript' src='showexp.js'></script>\n";
#
# This has to happen ...
#
$bodyclosestring = "<script type='text/javascript'>SET_DHTML();</script>\n";

echo "<script type='text/javascript' src='js/wz_dragdrop.js'></script>";
278 279 280 281 282
echo "<script type='text/javascript' language='javascript'>\n";
sajax_show_javascript();
echo "StartStateChangeWatch('$pid', '$eid', '$expstate');\n";
echo "</script>\n";

283 284 285 286
#
# Get a list of node types and classes in this experiment
#
$query_result =
287 288 289 290 291 292 293
    DBQueryFatal("select distinct v.type,t1.class,v.fixed,".
		 "   t2.type as ftype,t2.class as fclass from virt_nodes as v ".
		 "left join node_types as t1 on v.type=t1.type ".
		 "left join nodes as n on v.fixed is not null and ".
		 "     v.fixed=n.node_id ".
		 "left join node_types as t2 on t2.type=n.type ".
		 "where v.eid='$eid' and v.pid='$pid'");
294
while ($row = mysql_fetch_array($query_result)) {
295 296 297 298 299 300 301 302
    if (isset($row['ftype'])) {
	$classes[$row['fclass']] = 1;
	$types[$row['ftype']] = 1;
    }
    else {
	$classes[$row['class']] = 1;
	$types[$row['type']] = 1;
    }
303 304
}

305
echo "<font size=+2>$tag <b>".
306
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
307
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
308
echo "<br /><br />\n";
309
SUBPAGESTART();
310

311
SUBMENUSTART("$tag Options");
312

313
if ($expstate) {
314
    if (TBExptLogFile($exp_pid, $exp_eid)) {
315
	WRITESUBMENUBUTTON("View Activity Logfile",
316
			   "showlogfile.php3?pid=$exp_pid&eid=$exp_eid");
317
    }
318 319
    WRITESUBMENUDIVIDER();

320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
    if (!$lockdown) {
        # Swap option.
	if ($isbatch) {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Queue Batch Experiment",
			 "swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    $expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Stop Batch Experiment",
			 "swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
		WRITESUBMENUBUTTON("Dequeue Batch Experiment",
			 "swapexp.php3?inout=pause&pid=$exp_pid&eid=$exp_eid");
	    }
336
	}
337 338 339 340 341 342 343
	else {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Swap Experiment In",
			 "swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    ($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
344
		WRITESUBMENUBUTTON(($instance ?
345 346
				    "Terminate Instance" :
				    "Swap Experiment Out"),
347 348 349 350 351 352 353
			 "swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Cancel Experiment Swapin",
				   "swapexp.php3?inout=out".
				   "&pid=$exp_pid&eid=$exp_eid");
	    }
354
	}
355
    
356
	if (!$instance && $expstate != $TB_EXPTSTATE_PANICED) {
357 358
	    WRITESUBMENUBUTTON("Terminate Experiment",
			       "endexp.php3?pid=$exp_pid&eid=$exp_eid");
359 360
	}

361
        # Batch experiments can be modifed only when paused.
362
	if (!$instance && ($expstate == $TB_EXPTSTATE_SWAPPED ||
363
	    (!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE))) {
364 365 366
	    WRITESUBMENUBUTTON("Modify Experiment",
			       "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
	}
367
    }
368

369
    if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
370 371 372 373 374 375
	if ($instance->runidx()) {
	    WRITESUBMENUBUTTON("Stop Current Experiment Run",
			       "template_exprun.php?action=stop&guid=$guid".
			       "&version=$vers&eid=$exp_eid");
	}

376
	WRITESUBMENUBUTTON("Start New Experiment Run",
377
			   "template_exprun.php?action=start&guid=$guid".
378
			   "&version=$vers&eid=$exp_eid");
379

380 381 382 383 384 385 386 387 388 389 390
	if ($instance->pause_time()) {
	    WRITESUBMENUBUTTON("Continue Experiment RunTime",
		       "template_exprun.php?action=continue&guid=$guid".
		       "&version=$vers&eid=$exp_eid");
	}
	else {
	    WRITESUBMENUBUTTON("Pause Experiment Runtime",
		       "template_exprun.php?action=pause&guid=$guid".
		       "&version=$vers&eid=$exp_eid");
	}

391 392 393
	WRITESUBMENUBUTTON("Create New Template",
			   "template_commit.php?&guid=$guid".
			   "&version=$vers&exptidx=$expindex");
394
    }
395
    
396
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
397
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
398
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
399
    }
400 401
}

402
WRITESUBMENUBUTTON("Modify Metadata",
403
		   "editexp.php3?pid=$exp_pid&eid=$exp_eid");
404

405 406
WRITESUBMENUDIVIDER();

407
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
408 409 410
    WRITESUBMENUBUTTON("Link Tracing/Monitoring",
		       "linkmon_list.php3?pid=$exp_pid&eid=$exp_eid");
    
411 412 413
    WRITESUBMENUBUTTON("Event Viewer",
		       "showevents.php?pid=$exp_pid&eid=$exp_eid");
    
414 415 416
    #
    # Admin and project/experiment leaders get this option.
    #
417 418 419 420
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATE)) {
	WRITESUBMENUBUTTON("Update All Nodes",
			   "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
    }
421

422 423 424 425 426
    # Reboot option
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
	WRITESUBMENUBUTTON("Reboot All Nodes",
			   "boot.php3?pid=$exp_pid&eid=$exp_eid");
    }
427
}
428

429
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
430 431
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_MODIFY_RESWAP) &&
432 433 434 435 436 437
    (STUDLY() || $EXPOSELINKTEST)) {
    WRITESUBMENUBUTTON(($linktest_running ?
			"Stop LinkTest" : "Run LinkTest"), 
		       "linktest.php3?pid=$exp_pid&eid=$exp_eid".
		       ($linktest_running ? "&kill=1" : ""));
}
438

439
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
440
    if (STUDLY() && $classes['pcvm']) {
441
	WRITESUBMENUBUTTON("Record Feedback Data",
442 443
			   "feedback.php3?pid=$exp_pid&".
			   "eid=$exp_eid&mode=record");
444 445
    }
}
446 447 448

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
449
    STUDLY()) {
450 451
    WRITESUBMENUBUTTON("Clear Feedback Data",
		       "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=clear");
452 453 454 455
    if ($classes['pcvm']) {
	    WRITESUBMENUBUTTON("Remap Virtual Nodes",
			       "remapexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
456
}
457
    
458 459 460
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
461 462 463
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
464 465
}

466 467
WRITESUBMENUDIVIDER();

468 469 470 471
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

472
if (!$instance && STUDLY()) {
473 474 475 476
    WRITESUBMENUBUTTON("Duplicate Experiment",
		       "beginexp_html.php3?copyid=${exp_pid},${exp_eid}");
}

477 478
if ($EXPOSEARCHIVE) {
    WRITESUBMENUBUTTON("Experiment File Archive",
479
		       "archive_view.php3?exptidx=$expindex");
480 481
}

482
if ($types['garcia'] || $types['static-mica2'] || $types['robot']) {
483 484
    SUBMENUSECTION("Robot/Mote Options");
    WRITESUBMENUBUTTON("Robot/Mote Map",
485 486 487
		       "robotmap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
488 489 490 491 492 493 494 495 496 497
    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
	if ($types['static-mica2']) {
	    WRITESUBMENUBUTTON("Selector Applet",
			       "robotrack/selector.php3?".
			       "pid=$exp_pid&eid=$exp_eid");
	}
    }
    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
	    $expstate == $TB_EXPTSTATE_ACTIVATING) {
	WRITESUBMENUBUTTON("Tracker Applet",
498 499
			   "robotrack/robotrack.php3?".
			   "pid=$exp_pid&eid=$exp_eid");
500
    }
501 502
}

503 504
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
505
if ($classes['mote'] && $expstate == $TB_EXPTSTATE_ACTIVE) {
506
    WRITESUBMENUBUTTON("Show Blinky Lights",
507
		   "moteleds.php3?pid=$exp_pid&eid=$exp_eid","moteleds");
508 509
}

Leigh Stoller's avatar
Leigh Stoller committed
510
if ($isadmin) {
511
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
512
	SUBMENUSECTION("Beta-Test Options");
513
	WRITESUBMENUBUTTON("Restart Experiment",
514 515
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");
516 517
	WRITESUBMENUBUTTON("Replay Events",
			   "replayexp.php3?&pid=$exp_pid&eid=$exp_eid");
518

519 520
	SUBMENUSECTION("Admin Options");
	
521 522 523 524
	WRITESUBMENUBUTTON("Send an Idle Info Request",
			   "request_idleinfo.php3?".
			   "&pid=$exp_pid&eid=$exp_eid");
	
525 526 527 528 529 530 531
	WRITESUBMENUBUTTON("Send a Swap Request",
			   "request_swapexp.php3?".
			   "&pid=$exp_pid&eid=$exp_eid");
	
	WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
			   "swapexp.php3?inout=out&force=1".
			   "&pid=$exp_pid&eid=$exp_eid");
532
	
533 534 535 536
	SUBMENUSECTIONEND();
    }
}
    
537 538
SUBMENUEND_2A();

539 540
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
541
         <img border=1 alt='experiment vis'
Leigh Stoller's avatar
Leigh Stoller committed
542
              src='showthumb.php3?idx=$rsrcidx'></a>";
543 544

SUBMENUEND_2B();
545

Leigh Stoller's avatar
Leigh Stoller committed
546 547 548 549 550 551 552
#
# The center area is a form that can show NS file, Details, or Vis.
# IE complicates this, although in retrospect, I could have used plain
# input buttons instead of the fancy rendering kind of buttons, which do not
# work as expected (violates the html spec) in IE. 
#
echo "<script type='text/javascript' language='javascript'>
553
        var li_current = 'li_settings';
Leigh Stoller's avatar
Leigh Stoller committed
554
        function Show(which) {
555 556 557 558 559 560 561 562 563 564
	    li = getObjbyName(li_current);
            li.style.backgroundColor = '#DDE';
            li.style.borderBottom = 'none';

            li_current = 'li_' + which;
	    li = getObjbyName(li_current);
            li.style.backgroundColor = 'white';
            li.style.borderBottom = '1px solid white';

            x_Show(which, 0, 0, Show_cb);
Leigh Stoller's avatar
Leigh Stoller committed
565 566
            return false;
        }
567 568 569 570 571 572 573 574 575 576 577
        function Show_cb(html) {
	    visarea = getObjbyName('showexp_visarea');
            if (visarea) {
                visarea.innerHTML = html;
            }
        }
        function ShowVisInit() {
            ADD_DHTML(\"myvisdiv\");
        }
        function VisChange(zoom, detail) {
            x_Show('vis', zoom, detail, Show_cb);
Leigh Stoller's avatar
Leigh Stoller committed
578 579
            return false;
        }
580 581 582 583
        function GraphChange(which) {
            x_Show('graphs', which, 0, Show_cb);
            return false;
        }
584 585 586 587 588 589
        function SaveDetails() {
            window.open('spitreport.php?pid=$pid&eid=$eid',
                        '_blank','width=700,height=400,toolbar=no,".
                        "resizeable=yes,scrollbars=yes,status=yes,".
	                "menubar=yes');
        }
590 591
        function SaveNS() {
            window.open('spitnsdata.php3?pid=$pid&eid=$eid',
592
                        '_blank','width=700,height=400,toolbar=no,".
593 594 595
                        "resizeable=yes,scrollbars=yes,status=yes,".
	                "menubar=yes');
        }
596 597 598
        function FullScreenVis() {
	    window.location.replace('shownsfile.php3?pid=$pid&eid=$eid');
        }
Leigh Stoller's avatar
Leigh Stoller committed
599 600
      </script>\n";

601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
#
# This is the topbar
#
echo "<div width=\"100%\" align=center>\n";
echo "<ul id=\"topnavbar\">\n";
echo "<li>
          <a href=\"#A\" style=\"background-color:white\" ".
               "id=\"li_settings\" onclick=\"Show('settings');\">".
               "Settings</a></li>\n";
echo "<li>
          <a href=\"#B\" id=\"li_vis\" onclick=\"Show('vis');\">".
               "Visualization</a></li>\n";
echo "<li>
          <a href=\"#C\" id=\"li_nsfile\" onclick=\"Show('nsfile');\">".
              "NS File</a></li>\n";
echo "<li>
          <a href=\"#D\" id=\"li_details\" onclick=\"Show('details');\">".
              "Details</a></li>\n";
619 620 621 622 623 624

if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
    echo "<li>
              <a href=\"#E\" id=\"li_graphs\" onclick=\"Show('graphs');\">".
                  "Graphs</a></li>\n";
}
625
echo "</ul>\n";
Leigh Stoller's avatar
Leigh Stoller committed
626

627 628 629 630 631 632 633
#
# Start out with details ...
#
echo "<div align=center width=\"100%\" id=\"showexp_visarea\">\n";
SHOWEXP($exp_pid, $exp_eid);
echo "</div>\n";
echo "</div>\n";
634

Leigh Stoller's avatar
Leigh Stoller committed
635 636 637 638 639 640
if (TBExptFirewall($exp_pid, $exp_eid) &&
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_SWAPPING)) {
    echo "<center>\n";
641 642 643
    if ($paniced == 2) {
	#
	# Paniced due to failed swapout.
644
	# Only be semi-obnoxious (no blinking) since it was not their fault.
645 646 647 648 649 650 651 652 653 654 655 656
	#
	echo "<br><font size=+1 color=red>".
	     "Your experiment was cut off due to a failed swapout on $panic_date!".
	     "<br>".
	     "You will need to contact testbed operations to make further ".
  	     "changes (swap, terminate) to your experiment.</font>";
    }
    elseif ($paniced) {
	#
	# Paniced due to panic button.
  	# Full-on obnoxious is called for here!
	#
Leigh Stoller's avatar
Leigh Stoller committed
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
	echo "<br><font size=+1 color=red><blink>".
	     "Your experiment was cut off via the Panic Button on $panic_date!".
	     "<br>".
	     "You will need to contact testbed operations to make further ".
  	     "changes (swap, terminate) to your experiment.</blink></font>";
    }
    else {
	echo "<br><a href='panicbutton.php3?pid=$exp_pid&eid=$exp_eid'>
                 <img border=1 alt='panic button' src='panicbutton.gif'></a>";
	echo "<br><font color=red size=+2>".
	     " Press the Panic Button to contain your experiment".
	     "</font>\n";
    }
    echo "</center>\n";
}
672
SUBPAGEEND();
673

674
if ($instance &&
675 676 677
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING)) {
678
    $instance->ShowBindings();
679 680
}

681 682 683
#
# Dump the node information.
#
Mike Hibler's avatar
Mike Hibler committed
684
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
685

Leigh Stoller's avatar
Leigh Stoller committed
686
if ($isadmin) {
687 688 689 690 691 692 693
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

694 695 696 697
#
# Standard Testbed Footer
# 
PAGEFOOTER();
698
?>