showexp.php3 5.36 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-2003 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
28
29
if (!isset($eid) ||
    strcmp($eid, "") == 0) {
    USERERROR("You must provide an Experiment ID.", 1);
}
$exp_eid = $eid;
$exp_pid = $pid;
30

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

44
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
45
# Verify Permission.
46
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
47
48
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
49
50
}

51
52
53
54
#
# Need some DB info.
#
$query_result =
55
    DBQueryFatal("select e.idx,e.state,e.batchmode,s.rsrcidx ".
56
57
58
		 "  from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
		 "where e.eid='$eid' and e.pid='$pid'");
59
60
61
62
63
$row        = mysql_fetch_array($query_result);
$expindex   = $row["idx"];
$expstate   = $row["state"];
$rsrcidx    = $row["rsrcidx"];
$isbatch    = $row["batchmode"];
Chad Barb's avatar
   
Chad Barb committed
64

Chad Barb's avatar
   
Chad Barb committed
65
echo "<font size=+2>Experiment <b>".
Chad Barb's avatar
   
Chad Barb committed
66
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
67
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
Chad Barb's avatar
   
Chad Barb committed
68
echo "<br /><br />\n";
69
SUBPAGESTART();
Chad Barb's avatar
   
Chad Barb committed
70

71
SUBMENUSTART("Experiment Options");
72

73
if ($expstate) {
74
    if (TBExptLogFile($exp_pid, $exp_eid)) {
75
	WRITESUBMENUBUTTON("View Activity Logfile",
76
77
78
			   "spewlogfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
      
79
    if ($state == $TB_EXPTSTATE_ACTIVE) {
Jay Lepreau's avatar
Jay Lepreau committed
80
	WRITESUBMENUBUTTON("Visualization, NS File, Mapping",
81
82
83
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    else {
84
	WRITESUBMENUBUTTON("Visualization and NS File",
85
86
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
87
88
    WRITESUBMENUBUTTON("Download NS File",
		       "spitnsdata.php3?pid=$exp_pid&eid=$exp_eid");
89
90

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

    # Batch experiments can be modifed only when paused.
125
126
    if ($expstate == $TB_EXPTSTATE_SWAPPED ||
	(!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE)) {
127
128
129
	WRITESUBMENUBUTTON("Modify Experiment",
			   "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
    }
130
    
131
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
132
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
133
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
134
    }
135
136
}

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

140
141
142
#
# Admin and project/experiment leader get this option.
#
143
if ($expstate == $TB_EXPTSTATE_ACTIVE &&
144
    TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATE)) {
145
    WRITESUBMENUBUTTON("Update All Nodes",
146
147
148
		       "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
}

149
150
# Reboot option
if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
151
    WRITESUBMENUBUTTON("Reboot All Nodes",
152
153
154
		       "boot.php3?pid=$exp_pid&eid=$exp_eid");
}

155
156
157
158
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

159
if (ISADMIN($uid)) {
160
    if ($expstate == $TB_EXPTSTATE_ACTIVE) {
161
	SUBMENUSECTION("Beta-Test Options");
162
	WRITESUBMENUBUTTON("Restart Experiment",
Chad Barb's avatar
   
Chad Barb committed
163
164
165
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");

166
167
168
169
170
171
172
173
174
	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
175
	
176
177
178
179
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
180
181
SUBMENUEND_2A();

182
183
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
184
185
         <img border=1 alt='experiment vis'
              src='showthumb.php3?idx=$rsrcidx'></a>\n";
Chad Barb's avatar
   
Chad Barb committed
186
187

SUBMENUEND_2B();
188

189
SHOWEXP($exp_pid, $exp_eid);
190

191
SUBPAGEEND();
192
193
194
195
196
197

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

198
199
200
201
202
203
204
205
if (ISADMIN($uid)) {
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

206
207
208
209
#
# Standard Testbed Footer
# 
PAGEFOOTER();
210
?>