showexp.php3 5.92 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
    DBQueryFatal("select e.idx,e.state,e.batchmode,s.rsrcidx,r.wirelesslans ".
62
63
		 "  from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
64
		 "left join experiment_resources as r on s.rsrcidx=r.idx ".
65
		 "where e.eid='$eid' and e.pid='$pid'");
66
67
68
69
70
$row        = mysql_fetch_array($query_result);
$expindex   = $row["idx"];
$expstate   = $row["state"];
$rsrcidx    = $row["rsrcidx"];
$isbatch    = $row["batchmode"];
71
$wireless   = $row["wirelesslans"];
Chad Barb's avatar
   
Chad Barb committed
72

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

79
SUBMENUSTART("Experiment Options");
80

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

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

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

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

148
149
150
#
# Admin and project/experiment leader get this option.
#
151
if ($expstate == $TB_EXPTSTATE_ACTIVE &&
152
    TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATE)) {
153
    WRITESUBMENUBUTTON("Update All Nodes",
154
155
156
		       "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
}

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

163
164
165
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
166
167
168
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
169
170
}

171
172
173
174
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

175
176
177
178
179
if (STUDLY()) {
    WRITESUBMENUBUTTON("Run Linktest",
		       "linktest.php3?pid=$exp_pid&eid=$exp_eid");
}

180
if (ISADMIN($uid)) {
181
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
182
	SUBMENUSECTION("Beta-Test Options");
183
	WRITESUBMENUBUTTON("Restart Experiment",
Chad Barb's avatar
   
Chad Barb committed
184
185
186
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");

187
188
189
190
191
192
193
194
195
	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
196
	
197
198
199
200
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
201
202
SUBMENUEND_2A();

203
204
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
205
206
         <img border=1 alt='experiment vis'
              src='showthumb.php3?idx=$rsrcidx'></a>\n";
Chad Barb's avatar
   
Chad Barb committed
207
208

SUBMENUEND_2B();
209

210
SHOWEXP($exp_pid, $exp_eid);
211

212
SUBPAGEEND();
213
214
215
216

#
# Dump the node information.
#
217
SHOWNODES($exp_pid, $exp_eid, $sortby);
218

219
220
221
222
223
224
225
226
if (ISADMIN($uid)) {
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

227
228
229
230
#
# Standard Testbed Footer
# 
PAGEFOOTER();
231
?>