Commit bb56a192 authored by Mike Hibler's avatar Mike Hibler

1.275: Add timed-based mapping table for generic OSIDs. This augments the

       nextosid mechinism of 1.114 making it possible to map a generic *-STD
       OSID based on the time in which an experiment is created.  This
       provides backward compatibility for old experiments when the standard
       images are changed.

       The osid_map table lookup is triggered when the value of the nextosid
       field is set to 'MAP:osid_map'.  The nextosid also continues to behave
       as before: if it contains a valid osid, that OSID value is used to map
       independent of the experiment creation time.  The two styles can also
       be mixed, for example FBSD-JAIL has a nextosid of FBSD-STD which in
       turn is looked up and redirects to the osid_map and selects one of
       FBSD47-STD or FBSD410-STD depending on the time.

	CREATE TABLE osid_map (
	  osid varchar(35) NOT NULL default '',
	  btime datetime NOT NULL default '1000-01-01 00:00:00',
	  etime datetime NOT NULL default '9999-12-31 23:59:59',
	  nextosid varchar(35) default NULL,
	  PRIMARY KEY  (osid,btime,etime)
	) TYPE=MyISAM;

       Yeah, yeah, I'm using another magic date as a sentinel value.
       Tell ya what, in 7995 years, find out where I'm buried, dig me up,
       and kick my ass for being so short-sighted...

       The following commands are not strictly needed, they just give
       an example, default population of the table.  They cause the standard
       images to be revectored through the table and then remapped, based on
       two time ranges, to the exact same image.  Obviously, the second set
       would normally be mapped to a different set of images (say RHL90 and
       FBSD410):

	INSERT INTO osid_map (osid,etime,nextosid) VALUES \
	  ('RHL-STD','2004-09-08 08:59:59','emulab-ops-RHL73-STD');
	INSERT INTO osid_map (osid,etime,nextosid) VALUES \
	  ('FBSD-STD','2004-09-08 08:59:59','emulab-ops-FBSD47-STD');

	INSERT INTO osid_map (osid,btime,nextosid) VALUES \
	  ('RHL-STD','2004-09-08 09:00:00','emulab-ops-RHL73-STD');
	INSERT INTO osid_map (osid,btime,nextosid) VALUES \
	  ('FBSD-STD','2004-09-08 09:00:00','emulab-ops-FBSD47-STD');

	UPDATE os_info SET nextosid='MAP:osid_map' \
	  WHERE osname IN ('RHL-STD','FBSD-STD');
