Commit 2ef782c2 authored by Leigh Stoller's avatar Leigh Stoller

Redo the dump/load descriptor code, that is used to populate the

initiali set of descriptors on a new installation. Get rid of all that
crazy sql table stuff, and reuse web the backend scripts that take
small fragments of XML describing osinfos and images.
parent ad26f8d3
insert into temp_images set creator='elabman',default_osid='282',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD410-IPFW2',pid='emulab-ops',ezid='0',updated=NULL,loadlength='1',imageid='869',magic=NULL,global='1',part1_osid='282',path='/usr/testbed/images/FBSD410-IPFW2.ndz',mbr_version='1',frisbee_pid='0',description='FreeBSD 4.10 with built-in IPFW2 support',load_busy='0',part3_osid=NULL,created='2008-07-22 17:34:07',access_key=NULL,old_imageid='emulab-ops-FBSD410-IPFW2',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='285',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD410-STD',pid='emulab-ops',ezid='1',updated=NULL,loadlength='1',imageid='285',magic=NULL,global='1',part1_osid='285',path='/usr/testbed/images/FBSD410-STD.ndz',mbr_version='1',frisbee_pid='0',description='Testbed version of FreeBSD 4.10',load_busy='0',part3_osid=NULL,created='2008-07-22 17:34:07',access_key=NULL,old_imageid='emulab-ops-FBSD410-STD',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='940',part4_osid=NULL,loadpart='0',shared='0',load_address='',imagename='FBSD62+FC6-STD',pid='emulab-ops',ezid='0',updated=NULL,loadlength='4',imageid='947',magic=NULL,global='1',part1_osid='303',path='/usr/testbed/images/FBSD62+FC6-STD.ndz',mbr_version='1',frisbee_pid='0',description='FreeBSD 6.2 and Fedora Core 6 combo image',load_busy='0',part3_osid=NULL,created='2008-07-22 17:34:07',access_key='0f58499aa4e7280e7f95bf281b147a7c',old_imageid='',gid='emulab-ops',part2_osid='940';
insert into temp_images set creator='elabman',default_osid='303',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD62-STD',pid='emulab-ops',ezid='1',updated=NULL,loadlength='1',imageid='303',magic=NULL,global='1',part1_osid='303',path='/usr/testbed/images/FBSD62-STD.ndz',mbr_version='1',frisbee_pid='0',description='FreeBSD 6.2 pre-release',load_busy='0',part3_osid=NULL,created='2008-07-22 17:34:07',access_key=NULL,old_imageid='emulab-ops-FBSD62-STD',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='940',part4_osid=NULL,loadpart='2',shared='0',load_address='',imagename='FC6-STD',pid='emulab-ops',ezid='1',updated=NULL,loadlength='1',imageid='940',magic=NULL,global='1',part1_osid=NULL,path='/usr/testbed/images/FC6-STD.ndz',mbr_version='1',frisbee_pid='0',description='Emulab Standard Fedora Core 6 image.',load_busy='0',part3_osid=NULL,created='2008-07-22 17:34:07',access_key=NULL,old_imageid='',gid='emulab-ops',part2_osid='940';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='278',reboot_waittime='90',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-JAIL',old_osid='emulab-ops-FBSD-JAIL',OS='FreeBSD',magic='',old_nextosid='FBSD-STD',version='4.X',machinetype='',path=NULL,osfeatures='ping,ssh,isup,linktest',description='Generic OSID for jailed nodes',op_mode='PCVM',created='2008-07-22 17:34:08',nextosid='362';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='362',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-STD',old_osid='FBSD-STD',OS='FreeBSD',magic='FreeBSD',old_nextosid='MAP:osid_map',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Any Version of FreeBSD',op_mode='NORMAL',created='2008-07-22 17:34:08',nextosid='303';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='282',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD410-IPFW2',old_osid='emulab-ops-FBSD410-IPFW2',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.10',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest',description='FreeBSD 4.10 with IPFW2',op_mode='NORMALv2',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='285',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD410-STD',old_osid='emulab-ops-FBSD410-STD',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.10',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Testbed version of FreeBSD 4.10',op_mode='NORMALv2',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='303',reboot_waittime='120',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD62-STD',old_osid='emulab-ops-FBSD62-STD',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,mlinks,linktest,linkdelays',description='FreeBSD 6.2 pre-release',op_mode='NORMALv2',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='940',reboot_waittime='120',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FC6-STD',old_osid='',OS='Fedora',magic=NULL,old_nextosid='',version='6',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest',description='Emulab Standard Fedora Core 6 image.',op_mode='NORMALv2',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='399',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FREEBSD-MFS',old_osid='FREEBSD-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/freebsd',osfeatures='ping,ssh,ipod,isup',description='FreeBSD in an MFS',op_mode='PXEFBSD',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='403',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FRISBEE-MFS',old_osid='FRISBEE-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/frisbee',osfeatures='ping,ssh,ipod,isup',description='Frisbee (FreeBSD) in an MFS',op_mode='RELOAD',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='406',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FW-IPFW',old_osid='FW-IPFW',OS='FreeBSD',magic='FreeBSD',old_nextosid='emulab-ops-FBSD410-STD',version='',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks',description='IPFW Firewall',op_mode='NORMAL',created='2008-07-22 17:34:08',nextosid='285';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='407',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FW-IPFW2',old_osid='FW-IPFW2',OS='FreeBSD',magic='FreeBSD',old_nextosid='emulab-ops-FBSD410-IPFW2',version='',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks',description='IPFW2 Firewall',op_mode='NORMAL',created='2008-07-22 17:34:08',nextosid='282';
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='467',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='NEWNODE-MFS',old_osid='NEWNODE-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/freebsd.newnode',osfeatures='ping,ssh,ipod,isup',description='NewNode (FreeBSD) in an MFS',op_mode='PXEFBSD',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='470',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='OPSNODE-BSD',old_osid='OPSNODE-BSD',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.X',machinetype='',path='',osfeatures='ping,ssh,ipod,isup',description='FreeBSD on the Operations Node',op_mode='OPSNODEBSD',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='324',reboot_waittime='60',mustclean='1',shared='0',pid='emulab-ops',ezid='0',osname='POWER-CONTROLLER',old_osid='emulab-ops-POWER-CONTROLLER',OS='Other',magic='',old_nextosid='',version='0.00',machinetype='',path=NULL,osfeatures='',description='Stub descriptor for power controllers of any kind',op_mode='ALWAYSUP',created='2008-07-22 17:34:08',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='526',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='RHL-STD',old_osid='RHL-STD',OS='Linux',magic='Linux',old_nextosid='MAP:osid_map',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest,linkdelays',description='Any of RedHat Linux',op_mode='NORMAL',created='2008-07-22 17:34:08',nextosid='940';
insert into temp_images set creator='elabman',default_osid='285',part4_osid=NULL,loadpart='0',shared='0',load_address='',imagename='FBSD410+RHL90-STD',pid='emulab-ops',ezid='0',updated=NULL,loadlength='4',imageid='864',magic=NULL,global='1',part1_osid='285',path='/usr/testbed/images/FBSD410+RHL90-STD.ndz',mbr_version='1',frisbee_pid='0',description='FreeBSD 4.10 and RedHat 9.0',load_busy='0',part3_osid=NULL,created='2008-07-22 17:42:23',access_key=NULL,old_imageid='emulab-ops-FBSD410+RHL90-STD',gid='emulab-ops',part2_osid='336';
insert into temp_images set creator='elabman',default_osid='282',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD410-IPFW2',pid='emulab-ops',ezid='0',updated=NULL,loadlength='1',imageid='869',magic=NULL,global='1',part1_osid='282',path='/usr/testbed/images/FBSD410-IPFW2.ndz',mbr_version='1',frisbee_pid='0',description='FreeBSD 4.10 with built-in IPFW2 support',load_busy='0',part3_osid=NULL,created='2008-07-22 17:42:23',access_key=NULL,old_imageid='emulab-ops-FBSD410-IPFW2',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='285',part4_osid=NULL,loadpart='1',shared='0',load_address='',imagename='FBSD410-STD',pid='emulab-ops',ezid='1',updated=NULL,loadlength='1',imageid='285',magic=NULL,global='1',part1_osid='285',path='/usr/testbed/images/FBSD410-STD.ndz',mbr_version='1',frisbee_pid='0',description='Testbed version of FreeBSD 4.10',load_busy='0',part3_osid=NULL,created='2008-07-22 17:42:23',access_key=NULL,old_imageid='emulab-ops-FBSD410-STD',gid='emulab-ops',part2_osid=NULL;
insert into temp_images set creator='elabman',default_osid='336',part4_osid=NULL,loadpart='2',shared='0',load_address='',imagename='RHL90-STD',pid='emulab-ops',ezid='0',updated=NULL,loadlength='1',imageid='865',magic=NULL,global='1',part1_osid=NULL,path='/usr/testbed/images/RHL90-STD.ndz',mbr_version='1',frisbee_pid='0',description='Redhat 9.0 slice disk image',load_busy='0',part3_osid=NULL,created='2008-07-22 17:42:23',access_key=NULL,old_imageid='emulab-ops-RHL90-STD',gid='emulab-ops',part2_osid='336';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='278',reboot_waittime='90',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-JAIL',old_osid='emulab-ops-FBSD-JAIL',OS='FreeBSD',magic='',old_nextosid='FBSD-STD',version='4.X',machinetype='',path=NULL,osfeatures='ping,ssh,isup,linktest',description='Generic OSID for jailed nodes',op_mode='PCVM',created='2008-07-22 17:42:23',nextosid='362';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='362',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FBSD-STD',old_osid='FBSD-STD',OS='FreeBSD',magic='FreeBSD',old_nextosid='MAP:osid_map',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Any Version of FreeBSD',op_mode='NORMAL',created='2008-07-22 17:42:23',nextosid='285';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='282',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD410-IPFW2',old_osid='emulab-ops-FBSD410-IPFW2',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.10',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest',description='FreeBSD 4.10 with IPFW2',op_mode='NORMALv2',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='285',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='1',osname='FBSD410-STD',old_osid='emulab-ops-FBSD410-STD',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.10',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks,linktest,linkdelays',description='Testbed version of FreeBSD 4.10',op_mode='NORMALv2',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='399',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FREEBSD-MFS',old_osid='FREEBSD-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/freebsd',osfeatures='ping,ssh,ipod,isup',description='FreeBSD in an MFS',op_mode='PXEFBSD',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='403',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='FRISBEE-MFS',old_osid='FRISBEE-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/frisbee',osfeatures='ping,ssh,ipod,isup',description='Frisbee (FreeBSD) in an MFS',op_mode='RELOAD',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='406',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FW-IPFW',old_osid='FW-IPFW',OS='FreeBSD',magic='FreeBSD',old_nextosid='emulab-ops-FBSD410-STD',version='',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks',description='IPFW Firewall',op_mode='NORMAL',created='2008-07-22 17:42:23',nextosid='285';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='407',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='FW-IPFW2',old_osid='FW-IPFW2',OS='FreeBSD',magic='FreeBSD',old_nextosid='emulab-ops-FBSD410-IPFW2',version='',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,veths,mlinks',description='IPFW2 Firewall',op_mode='NORMAL',created='2008-07-22 17:42:23',nextosid='282';
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='467',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='NEWNODE-MFS',old_osid='NEWNODE-MFS',OS='FreeBSD',magic=NULL,old_nextosid='',version='6.2',machinetype='',path='/tftpboot/freebsd.newnode',osfeatures='ping,ssh,ipod,isup',description='NewNode (FreeBSD) in an MFS',op_mode='PXEFBSD',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='1',creator='elabman',max_concurrent=NULL,osid='470',reboot_waittime='150',mustclean='0',shared='1',pid='emulab-ops',ezid='0',osname='OPSNODE-BSD',old_osid='OPSNODE-BSD',OS='FreeBSD',magic=NULL,old_nextosid='',version='4.X',machinetype='',path='',osfeatures='ping,ssh,ipod,isup',description='FreeBSD on the Operations Node',op_mode='OPSNODEBSD',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='324',reboot_waittime='60',mustclean='1',shared='0',pid='emulab-ops',ezid='0',osname='POWER-CONTROLLER',old_osid='emulab-ops-POWER-CONTROLLER',OS='Other',magic='',old_nextosid='',version='0.00',machinetype='',path=NULL,osfeatures='',description='Stub descriptor for power controllers of any kind',op_mode='ALWAYSUP',created='2008-07-22 17:42:23',nextosid=NULL;
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='526',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='RHL-STD',old_osid='RHL-STD',OS='Linux',magic='Linux',old_nextosid='MAP:osid_map',version='',machinetype='pc600',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest,linkdelays',description='Any of RedHat Linux',op_mode='NORMAL',created='2008-07-22 17:42:23',nextosid='336';
insert into temp_os_info set mfs='0',creator='elabman',max_concurrent=NULL,osid='336',reboot_waittime='150',mustclean='1',shared='1',pid='emulab-ops',ezid='0',osname='RHL90-STD',old_osid='emulab-ops-RHL90-STD',OS='Linux',magic='',old_nextosid='',version='9.0',machinetype='',path=NULL,osfeatures='ping,ssh,ipod,isup,linktest,linkdelays',description='Testbed version of RedHat Linux 9.0',op_mode='NORMALv2',created='2008-07-22 17:42:23',nextosid=NULL;
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007, 2008 University of Utah and the Flux Group.
# Copyright (c) 2007-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -66,7 +66,7 @@ my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $BOSSNODE = "@BOSSNODE@";
my $TFTPDIR = "/tftpboot";
my $DUMPDESC = "$TB/sbin/dumpdescriptor";
#
# Testbed Support libraries
......@@ -74,11 +74,14 @@ my $TFTPDIR = "/tftpboot";
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use Image;
use OSinfo;
# Locals
my %tempkeys = ();
my $protouser = "elabman";
my $protoproj = TBOPSPID();
sub fatal($);
#
# Turn off line buffering on output
......@@ -111,157 +114,103 @@ 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 pid='$protoproj' and (".
join(" or ", map("imagename='$_'", @{$imagenames{$version}})) . ")");
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, drop uuid");
my %images = ();
my %osinfos = ();
#
# Before we dump the table contents, reset a few things.
# Gather up the images and any osinfos they reference.
#
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 = ();
foreach my $imagename (@{$imagenames{$version}}) {
my $image = Image->Lookup("$protoproj,$imagename");
if (!defined($image)) {
fatal("Cannot find image descriptor for $imagename");
}
$images{$image->imageid()} = $image;
#
# Pick up the osids that are used in this image, and add them to the
# list of osids to dump out.
# Get the osids it references.
#
foreach my $key (('part1_osid', 'part2_osid',
'part3_osid', 'part4_osid', 'default_osid')) {
my $osid = $image->$key();
next
if (!defined($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");
my $osinfo = OSinfo->Lookup($osid);
if (!defined($osinfo)) {
fatal("Cannot find OS descriptor for $osid");
}
$osinfos{$osinfo->osid()} = $osinfo;
}
$query_string .= join(",", @query_sets);
print OUTPUT "$query_string;\n";
}
#
# Add the osids we found above to the list.
# And the OSs
#
foreach my $key (keys(%tempkeys)) {
push(@osids, $key);
foreach my $osname (@osnames) {
my $osinfo = OSinfo->Lookup("$protoproj,$osname");
if (!defined($osinfo)) {
fatal("Cannot find os descriptor for $osname");
}
$osinfos{$osinfo->osid()} = $osinfo;
}
foreach my $osname (keys(%{$mappings{$version}})) {
my $nextosname = $mappings{$version}{$osname};
my $osinfo = OSinfo->Lookup("$protoproj,$nextosname");
if (!defined($osinfo)) {
fatal("Cannot find os descriptor for $nextosname");
}
$osinfos{$osinfo->osid()} = $osinfo;
}
#
# 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 pid='$protoproj' and ((".
join(" or ", map("osname='$_'", @osnames)) . ") or (".
join(" or ", map("osid='$_'", @osids)) . "))".
" order by osname");
$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, drop uuid");
#
# 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.
# Open tempfile.
#
open(OUTPUT, ">$filename") or
die("Could not open $filename for writing!\n");
print OUTPUT "<descriptors>\n";
foreach my $osname (keys(%{$mappings{$version}})) {
my $nextosname = $mappings{$version}{$osname};
$query_result =
DBQueryFatal("select osid from temp_os_info ".
"where pid='$protoproj' and osname='$nextosname'");
if (! $query_result->numrows) {
print "Could not map $protoproj,$osname to its osid!\n";
exit(-1);
}
my ($nextosid) = $query_result->fetchrow_array();
DBQueryFatal("update temp_os_info set nextosid='$nextosid' ".
"where pid='$protoproj' and osname='$osname'");
print OUTPUT "<mapping name=\"$osname\">\n";
print OUTPUT " <value>$nextosname</value>\n";
print OUTPUT "</mapping>\n";
}
close(OUTPUT);
$query_result =
DBQueryFatal("select * from temp_os_info");
#
# Hmm, this is interesting. We reuse OSids that were created via the EZ
# path, typically in the combo images. We need to delete those from the
# osinfos list since they get created when processing the EZ images in
# the load-descriptors script. Ordering is going to be important when
# loading them in.
#
foreach my $osid (keys(%osinfos)) {
my $osinfo = $osinfos{$osid};
while (my $rowref = $query_result->fetchrow_hashref()) {
my $query_string = "insert into temp_os_info set ";
my @query_sets = ();
next
if ($osinfo->ezid());
#
# 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);
system("$DUMPDESC -o $osid >> $filename") == 0
or fatal("Could not dump $osinfo");
}
foreach my $imageid (keys(%images)) {
my $image = $images{$imageid};
print OUTPUT "$query_string;\n";
system("$DUMPDESC -i $imageid >> $filename") == 0
or fatal("Could not dump $image");
}
open(OUTPUT, ">>$filename") or
die("Could not open $filename for writing!\n");
print OUTPUT "</descriptors>\n";
close(OUTPUT);
exit(0);
sub fatal($)
{
my ($mesg) = @_;
print STDERR "*** $0:\n".
" $mesg\n";
exit(-1);
}
This diff is collapsed.
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