showexp.php3 20.5 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-2007 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");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
10
include_once("template_defs.php");
11
sajax_init();
12
sajax_export("GetExpState", "Show", "ModifyAnno");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
13

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

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

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

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

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

49
50
51
52
53
54
55
56
57
58
59
60
# 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();
     }
}

61
62
63
64
65
#
# For the Sajax Interface
#
function GetExpState($a, $b)
{
66
    global $experiment;
67

68
    return $experiment->state();
69
}
70

71
72
73
74
75
76
77
78
function ModifyAnno($newtext)
{
    global $this_user, $instance;

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

79
function Show($which, $arg1, $arg2)
80
{
81
    global $experiment, $instance, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
82
83
    $pid  = $experiment->pid();
    $eid  = $experiment->eid();
84
85
86
87
    $html = "";

    if ($which == "settings") {
	ob_start();
88
	$experiment->Show();
89
90
91
	$html = ob_get_contents();
	ob_end_clean();
    }
92
93
94
95
96
97
98
99
    if ($which == "anno") {
	if (isset($instance)) {
	    ob_start();
	    $instance->ShowAnnotation(1);
	    $html = ob_get_contents();
	    ob_end_clean();
	}
    }
100
    elseif ($which == "details") {
101
	$showevents = $arg1;
102
103
104
105
106
	$output = array();
	$retval = 0;
	$html   = "";

        # Show event summary and firewall info.
107
        $flags = ($showevents ? "-e -a" : "-b -e -f");
108
109

	$result = exec("$TBSUEXEC_PATH $uid $TBADMINGROUP ".
110
		       "webtbreport $flags $pid $eid",
111
112
		       $output, $retval);

113
114
	$html = "<pre><div align=left id=\"showexp_details\" ".
	    "class=\"showexp_codeblock\">";
115
116
117
118
	for ($i = 0; $i < count($output); $i++) {
	    $html .= htmlentities($output[$i]);
	    $html .= "\n";
	}
119
120
	$html .= "</div></pre>\n";

121
122
123
124
125
126
	$html .= "<button name=showevents type=button value=1";
	$html .= " onclick=\"ShowEvents();\">";
	$html .= "Show Events</button>\n";
	
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";

127
128
	$html .= "<button name=savedetails type=button value=1";
	$html .= " onclick=\"SaveDetails();\">";
129
	$html .= "Save to File</button>\n";
130
    }
131
132
133
134
135
136
    elseif ($which == "graphs") {
	$graphtype = $arg1;

	if (!isset($graphtype) || !$graphtype)
	    $graphtype = "pps";
	
137
	$exptidx = $experiment->idx();
138
139
140
141
142
143
144
145
	# 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
146
	$html .= "       src='linkgraph_image.php?instance=$exptidx";
147
148
149
150
151
152
153
154
155
156
	$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";
    }
157
    elseif ($which == "vis") {
158
159
160
	$zoom   = $arg1;
	$detail = $arg2;
	
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
	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";
	}
207
208
209
210
	$html .= "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ";
	$html .= "<button name=fullscreenvis type=button value=1";
	$html .= " onclick=\"FullScreenVis();\">";
	$html .= "Full Screen</button>\n";
211
212
    }
    elseif ($which == "nsfile") {
213
	$nsdata = $experiment->NSFile();
214
	
215
216
	$html = "<pre><div align=left class=\"showexp_codeblock\">".
	    "$nsdata</div></pre>\n";
217
218
219
220
221
222
223
224
225
226
227
228
229

	$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; ".
230
	    "     position: relative; z-index:1010; height: 450px; ".
231
	    "     width: 90%; border: 2px solid black;'>\n".
232
            " <div id=myvisdiv style='position:relative;'>\n".
233
	    "   <img id=myvisimg border=0 style='cursor: move;' ".
234
235
236
237
238
239
240
241
242
	    "        onLoad=\"setTimeout('ShowVisInit();', 10);\" ".
	    "        src='top2image.php3?pid=$pid&eid=$eid".
	    "&zoom=$zoom&detail=$detail'>\n".
	    " </div>\n".
	    "</div>\n";

    return $html;
}

243
244
245
246
247
248
249
#
# 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
250
include_once("template_defs.php");
251

252
253
254
#
# Need some DB info.
#
255
256
257
258
259
260
261
$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();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
262
263
264
265

if (! ($experiment_stats = $experiment->GetStats())) {
    TBERROR("Could not get experiment stats object for $expindex", 1);
}
266
$rsrcidx    = $experiment_stats->rsrcidx();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
267
268
269
if (! ($experiment_resources = $experiment->GetResources())) {
    TBERROR("Could not get experiment resources object for $expindex", 1);
}
270
$wireless   = $experiment_resources->wirelesslans();
Chad Barb's avatar
 
Chad Barb committed
271

272
273
274
275
276
#
# Standard Testbed Header.
#
PAGEHEADER("$tag ($pid/$eid)");

277
278
279
280
281
282
283
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>";
284
285
286
287
288
echo "<script type='text/javascript' language='javascript'>\n";
sajax_show_javascript();
echo "StartStateChangeWatch('$pid', '$eid', '$expstate');\n";
echo "</script>\n";

289
290
291
292
#
# Get a list of node types and classes in this experiment
#
$query_result =
293
294
295
296
297
298
299
    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'");
300
while ($row = mysql_fetch_array($query_result)) {
301
302
303
304
305
306
307
308
    if (isset($row['ftype'])) {
	$classes[$row['fclass']] = 1;
	$types[$row['ftype']] = 1;
    }
    else {
	$classes[$row['class']] = 1;
	$types[$row['type']] = 1;
    }
309
310
}

311
echo $experiment->PageHeader();
Chad Barb's avatar
 
Chad Barb committed
312
echo "<br /><br />\n";
313
SUBPAGESTART();
Chad Barb's avatar
 
Chad Barb committed
314

315
SUBMENUSTART("$tag Options");
316

317
if ($expstate) {
318
    if ($experiment->logfile() && $experiment->logfile() != "") {
319
	WRITESUBMENUBUTTON("View Activity Logfile",
320
			   CreateURL("showlogfile", $experiment));
321
    }
322
323
    WRITESUBMENUDIVIDER();

324
325
326
327
328
    if (!$lockdown) {
        # Swap option.
	if ($isbatch) {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Queue Batch Experiment",
329
330
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
331
332
333
334
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    $expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Stop Batch Experiment",
335
336
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
337
338
339
	    }
	    elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
		WRITESUBMENUBUTTON("Dequeue Batch Experiment",
340
341
				   CreateURL("swapexp", $experiment,
					     "inout", "pause"));
342
	    }
343
	}
344
345
	else {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
346
347
348
		WRITESUBMENUBUTTON(($instance ?
				    "Swap Instance In" :
				    "Swap Experiment In"),
349
350
				   CreateURL("swapexp", $experiment,
					     "inout", "in"));
351
352
353
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    ($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
354
		WRITESUBMENUBUTTON(($instance ?
355
356
				    "Terminate Instance" :
				    "Swap Experiment Out"),
357
358
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
359
360
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
361
362
363
		WRITESUBMENUBUTTON(($instance ?
				   "Cancel Template Instantiation" :
  				   "Cancel Experiment Swapin"),
364
365
				   CreateURL("swapexp", $experiment,
					     "inout", "out"));
366
	    }
367
	}
368
    
369
	if (!$instance && $expstate != $TB_EXPTSTATE_PANICED) {
370
	    WRITESUBMENUBUTTON("Terminate Experiment",
371
			       CreateURL("endexp", $experiment));
372
	}
373
374
	elseif ($instance && $expstate == $TB_EXPTSTATE_SWAPPED) {
	    WRITESUBMENUBUTTON("Terminate Instance",
375
			       CreateURL("endexp", $experiment));
376
	}
377

378
        # Batch experiments can be modifed only when paused.
379
	if (!$instance && ($expstate == $TB_EXPTSTATE_SWAPPED ||
380
	    (!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE))) {
381
	    WRITESUBMENUBUTTON("Modify Experiment",
382
			       CreateURL("modifyexp", $experiment));
383
	}
384
    }
385

386
    if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
387
	if ($instance->runidx()) {
388
	    WRITESUBMENUBUTTON("Stop Current Run",
389
390
			       CreateURL("template_exprun", $instance,
					 "action", "stop"));
391
	    WRITESUBMENUBUTTON("Abort Current Run",
392
393
			       CreateURL("template_exprun", $instance,
					 "action", "abort"));
394
	}
395
396
397
	WRITESUBMENUBUTTON("Modify Resources",
			   CreateURL("template_exprun", $instance,
				     "action", "modify"));
398

399
	WRITESUBMENUBUTTON("Start New Run",
400
401
			   CreateURL("template_exprun", $instance,
				     "action", "start"));
402

403
404
	if ($instance->pause_time()) {
	    WRITESUBMENUBUTTON("Continue Experiment RunTime",
405
406
			       CreateURL("template_exprun", $instance,
					 "action", "continue"));
407
408
	}
	else {
409
	    WRITESUBMENUBUTTON("Pause Runtime",
410
411
			       CreateURL("template_exprun", $instance,
					 "action", "pause"));
412
413
	}

414
	WRITESUBMENUBUTTON("Create New Template",
415
			   CreateURL("template_commit", $instance));
416
    }
