showexp.php3 23.8 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
# Copyright (c) 2000-2012 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 B. Stoller's avatar
Leigh B. Stoller committed
23
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
24
include("defs.php3");
25
require("Sajax.php");
26
include("showstuff.php3");
27
include_once("node_defs.php");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
28
include_once("template_defs.php");
29
sajax_init();
30
sajax_export("GetExpState", "Show", "ModifyAnno", "FreeNodeHtml");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
31

32
#
33
# Only known and logged in users can look at experiments.
34
#
35 36 37 38
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();

Leigh B. Stoller's avatar
Leigh B. Stoller committed
39
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
40
# Verify page arguments.
41 42 43 44
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("sortby",     PAGEARG_STRING,
				 "showclass",  PAGEARG_STRING);
45

46
if (!isset($sortby)) {
47
    if ($experiment->pid() == $TBOPSPID)
48 49 50 51
	$sortby = "rsrvtime-down";
    else
	$sortby = "";
}
52 53
if (!isset($showclass))
     $showclass = null;
54

55 56 57 58
# Need these below.
$exp_eid = $eid = $experiment->eid();
$exp_pid = $pid = $experiment->pid();
$tag = "Experiment";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
59

60
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
61
# Verify Permission.
62
#
63
if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
64
    USERERROR("You do not have permission to view experiment $exp_eid!", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
65 66
}

67 68 69 70 71 72 73 74 75 76 77 78
# 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();
     }
}

79 80 81
#
# For the Sajax Interface
#
82 83 84
$USER_VIS_URL = "http://$USERNODE/exp-vis/$pid/$eid/";
$HAVE_USER_VIS = 0;
$whocares = null;
85
if ($EXP_VIS && CHECKURL($USER_VIS_URL, $whocares)) {
86 87 88
  $HAVE_USER_VIS = 1;
}

89 90
function FreeNodeHtml()
{
91 92 93
    global $this_user, $experiment;
    
    return ShowFreeNodes($this_user, $experiment->Group());
94 95
}

96 97
function GetExpState($a, $b)
{
98
    global $experiment;
99

100
    return $experiment->state();
101
}
102

103 104 105 106 107 108 109 110
function ModifyAnno($newtext)
{
    global $this_user, $instance;

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

111
function Show($which, $arg1, $arg2)
112
{
113
    global $experiment, $instance, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
114
    global $USER_VIS_URL;
115 116
    $pid  = $experiment->pid();
    $eid  = $experiment->eid();
117 118 119 120
    $html = "";

    if ($which == "settings") {
	ob_start();
121
	$experiment->Show();
122 123 124
	$html = ob_get_contents();
	ob_end_clean();
    }
125 126 127 128 129 130 131 132
    if ($which == "anno") {
	if (isset($instance)) {
	    ob_start();
	    $instance->ShowAnnotation(1);
	    $html = ob_get_contents();
	    ob_end_clean();
	}
    }
133
    elseif ($which == "details") {
134
	$showevents = $arg1;
135 136 137 138 139
	$output = array();
	$retval = 0;
	$html   = "";

        # Show event summary and firewall info.
140
        $flags = ($showevents ? "-e -a" : "-b -e -f");
141 142

	$result = exec("$TBSUEXEC_PATH $uid $TBADMINGROUP ".
143
		       "webtbreport $flags $pid $eid",
144 145
		       $output, $retval);

146 147
	$html = "<pre><div align=left id=\"showexp_details\" ".
	    "class=\"showexp_codeblock\">";
148 149 150 151
	for ($i = 0; $i < count($output); $i++) {
	    $html .= htmlentities($output[$i]);
	    $html .= "\n";
	}
152 153
	$html .= "</div></pre>\n";

154 155 156 157 158 159
	$html .= "<button name=showevents type=button value=1";
	$html .= " onclick=\"ShowEvents();\">";
	$html .= "Show Events</button>\n";
	
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";

160 161
	$html .= "<button name=savedetails type=button value=1";
	$html .= " onclick=\"SaveDetails();\">";
162
	$html .= "Save to File</button>\n";
163
    }
164 165 166 167 168 169
    elseif ($which == "graphs") {
	$graphtype = $arg1;

	if (!isset($graphtype) || !$graphtype)
	    $graphtype = "pps";
	
170
	$exptidx = $experiment->idx();
171 172 173 174 175 176 177 178
	# 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
179
	$html .= "       src='linkgraph_image.php?instance=$exptidx";
180 181 182 183 184 185 186 187 188 189
	$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";
    }
190
    elseif ($which == "vis") {
191 192 193
	$zoom   = $arg1;
	$detail = $arg2;
	
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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
	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";
	}
240 241 242 243
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";
	$html .= "<button name=fullscreenvis type=button value=1";
	$html .= " onclick=\"FullScreenVis();\">";
	$html .= "Full Screen</button>\n";
244 245
    }
    elseif ($which == "nsfile") {
246
	$nsdata = $experiment->NSFile();
247
	
248 249
	$html = "<pre><div align=left class=\"showexp_codeblock\">".
	    "$nsdata</div></pre>\n";
250 251 252 253 254

	$html .= "<button name=savens type=button value=1";
	$html .= " onclick=\"SaveNS();\">";
	$html .= "Save</button>\n";
    }
255 256
    elseif ($which == "uservis") {
	ob_start();
257
	$html .= "<iframe src=\"$USER_VIS_URL\" width=\"100%\" height=600 id=\"vis-iframe\"></iframe>";
258 259
	ob_end_clean();
    }
260 261 262 263 264 265 266 267
    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; ".
268
	    "     position: relative; z-index:1010; height: 450px; ".
269
	    "     width: 90%; border: 2px solid black;'>\n".
270
            " <div id=myvisdiv style='position:relative;'>\n".
271
	    "   <img id=myvisimg border=0 style='cursor: move;' ".
272 273 274 275 276 277 278 279 280
	    "        onLoad=\"setTimeout('ShowVisInit();', 10);\" ".
	    "        src='top2image.php3?pid=$pid&eid=$eid".
	    "&zoom=$zoom&detail=$detail'>\n".
	    " </div>\n".
	    "</div>\n";

    return $html;
}

