showexp.php3 6.51 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
12
13
14
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information");

15
16
17
#
# Only known and logged in users can end experiments.
#
18
$uid = GETLOGIN();
19
LOGGEDINORDIE($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
20
21

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

Leigh B. Stoller's avatar
Leigh B. Stoller committed
29
30
31
32
33
34
if (!isset($eid) ||
    strcmp($eid, "") == 0) {
    USERERROR("You must provide an Experiment ID.", 1);
}
$exp_eid = $eid;
$exp_pid = $pid;
35

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
$expindex = TBExptIndex($exp_pid, $exp_eid);
52
$expstate = TBExptState($exp_pid, $exp_eid);
Chad Barb's avatar
   
Chad Barb committed
53

Chad Barb's avatar
   
Chad Barb committed
54
echo "<font size=+2>Experiment <b>".
Chad Barb's avatar
   
Chad Barb committed
55
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
56
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
Chad Barb's avatar
   
Chad Barb committed
57
echo "<br /><br />\n";
58
SUBPAGESTART();
Chad Barb's avatar
   
Chad Barb committed
59

60
SUBMENUSTART("Experiment Options");
61

62
if ($expstate) {
63
    if (TBExptLogFile($exp_pid, $exp_eid)) {
64
65
66
67
	WRITESUBMENUBUTTON("View Activation Logfile",
			   "spewlogfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
      
68
    if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) == 0) {
Jay Lepreau's avatar
Jay Lepreau committed
69
	WRITESUBMENUBUTTON("Visualization, NS File, Mapping",
70
71
72
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    elseif (strcmp($expstate, $TB_EXPTSTATE_SWAPPED) == 0) {
Jay Lepreau's avatar
Jay Lepreau committed
73
	WRITESUBMENUBUTTON("Visualization and NS File",
74
75
76
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }
    else {
77
	WRITESUBMENUBUTTON("Visualization and NS File",
78
79
80
81
			   "shownsfile.php3?pid=$exp_pid&eid=$exp_eid");
    }

    # Swap option.
82
    if (strcmp($expstate, $TB_EXPTSTATE_SWAPPED) == 0) {
83
	WRITESUBMENUBUTTON("Swap this Experiment In",
84
		      "swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
85
86
    }
    elseif (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) == 0) {
87
	WRITESUBMENUBUTTON("Swap this Experiment Out",
88
		      "swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
89

90
	WRITESUBMENUBUTTON("Modify Traffic Shaping",
91
			   "delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
92
    }
93
94
}

95
WRITESUBMENUBUTTON("Terminate this Experiment",
96
97
		   "endexp.php3?pid=$exp_pid&eid=$exp_eid");

98
99
100
WRITESUBMENUBUTTON("Edit Experiment Meta-Data",
		   "showexp.php3?pid=$exp_pid&eid=$exp_eid&edit=1");

101
102
103
104
105
106
107
108
#
# Admin and project/experiment leader get this option.
#
if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATEACCOUNTS)) {
    WRITESUBMENUBUTTON("Update Mounts/Accounts",
		       "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
}

109
110
# Reboot option
if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
111
    WRITESUBMENUBUTTON("Reboot All Nodes",
112
		       "boot.php3?pid=$exp_pid&eid=$exp_eid");
Chad Barb's avatar
   
Chad Barb committed
113
114
115
    WRITESUBMENUBUTTON("Modify this Experiment",
		       "modifyexp.php3?pid=$exp_pid&eid=$exp_eid");

116
117
}

118
119
120
121
# History
WRITESUBMENUBUTTON("Show History",
		   "showstats.php3?showby=expt&which=$expindex");

122
if (ISADMIN($uid)) {
Chad Barb's avatar
   
Chad Barb committed
123
    if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) == 0) {		
124
	SUBMENUSECTION("Beta-Test Options");
Chad Barb's avatar
   
Chad Barb committed
125
126
127
128
	WRITESUBMENUBUTTON("Restart this Experiment",
			   "swapexp.php3?inout=restart&pid=$exp_pid".
			   "&eid=$exp_eid");

129
130
131
132
133
134
135
136
137
	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
138
	
139
140
141
142
	SUBMENUSECTIONEND();
    }
}
    
Chad Barb's avatar
   
Chad Barb committed
143
144
SUBMENUEND_2A();

145
146
147
148
echo "<br>
      <a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
         <img width=160 height=160 border=1 alt='experiment vis'
              src='top2image.php3?pid=$pid&eid=$eid&thumb=160'></a>\n";
Chad Barb's avatar
   
Chad Barb committed
149
150

SUBMENUEND_2B();
151

152
153
# if we got a submission of changes, update the db now...
if ($submit) {
154
155
156
    $exp_name = addslashes(str_replace('"',"",$exp_name));
    $noswap = addslashes(str_replace('"',"",$noswap));
    $noidleswap = addslashes(str_replace('"',"",$noidleswap));
157
158
    # exp name is always sent...
    $str = "expt_name=\"$exp_name\"";
159
    $mail=0;
160
161
    if (isset($noswap) && $noswap !="") {
	$str .= ",noswap_reason=\"$noswap\"";
162
	$mail=1;
163
164
165
    }
    if (isset($noidleswap) && $noidleswap !="") {
	$str .= ",noidleswap_reason=\"$noidleswap\"";
166
	$mail=1;
167
    }
168
169
170
171
    if (isset($idleswap) && $idleswap !="" && $idleswap>0 && ISADMIN()) {
	$str .= ",idleswap_timeout=\"".(60*$idleswap)."\"";
	$mail=1;
    }
172
173
    if (isset($autoswap) && $autoswap !="" && $autoswap>0) {
	$str .= ",autoswap_timeout=\"".(60*$autoswap)."\"";
174
	$mail=1;
175
176
    }
    DBQueryWarn("update experiments set $str where pid='$pid' and eid='$eid'");
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    if ($mail) {
	$q = DBQueryFatal("select * from experiments ".
			  "where pid='$pid' and eid='$eid'");
	$r = mysql_fetch_array($q);
	$s = ($r[swappable] ? "Yes" : "No");
	$sr= $r[noswap_reason];
	$i = ($r[idleswap] ? "Yes" : "No");
	$it= $r[idleswap_timeout] / 60.0;
	$ir= $r[noidleswap_reason];
	$a = ($r[autoswap] ? "Yes" : "No");
	$at= $r[autoswap_timeout] / 60.0;
	$cuid = $r[expt_head_uid];
	$suid= $r[expt_swap_uid];
	TBUserInfo($uid, $user_name, $user_email);
	TBUserInfo($cuid, $cname, $cemail);
	TBUserInfo($suid, $sname, $semail);
	TBMAIL($TBMAIL_OPS,"$pid/$eid swap settings changed",
	       "\nThe swap settings for $pid/$eid have changed.\n".
	       "\nThe reasons and/or timeouts have changed.\n".
	       "\nThe new settings are:\n".
	       "Swappable:\t$s\t('$sr')\n".
	       "Idleswap:\t$i\t(after $it hrs)\t('$ir')\n".
	       "Autoswap:\t$a\t(after $at hrs)\n".
	       "\nCreator:\t$cuid ($cname <$cemail>)\n".
	       "Swapper:\t$suid ($sname <$semail>)\n".
	       "\nIf it is necessary to change these settings, ".
	       "please reply to this message \nto notify the user, ".
	       "then change the settings here:\n\n".
	       "$TBBASE/showexp.php3?pid=$pid&eid=$eid\n\n".
	       "Thanks,\nTestbed WWW\n",
	       "From: $user_name <$user_email>\n".
	       "Errors-To: $TBMAIL_WWW");
    }
210
211
212
213
214
}

# Dump (possibly updated) experiment record.
if (!isset($edit)) { $edit=0; }
SHOWEXP($exp_pid, $exp_eid, $edit);
215

216
SUBPAGEEND();
217
218
219
220
221
222

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

223
224
225
226
227
228
229
230
if (ISADMIN($uid)) {
    echo "<center>
          <h3>Experiment Stats</h3>
         </center>\n";

    SHOWEXPTSTATS($exp_pid, $exp_eid);
}

231
232
233
234
#
# Standard Testbed Footer
# 
PAGEFOOTER();
235
?>