Commit d736629e authored by Robert Ricci's avatar Robert Ricci
Browse files

Add an 'identifier' to the new_nodes table, and add support for

passing this to the newnode client, web page, and viewing and
editing it.
parent 74ff641f
...@@ -31,6 +31,18 @@ my $ifconfig = "/sbin/ifconfig"; ...@@ -31,6 +31,18 @@ my $ifconfig = "/sbin/ifconfig";
my $dmesg = "/var/run/dmesg.boot"; my $dmesg = "/var/run/dmesg.boot";
my $teachswitch = "$prefix/teachswitch"; my $teachswitch = "$prefix/teachswitch";
#
# Accept an identifier, an opaque string to report to the web interface
#
my $identifier;
if (@ARGV) {
if (@ARGV == 1) {
$identifier = shift @ARGV;
} else {
die "Usage: $0 [identifier]";
}
}
# #
# Find out what our boss node was, so we don't have to hardcode it here # Find out what our boss node was, so we don't have to hardcode it here
# #
...@@ -159,6 +171,9 @@ my $URL = "http://$bossnode/$formURL?"; ...@@ -159,6 +171,9 @@ my $URL = "http://$bossnode/$formURL?";
$URL .= "cpuspeed=" . urlencode($speed); $URL .= "cpuspeed=" . urlencode($speed);
$URL .= "&diskdev=" . urlencode($diskdev); $URL .= "&diskdev=" . urlencode($diskdev);
$URL .= "&disksize=" . urlencode($disksize); $URL .= "&disksize=" . urlencode($disksize);
if ($identifier) {
$URL .= "&identifier=". urlencode($identifier);
}
my $ifaceindex = 0; my $ifaceindex = 0;
foreach my $aref (@ifaces) { foreach my $aref (@ifaces) {
......
...@@ -666,6 +666,7 @@ CREATE TABLE new_nodes ( ...@@ -666,6 +666,7 @@ CREATE TABLE new_nodes (
temporary_IP varchar(15) default NULL, temporary_IP varchar(15) default NULL,
dmesg text, dmesg text,
created timestamp(14) NOT NULL, created timestamp(14) NOT NULL,
identifier varchar(255) default NULL,
PRIMARY KEY (new_node_id) PRIMARY KEY (new_node_id)
) TYPE=MyISAM; ) TYPE=MyISAM;
......
...@@ -1552,3 +1552,8 @@ last_net_act,last_cpu_act,last_ext_act); ...@@ -1552,3 +1552,8 @@ last_net_act,last_cpu_act,last_ext_act);
alter table experiments add column useprepass tinyint(1) \ alter table experiments add column useprepass tinyint(1) \
default 0 not null; default 0 not null;
1.248: Add an 'identifier' column to the new_nodes table to give users a
way to figure out which new node is which.
alter table new_nodes add column identifier varchar(255);
...@@ -36,7 +36,7 @@ if (!$id) { ...@@ -36,7 +36,7 @@ if (!$id) {
# #
if ($node_id) { if ($node_id) {
DBQueryFatal("UPDATE new_nodes SET node_id='$node_id', type='$type', " . DBQueryFatal("UPDATE new_nodes SET node_id='$node_id', type='$type', " .
"IP='$IP' WHERE new_node_id='$id'"); "IP='$IP', identifier='$identifier' WHERE new_node_id='$id'");
} }
# #
...@@ -64,7 +64,8 @@ foreach ($HTTP_GET_VARS as $key => $value) { ...@@ -64,7 +64,8 @@ foreach ($HTTP_GET_VARS as $key => $value) {
# Get the information about the node they asked for # Get the information about the node they asked for
# #
$query_result = DBQueryFatal("SELECT new_node_id, node_id, type, IP, " . $query_result = DBQueryFatal("SELECT new_node_id, node_id, type, IP, " .
"DATE_FORMAT(created,'%M %e %H:%i:%s') as created, dmesg " . "DATE_FORMAT(created,'%M %e %H:%i:%s') as created, dmesg, " .
"identifier " .
"FROM new_nodes WHERE new_node_id='$id'"); "FROM new_nodes WHERE new_node_id='$id'");
if (mysql_num_rows($query_result) != 1) { if (mysql_num_rows($query_result) != 1) {
...@@ -94,6 +95,12 @@ $row = mysql_fetch_array($query_result) ...@@ -94,6 +95,12 @@ $row = mysql_fetch_array($query_result)
<input type="text" width=10 name="node_id" value="<?=$row['node_id']?>"> <input type="text" width=10 name="node_id" value="<?=$row['node_id']?>">
</td> </td>
</tr> </tr>
<tr>
<th>Identifier</th>
<td>
<input type="text" width=10 name="identifier" value="<?=$row['identifier']?>">
</td>
</tr>
<tr> <tr>
<th>Type</th> <th>Type</th>
<td> <td>
......
...@@ -112,8 +112,14 @@ $type = guess_node_type($cpuspeed,$disksize); ...@@ -112,8 +112,14 @@ $type = guess_node_type($cpuspeed,$disksize);
# #
# Stash this information in the database # Stash this information in the database
# #
if ($identifier) {
$identifier = "'$identifier'";
} else {
$identifier = "NULL";
}
DBQueryFatal("insert into new_nodes set node_id='$hostname', type='$type', " . DBQueryFatal("insert into new_nodes set node_id='$hostname', type='$type', " .
"IP='$IP', temporary_IP='$tmpIP', dmesg='$messages', created=now()"); "IP='$IP', temporary_IP='$tmpIP', dmesg='$messages', created=now(), " .
"identifier=$identifier");
$query_result = DBQueryFatal("select last_insert_id()"); $query_result = DBQueryFatal("select last_insert_id()");
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
......
...@@ -251,7 +251,8 @@ if ($renumber) { ...@@ -251,7 +251,8 @@ if ($renumber) {
# #
$query_result = DBQueryFatal("SELECT n.new_node_id, node_id, n.type, IP, " . $query_result = DBQueryFatal("SELECT n.new_node_id, node_id, n.type, IP, " .
"DATE_FORMAT(created,'%M %e %H:%i:%s') as created, i.MAC, " . "DATE_FORMAT(created,'%M %e %H:%i:%s') as created, i.MAC, " .
"i.switch_id, i.switch_card, i.switch_port, n.temporary_IP, n.dmesg " . "i.switch_id, i.switch_card, i.switch_port, n.temporary_IP, n.dmesg, " .
"n.identifier " .
"FROM new_nodes AS n " . "FROM new_nodes AS n " .
"LEFT JOIN node_types AS t on n.type=t.type " . "LEFT JOIN node_types AS t on n.type=t.type " .
"LEFT JOIN new_interfaces AS i ON n.new_node_id=i.new_node_id " . "LEFT JOIN new_interfaces AS i ON n.new_node_id=i.new_node_id " .
...@@ -283,6 +284,7 @@ function deselectAll(form) { ...@@ -283,6 +284,7 @@ function deselectAll(form) {
<th></th> <th></th>
<th>ID</th> <th>ID</th>
<th>Node ID</th> <th>Node ID</th>
<th>Identifier</th>
<th>Type</th> <th>Type</th>
<th>IP</th> <th>IP</th>
<th>Control MAC</th> <th>Control MAC</th>
...@@ -304,6 +306,7 @@ while ($row = mysql_fetch_array($query_result)) { ...@@ -304,6 +306,7 @@ while ($row = mysql_fetch_array($query_result)) {
$mac = $row["MAC"]; $mac = $row["MAC"];
$tempIP = $row["temporary_IP"]; $tempIP = $row["temporary_IP"];
$dmesg = $row["dmesg"]; $dmesg = $row["dmesg"];
$identifier = $row["identifier"];
if ($row["switch_id"]) { if ($row["switch_id"]) {
$port = "$row[switch_id].$row[switch_card]/$row[switch_port]"; $port = "$row[switch_id].$row[switch_card]/$row[switch_port]";
} else { } else {
...@@ -321,6 +324,7 @@ while ($row = mysql_fetch_array($query_result)) { ...@@ -321,6 +324,7 @@ while ($row = mysql_fetch_array($query_result)) {
"value='$id' $checked></td>\n"; "value='$id' $checked></td>\n";
echo " <td><a href=\"newnode_edit.php3?id=$id\">$id</a></td>\n"; echo " <td><a href=\"newnode_edit.php3?id=$id\">$id</a></td>\n";
echo " <td>$node_id</td>\n"; echo " <td>$node_id</td>\n";
echo " <td>$identifier</td>\n";
echo " <td>$type</td>\n"; echo " <td>$type</td>\n";
echo " <td>$IP</td>\n"; echo " <td>$IP</td>\n";
echo " <td>$mac</td>\n"; echo " <td>$mac</td>\n";
...@@ -339,7 +343,7 @@ while ($row = mysql_fetch_array($query_result)) { ...@@ -339,7 +343,7 @@ while ($row = mysql_fetch_array($query_result)) {
?> ?>
<tr> <tr>
<td align="center" colspan=11> <td align="center" colspan=12>
<input type="button" name="SelectAll" value="Select All" <input type="button" name="SelectAll" value="Select All"
onClick="selectAll(document.nodeform.elements['selected[]'])"> onClick="selectAll(document.nodeform.elements['selected[]'])">
&nbsp; &nbsp;
......
...@@ -568,7 +568,7 @@ function SHOWUSER($uid) { ...@@ -568,7 +568,7 @@ function SHOWUSER($uid) {
# #
# Show an experiment. # Show an experiment.
# #
function SHOWEXP($pid, $eid, $short = 0) { function SHOWEXP($pid, $eid, $short = 0, $sortby = "") {
global $TBDBNAME, $TBDOCBASE; global $TBDBNAME, $TBDOCBASE;
$nodecounts = array(); $nodecounts = array();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment