showstuff.php3 32.9 KB
Newer Older
1
2
<?php
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
3
4
5
6
7
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# 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
26
27
    echo "<center>
          <h3>Project Profile</h3>
          </center>
          <table align=center border=1>\n";
    
28
29
    $proj_created	= $row[created];
    $proj_expires	= $row[expires];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
30
    $proj_name		= stripslashes($row[name]);
31
    $proj_URL		= $row[URL];
32
    $proj_public        = $row[public];
33
    $proj_funders	= $row[funders];
34
35
36
37
    $proj_head_uid	= $row[head_uid];
    $proj_members       = $row[num_members];
    $proj_pcs           = $row[num_pcs];
    $proj_sharks        = $row[num_sharks];
38
    $proj_why           = nl2br($row[why]);
39
    $control_node	= $row[control_node];
40
    $approved           = $row[approved];
41
42
    $expt_count         = $row[expt_count];
    $expt_last          = $row[expt_last];
43

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

51
52
53
54
    if (!$expt_last) {
	$expt_last = "&nbsp";
    }

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    #
    # Generate the table.
    # 
    echo "<tr>
              <td>Name: </td>
              <td class=\"left\">$pid</td>
          </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\">
71
                <A href='showuser.php3?target_uid=$proj_head_uid'>
72
73
74
75
76
77
78
79
80
                     $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";
    
81
82
83
84
85
    echo "<tr>
              <td>Publicly Visible: </td>
              <td class=\"left\">$proj_public</td>
          </tr>\n";
    
86
87
88
89
90
    echo "<tr>
              <td>Funders: </td>
              <td class=\"left\">$proj_funders</td>
          </tr>\n";

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    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>
              <td>#Sharks: </td>
              <td class=\"left\">$proj_sharks</td>
          </tr>\n";
    
    echo "<tr>
              <td>Created: </td>
              <td class=\"left\">$proj_created</td>
          </tr>\n";
    
    echo "<tr>
              <td>Expires: </td>
              <td class=\"left\">$proj_expires</td>
          </tr>\n";
    
116
117
118
119
120
121
122
123
124
125
    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";
    
126
127
128
129
130
131
132
133
134
135
    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";

136
    echo "<tr>
137
              <td colspan='2'>Why?:</td>
138
139
140
141
142
143
144
145
146
          </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
147
148
149
150
151
152
153
154
#
# A Group
#
function SHOWGROUP($pid, $gid) {
    $query_result =
	DBQueryFatal("SELECT * FROM groups WHERE pid='$pid' and gid='$gid'");
    $row = mysql_fetch_array($query_result);

155
156
157
158
    echo "<center>
          <h3>Group Profile</h3>
          </center>
          <table align=center border=1>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
159
160
161

    $leader	= $row[leader];
    $created	= $row[created];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
162
    $description= stripslashes($row[description]);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    $expt_count = $row[expt_count];
    $expt_last  = $row[expt_last];
    $unix_gid   = $row[unix_gid];
    $unix_name  = $row[unix_name];

    if (!$expt_last) {
	$expt_last = "&nbsp";
    }

    #
    # Generate the table.
    # 
    echo "<tr>
              <td>GID: </td>
              <td class=\"left\">$gid</td>
          </tr>\n";
    
    echo "<tr>
              <td>PID: </td>
              <td class=\"left\">$pid</td>
          </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";
    
    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.
#
function SHOWGROUPMEMBERS($pid, $gid) {
    $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;
    }

    echo "<center>
          <h3>Group Members</h3>
          </center>
240
          <table align=center border=1 cellpadding=1 cellspacing=2>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276

    echo "<tr>
              <td align=center>Name</td>
              <td align=center>UID</td>
              <td align=center>Privs</td>
              <td align=center>Approved?</td>
          </tr>\n";

    while ($row = mysql_fetch_array($query_result)) {
        $target_uid = $row[uid];
	$usr_name   = $row[usr_name];
	$status     = $row[status];
	$trust      = $row[trust];

        echo "<tr>
                  <td>$usr_name</td>
                  <td>
                    <A href='showuser.php3?target_uid=$target_uid'>
                       $target_uid</A>
                  </td>
                  <td>$trust</td>\n";
	    
	if (strcmp($status, "active") == 0 ||
	    strcmp($status, "unverified") == 0) {
	    echo "<td align=center>
                      <img alt=\"Y\" src=\"greenball.gif\"></td>\n";
	}
	else {
	    echo "<td align=center>
                      <img alt=\"N\" src=\"redball.gif\"></td>\n";
	}
	echo "</tr>\n";
    }
    echo "</table>\n";
}

