Commit 3c1678d6 authored by Leigh Stoller's avatar Leigh Stoller

Changes for how we distribute the initial set of imageids and osids.

* install/dump-descriptors <filename> will write out a set of insert
  statements for the images and os_info table, slightly munged. In
  fact, what I do is create temporary tables called temp_images and
  temp_os_info, clean them a bit, and then write out the insert
  statements to load them into new tables of the same name.

  There are some arrays at the top of this script that says what images and
  osids to write out.

* install/load-descriptors <filename> takes the output of
  dump-descriptors, creates the two temporary tables and loads the
  data into them. Then it (optionally) updates those tables with the
  local indicies of elabman and the emulab-ops project and group.

  Then it computes an osidtoimageid table for all class='pc' types. On a
  new testbed this is a reasonable approach, in my opinion.

  Next it takes the contents of the two temp tables and moves them across
  to the actual tables.

* install/descriptors.sql is the current data set which has everything
  contained in sql/database-fill-supplemental.sql and install/images/*
parent a8257f67
......@@ -2496,6 +2496,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
dhcpd/dhcpd.conf.template dhcpd/GNUmakefile \
install/GNUmakefile \
install/ops-install install/boss-install install/fs-install \
install/load-descriptors.in install/dump-descriptors.in \
install/newnode_sshkeys/GNUmakefile install/smb.conf.head \
mote/GNUmakefile mote/tbuisp mote/tbsgmotepower mote/newmote \
mote/sgtools/GNUmakefile \
......
......@@ -877,6 +877,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
dhcpd/dhcpd.conf.template dhcpd/GNUmakefile \
install/GNUmakefile \
install/ops-install install/boss-install install/fs-install \
install/load-descriptors.in install/dump-descriptors.in \
install/newnode_sshkeys/GNUmakefile install/smb.conf.head \
mote/GNUmakefile mote/tbuisp mote/tbsgmotepower mote/newmote \
mote/sgtools/GNUmakefile \
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# Copyright (c) 2000-2005, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -15,7 +15,7 @@ include $(OBJDIR)/Makeconf
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: boss-install ops-install fs-install
all: boss-install ops-install fs-install dump-descriptors load-descriptors
include $(TESTBED_SRCDIR)/GNUmakerules
......
insert into temp_images set creator='elabman',default_osid='emulab-ops-FBSD410-STD',part4_osid=NULL,loadpart='0',shared='0',load_address='',imagename='FBSD410+RHL90-STD',pid='emulab-ops',ezid='0',updated=NULL,loadlength='4',imageid='emulab-ops-FBSD410+RHL90-STD',magic=NULL,global='1',part1_osid='emulab-ops-FBSD410-STD',path='/usr/testbed/images/FBSD410+RHL90-STD.ndz',frisbee_pid='0',description='FreeBSD 4.10 and RedHat 9.0',load_busy='0',part3_osid=NULL,created='2007-03-07 13:15:07',gid='emulab-ops',part2_osid='emulab-ops-RHL90-STD';
insert into temp_images set creator='elabman',default_osid='emulab-ops-FBSD410-STD',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD410-STD',pid='emulab-ops',ezid='1',updated=NULL,loadlength='1',imageid='emulab-ops-FBSD410-STD',magic=NULL,global='1',part1_osid='emulab-ops-FBSD410-STD',path='/usr/testbed/images/FBSD410-STD.ndz',frisbee_pid='0',description='Testbed version of FreeBSD 4.10',load_busy='0',part3_osid=NULL,created='2007-03-07 13:15:07',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='emulab-ops-RHL90-STD',part4_osid=NULL,loadpart='2',shared='0',load_address='',imagename='RHL90-STD',pid='emulab-ops',ezid='0',updated=NULL,loadlength='1',imageid='emulab-ops-RHL90-STD',magic=NULL,global='1',part1_osid=NULL,path='/usr/testbed/images/RHL90-STD.ndz',frisbee_pid='0',description='Redhat 9.0 slice disk image',load_busy='0',part3_osid=NULL,created='2007-03-07 13:15:07',gid='emulab-ops',part2_osid='emulab-ops-RHL90-STD';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='emulab-ops-FBSD-JAIL',reboot_waittime='90',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-JAIL',OS='FreeBSD',magic='',version='4.X',machinetype='',path=NULL,osfeatures='ping,ssh,isup,linktest',description='Generic OSID for jailed nodes',created='2007-03-07 13:15:07',op_mode='PCVM',nextosid='FBSD-STD';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='emulab-ops-FBSD410-STD',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD410-STD',OS='FreeBSD',magic=NULL,version='4.10',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Testbed version of FreeBSD 4.10',created='2007-03-07 13:15:07',op_mode='NORMALv2',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='emulab-ops-RHL90-STD',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='RHL90-STD',OS='Linux',magic='',version='9.0',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest,linkdelays',description='Testbed version of RedHat Linux 9.0',created='2007-03-07 13:15:07',op_mode='NORMALv2',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='FBSD-STD',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-STD',OS='FreeBSD',magic='FreeBSD',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Any Version of FreeBSD',created='2007-03-07 13:15:07',op_mode='NORMAL',nextosid='emulab-ops-FBSD410-STD';
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='FREEBSD-MFS',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FREEBSD-MFS',OS='FreeBSD',magic=NULL,version='4.5',machinetype='',path='/tftpboot/freebsd',osfeatures='ping,ssh,ipod,isup',description='FreeBSD in an MFS',created='2007-03-07 13:15:07',op_mode='PXEFBSD',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='FRISBEE-MFS',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FRISBEE-MFS',OS='FreeBSD',magic=NULL,version='4.5',machinetype='',path='/tftpboot/frisbee',osfeatures='ping,ssh,ipod,isup',description='Frisbee (FreeBSD) in an MFS',created='2007-03-07 13:15:07',op_mode='RELOAD',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='FW-IPFW',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FW-IPFW',OS='FreeBSD',magic='FreeBSD',version='',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks',description='IPFW Firewall',created='2007-03-07 13:15:07',op_mode='NORMAL',nextosid='emulab-ops-FBSD410-STD';
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='NEWNODE-MFS',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='NEWNODE-MFS',OS='FreeBSD',magic=NULL,version='4.5',machinetype='',path='/tftpboot/freebsd.newnode',osfeatures='ping,ssh,ipod,isup',description='NewNode (FreeBSD) in an MFS',created='2007-03-07 13:15:07',op_mode='PXEFBSD',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='OPSNODE-BSD',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='OPSNODE-BSD',OS='FreeBSD',magic=NULL,version='4.X',machinetype='',path='',osfeatures='ping,ssh,ipod,isup',description='FreeBSD on the Operations Node',created='2007-03-07 13:15:07',op_mode='OPSNODEBSD',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='RHL-STD',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='RHL-STD',OS='Linux',magic='Linux',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest,linkdelays',description='Any of RedHat Linux',created='2007-03-07 13:15:07',op_mode='NORMAL',nextosid='emulab-ops-RHL90-STD';
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use strict;
#
# Dump out an SQL file of statements to initialize the images and osids
# on a new testbed. Or maybe even an old testbed? Note that the output
# of thie script is the input to load-descriptors in this directory.
#
sub usage()
{
print STDOUT "Usage: dump-descriptors filename\n";
exit(-1);
}
#
# These are the images/osids we dump out. We of course get the embedded osids.
# We should probably add an export flag to the tables so we can avoid this
# hardwired list.
#
my @images = ('emulab-ops-FBSD410+RHL90-STD',
'emulab-ops-FBSD410-STD',
'emulab-ops-RHL90-STD');
my @osids = ('FREEBSD-MFS', 'FRISBEE-MFS', 'NEWNODE-MFS',
'OPSNODE-BSD', 'FW-IPFW',
'RHL-STD', 'FBSD-STD',
'emulab-ops-FBSD-JAIL');
my %osidtoimageid = ("RHL-STD" => "emulab-ops-RHL90-STD",
"FBSD-STD" => "emulab-ops-FBSD410-STD");
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $BOSSNODE = "@BOSSNODE@";
my $TFTPDIR = "/tftpboot";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
# Locals
my %tempkeys = ();
my $protouser = "elabman";
my $protoproj = TBOPSPID();
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/sbin:/usr/bin:";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
usage()
if (@ARGV != 1);
my $filename = $ARGV[0];
#
# Open tempfile.
#
open(OUTPUT, ">$filename") or
die("Could not open $filename for writing!\n");
#
# Create some temporary tables to mirror the existing tables. We
# populate these tables then spit them out. On the other side, when we
# load this table, we will move the rows out and into the local table,
# after adjustment.
#
#
# The images table.
#
DBQueryFatal("create temporary table temp_images like images");
DBQueryFatal("insert into temp_images ".
"select * from images where ".
join(" or ", map("imageid='$_'", @images)));
my $query_result = DBQueryFatal("show create table temp_images");
my $create_string = ($query_result->fetchrow_array())[1];
#
# Kill the idx slots; they may not be valid on the remote testbeds, and
# it simplifies backwards compatability.
#
DBQueryFatal("alter table temp_images ".
"drop pid_idx, drop gid_idx, drop creator_idx");
#
# Before we dump the table contents, reset a few things.
#
DBQueryFatal("update temp_images set ".
"creator='$protouser', ".
"pid='$protoproj', gid='$protoproj', ".
"load_address='', frisbee_pid=0, load_busy=0, ".
"created=now(), updated=NULL");
$query_result =
DBQueryFatal("select * from temp_images");
while (my $rowref = $query_result->fetchrow_hashref()) {
my $query_string = "insert into temp_images set ";
my @query_sets = ();
#
# Pick up the osids that are used in this image, and add them to the
# list of osids to dump out.
#
foreach my $key (('part1_osid', 'part2_osid',
'part3_osid', 'part4_osid', 'default_osid')) {
$tempkeys{$rowref->{$key}} = 1
if (defined($rowref->{$key}));
}
foreach my $key (keys(%{$rowref})) {
if (defined($rowref->{$key})) {
push(@query_sets, "${key}='" . $rowref->{$key} . "'");
}
else {
push(@query_sets, "${key}=NULL");
}
}
$query_string .= join(",", @query_sets);
print OUTPUT "$query_string;\n";
}
#
# Add the osids we found above to the list.
#
foreach my $key (keys(%tempkeys)) {
push(@osids, $key);
}
#
# Now do the osinfo table
#
DBQueryFatal("create temporary table temp_os_info like os_info");
DBQueryFatal("insert into temp_os_info ".
"select * from os_info where ".
join(" or ", map("osid='$_'", @osids)));
$query_result = DBQueryFatal("show create table temp_os_info");
$create_string = ($query_result->fetchrow_array())[1];
#
# Kill the idx slots; they may not be valid on the remote testbeds, and
# it simplifies backwards compatability.
#
DBQueryFatal("alter table temp_os_info ".
"drop pid_idx, drop creator_idx");
#
# Before we dump the table contents, reset a few things.
#
DBQueryFatal("update temp_os_info set ".
"creator='$protouser', ".
"pid='$protoproj', created=now()");
#
# We reset the nextosid slots in the -STD osids, rather then worrying
# about the osid_map table.
#
foreach my $osid (keys(%osidtoimageid)) {
my $nextosid = $osidtoimageid{$osid};
DBQueryFatal("update temp_os_info set nextosid='$nextosid' ".
"where osid='$osid'");
}
$query_result =
DBQueryFatal("select * from temp_os_info");
while (my $rowref = $query_result->fetchrow_hashref()) {
my $query_string = "insert into temp_os_info set ";
my @query_sets = ();
#
# Replace any host:path spec with just the path; pxeboot knows what to
# do and does not need the hostname in it.
#
if (defined($rowref->{'path'}) && $rowref->{'path'} ne "" &
$rowref->{'path'} =~ /^(.*):(.*)$/) {
$rowref->{'path'} = $2;
}
foreach my $key (keys(%{$rowref})) {
if (defined($rowref->{$key})) {
push(@query_sets, "${key}='" . $rowref->{$key} . "'");
}
else {
push(@query_sets, "${key}=NULL");
}
}
$query_string .= join(",", @query_sets);
print OUTPUT "$query_string;\n";
}
close(OUTPUT);
exit(0);
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use strict;
#
# Load in descriptors for images and osids. The input to this script is
# a file created with the dump-descriptors script in this directory,
#
sub usage()
{
print STDOUT "Usage: load-descriptors filename\n";
exit(-1);
}
#
# These are the OSIDs that are used to populate the osidtoimageid table
# using their nextosid entries.
#
my @standard_osids = ('RHL-STD', 'FBSD-STD');
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $BOSSNODE = "@BOSSNODE@";
my $TFTPDIR = "/tftpboot";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use User;
use Project;
#$libdb::DBQUERY_DEBUG = 1;
# Local
my %osidtoimageid = ();
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/sbin:/usr/bin:";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Protos
sub fatal($);
usage()
if (@ARGV != 1);
my $filename = $ARGV[0];
#
# We need to know various indicies, for the protouser (elabman) and the
# TBOPSPID (emulab-ops) project.
#
my $protouser = User->Lookup("elabman");
if (!defined($protouser)) {
fatal("Could not look up object for protouser (elabman)");
}
my $user_uid = $protouser->uid();
my $user_idx = $protouser->uid_idx();
my $protoproj = Project->Lookup(TBOPSPID());
if (!defined($protoproj)) {
fatal("Could not look up object for protoproj");
}
my $pid = $protoproj->pid();
my $pid_idx = $protoproj->pid_idx();
my $gid = $protoproj->gid();
my $gid_idx = $protoproj->gid_idx();
# Temp tables to hold new rows.
DBQueryFatal("create temporary table temp_images like images");
DBQueryFatal("create temporary table temp_os_info like os_info");
#
# Open tempfile.
#
open(OUTPUT, "$filename") or
die("Could not open $filename for reading!\n");
while (<OUTPUT>) {
DBQueryFatal($_);
}
close(OUTPUT);
#
# See if the local images table has the new indicies.
#
my $describe_result = DBQueryFatal("describe images");
while (my $rowref = $describe_result->fetchrow_hashref()) {
my $slot = $rowref->{"Field"};
if ($slot eq "pid_idx") {
DBQueryFatal("update temp_images set pid_idx='$pid_idx'");
}
elsif ($slot eq "gid_idx") {
DBQueryFatal("update temp_images set gid_idx='$gid_idx'");
}
elsif ($slot eq "creator_idx") {
DBQueryFatal("update temp_images set creator_idx='$user_idx'");
}
}
#
# Ditto for os_info table
#
$describe_result = DBQueryFatal("describe os_info");
while (my $rowref = $describe_result->fetchrow_hashref()) {
my $slot = $rowref->{"Field"};
if ($slot eq "pid_idx") {
DBQueryFatal("update temp_os_info set pid_idx='$pid_idx'");
}
elsif ($slot eq "creator_idx") {
DBQueryFatal("update temp_os_info set creator_idx='$user_idx'");
}
}
#
# Use the nextosid slot of the -STD osids to figure out what the default
# images are.
#
my $query_result =
DBQueryFatal("select nextosid from temp_os_info ".
"where nextosid is not null and (".
join(" or ", map("osid='$_'", @standard_osids)) . ")");
while (my ($nextosid) = $query_result->fetchrow_array()) {
my $subquery_result =
DBQueryFatal("select imageid from temp_images where ".
join(" or ", map("$_='$nextosid'",
("part1_osid", "part2_osid",
"part3_osid", "part4_osid"))));
if (!$subquery_result->numrows) {
print "*** WARNING: No osidtoimageid mapping for $nextosid\n";
next;
}
my ($imageid) = $subquery_result->fetchrow_array();
$osidtoimageid{$nextosid} = $imageid;
}
#
# Ready to populate the tables. Move the entries from temp_images and
# temp_os_info across to the real tables.
#
DBQueryFatal("replace into images select * from temp_images");
DBQueryFatal("replace into os_info select * from temp_os_info");
#
# Make up osidtoimageid entries for all local PCs. This is a shotgun
# approach, but for a new testbed is probably the right thing.
#
$query_result =
DBQueryFatal("select type from node_types where class='pc'");
while (my ($type) = $query_result->fetchrow_array()) {
foreach my $osid (keys(%osidtoimageid)) {
my $imageid = $osidtoimageid{$osid};
DBQueryFatal("replace into osidtoimageid values ".
"('$osid', '$type', '$imageid')");
}
}
exit(0);
sub fatal($)
{
my ($mesg) = $_[0];
die("*** $0:\n".
" $mesg\n");
}
......@@ -5,11 +5,6 @@
-- these is not idempotent, since a site may have changed them for some reason.
--
INSERT IGNORE INTO os_info VALUES ('FREEBSD-MFS','emulab-ops',1,'FREEBSD-MFS','root',0,NULL,'FreeBSD in an MFS','FreeBSD','4.5','boss:/tftpboot/freebsd',NULL,'','ping,ssh,ipod,isup',0,1,0,'PXEFBSD',NULL,NULL,1,150);
INSERT IGNORE INTO os_info VALUES ('FRISBEE-MFS','emulab-ops',1,'FRISBEE-MFS','root',0,NULL,'Frisbee (FreeBSD) in an MFS','FreeBSD','4.5','boss:/tftpboot/frisbee',NULL,'','ping,ssh,ipod,isup',0,1,0,'RELOAD',NULL,NULL,1,150);
INSERT IGNORE INTO os_info VALUES ('NEWNODE-MFS','emulab-ops',1,'NEWNODE-MFS','root',0,NULL,'NewNode (FreeBSD) in an MFS','FreeBSD','4.5','boss:/tftpboot/freebsd.newnode',NULL,'','ping,ssh,ipod,isup',0,1,0,'PXEFBSD',NULL,NULL,1,150);
INSERT IGNORE INTO os_info VALUES ('OPSNODE-BSD','emulab-ops',1,'OPSNODE-BSD','root',0,NULL,'FreeBSD on the Operations Node','FreeBSD','4.X','',NULL,'','ping,ssh,ipod,isup',0,1,0,'OPSNODEBSD',NULL,NULL,1,150);
INSERT IGNORE INTO os_info VALUES ('FW-IPFW','emulab-ops',1,'FW-IPFW','root',0,NULL,'IPFW Firewall','FreeBSD','',NULL,'FreeBSD','','ping,ssh,ipod,isup,veths,mlinks',0,1,1,'NORMAL','emulab-ops-FBSD47-STD',NULL,0,150);
INSERT INTO `node_types` VALUES ('pcvm','pcvm',NULL,NULL,1,0,1,1,0,0,0,0,0);
INSERT IGNORE INTO os_boot_cmd VALUES ('FreeBSD','4.10','delay','/kernel.delay');
......
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