Commit 39083d0e authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add widearea_updates table. A very simple mechanism to let Dave auto

update V3 nodes to V4 CDs, and the new image. By inserting an entry
into this table, the node will update its image the next time it
reboots and checks in for instructions. The actual instructions are
hardwired in the web still, but this allows Dave to schedule updates
as needed. Eventually, the instructions will be part of the DB state
as well, but this works.
parent 9589ccbc
......@@ -1637,6 +1637,18 @@ CREATE TABLE widearea_recent (
PRIMARY KEY (node_id1,iface1,node_id2,iface2)
) TYPE=MyISAM;
--
-- Table structure for table 'widearea_updates'
--
CREATE TABLE widearea_updates (
IP varchar(15) NOT NULL default '1.1.1.1',
roottag tinytext NOT NULL default '',
update_requested datetime NOT NULL default '0000-00-00 00:00:00',
update_started datetime default NULL,
PRIMARY KEY (IP)
) TYPE=MyISAM;
--
-- Table structure for table 'wires'
--
......
......@@ -644,3 +644,21 @@ last_net_act,last_cpu_act,last_ext_act);
alter table state_timeouts modify timeout int(11) not null;
alter table state_timeouts modify action mediumtext not null;
1.154: Add simple support for updating widearea images (slice 1 only).
CREATE TABLE widearea_updates (
IP varchar(15) NOT NULL default '1.1.1.1',
roottag tinytext NOT NULL default '',
update_requested datetime NOT NULL default '0000-00-00 00:00:00',
update_started datetime default NULL,
PRIMARY KEY (IP)
) TYPE=MyISAM;
The IP is of course the IP of the node you want to update.
The roottag is the MD5 of the new slice to be layed down,
which should also have a DB entry someplace, but I won't
bother with that now; I'll just hard code that into the web
page. The records are dynamic; someone like Dave will insert
them, and the web page will remove them after a node
sucessfully updates.
......@@ -15,6 +15,7 @@ define("CDROMSTATUS_BADPRIVKEY", 103);
define("CDROMSTATUS_BADIPADDR", 104);
define("CDROMSTATUS_BADREMOTEIP", 105);
define("CDROMSTATUS_IPADDRINUSE", 106);
define("CDROMSTATUS_UPGRADEERROR", 107);
define("CDROMSTATUS_OTHER", 199);
#
......@@ -192,16 +193,20 @@ if (isset($updated) && $updated == 1) {
"From: $TBMAIL_OPS\n".
"Errors-To: $TBMAIL_WWW");
}
$newroot = "";
if (isset($roottag)) {
$newroot = ",rootkey='$roottag'";
}
DBQueryFatal("update widearea_privkeys ".
"set privkey=nextprivkey,updated=now(),nextprivkey=NULL ".
" $newroot ".
(isset($roottag) ? ",rootkey='$roottag'" : "") .
"where privkey='$privkey'");
#
# Check for image upgrade completed. Delete record.
#
$query_result =
DBQueryFatal("delete from widearea_updates ".
"where IP='$IP' and roottag='$roottag' and " .
" update_started is not null");
#
# Update with new nickname. Nice if node changes its real hostname.
#
......@@ -226,37 +231,56 @@ if (strcmp($privIP, "1.1.1.1")) {
SPITSTATUS(CDROMSTATUS_BADIPADDR);
return;
}
if (strcmp($REMOTE_ADDR, $IP)) {
SPITSTATUS(CDROMSTATUS_BADREMOTEIP);
return;
}
$newroot = "";
if (isset($roottag)) {
$newroot = ",rootkey='$roottag'";
# if (strcmp($REMOTE_ADDR, $IP)) {
# SPITSTATUS(CDROMSTATUS_BADREMOTEIP);
# return;
# }
$upgrade_instructions = "";
#
# Check for image upgrade. Rather simplistic right now.
#
$query_result =
DBQueryFatal("select * from widearea_updates where IP='$IP'");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$newroot = $row["roottag"];
# Do not upgrade if the root tag already matches. ???
if (!isset($roottag) || strcmp($roottag, $newroot)) {
$update = 1;
DBQueryFatal("update widearea_updates set update_started=now() ".
"where IP='$IP'");
switch ($newroot) {
case "d326a1f604489c43b488fa80a88221f4":
$upgrade_instructions =
"slice1_image=slice1.ndz\n" .
"slice1_sig=slice1.ndz.sig\n" .
"slice1_md5=d326a1f604489c43b488fa80a88221f4";
break;
default:
SPITSTATUS(CDROMSTATUS_UPGRADEERROR);
break;
}
}
}
#
# For now we just give them a new privkey. There is no real image upgrade
# path in place yet.
# Generate a new privkey and stash in the DB. Always stash the root
# tag the node is running. If upgrading, it will be overwritten above
# when it completes. This helps to figure out where things went wrong.
#
$newkey = GENHASH();
DBQueryFatal("update widearea_privkeys ".
"set nextprivkey='$newkey',updated=now(),cdkey='$cdkey' ".
" $newroot ".
(isset($roottag) ? ",rootkey='$roottag'" : "") .
"where IP='$IP' and privkey='$privkey'");
header("Content-Type: text/plain");
echo "privkey=$newkey\n";
if (0 && $cdvers == 69) {
echo "slice1_image=http://${WWWHOST}/images/slice1-v4.ndz\n";
echo "slice1_md5=d10baf117e269e3faa9cf4ee5d089a7f\n";
echo "slice1_sig=https://${WWWHOST}/images/slice1-v4.ndz.sig\n";
# echo "slicex_slice=3\n";
# echo "slicex_mount=/users\n";
# echo "slicex_tarball=http://${WWWHOST}/images/slicex-v4.tar.gz\n";
# echo "slicex_sig=https://${WWWHOST}/images/slicex-v4.tar.gz.sig\n";
}
echo "$upgrade_instructions\n";
echo "emulab_status=0\n";
return;
......
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