parent 9992ae20
......@@ -1975,13 +1975,13 @@ sub TBOSCountInstances ($;@)
# Note: It's okay to call this function with a 'real' OSID, but it would be
# waseful to do so.
#
# usage: TBResolveNextOSID(char *osid)
# usage: TBResolveNextOSID(char *osid, char *pid, char *eid)
# returns: The 'real' OSID that the OSID resolves to, or undef if there is a
# problem (ie. unknown OSID)
#
sub TBResolveNextOSID($)
sub TBResolveNextOSID($;$$)
{
my ($osid) = @_;
my ($osid,$pid,$eid) = @_;
my $next_osid = $osid;
my $input_osid = $osid;
......@@ -2002,8 +2002,43 @@ sub TBResolveNextOSID($)
warn "Resolving $input_osid: Unable to fetch os_info for $osid!\n";
return undef;
}
($next_osid) = $result->fetchrow();
#
# See if we need to resolve using a map
#
if ($next_osid && $next_osid =~ /^MAP:(\w+)/) {
my $map = $1;
my $timestr;
if (defined($pid) && defined($eid)) {
my $m_result = DBQueryWarn("select expt_created ".
"from experiments where ".
"pid='$pid' and eid='$eid'");
if (!$m_result || $m_result->num_rows() == 0) {
warn "Resolving $input_osid: no experiment $pid/$eid!\n";
return undef;
}
my ($ctime) = $m_result->fetchrow();
$timestr = "'$ctime'";
} else {
$timestr = "now()";
}
$result = DBQueryWarn("select nextosid from $map ".
"where osid='$osid' and ".
"$timestr between btime and etime");
if (!$result) {
warn "No such osid map $map!\n";
return undef;
}
if ($result->num_rows() == 0) {
warn "Resolving $input_osid: Unable to map $osid!\n";
return undef;
}
($next_osid) = $result->fetchrow();
}
} while ($next_osid);
return $osid;
......
......@@ -1151,6 +1151,18 @@ CREATE TABLE os_info (
KEY path (path(255))
) TYPE=MyISAM;
--
-- Table structure for table `osid_map`
--
CREATE TABLE osid_map (
osid varchar(35) NOT NULL default '',
btime datetime NOT NULL default '1000-01-01 00:00:00',
etime datetime NOT NULL default '9999-12-31 23:59:59',
nextosid varchar(35) default NULL,
PRIMARY KEY (osid,btime,etime)
) TYPE=MyISAM;
--
-- Table structure for table `osidtoimageid`
--
......
......@@ -1963,3 +1963,49 @@ last_net_act,last_cpu_act,last_ext_act);
modify_date datetime default NULL,
PRIMARY KEY (order_id)
) TYPE=MyISAM;
1.275: Add timed-based mapping table for generic OSIDs. This augments the
nextosid mechinism of 1.114 making it possible to map a generic *-STD
OSID based on the time in which an experiment is created. This
provides backward compatibility for old experiments when the standard
images are changed.
The osid_map table lookup is triggered when the value of the nextosid
field is set to 'MAP:osid_map'. The nextosid also continues to behave
as before: if it contains a valid osid, that OSID value is used to map
independent of the experiment creation time. The two styles can also
be mixed, for example FBSD-JAIL has a nextosid of FBSD-STD which in
turn is looked up and redirects to the osid_map and selects one of
FBSD47-STD or FBSD410-STD depending on the time.
CREATE TABLE osid_map (
osid varchar(35) NOT NULL default '',
btime datetime NOT NULL default '1000-01-01 00:00:00',
etime datetime NOT NULL default '9999-12-31 23:59:59',
nextosid varchar(35) default NULL,
PRIMARY KEY (osid,btime,etime)
) TYPE=MyISAM;
Yeah, yeah, I'm using another magic date as a sentinel value.
Tell ya what, in 7995 years, find out where I'm buried, dig me up,
and kick my ass for being so short-sighted...
The following commands are not strictly needed, they just give
an example, default population of the table. They cause the standard
images to be revectored through the table and then remapped, based on
two time ranges, to the exact same image. Obviously, the second set
would normally be mapped to a different set of images (say RHL90 and
FBSD410):
INSERT INTO osid_map (osid,etime,nextosid) VALUES \
('RHL-STD','2004-09-08 08:59:59','emulab-ops-RHL73-STD');
INSERT INTO osid_map (osid,etime,nextosid) VALUES \
('FBSD-STD','2004-09-08 08:59:59','emulab-ops-FBSD47-STD');
INSERT INTO osid_map (osid,btime,nextosid) VALUES \
('RHL-STD','2004-09-08 09:00:00','emulab-ops-RHL73-STD');
INSERT INTO osid_map (osid,btime,nextosid) VALUES \
('FBSD-STD','2004-09-08 09:00:00','emulab-ops-FBSD47-STD');
UPDATE os_info SET nextosid='MAP:osid_map' \
WHERE osname IN ('RHL-STD','FBSD-STD');
......@@ -354,7 +354,13 @@ while (my %row = $db_result->fetchhash()) {
"*** $0:\n".
" No mapping can be made for $osid ($node)!");
}
my $nextosid = TBResolveNextOSID($osid);
my $nextosid = TBResolveNextOSID($osid, $pid, $eid);
if (!defined($nextosid)) {
die_noretry(
"*** $0:\n".
" No mapping can be made for $osid ($node)!");
}
#
# See if the nextosid is already on the disk. If not,
......
......@@ -258,7 +258,7 @@ while (my ($osid) = $result->fetchrow()) {
#
# Check to see if they were allowed to use the real OSID
#
my $realosid = TBResolveNextOSID($osid);
my $realosid = TBResolveNextOSID($osid, $pid, $exempt_eid);
if ($osid_node_types{$realosid}) {
foreach my $type (@{$osid_node_types{$realosid}}) {
push @{$node_type_osids{$type}}, $osid;
......
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