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

15
#
16
# Only known and logged in users can look at experiments.
17
#
18 19 20 21
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();

Leigh B. Stoller's avatar
Leigh B. Stoller committed
22
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
23
# Verify page arguments.
24 25 26 27
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("sortby",     PAGEARG_STRING,
				 "showclass",  PAGEARG_STRING);
28

29
if (!isset($sortby)) {
30
    if ($experiment->pid() == $TBOPSPID)
31 32 33 34
	$sortby = "rsrvtime-down";
    else
	$sortby = "";
}
35 36
if (!isset($showclass))
     $showclass = null;
37

38 39 40 41
# Need these below.
$exp_eid = $eid = $experiment->eid();
$exp_pid = $pid = $experiment->pid();
$tag = "Experiment";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
42

43
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
44
# Verify Permission.
45
#
46
if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
47
    USERERROR("You do not have permission to view experiment $exp_eid!", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48 49
}

50 51 52 53 54 55 56 57 58 59 60 61
# Template Instance Experiments get special treatment in this page.
$instance = NULL;
if ($EXPOSETEMPLATES) {
     $instance = TemplateInstance::LookupByExptidx($experiment->idx());

     if (! is_null($instance)) {
	 $tag = "Instance";
	 $guid = $instance->guid();
	 $vers = $instance->vers();
     }
}

62 63 64
#
# For the Sajax Interface
#
65 66 67
$USER_VIS_URL = "http://$USERNODE/exp-vis/$pid/$eid/";
$HAVE_USER_VIS = 0;
$whocares = null;
68
if ($EXP_VIS && CHECKURL($USER_VIS_URL, $whocares)) {
69 70 71
  $HAVE_USER_VIS = 1;
}

72 73
function FreeNodeHtml()
{
74 75 76
    global $this_user, $experiment;
    
    return ShowFreeNodes($this_user, $experiment->Group());
77 78
}

79 80
function GetExpState($a, $b)
{
81
    global $experiment;
82

83
    return $experiment->state();
84
}
85

86 87 88 89 90 91 92 93
function ModifyAnno($newtext)
{
    global $this_user, $instance;

    $instance->SetAnnotation($this_user, $newtext);
    return 0;
}

94
function Show($which, $arg1, $arg2)
95
{
96
    global $experiment, $instance, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
97
    global $USER_VIS_URL;
98 99
    $pid  = $experiment->pid();
    $eid  = $experiment->eid();
100 101 102 103
    $html = "";

    if ($which == "settings") {
	ob_start();
104
	$experiment->Show();
105 106 107
	$html = ob_get_contents();
	ob_end_clean();
    }
108 109 110 111 112 113 114 115
    if ($which == "anno") {
	if (isset($instance)) {
	    ob_start();
	    $instance->ShowAnnotation(1);
	    $html = ob_get_contents();
	    ob_end_clean();
	}
    }
116
    elseif ($which == "details") {
117
	$showevents = $arg1;
118 119 120 121 122
	$output = array();
	$retval = 0;
	$html   = "";

        # Show event summary and firewall info.
123
        $flags = ($showevents ? "-e -a" : "-b -e -f");
124 125

	$result = exec("$TBSUEXEC_PATH $uid $TBADMINGROUP ".
126
		       "webtbreport $flags $pid $eid",
127 128
		       $output, $retval);

129 130
	$html = "<pre><div align=left id=\"showexp_details\" ".
	    "class=\"showexp_codeblock\">";
131 132 133 134
	for ($i = 0; $i < count($output); $i++) {
	    $html .= htmlentities($output[$i]);
	    $html .= "\n";
	}
135 136
	$html .= "</div></pre>\n";

137 138 139 140 141 142
	$html .= "<button name=showevents type=button value=1";
	$html .= " onclick=\"ShowEvents();\">";
	$html .= "Show Events</button>\n";
	
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";

143 144
	$html .= "<button name=savedetails type=button value=1";
	$html .= " onclick=\"SaveDetails();\">";
145
	$html .= "Save to File</button>\n";
146
    }
147 148 149 150 151 152
    elseif ($which == "graphs") {
	$graphtype = $arg1;

	if (!isset($graphtype) || !$graphtype)
	    $graphtype = "pps";
	
153
	$exptidx = $experiment->idx();
154 155 156 157 158 159 160 161
	# 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 ";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
162
	$html .= "       src='linkgraph_image.php?instance=$exptidx";
163 164 165 166 167 168 169 170 171 172
	$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";
    }
173
    elseif ($which == "vis") {
174 175 176
	$zoom   = $arg1;
	$detail = $arg2;
	
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
	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";
	}
223 224 225 226
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";
	$html .= "<button name=fullscreenvis type=button value=1";
	$html .= " onclick=\"FullScreenVis();\">";
	$html .= "Full Screen</button>\n";
227 228
    }
    elseif ($which == "nsfile") {
229
	$nsdata = $experiment->NSFile();
230
	
231 232
	$html = "<pre><div align=left class=\"showexp_codeblock\">".
	    "$nsdata</div></pre>\n";
233 234 235 236 237

	$html .= "<button name=savens type=button value=1";
	$html .= " onclick=\"SaveNS();\">";
	$html .= "Save</button>\n";
    }