281 282 283 284 285 286 287
#
# 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
288
include_once("template_defs.php");
289

290 291 292
#
# Need some DB info.
#
293 294 295 296 297 298 299
$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();
300
$geniflags  = $experiment->geniflags();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
301 302 303 304

if (! ($experiment_stats = $experiment->GetStats())) {
    TBERROR("Could not get experiment stats object for $expindex", 1);
}
305
$rsrcidx    = $experiment_stats->rsrcidx();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
306 307 308
if (! ($experiment_resources = $experiment->GetResources())) {
    TBERROR("Could not get experiment resources object for $expindex", 1);
}
309
$wireless   = $experiment_resources->wirelesslans();
310

311 312 313 314 315
#
# Standard Testbed Header.
#
PAGEHEADER("$tag ($pid/$eid)");

316 317 318 319 320 321 322
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>";
323 324 325 326 327
echo "<script type='text/javascript' language='javascript'>\n";
sajax_show_javascript();
echo "StartStateChangeWatch('$pid', '$eid', '$expstate');\n";
echo "</script>\n";

328 329 330 331
#
# Get a list of node types and classes in this experiment
#
$query_result =
332 333 334 335 336 337 338
    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'");
339
while ($row = mysql_fetch_array($query_result)) {
340 341 342 343 344 345 346 347
    if (isset($row['ftype'])) {
	$classes[$row['fclass']] = 1;
	$types[$row['ftype']] = 1;
    }
    else {
	$classes[$row['class']] = 1;
	$types[$row['type']] = 1;
    }
348 349
}

350
SUBPAGESTART();
351

352
SUBMENUSTART("$tag Options");
353

354
if ($expstate) {
355
    if ($experiment->logfile() && $experiment->logfile() != "") {
356
	WRITESUBMENUBUTTON("View Activity Logfile",
357
			   CreateURL("showlogfile", $experiment));
358
    }
359 360
    WRITESUBMENUDIVIDER();

361 362 363 364 365
    if (!$lockdown) {
        # Swap option.
	if ($isbatch) {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Queue Batch Experiment",
366 367
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
368 369 370 371
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    $expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Stop Batch Experiment",
372 373
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
374 375 376
	    }
	    elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
		WRITESUBMENUBUTTON("Dequeue Batch Experiment",
377 378
				   CreateURL("swapexp", $experiment,
					     "inout", "pause"));
379
	    }
380
	}