277
278
279
280
#
# A list of groups for a user.
#
function SHOWGROUPMEMBERSHIP($uid) {
281
282
    $none = TBDB_TRUSTSTRING_NONE;
    
283
284
    $query_result =
	DBQueryFatal("SELECT * FROM group_membership ".
285
286
		     "WHERE uid='$uid' and trust!='$none' ".
		     "order by pid");
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
    
    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>
              <td align=center>PID</td>
              <td align=center>GID</td>
              <td align=center>Privs</td>
          </tr>\n";

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

308
309
310
311
312
313
314
	if (TBTrustConvert($trust) != $TBDB_TRUST_NONE) {
	    echo "<tr>
                      <td>$pid</td>
                      <td>$gid</td>
                      <td>$trust</td>\n";
	    echo "</tr>\n";
	}
315
316
317
318
    }
    echo "</table>\n";
}

319
320
321
322
323
#
# A User
#
function SHOWUSER($uid) {
    global $TBDBNAME;
324
325
326

    $userinfo_result =
	DBQueryFatal("SELECT * from users where uid='$uid'");
327
328
329
330
331

    $row	= mysql_fetch_array($userinfo_result);
    $usr_expires = $row[usr_expires];
    $usr_email   = $row[usr_email];
    $usr_URL     = $row[usr_URL];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
332
333
    $usr_addr    = stripslashes($row[usr_addr]);
    $usr_name    = stripslashes($row[usr_name]);
334
    $usr_phone   = $row[usr_phone];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
335
336
    $usr_title   = stripslashes($row[usr_title]);
    $usr_affil   = stripslashes($row[usr_affil]);
337
    $status      = $row[status];
338
339
    $admin       = $row[admin];
    $adminoff    = $row[adminoff];
340
341
342
343
344
345

    #
    # Last Login info.
    #
    if (($lastweblogin = LASTWEBLOGIN($uid)) == 0)
	$lastweblogin = "&nbsp";
346
    if (($lastuserslogininfo = TBUsersLastLogin($uid)) == 0)
347
348
349
	$lastuserslogin = "N/A";
    else {
	$lastuserslogin = $lastuserslogininfo["date"] . " " .
350
		          $lastuserslogininfo["time"];
351
352
353
354
355
356
357
358
359
    }
    
    if (($lastnodelogininfo = TBUidNodeLastLogin($uid)) == 0)
	$lastnodelogin = "N/A";
    else {
	$lastnodelogin = $lastnodelogininfo["date"] . " " .
		         $lastnodelogininfo["time"] . " " .
                         "(" . $lastnodelogininfo["node_id"] . ")";
    }
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
    
    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";
    
    echo "<tr>
              <td>Expiration date:</td>
              <td>$usr_expires</td>
          </tr>\n";
    
    echo "<tr>
              <td>Mailing Address:</td>
              <td>$usr_addr</td>
          </tr>\n";
    
    echo "<tr>
              <td>Phone #:</td>
              <td>$usr_phone</td>
          </tr>\n";
    
    echo "<tr>
              <td>Title/Position:</td>
              <td>$usr_title</td>
         </tr>\n";
    
    echo "<tr>
              <td>Institutional Affiliation:</td>
              <td>$usr_affil</td>
          </tr>\n";
    
408
409
410
411
    echo "<tr>
              <td>Status:</td>
              <td>$status</td>
          </tr>\n";
412
413
414
415
416
417
418
419
420
421
422

    if ($admin) {
	$onoff = ($adminoff ? "Off" : "On");
	$flip  = ($adminoff ? 0 : 1);
	echo "<tr>
                  <td>Admin (on/off):</td>
                  <td>Yes
                      <a href=adminmode.php3?target_uid=$uid&adminoff=$flip>
                         ($onoff)</td>
              </tr>\n";
    }
423
    
424
425
426
427
428
429
430
431
432
433
    echo "<tr>
              <td>Last Web Login:</td>
              <td>$lastweblogin</td>
          </tr>\n";
    
    echo "<tr>
              <td>Last Users Login:</td>
              <td>$lastuserslogin</td>
          </tr>\n";
    
434
435
436
437
438
    echo "<tr>
              <td>Last Node Login:</td>
              <td>$lastnodelogin</td>
          </tr>\n";
    
439
440
441
442
    echo "</table>\n";

}