238 239
    elseif ($which == "uservis") {
	ob_start();
240
	$html .= "<iframe src=\"$USER_VIS_URL\" width=\"100%\" height=600 id=\"vis-iframe\"></iframe>";
241 242
	ob_end_clean();
    }
243 244 245 246 247 248 249 250
    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; ".
251
	    "     position: relative; z-index:1010; height: 450px; ".
252
	    "     width: 90%; border: 2px solid black;'>\n".
253
            " <div id=myvisdiv style='position:relative;'>\n".
254
	    "   <img id=myvisimg border=0 style='cursor: move;' ".
255 256 257 258 259 260 261 262 263
	    "        onLoad=\"setTimeout('ShowVisInit();', 10);\" ".
	    "        src='top2image.php3?pid=$pid&eid=$eid".
	    "&zoom=$zoom&detail=$detail'>\n".
	    " </div>\n".
	    "</div>\n";

    return $html;
}

264 265 266 267 268 269 270
#
# 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
271
include_once("template_defs.php");
272

273 274 275
#
# Need some DB info.
#
276 277 278 279 280 281 282
$expindex   = $experiment->idx();
$expstate   = $experiment->state();
$isbatch    = $experiment->batchmode();
$linktest_running = $experiment->linktest_pid();
$paniced    = $experiment->paniced();
$panic_date = $experiment->panic_date();
$lockdown   = $experiment->lockdown();
283
$geniflags  = $experiment->geniflags();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
284 285 286 287

if (! ($experiment_stats = $experiment->GetStats())) {
    TBERROR("Could not get experiment stats object for $expindex", 1);
}
288
$rsrcidx    = $experiment_stats->rsrcidx();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
289 290 291
if (! ($experiment_resources = $experiment->GetResources())) {
    TBERROR("Could not get experiment resources object for $expindex", 1);
}
292
$wireless   = $experiment_resources->wirelesslans();
293

294 295 296 297 298
#
# Standard Testbed Header.
#
PAGEHEADER("$tag ($pid/$eid)");

299 300 301 302 303 304 305
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>";
306 307 308 309 310
echo "<script type='text/javascript' language='javascript'>\n";
sajax_show_javascript();
echo "StartStateChangeWatch('$pid', '$eid', '$expstate');\n";
echo "</script>\n";

311 312 313 314
#
# Get a list of node types and classes in this experiment
#
$query_result =
315 316 317 318 319 320 321
    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'");
322
while ($row = mysql_fetch_array($query_result)) {
323 324 325 326 327 328 329 330
    if (isset($row['ftype'])) {
	$classes[$row['fclass']] = 1;
	$types[$row['ftype']] = 1;
    }
    else {
	$classes[$row['class']] = 1;
	$types[$row['type']] = 1;
    }
331 332
}

333
SUBPAGESTART();
334

335
SUBMENUSTART("$tag Options");
336

337
if ($expstate) {
338
    if ($experiment->logfile() && $experiment->logfile() != "") {
339
	WRITESUBMENUBUTTON("View Activity Logfile",
340
			   CreateURL("showlogfile", $experiment));
341
    }
342 343
    WRITESUBMENUDIVIDER();

344 345 346 347 348
    if (!$lockdown) {
        # Swap option.
	if ($isbatch) {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Queue Batch Experiment",
349 350
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
351 352 353 354
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    $expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Stop Batch Experiment",
355 356
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
357 358 359
	    }
	    elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
		WRITESUBMENUBUTTON("Dequeue Batch Experiment",
360 361
				   CreateURL("swapexp", $experiment,
					     "inout", "pause"));
362
	    }
363
	}