417
    
418
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
419
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
420
			   CreateURL("delaycontrol", $experiment));
Chad Barb's avatar
 
Chad Barb committed
421
    }
422
423
}

424
WRITESUBMENUBUTTON("Modify Metadata",
425
		   CreateURL("editexp", $experiment));
426

427
428
WRITESUBMENUDIVIDER();

429
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
430
    WRITESUBMENUBUTTON("Link Tracing/Monitoring",
431
		       CreateURL("linkmon_list", $experiment));
432
    
433
    WRITESUBMENUBUTTON("Event Viewer",
434
		       CreateURL("showevents", $experiment));
435
    
436
437
438
    #
    # Admin and project/experiment leaders get this option.
    #
439
    if ($experiment->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
440
	WRITESUBMENUBUTTON("Update All Nodes",
441
			   CreateURL("updateaccounts", $experiment));
442
    }
443

444
    # Reboot option
445
    if ($experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
446
	WRITESUBMENUBUTTON("Reboot All Nodes",
447
			   CreateURL("boot", $experiment));
448
    }
449
}
450

451
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
452
453
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_MODIFY_RESWAP) &&
454
455
    (STUDLY() || $EXPOSELINKTEST)) {
    WRITESUBMENUBUTTON(($linktest_running ?
456
457
			"Stop LinkTest" : "Run LinkTest"),
		       CreateURL("linktest", $experiment) . 
458
459
		       ($linktest_running ? "&kill=1" : ""));
}
Timothy Stack's avatar
 
