showstuff.php3 57.9 KB
Newer Older
1
2
<?php
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
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
7
# All rights reserved.
#
#
8
9
10
11
12
13
14
15
16
17
18
# This is an included file. No headers or footers.
#
# Functions to dump out various things.  
#

#
# A project
#
function SHOWPROJECT($pid, $thisuid) {
    global $TBDBNAME;

19
20
    $query_result =
	DBQueryFatal("SELECT * FROM projects WHERE pid='$pid'");
21
22
    $row = mysql_fetch_array($query_result);

23
24
25
    echo "<center>
          <h3>Project Profile</h3>
          </center>
26
          <table align=center cellpadding=2 border=1>\n";
27
    
28
    $proj_created	= $row[created];
29
    #$proj_expires	= $row[expires];
30
    $proj_name		= $row[name];
31
    $proj_URL		= $row[URL];
32
    $proj_public        = $row[public];
33
    $proj_funders	= $row[funders];
34
35
36
    $proj_head_uid	= $row[head_uid];
    $proj_members       = $row[num_members];
    $proj_pcs           = $row[num_pcs];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
37
38
    $proj_ronpcs        = $row[num_ron];
    $proj_plabpcs       = $row[num_pcplab];
39
    $proj_linked        = $row[linked_to_us];
40
    $proj_why           = nl2br($row[why]);
41
    $control_node	= $row[control_node];
42
    $approved           = $row[approved];
43
44
    $expt_count         = $row[expt_count];
    $expt_last          = $row[expt_last];
45

46
47
48
49
50
51
52
    if ($proj_public) {
	$proj_public = "Yes";
    }
    else {
	$proj_public = "No";
    }

53
54
55
56
57
58
59
    if ($proj_linked) {
	$proj_linked = "Yes";
    }
    else {
	$proj_linked = "No";
    }

60
61
62
63
    if (!$expt_last) {
	$expt_last = "&nbsp";
    }

64
65
66
67
68
    #
    # Generate the table.
    # 
    echo "<tr>
              <td>Name: </td>
69
70
              <td class=\"left\">
                <a href='showproject.php3?pid=$pid'>$pid</a></td>
71
72
73
74
75
76
77
78
79
80
          </tr>\n";
    
    echo "<tr>
              <td>Long Name: </td>
              <td class=\"left\">$proj_name</td>
          </tr>\n";
    
    echo "<tr>
              <td>Project Head: </td>
              <td class=\"left\">
81
                <A href='showuser.php3?target_uid=$proj_head_uid'>
82
83
84
85
86
87
88
89
90
                     $proj_head_uid</A></td>
          </tr>\n";
    
    echo "<tr>
              <td>URL: </td>
              <td class=\"left\">
                  <A href='$proj_URL'>$proj_URL</A></td>
          </tr>\n";
    
91
92
93
94
95
    echo "<tr>
              <td>Publicly Visible: </td>
              <td class=\"left\">$proj_public</td>
          </tr>\n";
    
96
97
98
99
100
    echo "<tr>
              <td>Link to Us?: </td>
              <td class=\"left\">$proj_linked</td>
          </tr>\n";
    
101
102
103
104
105
    echo "<tr>
              <td>Funders: </td>
              <td class=\"left\">$proj_funders</td>
          </tr>\n";

106
107
108
109
110
111
112
113
114
115
116
    echo "<tr>
              <td>#Project Members: </td>
              <td class=\"left\">$proj_members</td>
          </tr>\n";
    
    echo "<tr>
              <td>#PCs: </td>
              <td class=\"left\">$proj_pcs</td>
          </tr>\n";
    
    echo "<tr>
117
118
119
120
121
122
123
              <td>#Planetlab PCs: </td>
              <td class=\"left\">$proj_plabpcs</td>
          </tr>\n";
    
    echo "<tr>
              <td>#RON PCs: </td>
              <td class=\"left\">$proj_ronpcs</td>
124
125
126
127
128
129
130
          </tr>\n";
    
    echo "<tr>
              <td>Created: </td>
              <td class=\"left\">$proj_created</td>
          </tr>\n";
    
131
132
133
134
    #echo "<tr>
    #          <td>Expires: </td>
    #          <td class=\"left\">$proj_expires</td>
    #      </tr>\n";
135
    
136
137
138
139
140
141
142
143
144
145
    echo "<tr>
              <td>Experiments Created:</td>
              <td class=\"left\">$expt_count</td>
          </tr>\n";
    
    echo "<tr>
              <td>Date of last experiment:</td>
              <td class=\"left\">$expt_last</td>
          </tr>\n";
    
146
147
148
149
150
151
152
153
154
155
    echo "<tr>
              <td>Approved?: </td>\n";
    if ($approved) {
	echo "<td class=left><img alt=\"Y\" src=\"greenball.gif\"></td>\n";
    }
    else {
	echo "<td class=left><img alt=\"N\" src=\"redball.gif\"></td>\n";
    }
    echo "</tr>\n";

156
    echo "<tr>
157
              <td colspan='2'>Why?:</td>
158
159
160
161
162
163
164
165
166
          </tr>\n";
    
    echo "<tr>
              <td colspan='2' width=600>$proj_why</td>
          </tr>\n";
    
    echo "</table>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
167
168
169
170
#
# A Group
#
function SHOWGROUP($pid, $gid) {
171
172
    global $OURDOMAIN;
    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
173
174
175
176
    $query_result =
	DBQueryFatal("SELECT * FROM groups WHERE pid='$pid' and gid='$gid'");
    $row = mysql_fetch_array($query_result);

177
178
179
180
    echo "<center>
          <h3>Group Profile</h3>
          </center>
          <table align=center border=1>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
181
182
183

    $leader	= $row[leader];
    $created	= $row[created];
184
    $description= $row[description];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
185
186
187
188
189
    $expt_count = $row[expt_count];
    $expt_last  = $row[expt_last];
    $unix_gid   = $row[unix_gid];
    $unix_name  = $row[unix_name];

190
191
192
193
194
    if (strcmp($pid,$gid))
	$mail = "$pid-$gid" . "-users@" . $OURDOMAIN;
    else
	$mail = "$pid" . "-users@" . $OURDOMAIN;

Leigh B. Stoller's avatar
Leigh B. Stoller committed
195
196
197
198
199
200
201
202
203
    if (!$expt_last) {
	$expt_last = "&nbsp";
    }

    #
    # Generate the table.
    # 
    echo "<tr>
              <td>GID: </td>
204
              <td class=\"left\">
Chad Barb's avatar
   
Chad Barb committed
205
                <a href='showgroup.php3?pid=$pid&gid=$gid'>$gid</a></td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
206
207
208
209
          </tr>\n";
    
    echo "<tr>
              <td>PID: </td>
210
211
              <td class=\"left\">
                <a href='showproject.php3?pid=$pid'>$pid</a></td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
          </tr>\n";
    
    echo "<tr>
              <td>Description: </td>
              <td class=\"left\">$description</td>
          </tr>\n";
    
    echo "<tr>
              <td>Unix GID: </td>
              <td class=\"left\">$unix_gid</td>
          </tr>\n";
    
    echo "<tr>
              <td>Unix Group Name: </td>
              <td class=\"left\">$unix_name</td>
          </tr>\n";
    
    echo "<tr>
              <td>Group Leader: </td>
              <td class=\"left\">
                <A href='showuser.php3?target_uid=$leader'>$leader</A></td>
          </tr>\n";
    
235
236
237
238
239
    echo "<tr>
              <td>Email List: </td>
              <td class=\"left\">$mail</td>
          </tr>\n";
    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
    echo "<tr>
              <td>Created: </td>
              <td class=\"left\">$created</td>
          </tr>\n";
    
    echo "<tr>
              <td>Experiments Created:</td>
              <td class=\"left\">$expt_count</td>
          </tr>\n";
    
    echo "<tr>
              <td>Date of last experiment:</td>
              <td class=\"left\">$expt_last</td>
          </tr>\n";
    
    echo "</table>\n";
}

#
# A list of Group members.
#
261
function SHOWGROUPMEMBERS($pid, $gid, $prived = 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
262
263
264
265
266
267
268
269
    $query_result =
	DBQueryFatal("SELECT m.*,u.* FROM group_membership as m ".
		     "left join users as u on u.uid=m.uid ".
		     "WHERE pid='$pid' and gid='$gid'");
    
    if (! mysql_num_rows($query_result)) {
	return;
    }
270
    $showdel = (($prived && !strcmp($pid, $gid)) ? 1 : 0);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
271

272
273
274
275
276
277
278
279
    echo "<center>\n";
    if (strcmp($pid, $gid)) {
	echo "<h3>Group Members</h3>\n";
    }
    else {
	echo "<h3>Project Members</h3>\n";
    }
    echo "</center>
280
          <table align=center border=1 cellpadding=1 cellspacing=2>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
281
282

    echo "<tr>
283
284
285
286
287
              <th>Name</th>\n";
    if (strcmp($pid, $gid)) {
	echo "<th>Email</th>\n";
    }
    echo "    <th>UID</th>
288
289
290
291
292
              <th>Privs</th>\n";
    if ($showdel) {
	echo "<th>Remove</th>\n";
    }
    echo "</tr>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
293
294
295
296

    while ($row = mysql_fetch_array($query_result)) {
        $target_uid = $row[uid];
	$usr_name   = $row[usr_name];
297
	$usr_email  = $row[usr_email];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
298
299
300
	$trust      = $row[trust];

        echo "<tr>
301
302
303
304
305
                  <td>$usr_name</td>\n";
	if (strcmp($pid, $gid)) {
	    echo "<td>$usr_email</td>\n";
	}
	echo "    <td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
306
307
                    <A href='showuser.php3?target_uid=$target_uid'>
                       $target_uid</A>
308
309
310
311
                  </td>\n";
	
	if (TBTrustConvert($trust) != $TBDB_TRUST_NONE) {
	    echo "<td>$trust</td>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
312
313
	}
	else {
314
315
316
	    echo "<td><font color=red>$trust</font></td>\n";
	}
	if ($showdel) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
317
	    echo "<td align=center>
318
319
320
		      <A href='deleteuser.php3?target_uid=$target_uid";
	    echo         "&target_pid=$pid'>
                         <img alt=N src=redball.gif></td>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
321
322
323
324
325
326
	}
	echo "</tr>\n";
    }
    echo "</table>\n";
}