364
	else {
365
	    if (!$geniflags && $expstate == $TB_EXPTSTATE_SWAPPED) {
366 367 368
		WRITESUBMENUBUTTON(($instance ?
				    "Swap Instance In" :
				    "Swap Experiment In"),
369 370
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
371 372 373
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    ($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
374
		WRITESUBMENUBUTTON(($instance ?
375 376
				    "Terminate Instance" :
				    "Swap Experiment Out"),
377 378
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
379
	    }
380
	    elseif (!$geniflags && $expstate == $TB_EXPTSTATE_ACTIVATING) {
381 382 383
		WRITESUBMENUBUTTON(($instance ?
				   "Cancel Template Instantiation" :
  				   "Cancel Experiment Swapin"),
384 385
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
386
	    }
387
	}
388
    
389
	if (!$instance && !$geniflags && $expstate != $TB_EXPTSTATE_PANICED) {
390
	    WRITESUBMENUBUTTON("Terminate Experiment",
391
			       CreateURL("endexp", $experiment));
392
	}
393 394
	elseif ($instance && $expstate == $TB_EXPTSTATE_SWAPPED) {
	    WRITESUBMENUBUTTON("Terminate Instance",
395
			       CreateURL("endexp", $experiment));
396
	}
397

398
        # Batch experiments can be modifed only when paused.
399 400
	if (!$geniflags &&
	    !$instance && ($expstate == $TB_EXPTSTATE_SWAPPED ||
401
	    (!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE))) {
402
	    WRITESUBMENUBUTTON("Modify Experiment",
403
			       CreateURL("modifyexp", $experiment));
404
	}
405
    }
406

407
    if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
408
	if ($instance->runidx()) {
409
	    WRITESUBMENUBUTTON("Stop Current Run",
410 411
			       CreateURL("template_exprun", $instance,
					 "action", "stop"));
412
	    WRITESUBMENUBUTTON("Abort Current Run",
413 414
			       CreateURL("template_exprun", $instance,
					 "action", "abort"));
415
	}
416 417 418
	#WRITESUBMENUBUTTON("Modify Resources",
	#		   CreateURL("template_exprun", $instance,
	#			     "action", "modify"));
419

420
	WRITESUBMENUBUTTON("Start New Run",
421 422
			   CreateURL("template_exprun", $instance,
				     "action", "start"));
423

424 425
	if ($instance->pause_time()) {
	    WRITESUBMENUBUTTON("Continue Experiment RunTime",
426 427
			       CreateURL("template_exprun", $instance,
					 "action", "continue"));
428 429
	}
	else {
430
	    WRITESUBMENUBUTTON("Pause Runtime",
431 432
			       CreateURL("template_exprun", $instance,
					 "action", "pause"));
433 434
	}

435
	WRITESUBMENUBUTTON("Create New Template",
436
			   CreateURL("template_commit", $instance));
437
    }
438
    
439
    if (!$geniflags && $expstate == $TB_EXPTSTATE_ACTIVE) {
440
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
441
			   CreateURL("delaycontrol", $experiment));
442
    }
443 444
}

445
WRITESUBMENUBUTTON("Modify Settings",
446
		   CreateURL("editexp", $experiment));
447

448 449
WRITESUBMENUDIVIDER();

450
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
451 452 453
    if (!$geniflags) {
	WRITESUBMENUBUTTON("Link Tracing/Monitoring",
			   CreateURL("linkmon_list", $experiment));
454
    
455 456 457
	WRITESUBMENUBUTTON("Event Viewer",
			   CreateURL("showevents", $experiment));
    }
458
    
459 460 461
    #
    # Admin and project/experiment leaders get this option.
    #
462
    if ($experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
463
	WRITESUBMENUBUTTON("Update All Nodes",
464
			   CreateURL("updateaccounts", $experiment));
465
    }
466

467
    # Reboot option
468
    if ($experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
469
	WRITESUBMENUBUTTON("Reboot All Nodes",
470
			   CreateURL("boot", $experiment));
471
    }
472
}
473

474
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
475 476
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_MODIFY_RESWAP) &&
477 478
    (STUDLY() || $EXPOSELINKTEST)) {
    WRITESUBMENUBUTTON(($linktest_running ?
479 480
			"Stop LinkTest" : "Run LinkTest"),
		       CreateURL("linktest", $experiment) . 
481 482
		       ($linktest_running ? "&kill=1" : ""));
}
Timothy Stack's avatar
Timothy Stack committed
483

484
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
485
    if (!$geniflags && STUDLY() && isset($classes['pcvm'])) {
486
	WRITESUBMENUBUTTON("Record Feedback Data",
487 488
			   CreateURL("feedback", $experiment) .
			   "&mode=record");
489 490
    }
}
491 492 493

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
494
    !$geniflags && STUDLY()) {
495
    WRITESUBMENUBUTTON("Clear Feedback Data",
496 497
		       CreateURL("feedback", $experiment) . "&mode=clear");
    if (isset($classes['pcvm'])) {
498
	    WRITESUBMENUBUTTON("Remap Virtual Nodes",
499
			       CreateURL("remapexp", $experiment));
500
    }
501
}
502
    