381
	else {
382
	    if (!$geniflags && $expstate == $TB_EXPTSTATE_SWAPPED) {
383 384 385
		WRITESUBMENUBUTTON(($instance ?
				    "Swap Instance In" :
				    "Swap Experiment In"),
386 387
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
388 389 390
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    ($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
391
		WRITESUBMENUBUTTON(($instance ?
392 393
				    "Terminate Instance" :
				    "Swap Experiment Out"),
394 395
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
396
	    }
397
	    elseif (!$geniflags && $expstate == $TB_EXPTSTATE_ACTIVATING) {
398 399 400
		WRITESUBMENUBUTTON(($instance ?
				   "Cancel Template Instantiation" :
  				   "Cancel Experiment Swapin"),
401 402
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
403
	    }
404
	}
405
    
406
	if (!$instance && !$geniflags && $expstate != $TB_EXPTSTATE_PANICED) {
407
	    WRITESUBMENUBUTTON("Terminate Experiment",
408
			       CreateURL("endexp", $experiment));
409
	}
410 411
	elseif ($instance && $expstate == $TB_EXPTSTATE_SWAPPED) {
	    WRITESUBMENUBUTTON("Terminate Instance",
412
			       CreateURL("endexp", $experiment));
413
	}
414

415
        # Batch experiments can be modifed only when paused.
416 417
	if (!$geniflags &&
	    !$instance && ($expstate == $TB_EXPTSTATE_SWAPPED ||
418
	    (!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE))) {
419
	    WRITESUBMENUBUTTON("Modify Experiment",
420
			       CreateURL("modifyexp", $experiment));
421
	}
422
    }
423

424
    if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
425
	if ($instance->runidx()) {
426
	    WRITESUBMENUBUTTON("Stop Current Run",
427 428
			       CreateURL("template_exprun", $instance,
					 "action", "stop"));
429
	    WRITESUBMENUBUTTON("Abort Current Run",
430 431
			       CreateURL("template_exprun", $instance,
					 "action", "abort"));
432
	}
433 434 435
	#WRITESUBMENUBUTTON("Modify Resources",
	#		   CreateURL("template_exprun", $instance,
	#			     "action", "modify"));
436

437
	WRITESUBMENUBUTTON("Start New Run",
438 439
			   CreateURL("template_exprun", $instance,
				     "action", "start"));
440

441 442
	if ($instance->pause_time()) {
	    WRITESUBMENUBUTTON("Continue Experiment RunTime",
443 444
			       CreateURL("template_exprun", $instance,
					 "action", "continue"));
445 446
	}
	else {
447
	    WRITESUBMENUBUTTON("Pause Runtime",
448 449
			       CreateURL("template_exprun", $instance,
					 "action", "pause"));
450 451
	}

452
	WRITESUBMENUBUTTON("Create New Template",
453
			   CreateURL("template_commit", $instance));
454
    }
455
    
456
    if (!$geniflags && $expstate == $TB_EXPTSTATE_ACTIVE) {
457
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
458
			   CreateURL("delaycontrol", $experiment));
459
    }
460 461
}

462
WRITESUBMENUBUTTON("Modify Settings",
463
		   CreateURL("editexp", $experiment));
464

465 466
WRITESUBMENUDIVIDER();

467
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
468 469 470
    if (!$geniflags) {
	WRITESUBMENUBUTTON("Link Tracing/Monitoring",
			   CreateURL("linkmon_list", $experiment));
471
    
472 473 474
	WRITESUBMENUBUTTON("Event Viewer",
			   CreateURL("showevents", $experiment));
    }
475
    
476 477 478
    #
    # Admin and project/experiment leaders get this option.
    #
479
    if ($experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
480
	WRITESUBMENUBUTTON("Update All Nodes",
481
			   CreateURL("updateaccounts", $experiment));
482
    }
483

484
    # Reboot option
485
    if ($experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
486
	WRITESUBMENUBUTTON("Reboot All Nodes",
487
			   CreateURL("boot", $experiment));
488
    }
489
}
490

491
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
492 493
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_MODIFY_RESWAP) &&
494 495
    (STUDLY() || $EXPOSELINKTEST)) {
    WRITESUBMENUBUTTON(($linktest_running ?
496 497
			"Stop LinkTest" : "Run LinkTest"),
		       CreateURL("linktest", $experiment) . 
498 499
		       ($linktest_running ? "&kill=1" : ""));
}
Timothy Stack's avatar
Timothy Stack committed
500

501
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
502
    if (!$geniflags && STUDLY() && isset($classes['pcvm'])) {
503
	WRITESUBMENUBUTTON("Record Feedback Data",
504 505
			   CreateURL("feedback", $experiment) .
			   "&mode=record");
506 507
    }
}
508 509 510

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
511
    !$geniflags && STUDLY()) {
512
    WRITESUBMENUBUTTON("Clear Feedback Data",
513 514
		       CreateURL("feedback", $experiment) . "&mode=clear");
    if (isset($classes['pcvm'])) {
515
	    WRITESUBMENUBUTTON("Remap Virtual Nodes",
516
			       CreateURL("remapexp", $experiment));
517
    }
518
}
519
    
