showexp.php3 8.22 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-2004 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,".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
63
		 "       e.paniced,e.panic_date,s.rsrcidx,r.wirelesslans ".
64
65
		 "  from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
66
		 "left join experiment_resources as r on s.rsrcidx=r.idx ".
67
		 "where e.eid='$eid' and e.pid='$pid'");
68
69
70
71
72
$row        = mysql_fetch_array($query_result);
$expindex   = $row["idx"];
$expstate   = $row["state"];
$rsrcidx    = $row["rsrcidx"];
$isbatch    = $row["batchmode"];
73
$wireless   = $row["wirelesslans"];
74
$linktest_running = $row["linktest_pid"];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
75
76
$paniced    = $row["paniced"];
$panic_date = $row["panic_date"];
Chad Barb's avatar
   
Chad Barb committed
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# Get a list of node types and classes in this experiment
#
$query_result =
    DBQueryFatal("select distinct t.type,t.class from reserved as r " .
		 "       left join nodes as n on r.node_id=n.node_id ".
		 "       left join node_types as t on n.type=t.type ".
		 "where r.eid='$eid' and r.pid='$pid'");
while ($row = mysql_fetch_array($query_result)) {
    $classes[$row['class']] = 1;
    $types[$row['type']] = 1;
}


Chad Barb's avatar
   
Chad Barb committed
92
echo "<font size=+2>Experiment <b>".
Chad Barb's avatar
   
Chad Barb committed
93
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
94
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
Chad Barb's avatar
   
Chad Barb committed
95
echo "<br /><br />\n";
96
SUBPAGESTART();
Chad Barb's avatar
   
Chad Barb committed
97

98
SUBMENUSTART("Experiment Options");
99

100
if ($expstate) {
101
    if (TBExptLogFile($exp_pid, $exp_eid)) {
102
	WRITESUBMENUBUTTON("View Activity Logfile",
103
104
105
			   "spewlogfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
      
106
    if ($state == $TB_EXPTSTATE_ACTIVE) {
Jay Lepreau's avatar
Jay Lepreau committed
107
	WRITESUBMENUBUTTON("Visualization, NS File, Mapping",
108
109
110
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    else {
111
	WRITESUBMENUBUTTON("Visualization and NS File",
112
113
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
114
115
    WRITESUBMENUBUTTON("Download NS File",
		       "spitnsdata.php3?pid=$exp_pid&eid=$exp_eid");
116
117

    # Swap option.
118
    if ($isbatch) {
119
	if ($expstate == $TB_EXPTSTATE_SWAPPED) {
120
121
122
	    WRITESUBMENUBUTTON("Queue Batch Experiment",
			"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	}
123
124
	elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		$expstate == $TB_EXPTSTATE_ACTIVATING) {
125
126
127
	    WRITESUBMENUBUTTON("Stop Batch Experiment",
			"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	}
128
	elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
129
	    WRITESUBMENUBUTTON("Dequeue Batch Experiment",
130
131
			"swapexp.php3?inout=pause&pid=$exp_pid&eid=$exp_eid");
	}
132
    }
133
    else {
134
	if ($expstate == $TB_EXPTSTATE_SWAPPED) {
135
136
137
	    WRITESUBMENUBUTTON("Swap Experiment In",
			"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
138
139
	elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
140
141
142
	    WRITESUBMENUBUTTON("Swap Experiment Out",
			"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	}
143
	elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
144
145
146
147
	    WRITESUBMENUBUTTON("Cancel Experiment Swapin",
			       "swapexp.php3?inout=out".
			       "&pid=$exp_pid&eid=$exp_eid");
	}
148
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
149
150
151
152
    if ($expstate != $TB_EXPTSTATE_PANICED) {
	WRITESUBMENUBUTTON("Terminate Experiment",
			   "endexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
153
154

    # Batch experiments can be modifed only when paused.
155
156
    if ($expstate == $TB_EXPTSTATE_SWAPPED ||
	(!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE)) {
157
158
159
	WRITESUBMENUBUTTON("Modify Experiment",
			   "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
160
    
161
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
162
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
163
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
164
    }
165
166
}

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

170
171
172
#
# Admin and project/experiment leader get this option.
#
173
174
175
176
177
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");
    }
178

179
180
181
182
183
    # Reboot option
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
	WRITESUBMENUBUTTON("Reboot All Nodes",
			   "boot.php3?pid=$exp_pid&eid=$exp_eid");
    }
184

185
    if (STUDLY()) {
186
187
	WRITESUBMENUBUTTON(($linktest_running ?
			    "Stop LinkTest" : "Run LinkTest"), 
188
			   "linktest.php3?pid=$exp_pid&eid=$exp_eid");
189
190
191
	
	WRITESUBMENUBUTTON("Record Feedback Data",
			   "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=record");
192
193
    }
}
194
195
196
197
198
199
200
201
202
203

if (($expstate == $TB_EXPTSTATE_ACTIVE ||
     $expstate == $TB_EXPTSTATE_SWAPPED) &&
    STUDLY()) {
    WRITESUBMENUBUTTON("Clear Feedback Data",
		       "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=clear");
    
    WRITESUBMENUBUTTON("Remap Virtual Nodes",
		       "remapexp.php3?pid=$exp_pid&eid=$exp_eid");
}
204
    
205
206
207
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
208
209
210
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
211
212
}

213
214
215
216
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

217
218
219
220
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
if ($types['garcia'] || $classes['sg']) {
    WRITESUBMENUBUTTON("Show Blinky Lights",
221
		   "moteleds.php3?pid=$exp_pid&eid=$exp_eid","moteleds");
222
223
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
224
if ($isadmin) {
225
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
226
	SUBMENUSECTION("Beta-Test Options");
227
	WRITESUBMENUBUTTON("Restart Experiment",
Chad Barb's avatar
   
Chad Barb committed
228
229
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");
230
231
	WRITESUBMENUBUTTON("Replay Events",
			   "replayexp.php3?&pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
232

233
234
235
236
237
238
239
240
241
	SUBMENUSECTION("Admin Options");
	
	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
242
	
243
244
245
246
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
247
248
SUBMENUEND_2A();

249
250
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
251
         <img border=1 alt='experiment vis'
Leigh B. Stoller's avatar
Leigh B. Stoller committed
252
              src='showthumb.php3?idx=$rsrcidx'></a>";
Chad Barb's avatar
   
Chad Barb committed
253
254

SUBMENUEND_2B();
255

256
SHOWEXP($exp_pid, $exp_eid);
257

Leigh B. Stoller's avatar
Leigh B. Stoller committed
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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";
}
280
SUBPAGEEND();
281
282
283
284

#
# Dump the node information.
#
285
SHOWNODES($exp_pid, $exp_eid, $sortby);
286

Leigh B. Stoller's avatar
Leigh B. Stoller committed
287
if ($isadmin) {
288
289
290
291
292
293
294
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

295
296
297
298
#
# Standard Testbed Footer
# 
PAGEFOOTER();
299
?>