Timothy Stack committed
460

461
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
462
    if (STUDLY() && isset($classes['pcvm'])) {
463
	WRITESUBMENUBUTTON("Record Feedback Data",
464
465
			   CreateURL("feedback", $experiment) .
			   "&mode=record");
466
467
    }
}
468
469
470

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
471
    STUDLY()) {
472
    WRITESUBMENUBUTTON("Clear Feedback Data",
473
474
		       CreateURL("feedback", $experiment) . "&mode=clear");
    if (isset($classes['pcvm'])) {
475
	    WRITESUBMENUBUTTON("Remap Virtual Nodes",
476
			       CreateURL("remapexp", $experiment));
477
    }
478
}
479
    
480
481
482
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
483
484
485
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
486
487
}

488
489
WRITESUBMENUDIVIDER();

490
# History
491
492
493
494
if (! $instance) {
    WRITESUBMENUBUTTON("Show History",
		       "showstats.php3?showby=expt&exptidx=$expindex");
}
495

496
if (!$instance && STUDLY()) {
497
498
499
500
    WRITESUBMENUBUTTON("Duplicate Experiment",
		       "beginexp_html.php3?copyid=${exp_pid},${exp_eid}");
}

501
if ($EXPOSEARCHIVE && !$instance) {
502
    WRITESUBMENUBUTTON("Experiment File Archive",
503
		       "archive_view.php3?experiment=$expindex");
504
505
}

506
507
508
if (isset($types['garcia']) ||
    isset($types['static-mica2']) ||
    isset($types['robot'])) {
509
510
    SUBMENUSECTION("Robot/Mote Options");
    WRITESUBMENUBUTTON("Robot/Mote Map",
Timothy Stack's avatar
 
Timothy Stack committed
511
512
513
		       "robotmap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
514
515
516
517
518
519
520
521
522
523
    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",
524
			   CreateURL("robotrack/robotrack", $experiment));
525
    }
Timothy Stack's avatar
 
Timothy Stack committed
526
527
}

