newnode_edit.php3 4.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?PHP
#
# EMULAB-COPYRIGHT
# Copyright (c) 2003 University of Utah and the Flux Group.
# All rights reserved.
#
require("defs.php3");

#
# List the nodes that have checked in and are awaint being added the the real
# testbed
#

#
# Standard Testbed Header
#
PAGEHEADER("New Testbed Node");

#
# Only admins can see this page
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    USERERROR("You do not have admin privileges!", 1);
}


if (!$id) {
    USERERROR("Must specify a node ID!",1);
}

#
# If we had any update information passed to us, do the update now
#
if ($node_id) {
    DBQueryFatal("UPDATE new_nodes SET node_id='$node_id', type='$type', " .
    	"IP='$IP' WHERE new_node_id='$id'");
}

#
# Same for interface update information
#
foreach ($HTTP_GET_VARS as $key => $value) {
46
47
48
49
50
51
52
    if (preg_match("/iface(\d+)_mac/",$key,$matches)) {
    	$card        = $matches[1];
    	$mac         = $HTTP_GET_VARS["iface${card}_mac"];
    	$type        = $HTTP_GET_VARS["iface${card}_type"];
    	$switch_id   = $HTTP_GET_VARS["iface${card}_switch_id"];
    	$switch_card = $HTTP_GET_VARS["iface${card}_switch_card"];
    	$switch_port = $HTTP_GET_VARS["iface${card}_switch_port"];
53
54
    	$cable       = $HTTP_GET_VARS["iface${card}_cable"];
    	$len         = $HTTP_GET_VARS["iface${card}_len"];
55
56
    	DBQueryFatal("UPDATE new_interfaces SET mac='$mac', " .
	    "interface_type='$type', switch_id='$switch_id', " .
57
58
	    "switch_card='$switch_card', switch_port='$switch_port', " .
	    "cable='$cable', len=$len " .
59
	    "WHERE new_node_id=$id AND card='$card'");
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
116
117
118
119
120
    }
}

#
# Get the information about the node they asked for
#
$query_result = DBQueryFatal("SELECT new_node_id, node_id, type, IP, " .
	"DATE_FORMAT(created,'%M %e %H:%i:%s') as created, dmesg " .
	"FROM new_nodes WHERE new_node_id='$id'");

if (mysql_num_rows($query_result) != 1) {
    USERERROR("Error getting information for node ID $id",1);
}

$row = mysql_fetch_array($query_result)

?>

<h4><a href="newnodes_list.php3">Back to the new node list</a></h4>

<form action="newnode_edit.php3" method="get">

<input type="hidden" name="id" value="<?=$id?>">

<h3 align="center">Node</h3>

<table align="center">
<tr>
    <th>ID</th>
    <td><?= $row['new_node_id'] ?></td>
</tr>
<tr>
    <th>Node ID</th>
    <td>
    <input type="text" width=10 name="node_id" value="<?=$row['node_id']?>">
    </td>
</tr>
<tr>
    <th>Type</th>
    <td>
    <input type="text" width=10 name="type" value="<?=$row['type']?>">
    </td>
</tr>
<tr>
    <th>IP</th>
    <td>
    <input type="text" width=10 name="IP" value="<?=$row['IP']?>">
    </td>
</tr>
<tr>
    <th>Created</th>
    <td><?= $row['created'] ?></td>
</tr>
<tr>
    <th>dmesg Output</th>
    <td><?= $row['dmesg'] ?></td>
</tr>
</table>

<h3 align="center">Interfaces</h3>

121
122
<em>Note:</em>Cable and Length are for informational use only, and are optional.

123
124
125
126
127
128
129
130
<table align="center">
<tr>
    <th>Interface</th>
    <th>MAC</th>
    <th>Type</th>
    <th>Switch</th>
    <th>Card</th>
    <th>Port</th>
131
132
    <th>Cable</th>
    <th>Length</th>
133
134
135
136
</tr>

<?

137
$query_result = DBQueryFatal("SELECT card, mac, interface_type, switch_id, " .
138
139
	"switch_card, switch_port, cable, len FROM new_interfaces " .
	"where new_node_id=$id");
140
while ($row = mysql_fetch_array($query_result)) {
141
    $card        = $row['card'];
142
143
144
145
146
    $mac         = $row['mac'];
    $type        = $row['interface_type'];
    $switch_id   = $row['switch_id'];
    $switch_card = $row['switch_card'];
    $switch_port = $row['switch_port'];
147
148
    $cable       = $row['cable'];
    $len         = $row['len'];
149
    echo "<tr>\n";
150
151
    echo "<td>$card</td>\n";
    echo "<td><input type='text' name='iface${card}_mac' size=12 " .
152
	"value='$mac'></td>\n";
153
    echo "<td><input type='text' name='iface${card}_type' size=5 " .
154
	"value='$type'></td>\n";
155
    echo "<td><input type='text' name='iface${card}_switch_id' size=10 " .
156
	"value='$switch_id'></td>\n";
157
    echo "<td><input type='text' name='iface${card}_switch_card' size=3 " .
158
	"value='$switch_card'></td>\n";
159
    echo "<td><input type='text' name='iface${card}_switch_port' size=3 " .
160
	"value='$switch_port'></td>\n";
161
162
163
164
    echo "<td><input type='text' name='iface${card}_cable' size=5 " .
	"value='$cable'></td>\n";
    echo "<td><input type='text' name='iface${card}_len' size=3 " .
	"value='$len'></td>\n";
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    echo "</tr>\n";
}

?>

</table>

<br>

<center>
<input type="submit" name="submit" value="Update node">
</center>

<?

#
# Standard Testbed Footer
# 
PAGEFOOTER();

?>