Commit 0af2a08d authored by Leigh Stoller's avatar Leigh Stoller

Long delayed fix to apt_instances, apt_instance_history, and

apt_instance_failures; instead of using the hostname (servername) to
determine the portal indirectly, store the actual portal like we do for
other tables. This makes for easier mysql queries.
parent a9a46b80
......@@ -710,7 +710,7 @@ sub RecordHistory($$)
" created,start_at,started,stop_at,now(),$expired, ".
" extension_count,extension_days,extension_hours, ".
" physnode_count,virtnode_count, ".
" servername,repourl,reponame,reporef,repohash, ".
" servername,portal,repourl,reponame,reporef,repohash, ".
" rspec,script,params,manifest ".
" from apt_instances where uuid='$uuid'")
or return -1;
......@@ -729,7 +729,7 @@ sub RecordError($$$)
" creator,creator_idx,creator_uuid,pid,pid_idx, ".
" gid,gid_idx, ".
" created,start_at,started,stop_at,'$exitcode', ".
" $safe_message,public_url,logfileid ".
" $safe_message,public_url,logfileid,portal ".
" from apt_instances where uuid='$uuid'")
or return -1;
......
......@@ -876,6 +876,7 @@ my $blob = {'uuid' => $quickvm_uuid,
'start_at' => $start_at,
'stop_at' => $stop_at,
'servername' => $SERVER_NAME,
'portal' => $portal,
'rspec' => $rspecstr,
'cert' => $alt_certificate->cert(),
'privkey' => $alt_certificate->PrivKeyDelimited(),
......
......@@ -352,6 +352,7 @@ CREATE TABLE `apt_instance_failures` (
`exitmessage` mediumtext,
`public_url` tinytext,
`logfileid` varchar(40) default NULL,
`portal` enum('emulab','aptlab','cloudlab','phantomnet','powder') default NULL,
PRIMARY KEY (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -388,6 +389,7 @@ CREATE TABLE `apt_instance_history` (
`physnode_count` smallint(5) unsigned NOT NULL default '0',
`virtnode_count` smallint(5) unsigned NOT NULL default '0',
`servername` tinytext,
`portal` enum('emulab','aptlab','cloudlab','phantomnet','powder') default NULL,
`repourl` tinytext,
`reponame` varchar(40) default NULL,
`reporef` varchar(128) default NULL,
......@@ -490,6 +492,7 @@ CREATE TABLE `apt_instances` (
`physnode_count` smallint(5) unsigned NOT NULL default '0',
`virtnode_count` smallint(5) unsigned NOT NULL default '0',
`servername` tinytext,
`portal` enum('emulab','aptlab','cloudlab','phantomnet','powder') default NULL,
`monitor_pid` int(11) default '0',
`needupdate` tinyint(3) NOT NULL default '0',
`isopenstack` tinyint(1) NOT NULL default '0',
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("apt_instance_failures", "portal")) {
DBQueryFatal("alter table apt_instance_failures add ".
" `portal` enum('emulab','aptlab','cloudlab', ".
" 'phantomnet','powder') default NULL ".
" after logfileid");
}
if (!DBSlotExists("apt_instance_history", "portal")) {
DBQueryFatal("alter table apt_instance_history add ".
" `portal` enum('emulab','aptlab','cloudlab', ".
" 'phantomnet','powder') default NULL ".
" after servername");
}
if (!DBSlotExists("apt_instances", "portal")) {
DBQueryFatal("alter table apt_instances add ".
" `portal` enum('emulab','aptlab','cloudlab', ".
" 'phantomnet','powder') default NULL ".
" after servername");
}
DBQueryFatal("update apt_instances set portal='emulab'");
DBQueryFatal("update apt_instance_history set portal='emulab'");
# This will not doing anything outside of utah.
my %PORTAL_MAPPING =
("www.aptlab.net" => "aptlab",
"www.cloudlab.us" => "cloudlab",
"www.phantomnet.org" => "phantomnet",
"www.powderwireless.net" => "powder");
foreach my $servername (keys(%PORTAL_MAPPING)) {
my $portal = $PORTAL_MAPPING{$servername};
DBQueryFatal("update apt_instances set portal='$portal' ".
"where servername='$servername'");
DBQueryFatal("update apt_instance_history set portal='$portal' ".
"where servername='$servername'");
}
DBQueryFatal("update apt_instance_failures,apt_instance_history ".
"set apt_instance_failures.portal=apt_instance_history.portal ".
"where apt_instance_failures.uuid=apt_instance_history.uuid");
DBQueryFatal("update apt_instance_failures,apt_instances ".
"set apt_instance_failures.portal=apt_instances.portal ".
"where apt_instance_failures.uuid=apt_instances.uuid");
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
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