327
328
329
330
#
# A list of groups for a user.
#
function SHOWGROUPMEMBERSHIP($uid) {
331
332
    $none = TBDB_TRUSTSTRING_NONE;
    
333
334
    $query_result =
	DBQueryFatal("SELECT * FROM group_membership ".
335
336
		     "WHERE uid='$uid' and trust!='$none' ".
		     "order by pid");
337
338
339
340
341
342
343
344
345
346
347
    
    if (! mysql_num_rows($query_result)) {
	return;
    }

    echo "<center>
          <h3>Group Membership</h3>
          </center>
          <table align=center border=1 cellpadding=1 cellspacing=2>\n";

    echo "<tr>
Chad Barb's avatar
   
Chad Barb committed
348
349
350
              <th>PID</th>
              <th>GID</th>
              <th>Privs</th>
351
352
353
354
355
356
357
          </tr>\n";

    while ($row = mysql_fetch_array($query_result)) {
	$pid   = $row[pid];
	$gid   = $row[gid];
	$trust = $row[trust];

358
359
	if (TBTrustConvert($trust) != $TBDB_TRUST_NONE) {
	    echo "<tr>
360
361
362
              <td><a href='showproject.php3?pid=$pid'>$pid</a></td>
              <td><a href='showgroup.php3?pid=$pid&gid=$gid'>$gid</a></td>
              <td>$trust</td>\n";
363
364
	    echo "</tr>\n";
	}
365
366
367
368
    }
    echo "</table>\n";
}

