showexp.php3 8.35 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
Leigh Stoller's avatar
Leigh Stoller committed
7
include("defs.php3");
8
include("showstuff.php3");
Leigh Stoller's avatar
Leigh Stoller committed
9

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

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

Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh 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 Stoller's avatar
Leigh Stoller committed
43
#
Leigh Stoller's avatar
Leigh Stoller committed
44
# Check to make sure this is a valid PID/EID tuple.
Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh Stoller committed
49 50
}

51
#
Leigh Stoller's avatar
Leigh Stoller committed
52
# Verify Permission.
53
#
Leigh Stoller's avatar
Leigh 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 Stoller's avatar
Leigh 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 Stoller's avatar
Leigh Stoller committed
76 77
$paniced    = $row["paniced"];
$panic_date = $row["panic_date"];
78
$lockdown   = $row["lockdown"];
79

80 81 82 83 84 85 86 87 88 89 90 91 92 93
#
# 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;
}


94
echo "<font size=+2>Experiment <b>".
95
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
96
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
97
echo "<br /><br />\n";
98
SUBPAGESTART();
99

100
SUBMENUSTART("Experiment Options");
101

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

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
    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");
	    }
135
	}
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
	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");
	    }
151
	}
152 153 154 155
    
	if ($expstate != $TB_EXPTSTATE_PANICED) {
	    WRITESUBMENUBUTTON("Terminate Experiment",
			       "endexp.php3?pid=$exp_pid&eid=$exp_eid");
156 157
	}

158 159 160 161 162 163
        # 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");
	}
164
    }
165
    
166
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
167
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
168
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
169
    }
170 171
}

172
WRITESUBMENUBUTTON("Edit Experiment Metadata",
173
		   "editexp.php3?pid=$exp_pid&eid=$exp_eid");
174

175 176 177
#
# Admin and project/experiment leader get this option.
#
178 179 180 181 182
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");
    }
183

184 185 186 187 188
    # Reboot option
    if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
	WRITESUBMENUBUTTON("Reboot All Nodes",
			   "boot.php3?pid=$exp_pid&eid=$exp_eid");
    }
189

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

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");
}
209
    
210 211 212
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
    WRITESUBMENUBUTTON("Wireless Node Map",
213 214 215
		       "floormap.php3".
		       ($expstate == $TB_EXPTSTATE_ACTIVE ?
			"?pid=$exp_pid&eid=$exp_eid" : ""));
216 217
}

218 219 220 221
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

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

Leigh Stoller's avatar
Leigh Stoller committed
229
if ($isadmin) {
230
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
231
	SUBMENUSECTION("Beta-Test Options");
232
	WRITESUBMENUBUTTON("Restart Experiment",
233 234
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");
235 236
	WRITESUBMENUBUTTON("Replay Events",
			   "replayexp.php3?&pid=$exp_pid&eid=$exp_eid");
237

238 239 240 241 242 243 244 245 246
	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");
247
	
248 249 250 251
	SUBMENUSECTIONEND();
    }
}
    
252 253
SUBMENUEND_2A();

254 255
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
256
         <img border=1 alt='experiment vis'
Leigh Stoller's avatar
Leigh Stoller committed
257
              src='showthumb.php3?idx=$rsrcidx'></a>";
258 259

SUBMENUEND_2B();
260

261
SHOWEXP($exp_pid, $exp_eid);
262

Leigh Stoller's avatar
Leigh Stoller committed
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
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";
}
285
SUBPAGEEND();
286 287 288 289

#
# Dump the node information.
#
290
SHOWNODES($exp_pid, $exp_eid, $sortby);
291

Leigh Stoller's avatar
Leigh Stoller committed
292
if ($isadmin) {
293 294 295 296 297 298 299
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

300 301 302 303
#
# Standard Testbed Footer
# 
PAGEFOOTER();
304
?>