newnode_edit.php3 3.9 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 55
    	DBQueryFatal("UPDATE new_interfaces SET mac='$mac', " .
	    "interface_type='$type', switch_id='$switch_id', " .
	    "switch_card='$switch_card', switch_port='$switch_port' " .
56
	    "WHERE new_node_id=$id AND card='$card'");
57 58 59 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 121 122 123 124 125 126 127 128 129
    }
}

#
# 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>

<table align="center">
<tr>
    <th>Interface</th>
    <th>MAC</th>
    <th>Type</th>
    <th>Switch</th>
    <th>Card</th>
    <th>Port</th>
</tr>

<?

130
$query_result = DBQueryFatal("SELECT card, mac, interface_type, switch_id, " .
131 132
	"switch_card, switch_port FROM new_interfaces where new_node_id=$id");
while ($row = mysql_fetch_array($query_result)) {
133
    $card        = $row['card'];
134 135 136 137 138 139
    $mac         = $row['mac'];
    $type        = $row['interface_type'];
    $switch_id   = $row['switch_id'];
    $switch_card = $row['switch_card'];
    $switch_port = $row['switch_port'];
    echo "<tr>\n";
140 141
    echo "<td>$card</td>\n";
    echo "<td><input type='text' name='iface${card}_mac' size=12 " .
142
	"value='$mac'></td>\n";
143
    echo "<td><input type='text' name='iface${card}_type' size=5 " .
144
	"value='$type'></td>\n";
145
    echo "<td><input type='text' name='iface${card}_switch_id' size=10 " .
146
	"value='$switch_id'></td>\n";
147
    echo "<td><input type='text' name='iface${card}_switch_card' size=3 " .
148
	"value='$switch_card'></td>\n";
149
    echo "<td><input type='text' name='iface${card}_switch_port' size=3 " .
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
	"value='$switch_port'></td>\n";
    echo "</tr>\n";
}

?>

</table>

<br>

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

<?

#
# Standard Testbed Footer
# 
PAGEFOOTER();

?>