369
370
371
372
373
#
# A User
#
function SHOWUSER($uid) {
    global $TBDBNAME;
374
375
376

    $userinfo_result =
	DBQueryFatal("SELECT * from users where uid='$uid'");
377
378

    $row	= mysql_fetch_array($userinfo_result);
379
    #$usr_expires = $row[usr_expires];
380
381
    $usr_email   = $row[usr_email];
    $usr_URL     = $row[usr_URL];
382
383
384
385
386
387
388
    $usr_addr    = $row[usr_addr];
    $usr_addr2   = $row[usr_addr2];
    $usr_city    = $row[usr_city];
    $usr_state   = $row[usr_state];
    $usr_zip     = $row[usr_zip];
    $usr_country = $row[usr_country];
    $usr_name    = $row[usr_name];
389
    $usr_phone   = $row[usr_phone];
390
391
392
    $usr_shell   = $row[usr_shell];
    $usr_title   = $row[usr_title];
    $usr_affil   = $row[usr_affil];
393
    $status      = $row[status];
394
395
    $admin       = $row[admin];
    $adminoff    = $row[adminoff];
396
397
398
399
    $notes       = $row[notes];
    $frozen      = $row['weblogin_frozen'];
    $failcount   = $row['weblogin_failcount'];
    $failstamp   = $row['weblogin_failstamp'];
400

401
402
403
404
405
406
407
408
    if (!strcmp($usr_addr2, ""))
	$usr_addr2 = "&nbsp";
    if (!strcmp($usr_city, ""))
	$usr_city = "&nbsp";
    if (!strcmp($usr_state, ""))
	$usr_state = "&nbsp";
    if (!strcmp($usr_zip, ""))
	$usr_zip = "&nbsp";
Chad Barb's avatar
   
Chad Barb committed
409
410
    if (!strcmp($usr_country, ""))
	$usr_country = "&nbsp";
411
412
    if (!strcmp($notes, ""))
	$notes = "&nbsp";
413

414
415
416
417
418
    #
    # Last Login info.
    #
    if (($lastweblogin = LASTWEBLOGIN($uid)) == 0)
	$lastweblogin = "&nbsp";
419
    if (($lastuserslogininfo = TBUsersLastLogin($uid)) == 0)
420
421
422
	$lastuserslogin = "N/A";
    else {
	$lastuserslogin = $lastuserslogininfo["date"] . " " .
423
		          $lastuserslogininfo["time"];
424
425
426
427
428
429
430
431
432
    }
    
    if (($lastnodelogininfo = TBUidNodeLastLogin($uid)) == 0)
	$lastnodelogin = "N/A";
    else {
	$lastnodelogin = $lastnodelogininfo["date"] . " " .
		         $lastnodelogininfo["time"] . " " .
                         "(" . $lastnodelogininfo["node_id"] . ")";
    }
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
    
    echo "<table align=center border=1>\n";
    
    echo "<tr>
              <td>Username:</td>
              <td>$uid</td>
          </tr>\n";
    
    echo "<tr>
              <td>Full Name:</td>
              <td>$usr_name</td>
          </tr>\n";
    
    echo "<tr>
              <td>Email Address:</td>
              <td>$usr_email</td>
          </tr>\n";
    
    echo "<tr>
              <td>Home Page URL:</td>
              <td><A href='$usr_URL'>$usr_URL</A></td>
          </tr>\n";
    
456
457
458
459
    #echo "<tr>
    #          <td>Expiration date:</td>
    #          <td>$usr_expires</td>
    #      </tr>\n";
460
461
    
    echo "<tr>
462
              <td>Address 1:</td>
463
464
465
              <td>$usr_addr</td>
          </tr>\n";
    
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
    echo "<tr>
              <td>Address 2:</td>
              <td>$usr_addr2</td>
          </tr>\n";
    
    echo "<tr>
              <td>City:</td>
              <td>$usr_city</td>
          </tr>\n";
    
    echo "<tr>
              <td>State:</td>
              <td>$usr_state</td>
          </tr>\n";
    
    echo "<tr>
Chad Barb's avatar
   
Chad Barb committed
482
              <td>ZIP:</td>
483
484
              <td>$usr_zip</td>
          </tr>\n";
Chad Barb's avatar
   
Chad Barb committed
485
486
487
488
489

    echo "<tr>
              <td>Country:</td>
              <td>$usr_country</td>
          </tr>\n";
490
    
491
492
493
494
    echo "<tr>
              <td>Phone #:</td>
              <td>$usr_phone</td>
          </tr>\n";
Chad Barb's avatar
   
Chad Barb committed
495
496
497
498
499

    echo "<tr>
	      <td>Shell:</td>
	      <td>$usr_shell</td>
          </tr>\n";
500
501
502
503
504
505
506
507
508
509
510
    
    echo "<tr>
              <td>Title/Position:</td>
              <td>$usr_title</td>
         </tr>\n";
    
    echo "<tr>
              <td>Institutional Affiliation:</td>
              <td>$usr_affil</td>
          </tr>\n";
    
511
512
513
514
    echo "<tr>
              <td>Status:</td>
              <td>$status</td>
          </tr>\n";
515
516
517
518
519

    if ($admin) {
	$onoff = ($adminoff ? "Off" : "On");
	$flip  = ($adminoff ? 0 : 1);
	echo "<tr>
520
521
522
523
              <td>Admin (on/off):</td>
              <td>Yes
              <a href=toggle.php?target_uid=$uid&type=adminoff&value=$flip>
              ($onoff)</td>
524
525
              </tr>\n";
    }
526
    
527
528
529
530
531
532
533
534
535
536
    echo "<tr>
              <td>Last Web Login:</td>
              <td>$lastweblogin</td>
          </tr>\n";
    
    echo "<tr>
              <td>Last Users Login:</td>
              <td>$lastuserslogin</td>
          </tr>\n";
    
537
538
539
540
    echo "<tr>
              <td>Last Node Login:</td>
              <td>$lastnodelogin</td>
          </tr>\n";
541
542

    if (ISADMIN()) {
543
544
545
546
547
548
549
550
551
552
553
	$freezeflip = ($frozen ? 0 : 1);
	
	echo "<tr>
                  <td>Web Freeze:</td>
                  <td>$frozen (<a href=toggle.php?target_uid=$uid".
	                          "&type=webfreeze&value=$freezeflip>Toggle</a>)
              </tr>\n";
	
	if ($frozen && $failstamp && $failcount) {
	    $when = strftime("20%y-%m-%d %H:%M:%S", $failstamp);
	    
554
	    echo "<tr>
555
556
                      <td>Login Failures:</td>
                      <td>$failcount ($when)</td>
557
                  </tr>\n";
558
559
560
561
562
	}
	echo "<tr>
                  <td>Notes:</td>
                  <td>$notes</td>
              </tr>\n";
563
    }
564
565
566
567
    echo "</table>\n";

}

568
569
570
#
# Show an experiment.
#
571
function SHOWEXP($pid, $eid, $short = 0) {
572
    global $TBDBNAME, $TBDOCBASE;
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
    $nodecounts  = array();

    # Node counts, by class. 
    $query_result =
	DBQueryFatal("select nt.class,count(*) from reserved as r ".
		     "left join nodes as n on n.node_id=r.node_id ".
		     "left join node_types as nt on n.type=nt.type ".
		     "where pid='$pid' and eid='$eid' group by nt.class");

    while ($row = mysql_fetch_array($query_result)) {
	$class = $row[0];
	$count = $row[1];
	
	$nodecounts[$class] = $count;
    }
588
		
Leigh B. Stoller's avatar
Leigh B. Stoller committed
589
    $query_result =
590
591
592
593
	DBQueryFatal("select e.*, pl.slicename, ". 
                     "round(e.minimum_nodes+.1,0) as min_nodes ".
		     " from experiments as e left join plab_slices as pl".
                     " on e.pid = pl.pid and e.eid = pl.eid ".
594
		     "where e.pid='$pid' and e.eid='$eid'");
595
    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
596
597
598
    if (($exprow = mysql_fetch_array($query_result)) == 0) {
	TBERROR("Experiment $eid in project $pid is gone!\n", 1);
    }
599

Leigh B. Stoller's avatar
Leigh B. Stoller committed
600
    $exp_gid     = $exprow[gid];
601
    $exp_name    = $exprow[expt_name];
602
    $exp_swapped = $exprow[expt_swapped];
603
    $exp_swapuid = $exprow[expt_swap_uid];
604
605
606
    $exp_end     = $exprow[expt_end];
    $exp_created = $exprow[expt_created];
    $exp_head    = $exprow[expt_head_uid];
607
    $exp_state   = $exprow[state];
608
    $exp_shared  = $exprow[shared];
609
610
    $exp_path    = $exprow[path];
    $batchmode   = $exprow[batchmode];
611
    $canceled    = $exprow[canceled];
612
    $attempts    = $exprow[attempts];
613
    $expt_locked = $exprow[expt_locked];
614
615
    $priority    = $exprow[priority];
    $swappable   = $exprow[swappable];
616
    $noswap_reason = $exprow[noswap_reason];
617
    $idleswap    = $exprow[idleswap];
618
    $idleswap_timeout  = $exprow[idleswap_timeout];
619
    $noidleswap_reason = $exprow[noidleswap_reason];
620
    $autoswap    = $exprow[autoswap];
621
    $autoswap_timeout  = $exprow[autoswap_timeout];
622
    $idle_ignore = $exprow[idle_ignore];
623
624
    $swapreqs    = $exprow[swap_requests];
    $lastswapreq = $exprow[last_swap_req];
625
    $minnodes    = $exprow["min_nodes"];
626
    $syncserver  = $exprow["sync_server"];
627
628
    $mem_usage   = $exprow["mem_usage"];
    $cpu_usage   = $exprow["cpu_usage"];
629
    $exp_slice   = $exprow[slicename];
630

631
632
    $autoswap_hrs= ($autoswap_timeout/60.0);
    $idleswap_hrs= ($idleswap_timeout/60.0);
633
634
635
636
    $noswap = "($noswap_reason)";
    $noidleswap = "($noidleswap_reason)";
    $autoswap_str= $autoswap_hrs." hour".($autoswap_hrs==1 ? "" : "s");
    $idleswap_str= $idleswap_hrs." hour".($idleswap_hrs==1 ? "":"s");
637

638
639
640
641
    if ($swappable)
	$swappable = "Yes";
    else
	$swappable = "<b>No</b> $noswap";
642

643
644
645
646
    if ($idleswap)
	$idleswap = "Yes (after $idleswap_str)";
    else
	$idleswap = "<b>No</b> $noidleswap";
647

648
649
650
651
    if ($autoswap)
	$autoswap = "<b>Yes</b> (after $autoswap_str)";
    else
	$autoswap = "No";
652

653
654
655
656
    if ($idle_ignore)
	$idle_ignore = "<b>Yes</b>";
    else
	$idle_ignore = "No";
657

658
659
660
661
662
    if ($expt_locked)
	$expt_locked = "($expt_locked)";
    else
	$expt_locked = "";

663
664
665
    #
    # Generate the table.
    #
Chad Barb's avatar
   
Chad Barb committed
666
    echo "<table align=center cellpadding=2 cellspacing=2 border=1>\n";
667

668
669
670
671
672
    if (!$short) {
	echo "<tr>
                <td>Name: </td>
                <td class=left>$eid</td>
              </tr>\n";
673

674
	echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
675
                <td>Description: </td>
676
677
                <td class=\"left\">$exp_name</td>
              </tr>\n";
678

679
680
681
682
683
	echo "<tr>
                <td>Project: </td>
                <td class=\"left\">
                  <a href='showproject.php3?pid=$pid'>$pid</a></td>
              </tr>\n";
684

685
686
687
688
689
690
        echo "<tr>
                <td>Group: </td>
                <td class=\"left\">
                  <a href='showgroup.php3?pid=$pid&gid=$exp_gid'>$exp_gid</a>
                </td>
              </tr>\n";
691
692
693
694
695
696
697

        if (isset($exp_slice)) {
          echo "<tr>
                  <td>Planetlab Slice: </td>
                  <td class=\"left\">$exp_slice</td>
                </tr>\n";
        }
698
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
699

700
701
702
    echo "<tr>
            <td>Experiment Head: </td>
            <td class=\"left\">
703
              <a href='showuser.php3?target_uid=$exp_head'>$exp_head</a></td>
704
705
          </tr>\n";

706
707
708
709
    if (!$short) {
	echo "<tr>
                <td>Created: </td>
                <td class=\"left\">$exp_created</td>
710
              </tr>\n";
711

712
713
714
715
716
717
	if ($exp_swapped) {
	    echo "<tr>
                    <td>Last Swap/Modify: </td>
                    <td class=\"left\">$exp_swapped ($exp_swapuid)</td>
                  </tr>\n";
	}
718

719
720
721
722
723
724
725
726
727
728
729
730
731
	if (ISADMIN()) {
	    echo "<tr>
                    <td><a href='$TBDOCBASE/docwrapper.php3?".
		           "docname=swapping.html#swapping'>Swappable:</a></td>
                    <td class=\"left\">$swappable</td>
                  </tr>\n";
	}
    
	echo "<tr>
                  <td><a href='$TBDOCBASE/docwrapper.php3?".
	                 "docname=swapping.html#idleswap'>Idle-Swap:</a></td>
                  <td class=\"left\">$idleswap</td>
              </tr>\n";
732

733
	echo "<tr>
734
735
736
737
                <td><a href='$TBDOCBASE/docwrapper.php3?".
	               "docname=swapping.html#autoswap'>Max. Duration:</a></td>
                <td class=\"left\">$autoswap</td>
              </tr>\n";
738

739
740
741
742
743
744
745
746
747
748
749
	if (ISADMIN()) {
	    echo "<tr>
                    <td>Idle Ignore:</td>
                    <td class=\"left\">$idle_ignore</td>
                 </tr>\n";
	}
    
	echo "<tr>
                <td>Path: </td>
                <td class=left>$exp_path</td>
              </tr>\n";
750

751
752
753
754
        echo "<tr>
                <td>Status: </td>
                <td class=\"left\">$exp_state $expt_locked</td>
              </tr>\n";
755
    }
756

757
    if (count($nodecounts)) {
758
	echo "<tr>
759
760
                 <td>Reserved Nodes: </td>
                 <td class=\"left\">\n";
761
762
763
	while (list ($class, $count) = each($nodecounts)) {
	    echo "$count ($class) &nbsp ";
	}
764
765
766
767
	echo "   </td>
              </tr>\n";
    }
    elseif (!$short) {
768
769
	if ($minnodes!="") {
	    echo "<tr>
770
771
772
773
774
775
                      <td>Minumum Nodes: </td>
                      <td class=\"left\"><font color=green>
                          $minnodes (estimate)</font></td>
                  </tr>\n";
	}
	else {
776
	    echo "<tr>
777
778
779
                      <td>Minumum Nodes: </td>
                      <td class=\"left\"><font color=green>Unknown</font></td>
                  </tr>\n";
780
	}
781
    }
782
783
784
785
786
787
    if (!$short) {
	if ($mem_usage || $cpu_usage) {
	    echo "<tr>
                      <td>Mem Usage Est: </td>
                      <td class=\"left\">$mem_usage</td>
                  </tr>\n";
788

789
790
791
792
793
	    echo "<tr>
                      <td>CPU Usage Est: </td>
                      <td class=\"left\">$cpu_usage</td>
                  </tr>\n";
	}
794

795
796
797
	$lastact = TBGetExptLastAct($pid,$eid);
	$idletime = TBGetExptIdleTime($pid,$eid);
	$stale = TBGetExptIdleStale($pid,$eid);
798
    
799
800
801
802
803
	if ($lastact != -1) {
	    echo "<tr>
                      <td>Last Activity: </td>
                      <td class=\"left\">$lastact</td>
                  </tr>\n";
804

805
	    if ($stale) { $str = "(stale)"; } else { $str = ""; }
806
	
807
808
809
810
811
	    echo "<tr>
                      <td>Idle Time: </td>
                      <td class=\"left\">$idletime hours $str</td>
                  </tr>\n";
	}
812

813
814
815
816
817
	if (! ($swapreqs=="" || $swapreqs==0)) {
	    echo "<tr>
                      <td>Swap Requests: </td>
                      <td class=\"left\">$swapreqs</td>
                  </tr>\n";
818

819
820
821
822
823
	    echo "<tr>
                      <td>Last Swap Req.: </td>
                      <td class=\"left\">$lastswapreq</td>
                  </tr>\n";
	}
824
825
    }
    
826
827
828
829
830
831
832
833
834
835
836
    if ($batchmode) {
	    echo "<tr>
                    <td>Batch Mode: </td>
                    <td class=\"left\">Yes</td>
                  </tr>\n";

	    echo "<tr>
                    <td>Start Attempts: </td>
                    <td class=\"left\">$attempts</td>
                  </tr>\n";
    }
837

838
    if ($canceled) {
839
	echo "<tr>
840
841
                 <td>Cancel Flag: </td>
                 <td class=\"left\">$canceled</td>
842
843
844
              </tr>\n";
    }

845
846
847
848
849
850
851
852
853
    if (!$short) {
	if (isset($syncserver)) {
	    echo "<tr>
                      <td>Sync Server: </td>
                      <td class=\"left\">$syncserver</td>
                  </tr>\n";
	}
    }

854
855
856
    echo "</table>\n";
}

857
858
859
#
# Show a listing of experiments by user/pid/gid
#
860
function SHOWEXPLIST($type,$id,$gid = "") {
861
862
    global $TB_EXPTSTATE_SWAPPED, $TB_EXPTSTATE_SWAPPING;
    
863
864
865
866
867
868
869
870
    if ($type == "USER") {
	$where = "expt_head_uid='$id'";
	$title = "Current";
    } elseif ($type == "PROJ") {
	$where = "e.pid='$id'";
	$title = "Project";
	$nopid = 1;
    } elseif ($type == "GROUP") {
871
	$where = "e.pid='$id' and e.gid='$gid'";
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
	$title = "Group";
	$nopid = 1;
    } else {
	$where = "e.eid='$id'";
	$title = "Bad id '$id'!";
    }
    
    $query_result =
	DBQueryFatal("select e.*,count(r.node_id) as nodes, ".
		     "round(minimum_nodes+.1,0) as min_nodes ".
		     "from experiments as e ".
		     "left join reserved as r on e.pid=r.pid and e.eid=r.eid ".
		     "where $where ".
		     "group by e.pid,e.eid order by e.state,e.eid");
    
    if (mysql_num_rows($query_result)) {
	echo "<center>
          <h3>$title Experiments</h3>
          </center>
          <table align=center border=1 cellpadding=2 cellspacing=2>\n";

	if ($nopid) {
	    $pidrow="";
	} else {
	    $pidrow="\n<th>PID</th>";
	}
	
	echo "<tr>$pidrow
              <th>EID</th>
              <th>State</th>
902
903
              <th align=center>Nodes [1]</th>
              <th align=center>Hours Idle [2]</th>
904
905
906
              <th>Description</th>
          </tr>\n";

907
908
909
	$idlemark = "<b>*</b>";
	$stalemark = "<b>?</b>";
	
910
911
912
	while ($row = mysql_fetch_array($query_result)) {
	    $pid  = $row[pid];
	    $eid  = $row[eid];
913
	    $state= $row[state];
914
915
916
	    $nodes= $row["nodes"];
	    $minnodes = $row["min_nodes"];
	    $idlehours = TBGetExptIdleTime($pid,$eid);
917
918
	    $stale = TBGetExptIdleStale($pid,$eid);
	    $ignore = $row["idle_ignore"];
919
	    $name = $row[expt_name];
920
	    if ($nodes==0) {
921
		$nodes = "<font color=green>$minnodes</font>";
922
923
	    } elseif ($row[swap_requests] > 0) {
		$nodes .= $idlemark;
924
925
926
927
928
929
930
931
	    }

	    if ($nopid) {
		$pidrow="";
	    } else {
		$pidrow="\n<td>".
		    "<A href='showproject.php3?pid=$pid'>$pid</A></td>";
	    }
932
933
934
935
936
937

	    $idlestr = $idlehours;
	    if ($idlehours > 0) {
		if ($stale) { $idlestr .= $stalemark; }
		if ($ignore) { $idlestr = "($idlestr)"; $parens=1; }
	    } elseif ($idlehours == -1) { $idlestr = "&nbsp;"; }
938
939
940
	    
	    echo "<tr>$pidrow
                 <td><A href='showexp.php3?pid=$pid&eid=$eid'>$eid</A></td>
941
		 <td>$state</td>
942
                 <td align=center>$nodes</td>
943
                 <td align=center>$idlestr</td>
944
945
946
947
                 <td>$name</td>
             </tr>\n";
	}
	echo "</table>\n";
948
949
950
	echo "<table align=center cellpadding=0 class=stealth><tr>\n".
	    "<td class=stealth align=left><font size=-1><ol>\n".
	    "<li>Node counts in <font color=green><b>green</b></font>\n".
951
	    "show a rough estimate of the minimum number of \n".
952
953
954
955
956
957
958
959
960
961
962
963
	    "nodes <br>required to swap in.\n".
	    "They account for delay nodes, but not for node types, etc.\n".
	    "<li>A $stalemark indicates that the data is stale, and ".
	    "at least one node in the experiment has not <br>reported ".
	    "on its proper schedule.\n"; 
	if ($parens) {
            # don't show this unless we did it... most users shouldn't ever
	    # need to know that some expts have their idleness ignored
	    echo "Values are in parenthesis for idle-ignore experiments.\n";
	}
	echo "</ol></font></td></tr></table>\n";

964
965
966
    }   
}

967
968
969
#
# Show Node information for an experiment.
#
970
function SHOWNODES($pid, $eid, $sortby) {
971
    global $SCRIPT_NAME;
972
    global $TBOPSPID;
973
    
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
    #
    # If this is an expt in emulab-ops, we also want to see the reserved
    # time. Note that vname might not be useful, but show it anyway.
    #
    # XXX The above is not always true. There are also real experiments in
    # emulab-ops.
    #
    if (!isset($sortby)) {
	$sortclause = "n.type,n.priority";
    }
    elseif ($sortby == "vname") {
	$sortclause = "r.vname";
    }
    elseif ($sortby == "rsrvtime-up") {
	$sortclause = "rsrvtime asc";
    }
    elseif ($sortby == "rsrvtime-down") {
	$sortclause = "rsrvtime desc";
    }
    elseif ($sortby == "nodeid") {
	$sortclause = "n.node_id";
    }
    else {
	$sortclause = "n.type,n.priority";
998
    }
999

1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
    $query_result =
	DBQueryFatal("SELECT r.*,n.*,nt.isvirtnode, ".
		     " ns.status as nodestatus, ".
		     " date_format(rsrv_time,\"%Y-%m-%d&nbsp;%T\") as rsrvtime ".
		     "from reserved as r ".
		     "left join nodes as n on n.node_id=r.node_id ".
		     "left join node_types as nt on nt.type=n.type ".
		     "left join node_status as ns on ns.node_id=r.node_id ".
		     "WHERE r.eid='$eid' and r.pid='$pid' ".
		     "ORDER BY $sortclause");
    
    if (mysql_num_rows($query_result)) {
1012
1013
1014
1015
1016
	echo "<center>
              <h3>Reserved Nodes</h3>
              </center>
              <table align=center border=1>
              <tr>
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
                <th><a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
	                        "&sortby=nodeid\">Node ID</a></th>
                <th><a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
	                 "&sortby=vname\">Name</a></th>\n";
	if ($pid == $TBOPSPID) {
	    echo "<th>Reserved<br>
                      <a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
		         "&sortby=rsrvtime-up\">Up</a> or 
                      <a href=\"$SCRIPT_NAME?pid=$pid&eid=$eid".
		         "&sortby=rsrvtime-down\">Down</a>
                  </th>\n";
	}
	echo "  <th>Type</th>
1030
1031
                <th>Default OSID</th>
                <th>Node<br>Status</th>
1032
1033
                <th>Hours<br>Idle[<b>1</b>]</th>
                <th>Startup<br>Status[<b>2</b>]</th>
1034
1035
1036
                <th><a href=\"docwrapper.php3?docname=ssh-mime.html\">SSH</a>
		    </th>
                <th><a href=\"faq.php3#UTT-TUNNEL\">Console</a></th>
1037
              </tr>\n";
1038

1039
	$stalemark = "<b>?</b>";
1040
	$count = 0;
1041

1042
1043
	while ($row = mysql_fetch_array($query_result)) {
	    $node_id = $row[node_id];
1044
1045
	    $vname   = $row[vname];
	    $rsrvtime= $row[rsrvtime];
1046
	    $type    = $row[type];
1047
1048
	    $def_boot_osid = $row[def_boot_osid];
	    $startstatus   = $row[startstatus];
1049
	    $status        = $row[nodestatus];
1050
	    $bootstate     = $row[eventstate];
1051
	    $isvirtnode    = $row[isvirtnode];
1052
1053
1054
1055
1056
1057
1058
1059
	    $idlehours = TBGetNodeIdleTime($node_id);
	    $stale = TBGetNodeIdleStale($node_id);

	    $idlestr = $idlehours;
	    if ($idlehours > 0) {
		if ($stale) { $idlestr .= $stalemark; }
		if ($ignore) { $idlestr = "($idlestr)"; $parens=1; }
	    } elseif ($idlehours == -1) { $idlestr = "&nbsp;"; }
1060

1061
1062
1063
	    if (!$vname)
		$vname = "--";

1064
1065
1066
1067
1068
	    if ($count & 1) {
		echo "<tr></tr>\n";
	    }
	    $count++;

1069
	    echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1070
1071
                    <td><A href='shownode.php3?node_id=$node_id'>$node_id</a>
                        </td>
1072
1073
1074
1075
                    <td>$vname</td>\n";
	    if ($pid == $TBOPSPID)
		echo "<td>$rsrvtime</td>\n";
            echo "  <td>$type</td>\n";
1076
1077
1078
1079
1080
	    if ($def_boot_osid) {
		echo "<td>";
		SPITOSINFOLINK($def_boot_osid);
		echo "</td>";
	    }
1081
1082
	    else
		echo "<td>&nbsp</td>\n";
1083
1084
1085
1086
1087
1088

	    if ($bootstate != "ISUP") {
		echo "  <td>$status ($bootstate)</td>\n";
	    } else {
		echo "  <td>$status</td>\n";
	    }
1089
	    
1090
	    echo "  <td>$idlestr</td>
1091
1092
1093
1094
1095
                    <td align=center>$startstatus</td>\n";

	    echo "  <td align=center>
                     <A href='nodessh.php3?node_id=$node_id'>
                     <img src=\"ssh.gif\" alt=s></A></td>\n";
1096
1097
1098
1099
1100
1101
1102
1103
	    if ($isvirtnode) {
		echo "<td>&nbsp</td>\n";
	    }
	    else {
		echo "  <td align=center>
                           <A href='nodetipacl.php3?node_id=$node_id'>
                          <img src=\"console.gif\" alt=c></A></td>\n";
	    }
1104
	    echo "</tr>\n";
1105
1106
	}
	echo "</table>\n";
1107
1108
	echo "<h4><blockquote><blockquote><blockquote>
              <ol>
1109
1110
	        <li>A $stalemark indicates that the data is stale, and
	            the node has not reported on its proper schedule. 
1111
                <li>Exit value of the node startup command. A value of
1112
                        666 indicates a testbed internal error.
1113
1114
              </ol>
              </blockquote></blockquote></blockquote></h4>\n";
1115
1116
1117
    }
}

1118
1119
1120
1121
#
# Show OS INFO record.
#
function SHOWOSINFO($osid) {
1122
1123
    $query_result =
	DBQueryFatal("SELECT * FROM os_info WHERE osid='$osid'");
1124
1125
1126

    $osrow = mysql_fetch_array($query_result);

1127
    $os_description = $osrow[description];
1128
1129
1130
1131
1132
    $os_OS          = $osrow[OS];
    $os_version     = $osrow[version];
    $os_path        = $osrow[path];
    $os_magic       = $osrow[magic];
    $os_osfeatures  = $osrow[osfeatures];
1133
    $os_op_mode     = $osrow[op_mode];
1134
    $os_pid         = $osrow[pid];
1135
1136
    $os_shared      = $osrow[shared];
    $os_osname      = $osrow[osname];
1137
1138
    $creator        = $osrow[creator];
    $created        = $osrow[created];
1139
    $mustclean      = $osrow[mustclean];
1140
    $nextosid       = $osrow[nextosid];
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151

    if (!$os_description)
	$os_description = "&nbsp";
    if (!$os_version)
	$os_version = "&nbsp";
    if (!$os_path)
	$os_path = "&nbsp";
    if (!$os_magic)
	$os_magic = "&nbsp";
    if (!$os_osfeatures)
	$os_osfeatures = "&nbsp";
1152
1153
    if (!$os_op_mode)
	$os_op_mode = "&nbsp";
1154
1155
    if (!$created)
	$created = "N/A";
1156
1157
1158
1159
1160
1161
1162

    #
    # Generate the table.
    #
    echo "<table align=center border=1>\n";

    echo "<tr>
1163
1164
1165
1166
1167
1168
            <td>Name: </td>
            <td class=\"left\">$os_osname</td>
          </tr>\n";

    echo "<tr>
            <td>Project: </td>
1169
1170
            <td class=\"left\">
              <a href='showproject.php3?pid=$os_pid'>$os_pid</a></td>
1171
1172
          </tr>\n";

1173
1174
    echo "<tr>
            <td>Creator: </td>
1175
1176
            <td class=left>
              <a href='showuser.php3?target_uid=$creator'>$creator</a></td>
1177
1178
1179
1180
1181
1182
1183
 	  </tr>\n";

    echo "<tr>
            <td>Created: </td>
            <td class=left>$created</td>
 	  </tr>\n";

1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
    echo "<tr>
            <td>Description: </td>
            <td class=\"left\">$os_description</td>
          </tr>\n";

    echo "<tr>
            <td>Operating System: </td>
            <td class=\"left\">$os_OS</td>
          </tr>\n";

    echo "<tr>
            <td>Version: </td>
            <td class=\"left\">$os_version</td>
          </tr>\n";

    echo "<tr>
            <td>Path: </td>
            <td class=\"left\">$os_path</td>
          </tr>\n";

    echo "<tr>
            <td>Magic (uname -r -s): </td>
            <td class=\"left\">$os_magic</td>
          </tr>\n";

    echo "<tr>
1210
1211
            <td>Features: </td>
            <td class=\"left\">$os_osfeatures</td>
1212
1213
          </tr>\n";

1214
1215
1216
1217
1218
    echo "<tr>
            <td>Operational Mode: </td>
            <td class=\"left\">$os_op_mode</td>
          </tr>\n";

1219
    echo "<tr>
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
            <td>Shared?: </td>
            <td class=left>\n";

    if ($os_shared)
	echo "Yes";
    else
	echo "No";
    
    echo "  </td>
          </tr>\n";

1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
    echo "<tr>
            <td>Must Clean?: </td>
            <td class=left>\n";

    if ($mustclean)
	echo "Yes";
    else
	echo "No";
    
    echo "  </td>
          </tr>\n";

1243
1244
1245
1246
1247
1248
1249
1250
    if ($nextosid) {
	echo "<tr>
                <td>Next Osid: </td>
                <td class=left>
                    <A href='showosinfo.php3?osid=$nextosid'>$nextosid</A></td>
              </tr>\n";
    }

1251
1252
1253
    echo "<tr>
            <td>Internal ID: </td>
            <td class=\"left\">$osid</td>
1254
1255
1256
1257
1258
          </tr>\n";

    echo "</table>\n";
}

1259
1260
1261
#
# Show ImageID record.
#
1262
function SHOWIMAGEID($imageid, $edit, $isadmin = 0) {
1263
1264
    $query_result =
	DBQueryFatal("select * from images where imageid='$imageid'");
1265
1266
1267

    $row = mysql_fetch_array($query_result);

1268
1269
    $imagename   = $row[imagename];
    $pid         = $row[pid];
1270
    $gid         = $row[gid];
1271
    $description = $row[description];
1272
1273
1274
1275
1276
1277
1278
1279
1280
    $loadpart	 = $row[loadpart];
    $loadlength	 = $row[loadlength];
    $part1_osid	 = $row[part1_osid];
    $part2_osid	 = $row[part2_osid];
    $part3_osid	 = $row[part3_osid];
    $part4_osid	 = $row[part4_osid];
    $default_osid= $row[default_osid];
    $path 	 = $row[path];
    $loadaddr	 = $row[load_address];
1281
    $frisbee_pid = $row[frisbee_pid];
1282
    $shared	 = $row[shared];
1283
    $globalid	 = $row["global"];
1284
1285
    $creator     = $row[creator];
    $created     = $row[created];
1286
1287
1288
1289
1290
1291
1292
1293

    if ($edit) {
	if (!$description)
	    $description = "";
	if (!$path)
	    $path = "";
	if (!$loadaddr)
	    $loadaddr = "";
1294
1295
	if (!$frisbee_pid)
	    $frisbee_pid = "";
1296
1297
1298
1299
1300
1301
1302
1303
    }
    else {
	if (!$description)
	    $description = "&nbsp";
	if (!$path)
	    $path = "&nbsp";
	if (!$loadaddr)
	    $loadaddr = "&nbsp";
1304
1305
	if (!$frisbee_pid)
	    $frisbee_pid = "&nbsp";
1306
1307
	if (!$created)
	    $created = "N/A";
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
    }
    
    #
    # Generate the table.
    #
    echo "<table align=center border=2 cellpadding=2 cellspacing=2>\n";

    if ($edit) {
	$imageid_encoded = rawurlencode($imageid);
	
	echo "<form action='editimageid.php3?imageid=$imageid_encoded'
                    method=post>\n";
    }

    echo "<tr>
1323
1324
1325
1326
1327
1328
            <td>Image Name: </td>
            <td class=\"left\">$imagename</td>
          </tr>\n";

    echo "<tr>
            <td>Project: </td>
1329
1330
            <td class=\"left\">
              <a href='showproject.php3?pid=$pid'>$pid</a></td>
1331
          </tr>\n";