443
444
445
446
#
# Show an experiment.
#
function SHOWEXP($pid, $eid) {
447
    global $TBDBNAME, $TBDOCBASE;
448
		
Leigh B. Stoller's avatar
Leigh B. Stoller committed
449
    $query_result =
450
451
452
453
454
	DBQueryFatal("select e.*,count(r.node_id) from experiments as e ".
		     "left join reserved as r on e.pid=r.pid and e.eid=r.eid ".
		     "where e.pid='$pid' and e.eid='$eid' ".
		     "group by e.eid order by eid");
    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
455
456
457
    if (($exprow = mysql_fetch_array($query_result)) == 0) {
	TBERROR("Experiment $eid in project $pid is gone!\n", 1);
    }
458

Leigh B. Stoller's avatar
Leigh B. Stoller committed
459
    $exp_gid     = $exprow[gid];
460
    $exp_expires = $exprow[expt_expires];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
461
    $exp_name    = stripslashes($exprow[expt_name]);
462
463
    $exp_created = $exprow[expt_created];
    $exp_start   = $exprow[expt_start];
464
    $exp_swapped = $exprow[expt_swapped];
465
466
467
    $exp_end     = $exprow[expt_end];
    $exp_created = $exprow[expt_created];
    $exp_head    = $exprow[expt_head_uid];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
468
    $exp_status  = $exprow[state];
469
    $exp_shared  = $exprow[shared];
470
471
472
473
    $exp_path    = $exprow[path];
    $batchmode   = $exprow[batchmode];
    $attempts    = $exprow[attempts];
    $batchstate  = $exprow[batchstate];
474
475
    $priority    = $exprow[priority];
    $swappable   = $exprow[swappable];
476
    $nodes       = $exprow["count(r.node_id)"];
477
478
479
480
481

    if ($swappable)
	$swappable = "Yes";
    else
	$swappable = "No";
482
483
484
485

    #
    # Generate the table.
    #
486
    echo "<table align=center cellpadding=2 cellspacing=0 border=1>\n";
487
488
489

    echo "<tr>
            <td>Name: </td>
490
            <td class=left>$eid</td>
491
492
493
494
495
496
497
498
499
          </tr>\n";

    echo "<tr>
            <td>Long Name: </td>
            <td class=\"left\">$exp_name</td>
          </tr>\n";

    echo "<tr>
            <td>Project: </td>
500
501
            <td class=\"left\">
                <A href='showproject.php3?pid=$pid'>$pid</td>
502
503
          </tr>\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
504
505
506
507
508
509
    echo "<tr>
            <td>Group: </td>
            <td class=\"left\">
                <A href='showgroup.php3?pid=$pid&gid=$exp_gid'>$exp_gid</td>
          </tr>\n";

510
511
512
513
514
515
516
517
518
519
520
521
522
    echo "<tr>
            <td>Experiment Head: </td>
            <td class=\"left\">
                <A href='showuser.php3?target_uid=$exp_head'>
                   $exp_head</td>
          </tr>\n";

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

    echo "<tr>
523
524
            <td>Expires: </td>
            <td class=\"left\">$exp_expires</td>
525
526
527
          </tr>\n";

    echo "<tr>
528
529
            <td>Started: </td>
            <td class=\"left\">$exp_start</td>
530
531
          </tr>\n";

532
533
534
535
536
    echo "<tr>
            <td>Last Swapped (in or out): </td>
            <td class=\"left\">$exp_swapped</td>
          </tr>\n";

537
    echo "<tr>
538
            <td><a href='$TBDOCBASE/faq.php3#UTT-Swapping'>Swappable:</a></td>
539
540
541
542
543
544
545
546
            <td class=\"left\">$swappable</td>
          </tr>\n";

    echo "<tr>
            <td>Priority: (0 is highest) </td>
            <td class=\"left\">$priority</td>
          </tr>\n";

547
548
549
550
551
552
553
554
555
556
557
558
    echo "<tr>
            <td>Shared: </td>
            <td class=\"left\">";
    if ($exp_shared) {
	echo "<A href='expaccess_form.php3?pid=$pid&eid=$eid'>Yes</a>";
    }
    else {
	echo "No";
    }
    echo "   </td>
          </tr>\n";

559
560
561
562
563
    echo "<tr>
            <td>Path: </td>
            <td class=left>$exp_path</td>
          </tr>\n";

564
565
566
567
568
    echo "<tr>
            <td>Status: </td>
            <td class=\"left\">$exp_status</td>
          </tr>\n";

569
570
571
572
573
    echo "<tr>
            <td>Reserved Nodes: </td>
            <td class=\"left\">$nodes</td>
          </tr>\n";

574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
    if ($batchmode) {
	    echo "<tr>
                    <td>Batch Mode: </td>
                    <td class=\"left\">Yes</td>
                  </tr>\n";

	    echo "<tr>
                    <td>Batch Status: </td>
                    <td class=\"left\">$batchstate</td>
                  </tr>\n";

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

591
592
593
594
595
596
597
598
    echo "</table>\n";
}

#
# Show Node information for an experiment.
#
function SHOWNODES($pid, $eid) {
    global $TBDBNAME;
599
    global $TBOPSPID;
600
		
601
602
603
    $reserved_result =
	DBQueryFatal("SELECT * FROM reserved WHERE ".
		     "eid='$eid' and pid='$pid'");
604
    
605
606
607
608
609
610
611
612
613
614
615
    # If this is an expt in emulab-ops, we don't care about vname,
    # since it won't be defined. But we do want to know when the node
    # entered the experiment, since it won't match the experiment's
    # swapin date.
    $nodename="Node Name";
    $vnamefield="vname";
    if (!strcmp($pid, $TBOPSPID)) {
      $nodename="Reserve Time";
      $vnamefield="rsrvtime";
    }
    
616
617
618
619
620
621
622
    if (mysql_num_rows($reserved_result)) {
	echo "<center>
              <h3>Reserved Nodes</h3>
              </center>
              <table align=center border=1>
              <tr>
                <td align=center>Node ID</td>
623
                <td align=center>$nodename</td>
624
                <td align=center>Type</td>
625
                <td align=center>Default<br>OSID</td>
626
627
                <td align=center>Default<br>Path</td>
                <td align=center>Default<br>Cmdline</td>
628
                <td align=center>Boot<br>Status[<b>1</b>]</td>
629
                <td align=center>Startup<br>Command</td>
630
631
                <td align=center>Startup<br>Status[<b>2</b>]</td>
                <td align=center>Ready<br>Status[<b>3</b>]</td>
632
633
              </tr>\n";
	
634
635
	$query_result =
	    DBQueryFatal("SELECT nodes.*,reserved.vname, ".
636
	        "date_format(rsrv_time,\"%Y-%m-%d&nbsp;%T\") as rsrvtime ".
637
638
639
	        "FROM nodes LEFT JOIN reserved ".
	        "ON nodes.node_id=reserved.node_id ".
	        "WHERE reserved.eid=\"$eid\" and reserved.pid=\"$pid\" ".
640
	        "ORDER BY type,priority");
641
642
643

	while ($row = mysql_fetch_array($query_result)) {
	    $node_id = $row[node_id];
644
	    $vname   = $row[$vnamefield];
645
	    $type    = $row[type];
646
	    $def_boot_osid      = $row[def_boot_osid];
647
648
649
650
651
652
	    $def_boot_path      = $row[def_boot_path];
	    $def_boot_cmd_line  = $row[def_boot_cmd_line];
	    $next_boot_path     = $row[next_boot_path];
	    $next_boot_cmd_line = $row[next_boot_cmd_line];
	    $startupcmd         = $row[startupcmd];
	    $startstatus        = $row[startstatus];
653
	    $readystatus        = $row[ready];
654
	    $bootstatus         = $row[bootstatus];
655
656
657
658
659
660
661
662
663
664
665
666
667

	    if (!$def_boot_cmd_line)
		$def_boot_cmd_line = "NULL";
	    if (!$def_boot_path)
		$def_boot_path = "NULL";
	    if (!$next_boot_path)
		$next_boot_path = "NULL";
	    if (!$next_boot_cmd_line)
		$next_boot_cmd_line = "NULL";
	    if (!$startupcmd)
		$startupcmd = "NULL";
	    if (!$vname)
		$vname = "--";
668
669
670
671
	    if ($readystatus)
		$readylabel = "Yes";
	    else
		$readylabel = "No";
672
673

	    echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
674
675
                    <td><A href='shownode.php3?node_id=$node_id'>$node_id</a>
                        </td>
676
                    <td>$vname</td>
677
                    <td>$type</td>\n";
678
679
680
681
682
	    if ($def_boot_osid) {
		echo "<td>";
		SPITOSINFOLINK($def_boot_osid);
		echo "</td>";
	    }
683
684
685
	    else
		echo "<td>&nbsp</td>\n";
	    
686
	    echo "  <td>$def_boot_path</td>
687
                    <td>$def_boot_cmd_line</td>
688
                    <td align=center>$bootstatus</td>
689
690
                    <td>$startupcmd</td>
                    <td align=center>$startstatus</td>
691
                    <td align=center>$readylabel</td>
692
                   </tr>\n";
693
694
	}
	echo "</table>\n";
695
696
697
698
	echo "<h4><blockquote><blockquote><blockquote>
              <ol>
                <li>Node has rebooted successfully after experiment creation.
                <li>Exit value of the node startup command. A value of
699
                        666 indicates a testbed internal error.
700
701
702
                <li>User application ready status, reported via TMCC.
              </ol>
              </blockquote></blockquote></blockquote></h4>\n";
703
704
705
    }
}

706
707
708
709
710
711
#
# Show OS INFO record.
#
function SHOWOSINFO($osid) {
    global $TBDBNAME;
		
712
713
    $query_result =
	DBQueryFatal("SELECT * FROM os_info WHERE osid='$osid'");
714
715
716

    $osrow = mysql_fetch_array($query_result);

Leigh B. Stoller's avatar
Leigh B. Stoller committed
717
    $os_description = stripslashes($osrow[description]);
718
719
720
721
722
723
    $os_OS          = $osrow[OS];
    $os_version     = $osrow[version];
    $os_path        = $osrow[path];
    $os_magic       = $osrow[magic];
    $os_osfeatures  = $osrow[osfeatures];
    $os_pid         = $osrow[pid];
724
725
    $os_shared      = $osrow[shared];
    $os_osname      = $osrow[osname];
726
727
    $creator        = $osrow[creator];
    $created        = $osrow[created];
728
    $mustclean      = $osrow[mustclean];
729
730
731
732
733
734
735
736
737
738
739

    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";
740
741
    if (!$created)
	$created = "N/A";
742
743
744
745
746
747
748

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

    echo "<tr>
749
750
751
752
753
754
755
            <td>Name: </td>
            <td class=\"left\">$os_osname</td>
          </tr>\n";

    echo "<tr>
            <td>Project: </td>
            <td class=\"left\">$os_pid</td>
756
757
          </tr>\n";

758
759
760
761
762
763
764
765
766
767
    echo "<tr>
            <td>Creator: </td>
            <td class=left>$creator</td>
 	  </tr>\n";

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

768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
    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>
794
795
            <td>Features: </td>
            <td class=\"left\">$os_osfeatures</td>
796
797
798
          </tr>\n";

    echo "<tr>
799
800
801
802
803
804
805
806
807
808
809
            <td>Shared?: </td>
            <td class=left>\n";

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

810
811
812
813
814
815
816
817
818
819
820
821
    echo "<tr>
            <td>Must Clean?: </td>
            <td class=left>\n";

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

822
823
824
    echo "<tr>
            <td>Internal ID: </td>
            <td class=\"left\">$osid</td>
825
826
827
828
829
          </tr>\n";

    echo "</table>\n";
}

830
831
832
833
834
835
#
# Show ImageID record.
#
function SHOWIMAGEID($imageid, $edit) {
    global $TBDBNAME;
		
836
837
    $query_result =
	DBQueryFatal("select * from images where imageid='$imageid'");
838
839
840

    $row = mysql_fetch_array($query_result);

841
842
    $imagename   = $row[imagename];
    $pid         = $row[pid];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
843
    $description = stripslashes($row[description]);
844
845
846
847
848
849
850
851
852
    $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];
853
    $shared	 = $row[shared];
854
855
    $creator     = $row[creator];
    $created     = $row[created];
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871

    if ($edit) {
	if (!$description)
	    $description = "";
	if (!$path)
	    $path = "";
	if (!$loadaddr)
	    $loadaddr = "";
    }
    else {
	if (!$description)
	    $description = "&nbsp";
	if (!$path)
	    $path = "&nbsp";
	if (!$loadaddr)
	    $loadaddr = "&nbsp";
872
873
	if (!$created)
	    $created = "N/A";
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
    }
    
    #
    # 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>
889
890
891
892
893
894
895
            <td>Image Name: </td>
            <td class=\"left\">$imagename</td>
          </tr>\n";

    echo "<tr>
            <td>Project: </td>
            <td class=\"left\">$pid</td>
896
          </tr>\n";
897
898
899
900
901
902
903
904
905
906

    echo "<tr>
            <td>Creator: </td>
            <td class=left>$creator</td>
 	  </tr>\n";

    echo "<tr>
            <td>Created: </td>
            <td class=left>$created</td>
 	  </tr>\n";
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933

    echo "<tr>
            <td>Description: </td>
            <td class=left>\n";

    if ($edit) {
	echo "<input type=text name=description size=60
                     maxlength=256 value='$description'>";
    }
    else {
	echo "$description";
    }
    echo "   </td>
 	  </tr>\n";

    echo "<tr>
            <td>Load Partition: </td>
            <td class=\"left\">$loadpart</td>
          </tr>\n";

    echo "<tr>
            <td>Load Length: </td>
            <td class=\"left\">$loadlength</td>
          </tr>\n";

    if ($part1_osid) {
	echo "<tr>
934
935
936
937
                 <td>Partition 1 OS: </td>
                 <td class=\"left\">";
	SPITOSINFOLINK($part1_osid);
	echo "   </td>
938
939
940
941
942
              </tr>\n";
    }

    if ($part2_osid) {
	echo "<tr>
943
944
945
946
                 <td>Partition 2 OS: </td>
                 <td class=\"left\">";
	SPITOSINFOLINK($part2_osid);
	echo "   </td>
947
948
949
950
951
              </tr>\n";
    }

    if ($part3_osid) {
	echo "<tr>
952
953
954
955
                 <td>Partition 3 OS: </td>
                 <td class=\"left\">";
	SPITOSINFOLINK($part3_osid);
	echo "   </td>
956
957
958
959
960
              </tr>\n";
    }

    if ($part4_osid) {
	echo "<tr>
961
962
963
964
                 <td>Partition 4 OS: </td>
                 <td class=\"left\">";
	SPITOSINFOLINK($part4_osid);
	echo "   </td>
965
966
967
968
969
              </tr>\n";
    }

    if ($default_osid) {
	echo "<tr>
970
971
972
973
                 <td>Boot OS: </td>
                 <td class=\"left\">";
	SPITOSINFOLINK($default_osid);
	echo "   </td>
974
975
976
977
              </tr>\n";
    }

    echo "<tr>
978
            <td>Filename: </td>
979
980
981
982
983
984
985
986
987
988
989
990
            <td class=left>\n";

    if ($edit) {
	echo "<input type=text name=path size=60
                     maxlength=256 value='$path'>";
    }
    else {
	echo "$path";
    }
    echo "  </td>
          </tr>\n";

991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
    if (! $edit) {
	echo "<tr>
                  <td>Types: </td>
                  <td class=left>\n";

	$types_result =
	    DBQueryFatal("select distinct type from osidtoimageid ".
			 "where imageid='$imageid'");

	if (mysql_num_rows($types_result)) {
	    while ($row = mysql_fetch_array($types_result)) {
		$type = $row[type];
		echo "$type &nbsp ";
	    }
	}
	else {
	    echo "&nbsp";
	}
	echo "  </td>
              </tr>\n";
    }

    echo "<tr>
            <td>Shared?: </td>
            <td class=left>\n";

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

    echo "<tr>
            <td>Internal ID: </td>
            <td class=left>$imageid</td>
          </tr>\n";

1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
    echo "<tr>
            <td>Load Address: </td>
            <td class=left>\n";

    if ($edit) {
	echo "<input type=text name=loadaddr size=20
                     maxlength=256 value='$loadaddr'>";
    }
    else {
	echo "$loadaddr";
    }
    echo "  </td>
          </tr>\n";

    if ($edit) {
	echo "<tr>
                 <td colspan=2 align=center>
                     <b><input type=submit value=Submit></b>
                 </td>
              </tr>
              </form>\n";
    }

    echo "</table>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
1056
1057
1058
1059
1060
#
# Show node record.
#
function SHOWNODE($node_id) {
    $query_result =
1061
	DBQueryFatal("select n.*,r.vname,r.pid,r.eid from nodes as n ".
1062
1063
		     "left join reserved as r on n.node_id=r.node_id ".
		     "where n.node_id='$node_id'");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1064
1065
1066
1067
1068
1069
1070
1071
    
    if (mysql_num_rows($query_result) == 0) {
	TBERROR("The node $node_id is not a valid nodeid!", 1);
    }
		
    $row = mysql_fetch_array($query_result);

    $node_id            = $row[node_id]; 
1072
    $phys_nodeid        = $row[phys_nodeid]; 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1073
    $type               = $row[type];
1074
    $vname		= $row[vname];
1075
1076
    $pid 		= $row[pid];
    $eid		= $row[eid];
1077
    $bios               = $row[bios_version];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1078
1079
1080
1081
1082
1083
1084
1085
1086
    $def_boot_osid      = $row[def_boot_osid];
    $def_boot_path      = $row[def_boot_path];
    $def_boot_cmd_line  = $row[def_boot_cmd_line];
    $next_boot_osid     = $row[next_boot_osid];
    $next_boot_path     = $row[next_boot_path];
    $next_boot_cmd_line = $row[next_boot_cmd_line];
    $rpms               = $row[rpms];
    $tarballs           = $row[tarballs];
    $startupcmd         = $row[startupcmd];
1087
    $routertype         = $row[routertype];
1088
1089
1090
1091
    $eventstate         = $row[eventstate];
    $state_timestamp    = $row[state_timestamp];
    $op_mode            = $row[op_mode];
    $op_mode_timestamp  = $row[op_mode_timestamp];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106

    if (!$def_boot_cmd_line)
	$def_boot_cmd_line = "&nbsp";
    if (!$def_boot_path)
	$def_boot_path = "&nbsp";
    if (!$next_boot_path)
	$next_boot_path = "&nbsp";
    if (!$next_boot_cmd_line)
	$next_boot_cmd_line = "&nbsp";
    if (!$rpms)
	$rpms = "&nbsp";
    if (!$tarballs)
	$tarballs = "&nbsp";
    if (!$startupcmd)
	$startupcmd = "&nbsp";
1107
1108
    if (!$bios)
	$bios = "&nbsp";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1109
1110
1111
1112
1113
1114
1115

    echo "<table border=2 cellpadding=0 cellspacing=2
                 align=center>\n";

    echo "<tr>
              <td>Node ID:</td>
              <td class=left>$node_id</td>
1116
1117
          </tr>\n";

1118
1119
1120
1121
1122
1123
1124
1125
1126
    if (strcmp($node_id, $phys_nodeid)) {
	echo "<tr>
                  <td>Phys ID:</td>
                  <td class=left>
		      <A href='shownode.php3?node_id=$phys_nodeid'>
                         $phys_nodeid</a></td>
              </tr>\n";
    }

1127
1128
1129
1130
1131
1132
    if ($vname) {
	echo "<tr>
                  <td>Virtual Name:</td>
                  <td class=left>$vname</td>
              </tr>\n";
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1133

1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
    if ($pid) {
	echo "<tr>
                <td>Project: </td>
                <td class=\"left\">
                    <A href='showproject.php3?pid=$pid'>$pid</td>
              </tr>\n";

	echo "<tr>
                  <td>Experiment:</td>
                  <td><A href='showexp.php3?pid=$pid&eid=$eid'>$eid</A></td>
               </tr>\n";
    }

Leigh B. Stoller's avatar
Leigh B. Stoller committed
1147
1148
1149
1150
1151
    echo "<tr>
              <td>Node Type:</td>
              <td class=left>$type</td>
          </tr>\n";

1152
1153
1154
1155
1156
    echo "<tr>
              <td>Bios Version:</td>
              <td class=left>$bios</td>
          </tr>\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
1157
    echo "<tr>
1158
1159
1160
1161
              <td>Def Boot OS:</td>
              <td class=left>";
    SPITOSINFOLINK($def_boot_osid);
    echo "    </td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
          </tr>\n";

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

    echo "<tr>
              <td>Def Boot Command Line:</td>
              <td class=left>$def_boot_cmd_line</td>
          </tr>\n";

    echo "<tr>
1175
1176
1177
1178
1179
1180
1181
1182
1183
              <td>Next Boot OS:</td>
              <td class=left>";
    
    if ($next_boot_osid)
	SPITOSINFOLINK($next_boot_osid);
    else
	echo "&nbsp";

    echo "    </td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
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
1210
          </tr>\n";

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

    echo "<tr>
              <td>Next Boot Command Line:</td>
              <td class=left>$next_boot_cmd_line</td>
          </tr>\n";

    echo "<tr>
              <td>Startup Command:</td>
              <td class=left>$startupcmd</td>
          </tr>\n";

    echo "<tr>
              <td>RPMs:</td>
              <td class=left>$rpms</td>
          </tr>\n";

    echo "<tr>
              <td>Tarballs:</td>
              <td class=left>$tarballs</td>
      </tr>\n";

1211
1212
1213
1214
1215
    echo "<tr>
              <td>Router Type:</td>
              <td class=left>$routertype</td>
      </tr>\n";

1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
    if ($eventstate) {
	$when = strftime("20%y-%m-%d %H:%M:%S", $state_timestamp);
	echo "<tr>
                 <td>EventState:</td>
                 <td class=left>$eventstate ($when)</td>
              </tr>\n";
    }

    if ($op_mode) {
	$when = strftime("20%y%m%d-%H:%M:%S", $op_mode_timestamp);
	echo "<tr>
                 <td>Operating Mode:</td>
                 <td class=left>$op_mode ($when)</td>
              </tr>\n";
    }

1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
    #
    # We want the last login for this node, but only if its *after* the
    # experiment was created (or swapped in).
    #
    if ($lastnodeuidlogin = TBNodeUidLastLogin($node_id)) {

	$foo = $lastnodeuidlogin["date"] . " " .
	       $lastnodeuidlogin["time"] . " " .
	       "(" . $lastnodeuidlogin["uid"] . ")";
	
	echo "<tr>
                  <td>Last Login:</td>
                  <td class=left>$foo</td>
             </tr>\n";
    }

Leigh B. Stoller's avatar
Leigh B. Stoller committed
1248
1249
1250
    echo "</table>\n";
}

1251
#
1252
# Show log.
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
# 
function SHOWNODELOG($node_id)
{
    $query_result =
	DBQueryFatal("select * from nodelog where node_id='$node_id'".
		     "order by reported");

    if (! mysql_num_rows($query_result)) {
	echo "<br>
              <center>
               There are no entries in the log for node $node_id.
              </center>\n";

	return;
    }

    echo "<br>
          <center>
            Log for node $node_id.
          </center><br>\n";

    echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";

    echo "<tr>
1277
             <td align=center>Delete?</td>
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
             <td align=center>Date</td>
             <td align=center>ID</td>
             <td align=center>Type</td>
             <td align=center>Reporter</td>
             <td align=center>Entry</td>
          </tr>\n";

    while ($row = mysql_fetch_array($query_result)) {
	$type       = $row[type];
	$log_id     = $row[log_id];
	$reporter   = $row[reporting_uid];
	$date       = $row[reported];
1290
	$entry      = stripslashes($row[entry]);
1291
1292

	echo "<tr>
1293
1294
1295
 	         <td align=center>
                  <A href='deletenodelog.php3?node_id=$node_id&log_id=$log_id'>
                     <img alt='o' src='redball.gif'></A></td>
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
                 <td>$date</td>
                 <td>$log_id</td>
                 <td>$type</td>
                 <td>$reporter</td>
                 <td>$entry</td>
              </tr>\n";
    }
    echo "</table>\n";
}

1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
#
# Show one log entry.
# 
function SHOWNODELOGENTRY($node_id, $log_id)
{
    $query_result =
	DBQueryFatal("select * from nodelog where ".
		     "node_id='$node_id' and log_id=$log_id");

    if (! mysql_num_rows($query_result)) {
	return;
    }

    echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";

    $row = mysql_fetch_array($query_result);
    
    $type       = $row[type];
    $log_id     = $row[log_id];
    $reporter   = $row[reporting_uid];
    $date       = $row[reported];
1327
    $entry      = stripslashes($row[entry]);
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338

    echo "<tr>
             <td>$date</td>
             <td>$log_id</td>
             <td>$type</td>
             <td>$reporter</td>
             <td>$entry</td>
          </tr>\n";
    echo "</table>\n";
}

1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
#
# Spit out an OSID link in user format.
#
function SPITOSINFOLINK($osid)
{
    if (! TBOSInfo($osid, $osname, $pid))
	return;
    
    echo "<A href='showosinfo.php3?osid=$osid'>$osname</A>\n";
}

1350
1351
1352
1353
#
# This is an included file.
# 
?>