520 521 522
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
523 524 525
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
526 527
}

528 529
WRITESUBMENUDIVIDER();

530
# History
531 532 533 534
if (! $instance) {
    WRITESUBMENUBUTTON("Show History",
		       "showstats.php3?showby=expt&exptidx=$expindex");
}
535

536 537
if (!$geniflags) {
    WRITESUBMENUBUTTON("Duplicate Experiment",
538
		       "beginexp.php?copyid=$expindex");
539
}
540

541
if ($EXPOSEARCHIVE && !$instance && !$geniflags) {
542
    WRITESUBMENUBUTTON("Experiment File Archive",
543
		       "archive_view.php3?experiment=$expindex");
544 545
}

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

Leigh B. Stoller's avatar
Leigh B. Stoller committed
553
if ($isadmin) {
Leigh B Stoller's avatar
Leigh B Stoller committed
554 555 556 557
    if ($expstate == $TB_EXPTSTATE_ACTIVE ||
	$expstate == $TB_EXPTSTATE_PANICED) {

	if ($expstate == $TB_EXPTSTATE_ACTIVE && !$geniflags) {
558 559 560 561 562 563 564
	    SUBMENUSECTION("Beta-Test Options");
	    WRITESUBMENUBUTTON("Restart Experiment",
			       CreateURL("swapexp", $experiment,
					 "inout", "restart"));
	    WRITESUBMENUBUTTON("Replay Events",
			       CreateURL("replayexp", $experiment));
	}
565

566
	SUBMENUSECTION("Admin Options");
567

Leigh B Stoller's avatar
Leigh B Stoller committed
568
	if ($expstate == $TB_EXPTSTATE_ACTIVE && !$geniflags) {
569 570
	    WRITESUBMENUBUTTON("Send an Idle Info Request",
			       CreateURL("request_idleinfo", $experiment));
571
	
572 573 574
	    WRITESUBMENUBUTTON("Send a Swap Request",
			       CreateURL("request_swapexp", $experiment));
	}
Leigh B Stoller's avatar
Leigh B Stoller committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
	if ($expstate == $TB_EXPTSTATE_PANICED) {
	    WRITESUBMENUBUTTON("Clear Panic Mode",
			       CreateURL("panicbutton", $experiment,
					 "clear", 1));
	}
	else {
	    WRITESUBMENUBUTTON("Panic Mode (level 1)",
			       CreateURL("panicbutton", $experiment,
					 "level", 1));
	    WRITESUBMENUBUTTON("Panic Mode (level 2)",
			       CreateURL("panicbutton", $experiment,
					 "level", 2));

	    WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
			       CreateURL("swapexp", $experiment,
					 "inout", "out", "force", 1));
	}
592 593 594 595
	SUBMENUSECTIONEND();
    }
}
    
596 597
SUBMENUEND_2A();

598 599 600 601 602 603 604 605 606 607 608 609 610
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";
611
echo   ShowFreeNodes($this_user, $experiment->Group());
612 613
echo "</div>\n";

614 615
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
616
         <img border=1 alt='experiment vis'
Leigh B. Stoller's avatar
Leigh B. Stoller committed
617
              src='showthumb.php3?idx=$rsrcidx'></a>";
618 619

SUBMENUEND_2B();
620

Leigh B. Stoller's avatar
Leigh B. Stoller committed
621 622 623 624 625 626 627
#
# 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'>
628
        var li_current = 'li_settings';
Leigh B. Stoller's avatar
Leigh B. Stoller committed
629
        function Show(which) {
630
	    li = getObjbyName(li_current);
631 632 633 634
            if (li) {
                li.style.backgroundColor = '#DDE';
                li.style.borderBottom = '1px solid #778';
            }
635 636 637

            li_current = 'li_' + which;
	    li = getObjbyName(li_current);
638 639 640 641 642
            if (li) {
                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
643 644
            return false;
        }
645 646 647 648 649 650 651 652 653 654 655
        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
656 657
            return false;
        }
658 659 660 661
        function GraphChange(which) {
            x_Show('graphs', which, 0, Show_cb);
            return false;
        }
662 663 664 665
        function ShowEvents() {
            x_Show('details', 1, 0, Show_cb);
            return false;
        }
666 667 668 669 670 671
        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');
        }
