showexp.php3 6.46 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
16

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

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

37
38
39
40
41
#
# 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
42
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
43
# Check to make sure this is a valid PID/EID tuple.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
44
#
45
if (! TBValidExperiment($exp_pid, $exp_eid)) {
46
47
  USERERROR("The experiment $exp_eid is not a valid experiment ".
            "in project $exp_pid.", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48
49
}

50
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
51
# Verify Permission.
52
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
53
54
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
55
56
}

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

Chad Barb's avatar
   
Chad Barb committed
75
echo "<font size=+2>Experiment <b>".
Chad Barb's avatar
   
Chad Barb committed
76
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
77
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
Chad Barb's avatar
   
Chad Barb committed
78
echo "<br /><br />\n";
79
SUBPAGESTART();
Chad Barb's avatar
   
Chad Barb committed
80

81
SUBMENUSTART("Experiment Options");
82

83
if ($expstate) {
84
    if (TBExptLogFile($exp_pid, $exp_eid)) {
85
	WRITESUBMENUBUTTON("View Activity Logfile",
86
87
88
			   "spewlogfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
      
89
    if ($state == $TB_EXPTSTATE_ACTIVE) {
Jay Lepreau's avatar
Jay Lepreau committed
90
	WRITESUBMENUBUTTON("Visualization, NS File, Mapping",
91
92
93
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    else {
94
	WRITESUBMENUBUTTON("Visualization and NS File",
95
96
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
97
98
    WRITESUBMENUBUTTON("Download NS File",
		       "spitnsdata.php3?pid=$exp_pid&eid=$exp_eid");
99
100

    # Swap option.
101
    if ($isbatch) {
102
	if ($expstate == $TB_EXPTSTATE_SWAPPED) {
103
104
105
	    WRITESUBMENUBUTTON("Queue Batch Experiment",
			"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	}
106
107
	elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
		$expstate == $TB_EXPTSTATE_ACTIVATING) {
108
109
110
	    WRITESUBMENUBUTTON("Stop Batch Experiment",
			"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	}
111
	elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
112
	    WRITESUBMENUBUTTON("Dequeue Batch Experiment",
113
114
			"swapexp.php3?inout=pause&pid=$exp_pid&eid=$exp_eid");
	}
115
    }
116
    else {
117
	if ($expstate == $TB_EXPTSTATE_SWAPPED) {
118
119
120
	    WRITESUBMENUBUTTON("Swap Experiment In",
			"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
	}
121
	elseif ($expstate == $TB_EXPTSTATE_ACTIVE) {
122
123
124
	    WRITESUBMENUBUTTON("Swap Experiment Out",
			"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
	}
125
	elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
126
127
128
129
	    WRITESUBMENUBUTTON("Cancel Experiment Swapin",
			       "swapexp.php3?inout=out".
			       "&pid=$exp_pid&eid=$exp_eid");
	}
130
131
132
    }
    WRITESUBMENUBUTTON("Terminate Experiment",
		       "endexp.php3?pid=$exp_pid&eid=$exp_eid");
133
134

    # Batch experiments can be modifed only when paused.
135
136
    if ($expstate == $TB_EXPTSTATE_SWAPPED ||
	(!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE)) {
137
138
139
	WRITESUBMENUBUTTON("Modify Experiment",
			   "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
140
    
141
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
142
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
143
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
144
    }
145
146
}

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

150
151
152
#
# Admin and project/experiment leader get this option.
#
153
154
155
156
157
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");
    }
158

159
160
161
162
163
    # Reboot option
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
	WRITESUBMENUBUTTON("Reboot All Nodes",
			   "boot.php3?pid=$exp_pid&eid=$exp_eid");
    }
164

165
    if (STUDLY()) {
166
167
	WRITESUBMENUBUTTON(($linktest_running ?
			    "Stop LinkTest" : "Run LinkTest"), 
168
			   "linktest.php3?pid=$exp_pid&eid=$exp_eid");
169
170
171
	
	WRITESUBMENUBUTTON("Record Feedback Data",
			   "feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=record");
172
173
    }
}
174
175
176
177
178
179
180
181
182
183

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");
}
184
    
185
186
187
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
188
189
190
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
191
192
}

193
194
195
196
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

197
if (ISADMIN($uid)) {
198
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
199
	SUBMENUSECTION("Beta-Test Options");
200
	WRITESUBMENUBUTTON("Restart Experiment",
Chad Barb's avatar
   
Chad Barb committed
201
202
203
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");

204
205
206
207
208
209
210
211
212
	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
213
	
214
215
216
217
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
218
219
SUBMENUEND_2A();

220
221
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
222
223
         <img border=1 alt='experiment vis'
              src='showthumb.php3?idx=$rsrcidx'></a>\n";
Chad Barb's avatar
   
Chad Barb committed
224
225

SUBMENUEND_2B();
226

227
SHOWEXP($exp_pid, $exp_eid);
228

229
SUBPAGEEND();
230
231
232
233

#
# Dump the node information.
#
234
SHOWNODES($exp_pid, $exp_eid, $sortby);
235

236
237
238
239
240
241
242
243
if (ISADMIN($uid)) {
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

244
245
246
247
#
# Standard Testbed Footer
# 
PAGEFOOTER();
248
?>