528
529
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
530
if (isset($classes['mote']) && $expstate == $TB_EXPTSTATE_ACTIVE) {
531
    WRITESUBMENUBUTTON("Show Blinky Lights",
532
		       CreateURL("moteleds", $experiment), "moteleds");
533
534
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
535
if ($isadmin) {
536
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
537
	SUBMENUSECTION("Beta-Test Options");
538
	WRITESUBMENUBUTTON("Restart Experiment",
539
540
			   CreateURL("swapexp", $experiment,
				     "inout", "restart"));
541
	WRITESUBMENUBUTTON("Replay Events",
542
			   CreateURL("replayexp", $experiment));
Chad Barb's avatar
 
Chad Barb committed
543

544
545
	SUBMENUSECTION("Admin Options");
	
546
	WRITESUBMENUBUTTON("Send an Idle Info Request",
547
			   CreateURL("request_idleinfo", $experiment));
548
	
549
	WRITESUBMENUBUTTON("Send a Swap Request",
550
			   CreateURL("request_swapexp", $experiment));
551
552
	
	WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
553
554
			   CreateURL("swapexp", $experiment,
				     "inout", "out", "force", 1));
Chad Barb's avatar
Chad Barb committed
555
	
556
557
558
559
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
 
Chad Barb committed
560
561
SUBMENUEND_2A();

562
563
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
564
         <img border=1 alt='experiment vis'
Leigh B. Stoller's avatar
Leigh B. Stoller committed
565
              src='showthumb.php3?idx=$rsrcidx'></a>";
Chad Barb's avatar
 
Chad Barb committed
566
567

SUBMENUEND_2B();
568

Leigh B. Stoller's avatar
Leigh B. Stoller committed
569
570
571
572
573
574
575
#
# 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'>
576
        var li_current = 'li_settings';
Leigh B. Stoller's avatar
Leigh B. Stoller committed
577
        function Show(which) {
578
579
580
581
582
583
584
585
586
587
	    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 B. Stoller's avatar
Leigh B. Stoller committed
588
589
            return false;
        }
590
591
592
593
594
595
596
597
598
599
600
        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
601
602
            return false;
        }
603
604
605
606
        function GraphChange(which) {
            x_Show('graphs', which, 0, Show_cb);
            return false;
        }
607
608
609
610
        function ShowEvents() {
            x_Show('details', 1, 0, Show_cb);
            return false;
        }
611
612
613
614
615
616
        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');
        }
617
618
        function SaveNS() {
            window.open('spitnsdata.php3?pid=$pid&eid=$eid',
619
                        '_blank','width=700,height=400,toolbar=no,".
620
621
622
                        "resizeable=yes,scrollbars=yes,status=yes,".
	                "menubar=yes');
        }
623
624
625
        function FullScreenVis() {
	    window.location.replace('shownsfile.php3?pid=$pid&eid=$eid');
        }
626
627
628
629
630
631
        function ModifyAnno() {
            textarea = getObjbyName('annotation');
            x_ModifyAnno(textarea.value, ModifyAnno_cb);
        }
        function ModifyAnno_cb(val) {
        }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
632
633
      </script>\n";

634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
#
# 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";
652

653
if ($instance) {
654
    echo "<li>
655
656
              <a href=\"#E\" id=\"li_anno\" onclick=\"Show('anno');\">".
                  "Annotation</a></li>\n";
657
}
658
echo "</ul>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
659

660
661
662
663
#
# Start out with details ...
#
echo "<div align=center width=\"100%\" id=\"showexp_visarea\">\n";
664
$experiment->Show();
665
666
echo "</div>\n";
echo "</div>\n";
667

668
if ($experiment->Firewalled() &&
Leigh B. Stoller's avatar
Leigh B. Stoller committed
669
670
671
672
673
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_SWAPPING)) {
    echo "<center>\n";
674
675
676
    if ($paniced == 2) {
	#
	# Paniced due to failed swapout.
677
	# Only be semi-obnoxious (no blinking) since it was not their fault.
678
679
680
681
682
683
684
685
686
687
688
689
	#
	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
690
691
692
693
694
695
696
	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 {
697
698
699
	$panic_url = CreateURL("panicbutton", $experiment);
	
	echo "<br><a href='$panic_url'>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
700
701
702
703
704
705
706
                 <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";
}
707
SUBPAGEEND();
708

709
710
if ($instance) {
    $instance->ShowCurrentBindings();
711
712
}

713
714
715
#
# Dump the node information.
#
Mike Hibler's avatar
Mike Hibler committed
716
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
717

Leigh B. Stoller's avatar
Leigh B. Stoller committed
718
if ($isadmin) {
719
720
721
722
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

723
    $experiment->ShowStats();
724
725
}

726
727
728
729
#
# Standard Testbed Footer
# 
PAGEFOOTER();
730
?>