shownodetype.php3 4 KB
Newer Older
1
2
3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
5
6
7
# All rights reserved.
#
include("defs.php3");
8
include("imageid_defs.php");
9
10
11
12
13
14
15
16
17

#
# Standard Testbed Header
#
PAGEHEADER("Node Type Information");

#
# Anyone can access this info, its a PUBLIC PAGE!
#
18
$reqargs = RequiredPageArguments("node_type", PAGEARG_STRING);
19

Leigh B. Stoller's avatar
Leigh B. Stoller committed
20
21
22
23
# Sanitize.
if (!preg_match("/^[-\w]+$/", $node_type)) {
    PAGEARGERROR("Invalid characters in arguments.");
}
24
25
26
27
28
29

$query_result =
    DBQueryFatal("select * from node_types ".
		 "where type='$node_type'");

if (! mysql_num_rows($query_result) != 0) {
30
    USERERROR("No such node_type $node_type!", 1);
31
32
33
34
}
$noderow = mysql_fetch_assoc($query_result);

echo "<font size=+2>".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
35
36
     "Node Type <b>$node_type</b>".
     "</font>\n";
37
38
39
40

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

41
# Stuff from the node types table.
42
43
44
45
$class		= $noderow["class"];
$isvirtnode	= $noderow["isvirtnode"];
$isremotenode	= $noderow["isremotenode"];

46
47
48
49
# Grab the attributes for the type.
$query_result = DBQueryFatal("select * from node_type_attributes ".
			     "where type='$node_type' ".
			     "order by attrkey");
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

echo "<tr>
      <td>Type:</td>
      <td class=left>$node_type</td>
          </tr>\n";

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

if ($isremotenode) {
    echo "<tr>
          <td>Remote:</td>
          <td class=left>Yes</td>
              </tr>\n";
}

if ($isvirtnode) {
    echo "<tr>
          <td>Virtual:</td>
          <td class=left>Yes</td>
              </tr>\n";
}

75
76
77
78
79
80
81
82
83
84
85
#
# And now all of the attributes ...
#
while ($row = mysql_fetch_array($query_result)) {
    $key      = $row["attrkey"];
    $val      = $row["attrvalue"];
    $attrtype = $row["attrtype"];

    if ($key == "default_osid" ||
	$key == "jail_osid" ||
	$key == "delay_osid") {
86
87
88
	if ($osinfo = OSinfo::Lookup($val)) {
	    $val = $osinfo->osname();
	}
89
90
    }
    elseif ($key == "default_imageid") {
91
92
93
	if ($image = Image::Lookup($val)) {
	    $val = $image->imagename();
	}
94
95
96
97
98
    }
    echo "<tr>\n";
    echo "<td>$key:</td>\n";
    echo "<td class=left>$val</td>\n";
    echo "</tr>\n";
99
}
100
101
echo "</table>\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
102
103
104
105
106
#
# Suck out info for all the nodes of this type. We are going to show
# just a list of dots, in two color mode.
# 
$query_result =
Timothy Stack's avatar
   
Timothy Stack committed
107
    DBQueryFatal("select n.node_id,n.eventstate,r.pid ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
108
109
110
111
112
113
114
115
116
117
118
		 "from nodes as n ".
		 "left join node_types as nt on n.type=nt.type ".
		 "left join reserved as r on n.node_id=r.node_id ".
		 "where nt.type='$node_type' and ".
		 "      (role='testnode' or role='virtnode') ".
		 "ORDER BY priority");


if (mysql_num_rows($query_result)) {
    echo "<br>
          <center>
119
120
	  Nodes (<a href=nodecontrol_list.php3?showtype=$node_type>Show details</a>)
	  <br>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
121
122
123
124
125
126
127
          <table class=nogrid cellspacing=0 border=0 cellpadding=5>\n";

    $maxcolumns = 4;
    $column     = 0;
    
    while ($row = mysql_fetch_array($query_result)) {
	$node_id = $row["node_id"];
Timothy Stack's avatar
   
Timothy Stack committed
128
	$es      = $row["eventstate"];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
129
130
131
132
133
134
135
136
137
138
	$pid     = $row["pid"];

	if ($column == 0) {
	    echo "<tr>\n";
	}
	$column++;

	echo "<td align=left><nobr>\n";

	if (!$pid) {
Timothy Stack's avatar
   
Timothy Stack committed
139
140
141
142
143
144
145
146
147
	    if (($es == TBDB_NODESTATE_ISUP) ||
		($es == TBDB_NODESTATE_ALWAYSUP) ||
		($es == TBDB_NODESTATE_POWEROFF) ||
		($es == TBDB_NODESTATE_PXEWAIT)) {
		echo "<img src=\"/autostatus-icons/greenball.gif\" alt=free>\n";
	    }
	    else {
		echo "<img src=\"/autostatus-icons/yellowball.gif\" alt='unusable free'>\n";
	    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
	}
	else {
	    echo "<img src=\"/autostatus-icons/redball.gif\" alt=reserved>\n";
	}
	echo "&nbsp;";
#	echo "<a href=shownode.php3?node_id=$node_id>";
	echo "$node_id";
#	echo "</a>";
	echo "</nobr>
              </td>\n";
	
	if ($column == $maxcolumns) {
	    echo "</tr>\n";
	    $column = 0;
	}
    }
    echo "</table>\n";
    echo "<br>
          <img src=\"/autostatus-icons/greenball.gif\" alt=free>&nbsp;Free
167
          &nbsp; &nbsp; &nbsp;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
168
169
170
171
          <img src=\"/autostatus-icons/redball.gif\" alt=free>&nbsp;Reserved
          </center>\n";
}

172
173
174
175
176
177
178
179
180
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>