503 504 505
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
506 507 508
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
509 510
}

511 512
WRITESUBMENUDIVIDER();

513
# History
514 515 516 517
if (! $instance) {
    WRITESUBMENUBUTTON("Show History",
		       "showstats.php3?showby=expt&exptidx=$expindex");
}
518

519 520 521 522
if (!$geniflags) {
    WRITESUBMENUBUTTON("Duplicate Experiment",
		       "beginexp_html.php3?copyid=$expindex");
}
523

524
if ($EXPOSEARCHIVE && !$instance && !$geniflags) {
525
    WRITESUBMENUBUTTON("Experiment File Archive",
526
		       "archive_view.php3?experiment=$expindex");
527 528
}

529 530 531
if (isset($types['garcia']) ||
    isset($types['static-mica2']) ||
    isset($types['robot'])) {
532 533
    SUBMENUSECTION("Robot/Mote Options");
    WRITESUBMENUBUTTON("Robot/Mote Map",
Timothy Stack's avatar
Timothy Stack committed
534 535 536
		       "robotmap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
537 538 539 540 541 542 543 544 545 546
    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",
547
			   CreateURL("robotrack/robotrack", $experiment));
548
    }
Timothy Stack's avatar
Timothy Stack committed
549 550
}

551 552
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
553
if (isset($classes['mote']) && $expstate == $TB_EXPTSTATE_ACTIVE) {
554
    WRITESUBMENUBUTTON("Show Blinky Lights",
555
		       CreateURL("moteleds", $experiment), "moteleds");
556 557
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
558
if ($isadmin) {
559
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
560 561 562 563 564 565 566 567
	if (!$geniflags) {
	    SUBMENUSECTION("Beta-Test Options");
	    WRITESUBMENUBUTTON("Restart Experiment",
			       CreateURL("swapexp", $experiment,
					 "inout", "restart"));
	    WRITESUBMENUBUTTON("Replay Events",
			       CreateURL("replayexp", $experiment));
	}
568

569
	SUBMENUSECTION("Admin Options");
570 571 572 573

	if (!$geniflags) {
	    WRITESUBMENUBUTTON("Send an Idle Info Request",
			       CreateURL("request_idleinfo", $experiment));
574
	
575 576 577
	    WRITESUBMENUBUTTON("Send a Swap Request",
			       CreateURL("request_swapexp", $experiment));
	}
578
	WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
579 580
			   CreateURL("swapexp", $experiment,
				     "inout", "out", "force", 1));
Chad Barb's avatar
Chad Barb committed
581
	
582 583 584 585
	SUBMENUSECTIONEND();
    }
}
    
586 587
SUBMENUEND_2A();

588 589 590 591 592 593 594 595 596 597 598 599 600
echo "<br>\n";
echo "<script>\n";
echo "function FreeNodeHtml_CB(stuff) {
         getObjbyName('showexpusagefreenodes').innerHTML = stuff;
         setTimeout('GetFreeNodeHtml()', 60000);
      }
      function GetFreeNodeHtml() {
         x_FreeNodeHtml(FreeNodeHtml_CB);
      }
      setTimeout('GetFreeNodeHtml()', 60000);
      </script>\n";
	  
echo "<div id=showexpusagefreenodes>\n";
601
echo   ShowFreeNodes($this_user, $experiment->Group());
602 603
echo "</div>\n";

604 605
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
606
         <img border=1 alt='experiment vis'
Leigh B. Stoller's avatar
Leigh B. Stoller committed
607
              src='showthumb.php3?idx=$rsrcidx'></a>";
608 609

SUBMENUEND_2B();
610

Leigh B. Stoller's avatar
Leigh B. Stoller committed
611 612 613 614 615 616 617
#
# 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'>
618
        var li_current = 'li_settings';
Leigh B. Stoller's avatar
Leigh B. Stoller committed
619
        function Show(which) {
620 621
	    li = getObjbyName(li_current);
            li.style.backgroundColor = '#DDE';
622
            li.style.borderBottom = '1px solid #778';
623 624 625 626 627 628 629

            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 B. Stoller's avatar
Leigh B. Stoller committed
630 631
            return false;
        }
632 633 634 635 636 637 638 639 640 641 642
        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 B. Stoller's avatar
Leigh B. Stoller committed
643 644
            return false;
        }
645 646 647 648
        function GraphChange(which) {
            x_Show('graphs', which, 0, Show_cb);
            return false;
        }
649 650 651 652
        function ShowEvents() {
            x_Show('details', 1, 0, Show_cb);
            return false;
        }
