showexp.php3 9.55 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-2005 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
include("showstuff.php3");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
9

10
#
11
# Only known and logged in users can look at experiments.
12
#
13
$uid = GETLOGIN();
14
LOGGEDINORDIE($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
15
$isadmin = ISADMIN($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
16
17

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

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

38
39
40
41
42
#
# Standard Testbed Header now that we have the pid/eid okay.
#
PAGEHEADER("Experiment Information ($pid/$eid)");

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

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

58
59
60
61
#
# Need some DB info.
#
$query_result =
62
    DBQueryFatal("select e.idx,e.state,e.batchmode,e.linktest_pid,".
63
64
		 "       e.paniced,e.panic_date,s.rsrcidx,r.wirelesslans, ".
		 "       e.lockdown ".
65
66
		 "  from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
67
		 "left join experiment_resources as r on s.rsrcidx=r.idx ".
68
		 "where e.eid='$eid' and e.pid='$pid'");
69
70
71
72
73
$row        = mysql_fetch_array($query_result);
$expindex   = $row["idx"];
$expstate   = $row["state"];
$rsrcidx    = $row["rsrcidx"];
$isbatch    = $row["batchmode"];
74
$wireless   = $row["wirelesslans"];
75
$linktest_running = $row["linktest_pid"];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
76
77
$paniced    = $row["paniced"];
$panic_date = $row["panic_date"];
78
$lockdown   = $row["lockdown"];
Chad Barb's avatar
   
Chad Barb committed
79

80
81
82
83
#
# Get a list of node types and classes in this experiment
#
$query_result =
84
85
86
87
88
89
90
    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'");
91
while ($row = mysql_fetch_array($query_result)) {
92
93
94
95
96
97
98
99
    if (isset($row['ftype'])) {
	$classes[$row['fclass']] = 1;
	$types[$row['ftype']] = 1;
    }
    else {
	$classes[$row['class']] = 1;
	$types[$row['type']] = 1;
    }
100
101
102
}


Chad Barb's avatar
   
Chad Barb committed
103
echo "<font size=+2>Experiment <b>".
Chad Barb's avatar
   
Chad Barb committed
104
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
105
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
Chad Barb's avatar
   
Chad Barb committed
106
echo "<br /><br />\n";
107
SUBPAGESTART();
Chad Barb's avatar
   
Chad Barb committed
108

109
SUBMENUSTART("Experiment Options");
110

111
if ($expstate) {
112
    if (TBExptLogFile($exp_pid, $exp_eid)) {
113
	WRITESUBMENUBUTTON("View Activity Logfile",
114
			   "showlogfile.php3?pid=$exp_pid&eid=$exp_eid");
115
116
    }
      
117
    if ($state == $TB_EXPTSTATE_ACTIVE) {
Jay Lepreau's avatar
Jay Lepreau committed
118
	WRITESUBMENUBUTTON("Visualization, NS File, Mapping",
119
120
121
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    else {
122
	WRITESUBMENUBUTTON("Visualization and NS File",
123
124
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
125
126
    WRITESUBMENUBUTTON("Download NS File",
		       "spitnsdata.php3?pid=$exp_pid&eid=$exp_eid");
127

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    if (!$lockdown) {
        # Swap option.
	if ($isbatch) {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Queue Batch Experiment",
			 "swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    $expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Stop Batch Experiment",
			 "swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
		WRITESUBMENUBUTTON("Dequeue Batch Experiment",
			 "swapexp.php3?inout=pause&pid=$exp_pid&eid=$exp_eid");
	    }
144
	}
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
	else {
	    if ($expstate == $TB_EXPTSTATE_SWAPPED) {
		WRITESUBMENUBUTTON("Swap Experiment In",
			 "swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		    ($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
		WRITESUBMENUBUTTON("Swap Experiment Out",
			 "swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	    }
	    elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
		WRITESUBMENUBUTTON("Cancel Experiment Swapin",
				   "swapexp.php3?inout=out".
				   "&pid=$exp_pid&eid=$exp_eid");
	    }
160
	}
161
162
163
164
    
	if ($expstate != $TB_EXPTSTATE_PANICED) {
	    WRITESUBMENUBUTTON("Terminate Experiment",
			       "endexp.php3?pid=$exp_pid&eid=$exp_eid");
165
166
	}

167
168
169
170
171
172
        # Batch experiments can be modifed only when paused.
	if ($expstate == $TB_EXPTSTATE_SWAPPED ||
	    (!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE)) {
	    WRITESUBMENUBUTTON("Modify Experiment",
			       "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
	}
173
    }
174
    
175
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
176
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
177
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
178
179
180

	WRITESUBMENUBUTTON("Link Tracing/Monitoring",
			   "linkmon_list.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
181
    }
182
183
}

Jay Lepreau's avatar
Jay Lepreau committed
184
WRITESUBMENUBUTTON("Edit Experiment Metadata",
185
		   "editexp.php3?pid=$exp_pid&eid=$exp_eid");
186

187
188
189
#
# Admin and project/experiment leader get this option.
#
190
191
192
193
194
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATE)) {
	WRITESUBMENUBUTTON("Update All Nodes",
			   "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
    }
195

196
197
198
199
200
    # Reboot option
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
	WRITESUBMENUBUTTON("Reboot All Nodes",
			   "boot.php3?pid=$exp_pid&eid=$exp_eid");
    }
201

202
    if (STUDLY()) {
203
204
	WRITESUBMENUBUTTON(($linktest_running ?
			    "Stop LinkTest" : "Run LinkTest"), 
205
			   "linktest.php3?pid=$exp_pid&eid=$exp_eid");
Timothy Stack's avatar
   
Timothy Stack committed
206
207
    }

208
    if (STUDLY() && $classes['pcvm']) {
209
210
	WRITESUBMENUBUTTON("Record Feedback Data",
			   "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=record");
211
212
    }
}
213
214
215

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
216
    STUDLY()) {
217
218
    WRITESUBMENUBUTTON("Clear Feedback Data",
		       "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=clear");
219
220
221
222
    if ($classes['pcvm']) {
	    WRITESUBMENUBUTTON("Remap Virtual Nodes",
			       "remapexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
223
}
224
    
225
226
227
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
228
229
230
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
231
232
}

233
234
235
236
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

237
238
239
if ($types['garcia'] || $types['static-mica2']) {
    SUBMENUSECTION("Robot/Mote Options");
    WRITESUBMENUBUTTON("Robot/Mote Map",
Timothy Stack's avatar
   
Timothy Stack committed
240
241
242
		       "robotmap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
243
244
245
246
247
248
249
250
251
252
    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",
253
254
			   "robotrack/robotrack.php3?".
			   "pid=$exp_pid&eid=$exp_eid");
255
    }
Timothy Stack's avatar
   
Timothy Stack committed
256
257
}

258
259
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
260
if ($classes['mote'] && $expstate == $TB_EXPTSTATE_ACTIVE) {
261
    WRITESUBMENUBUTTON("Show Blinky Lights",
262
		   "moteleds.php3?pid=$exp_pid&eid=$exp_eid","moteleds");
263
264
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
265
if ($isadmin) {
266
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
267
	SUBMENUSECTION("Beta-Test Options");
268
	WRITESUBMENUBUTTON("Restart Experiment",
Chad Barb's avatar
   
Chad Barb committed
269
270
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");
271
272
	WRITESUBMENUBUTTON("Replay Events",
			   "replayexp.php3?&pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
273

274
275
	SUBMENUSECTION("Admin Options");
	
276
277
278
279
	WRITESUBMENUBUTTON("Send an Idle Info Request",
			   "request_idleinfo.php3?".
			   "&pid=$exp_pid&eid=$exp_eid");
	
280
281
282
283
284
285
286
	WRITESUBMENUBUTTON("Send a Swap Request",
			   "request_swapexp.php3?".
			   "&pid=$exp_pid&eid=$exp_eid");
	
	WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
			   "swapexp.php3?inout=out&force=1".
			   "&pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
Chad Barb committed
287
	
288
289
290
291
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
292
293
SUBMENUEND_2A();

294
295
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
296
         <img border=1 alt='experiment vis'
Leigh B. Stoller's avatar
Leigh B. Stoller committed
297
              src='showthumb.php3?idx=$rsrcidx'></a>";
Chad Barb's avatar
   
Chad Barb committed
298
299

SUBMENUEND_2B();
300

301
SHOWEXP($exp_pid, $exp_eid);
302

Leigh B. Stoller's avatar
Leigh B. Stoller committed
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
if (TBExptFirewall($exp_pid, $exp_eid) &&
    ($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_PANICED ||
     $expstate == $TB_EXPTSTATE_ACTIVATING ||
     $expstate == $TB_EXPTSTATE_SWAPPING)) {
    echo "<center>\n";
    if ($paniced) {
	echo "<br><font size=+1 color=red><blink>".
	     "Your experiment was cut off via the Panic Button on $panic_date!".
	     "<br>".
	     "You will need to contact testbed operations to make further ".
  	     "changes (swap, terminate) to your experiment.</blink></font>";
    }
    else {
	echo "<br><a href='panicbutton.php3?pid=$exp_pid&eid=$exp_eid'>
                 <img border=1 alt='panic button' src='panicbutton.gif'></a>";
	echo "<br><font color=red size=+2>".
	     " Press the Panic Button to contain your experiment".
	     "</font>\n";
    }
    echo "</center>\n";
}
325
SUBPAGEEND();
326
327
328
329

#
# Dump the node information.
#
Mike Hibler's avatar
Mike Hibler committed
330
SHOWNODES($exp_pid, $exp_eid, $sortby, $showclass);
331

Leigh B. Stoller's avatar
Leigh B. Stoller committed
332
if ($isadmin) {
333
334
335
336
337
338
339
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

340
341
342
343
#
# Standard Testbed Footer
# 
PAGEFOOTER();
344
?>