672 673
        function SaveNS() {
            window.open('spitnsdata.php3?pid=$pid&eid=$eid',
674
                        '_blank','width=700,height=400,toolbar=no,".
675 676 677
                        "resizeable=yes,scrollbars=yes,status=yes,".
	                "menubar=yes');
        }
678 679 680
        function FullScreenVis() {
	    window.location.replace('shownsfile.php3?pid=$pid&eid=$eid');
        }
681 682 683 684 685 686
        function ModifyAnno() {
            textarea = getObjbyName('annotation');
            x_ModifyAnno(textarea.value, ModifyAnno_cb);
        }
        function ModifyAnno_cb(val) {
        }
687
        function Setup() {
688 689 690
	    var urllocation = location.href; //find url parameter
	    if (urllocation && urllocation.indexOf('#') >= 0) {
                var which = urllocation.substr(urllocation.indexOf('#') + 1);
691 692 693 694 695

	        li = getObjbyName('li_' + which);
                if (!li) {
                    which = 'settings';
                }
696 697 698 699
                Show(which);
            }
            else {
	        li = getObjbyName(li_current);
700 701 702 703
                if (li) {
                    li.style.backgroundColor = 'white';
                    li.style.borderBottom = '1px solid white';
                }
704
            }
705
        }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
706 707
      </script>\n";

708 709 710 711 712 713
#
# This is the topbar
#
echo "<div width=\"100%\" align=center>\n";
echo "<ul id=\"topnavbar\">\n";
echo "<li>
714 715
          <a href=\"#settings\" ".
               "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
716 717 718
               "id=\"li_settings\" onclick=\"Show('settings');\">".
               "Settings</a></li>\n";
echo "<li>
719 720
          <a href=\"#vis\" ".
               "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
721
               "id=\"li_vis\" onclick=\"Show('vis');\">".
722 723
               "Visualization</a></li>\n";
echo "<li>
724 725
          <a href=\"#nsfile\" ".
              "class=topnavbar onfocus=\"this.hideFocus=true;\"  ".
726
              "id=\"li_nsfile\" onclick=\"Show('nsfile');\">".
727 728
              "NS File</a></li>\n";
echo "<li>
729 730
          <a href=\"#details\" ".
              "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
731
              "id=\"li_details\" onclick=\"Show('details');\">".
732
              "Details</a></li>\n";
733

734
if ($instance) {
735
    echo "<li>
736 737
              <a href=\"#anno\" ".
	          "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
738
	          "id=\"li_anno\" onclick=\"Show('anno');\">".
739
                  "Annotation</a></li>\n";
740
}
741 742
if ($HAVE_USER_VIS) {
    echo "<li>
743 744
              <a href=\"#uservis\" ".
	          "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
745 746 747
	          "id=\"li_uservis\" onclick=\"Show('uservis');\">".
                  "User Visualization</a></li>\n";
}
748
echo "</ul>\n";
749 750
echo "</div>\n";
echo "<div align=center id=topnavbarbottom>&nbsp</div>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
751

752 753 754 755
#
# Start out with details ...
#
echo "<div align=center width=\"100%\" id=\"showexp_visarea\">\n";
756
$experiment->Show();
757
echo "</div>\n";
758

759
if ($experiment->Firewalled() &&
Leigh B. Stoller's avatar
Leigh B. Stoller committed
760 761 762 763 764
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_SWAPPING)) {
    echo "<center>\n";
765 766 767
    if ($paniced == 2) {
	#
	# Paniced due to failed swapout.
768
	# Only be semi-obnoxious (no blinking) since it was not their fault.
769 770 771 772 773 774 775 776 777 778 779 780
	#
	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
781 782 783 784 785 786 787
	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 {
788 789 790
	$panic_url = CreateURL("panicbutton", $experiment);
	
	echo "<br><a href='$panic_url'>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
791 792 793 794 795 796 797
                 <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";
}
798
SUBPAGEEND();
799

800 801
if ($instance) {
    $instance->ShowCurrentBindings();
802 803
}

804 805 806
#
# Dump the node information.
#
807
echo "<center>\n";
Mike Hibler's avatar
Mike Hibler committed
808
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
809
echo "</center>\n";
810

Leigh B. Stoller's avatar
Leigh B. Stoller committed
811
if ($isadmin) {
812 813 814 815
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

816
    $experiment->ShowStats();
817 818
}

819 820 821 822 823 824 825
#
# Get the active tab to look right.
#
echo "<script type='text/javascript' language='javascript'>
      Setup();
      </script>\n";

826 827 828 829
#
# Standard Testbed Footer
# 
PAGEFOOTER();
830
?>