showexp.php3 24.1 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2016 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
#
Leigh Stoller's avatar
Leigh Stoller committed
24
include("defs.php3");
25
require("Sajax.php");
26
include("showstuff.php3");
27
include_once("node_defs.php");
Leigh Stoller's avatar
Leigh Stoller committed
28
include_once("template_defs.php");
29
sajax_init();
30
sajax_export("GetExpState", "Show", "ModifyAnno", "FreeNodeHtml");
Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh Stoller committed
39
#
Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh Stoller committed
59

60
#
Leigh Stoller's avatar
Leigh Stoller committed
61
# Verify Permission.
62
#
63
if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
Leigh Stoller's avatar
Leigh Stoller committed
64
    USERERROR("You do not have permission to view experiment $exp_eid!", 1);
Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh 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 Stoller's avatar
Leigh 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 Stoller's avatar
Leigh 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 && !$geniflags) {
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 463 464 465 466
if (!$geniflags) {
    WRITESUBMENUBUTTON("Modify Settings",
                       CreateURL("editexp", $experiment));
    WRITESUBMENUDIVIDER();
}
467

468
if (!$geniflags && $expstate == $TB_EXPTSTATE_ACTIVE) {
469 470 471
    if (!$geniflags) {
	WRITESUBMENUBUTTON("Link Tracing/Monitoring",
			   CreateURL("linkmon_list", $experiment));
472
    
473 474
	WRITESUBMENUBUTTON("Event Viewer",
			   CreateURL("showevents", $experiment));
475
    
476 477 478 479 480 481 482
        #
        # Admin and project/experiment leaders get this option.
        #
        if ($experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
                WRITESUBMENUBUTTON("Update All Nodes",
                                   CreateURL("updateaccounts", $experiment));
        }
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" : ""));
}
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
    if (1) {
540 541 542 543
        $uuid = $experiment->uuid();
        WRITESUBMENUBUTTON("Create Profile from Experiment",
                           "portal/manage_profile.php?fromexp=$uuid");
    }
544 545
}
if ($EXPOSEARCHIVE && !$instance && !$geniflags) {
546
    WRITESUBMENUBUTTON("Experiment File Archive",
547
		       "archive_view.php3?experiment=$expindex");
548 549
}

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

Leigh Stoller's avatar
Leigh Stoller committed
557
if ($isadmin) {
Leigh Stoller's avatar
Leigh Stoller committed
558 559 560 561
    if ($expstate == $TB_EXPTSTATE_ACTIVE ||
	$expstate == $TB_EXPTSTATE_PANICED) {

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

570
	SUBMENUSECTION("Admin Options");
571

Leigh Stoller's avatar
Leigh Stoller committed
572
	if ($expstate == $TB_EXPTSTATE_ACTIVE && !$geniflags) {
573 574
	    WRITESUBMENUBUTTON("Send an Idle Info Request",
			       CreateURL("request_idleinfo", $experiment));
575
	
576 577 578
	    WRITESUBMENUBUTTON("Send a Swap Request",
			       CreateURL("request_swapexp", $experiment));
	}
Leigh Stoller's avatar
Leigh Stoller committed
579 580 581 582 583 584 585 586 587
	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));
588 589 590 591 592
	    if (! $geniflags) {
		WRITESUBMENUBUTTON("Panic Mode (level 2)",
				   CreateURL("panicbutton", $experiment,
					     "level", 2));
	    }
Leigh Stoller's avatar
Leigh Stoller committed
593 594 595 596
	    WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
			       CreateURL("swapexp", $experiment,
					 "inout", "out", "force", 1));
	}
597 598 599 600
	SUBMENUSECTIONEND();
    }
}
    
601 602
SUBMENUEND_2A();

603 604 605 606 607 608 609 610 611 612 613 614 615
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";
616
echo   ShowFreeNodes($this_user, $experiment->Group());
617 618
echo "</div>\n";

619 620
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
621
         <img border=1 alt='experiment vis'
Leigh Stoller's avatar
Leigh Stoller committed
622
              src='showthumb.php3?idx=$rsrcidx'></a>";
623 624

SUBMENUEND_2B();
625

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

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

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

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

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

757 758 759 760
#
# Start out with details ...
#
echo "<div align=center width=\"100%\" id=\"showexp_visarea\">\n";
761
$experiment->Show();
762
echo "</div>\n";
763

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

805 806
if ($instance) {
    $instance->ShowCurrentBindings();
807 808
}

809 810 811
#
# Dump the node information.
#
812
echo "<center>\n";
Mike Hibler's avatar
Mike Hibler committed
813
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
814
echo "</center>\n";
815

Leigh Stoller's avatar
Leigh Stoller committed
816
if ($isadmin) {
817 818 819 820
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

821
    $experiment->ShowStats();
822 823
}

824 825 826 827 828 829 830
#
# Get the active tab to look right.
#
echo "<script type='text/javascript' language='javascript'>
      Setup();
      </script>\n";

831 832 833 834
#
# Standard Testbed Footer
# 
PAGEFOOTER();
835
?>