653 654 655 656 657 658
        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');
        }
659 660
        function SaveNS() {
            window.open('spitnsdata.php3?pid=$pid&eid=$eid',
661
                        '_blank','width=700,height=400,toolbar=no,".
662 663 664
                        "resizeable=yes,scrollbars=yes,status=yes,".
	                "menubar=yes');
        }
665 666 667
        function FullScreenVis() {
	    window.location.replace('shownsfile.php3?pid=$pid&eid=$eid');
        }
668 669 670 671 672 673
        function ModifyAnno() {
            textarea = getObjbyName('annotation');
            x_ModifyAnno(textarea.value, ModifyAnno_cb);
        }
        function ModifyAnno_cb(val) {
        }
674
        function Setup() {
675 676 677 678 679 680 681 682 683 684
	    var urllocation = location.href; //find url parameter
	    if (urllocation && urllocation.indexOf('#') >= 0) {
                var which = urllocation.substr(urllocation.indexOf('#') + 1);
                Show(which);
            }
            else {
	        li = getObjbyName(li_current);
                li.style.backgroundColor = 'white';
                li.style.borderBottom = '1px solid white';
            }
685
        }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
686 687
      </script>\n";

688 689 690 691 692 693
#
# This is the topbar
#
echo "<div width=\"100%\" align=center>\n";
echo "<ul id=\"topnavbar\">\n";
echo "<li>
694 695
          <a href=\"#settings\" ".
               "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
696 697 698
               "id=\"li_settings\" onclick=\"Show('settings');\">".
               "Settings</a></li>\n";
echo "<li>
699 700
          <a href=\"#vis\" ".
               "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
701
               "id=\"li_vis\" onclick=\"Show('vis');\">".
702 703
               "Visualization</a></li>\n";
echo "<li>
704 705
          <a href=\"#nsfile\" ".
              "class=topnavbar onfocus=\"this.hideFocus=true;\"  ".
706
              "id=\"li_nsfile\" onclick=\"Show('nsfile');\">".
707 708
              "NS File</a></li>\n";
echo "<li>
709 710
          <a href=\"#details\" ".
              "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
711
              "id=\"li_details\" onclick=\"Show('details');\">".
712
              "Details</a></li>\n";
713

714
if ($instance) {
715
    echo "<li>
716 717
              <a href=\"#anno\" ".
	          "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
718
	          "id=\"li_anno\" onclick=\"Show('anno');\">".
719
                  "Annotation</a></li>\n";
720
}
721 722
if ($HAVE_USER_VIS) {
    echo "<li>
723 724
              <a href=\"#uservis\" ".
	          "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
725 726 727
	          "id=\"li_uservis\" onclick=\"Show('uservis');\">".
                  "User Visualization</a></li>\n";
}
728
echo "</ul>\n";
729 730
echo "</div>\n";
echo "<div align=center id=topnavbarbottom>&nbsp</div>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
731

732 733 734 735
#
# Start out with details ...
#
echo "<div align=center width=\"100%\" id=\"showexp_visarea\">\n";
736
$experiment->Show();
737
echo "</div>\n";
738

739
if ($experiment->Firewalled() &&
Leigh B. Stoller's avatar
Leigh B. Stoller committed
740 741 742 743 744
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_SWAPPING)) {
    echo "<center>\n";
745 746 747
    if ($paniced == 2) {
	#
	# Paniced due to failed swapout.
748
	# Only be semi-obnoxious (no blinking) since it was not their fault.
749 750 751 752 753 754 755 756 757 758 759 760
	#
	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 B. Stoller's avatar
Leigh B. Stoller committed
761 762 763 764 765 766 767
	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 {
768 769 770
	$panic_url = CreateURL("panicbutton", $experiment);
	
	echo "<br><a href='$panic_url'>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
771 772 773 774 775 776 777
                 <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";
}
778
SUBPAGEEND();
779

780 781
if ($instance) {
    $instance->ShowCurrentBindings();
782 783
}

784 785 786
#
# Dump the node information.
#
787
echo "<center>\n";
Mike Hibler's avatar
Mike Hibler committed
788
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
789
echo "</center>\n";
790

Leigh B. Stoller's avatar
Leigh B. Stoller committed
791
if ($isadmin) {
792 793 794 795
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

796
    $experiment->ShowStats();
797 798
}

799 800 801 802 803 804 805
#
# Get the active tab to look right.
#
echo "<script type='text/javascript' language='javascript'>
      Setup();
      </script>\n";

806 807 808 809
#
# Standard Testbed Footer
# 
PAGEFOOTER();
810
?>