Commit ce613288 authored by Leigh Stoller's avatar Leigh Stoller

Checkpoint a set of hacky changes to support your own OSKit kernel

via the create-os directive in the NS file.
tbsetup/ir/handle_os.tcl - Do a valid check for the image given with
	set-node-os in the NS file, and propogate that information through
        to the IR file. Nothing is added to the DB.
tbsetup/mkexpdir - Add a tftpboot to the list of experiment directories. The
	tftpd daemon now allows kernels from /proj.
tbsetup/os_setup - Very hacky changes to allow for multiboot kernels. Read
	local images table and cross check against that for nodeos spec.
        Hardwire in "mb" as a special partition tag that says to not try
	and do too much with it. This should be changed to a DB check of
	some kind. On reboot, do not wait for these nodes to come alive since
	there is no way to determine if an oskit kernel (or any foreign)
	kernel is running.
parent 15bb3655
......@@ -44,23 +44,34 @@ set fp [open $nsfile r]
#
# Verify that the OS is valid for the node. Return zero if not supported.
#
# XXX Checks just for PCs in the disk_images table. Need to add support
# for the sharks and for create OS.
# XXX Checks for PCs in the DB disk_images table or in the local images table.
# Need to add support for the sharks.
#
proc checkimage {node label} {
global DB
global images
#
# DB holds our supported OS images.
#
sql query $DB "select image_id from disk_images \
where type='pc' and image_id='$label'"
if {[sql fetchrow $DB] != {}} {
set ret 1
} else {
set ret 0
sql endquery $DB
return 1;
}
sql endquery $DB
return $ret;
#
# Check local images table for a match.
#
foreach n [array names images] {
if {[string match $n $label] == 1} {
return 1;
}
}
return 0;
}
while {[gets $fp line] >= 0} {
......@@ -117,16 +128,16 @@ while {[gets $fp line] >= 0} {
if {! [ir exists /os]} {
set fp [open $irfile a]
puts $fp "START os"
puts $fp "START nodes"
foreach n [array names os] {
puts $fp "$n $os($n)"
}
puts $fp "END nodes"
puts $fp "START images"
foreach i [array names images] {
puts $fp "$i $images($i)"
}
puts $fp "END images"
puts $fp "START nodes"
foreach n [array names os] {
puts $fp "$n $os($n)"
}
puts $fp "END nodes"
puts $fp "END os"
close $fp
} else {
......
......@@ -10,7 +10,7 @@ use English;
my $tbdir = "/usr/testbed/bin/";
my $projroot = "/proj";
my $tbdata = "tbdata";
my @dirlist = ($tbdata, "bin", "tmp", "logs");
my @dirlist = ($tbdata, "bin", "tmp", "logs", "tftpboot");
#
# Untaint the path
......
......@@ -4,6 +4,8 @@ use English;
#
# TODO: Delta stuff.
# Reload disk images.
# Finish up local OS spec stuff. Kinda hacky right now. Does not deal
# with command lines or disk images. Only does neboot type stuff.
#
#
......@@ -20,9 +22,13 @@ my $TB = "/usr/testbed/bin";
my $power = "$TB/power";
my $ping = "/sbin/ping";
my $dbg = 1;
my %imagepaths = ();
my %imageparts = ();
my %nodeos = ();
my %nodepath = ();
my %waitfor = ();
my $SAVEUID = $UID;
my @row;
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
......@@ -57,11 +63,11 @@ if ($UID != 0) {
if ($db_result->numrows < 1) {
die("There is no experiment '$eid' in project '$pid'.\n");
}
my @row = $db_result->fetchrow_array();
@row = $db_result->fetchrow_array();
if ($row[0] ne "$me") {
print STDOUT "Checking for admin status ...\n" if $dbg;
$db_result = $DB->query("select admin from users where uid='$me'");
my @row = $db_result->fetchrow_array();
@row = $db_result->fetchrow_array();
if ($row[0] != 1) {
die("mkprojdir: You must be root or a TB administrator\n");
}
......@@ -94,6 +100,24 @@ if ($ossection == 0) {
die("No OS section in $ir\n");
}
#
# Parse the images table to see what the local images are.
#
while (<IN>) {
if ( /^start images/i ) {
print STDERR "Start IMAGES section...\n" if $dbg;
next;
}
elsif ( /^end images/i ) {
print STDERR "End IMAGES section...\n" if $dbg;
last;
}
my ($id,$path,$part) = split();
print STDERR "$id $path $part\n" if $dbg;
$imagepaths{$id} = $path;
$imageparts{$id} = $part;
}
#
# Okay, parse the OS section.
#
......@@ -117,14 +141,35 @@ while (<IN>) {
$db_result = $DB->query("select pid,eid from reserved ".
"where node_id='$node'");
if ($db_result->numrows < 1) {
die("There is no node '$node' in the DB.\n");
die("There is no node '$node' reserved in the DB.\n");
}
my @row = $db_result->fetchrow_array();
@row = $db_result->fetchrow_array();
if ($row[0] ne "$pid" ||
$row[1] ne "$eid") {
die("Node '$node' pid/eid mismatch: $pid/$eid ... $row[0]/$row[1]\n");
}
#
# First see if the OS spec is a local one from the images table. We
# leave it up to the user to make sure the OS is capable of running
# on the node! This local image stuff is pretty hacky right now. I'm
# only going to allow netboot type stuff.
#
if ($imagepaths{$os}) {
if ($imageparts{$os} ne "mb") {
die("Improper local OS spec: $os. ".
"Partition can only be 'mb' right now.");
}
#
# Okay, now it gets really bad. I'm going to form the tftpboot
# path right here, since local OS specs are not in the database
# disk_images table.
#
$nodepath{$node} = "/proj/$pid/exp/$eid/tftpboot/$imagepaths{$os}";
$waitfor{$node} = 0;
next;
}
#
# Check to make sure that the OS spec is valid by checking the database.
# Cross check type from nodes table against image_ids for that type in
......@@ -139,8 +184,14 @@ while (<IN>) {
if ($db_result->numrows < 1) {
die("Improper image specification $node:$os in IR file.\n");
}
my @row = $db_result->fetchrow_array();
@row = $db_result->fetchrow_array();
$nodepath{$node} = $row[1];
if ($row[1]) {
$waitfor{$node} = 0;
}
else {
$waitfor{$node} = 1;
}
}
#
......@@ -230,6 +281,15 @@ foreach my $node ( keys %nodeos ) {
foreach my $node ( keys %nodeos ) {
my $pc = $node;
#
# Don't bother to wait for nodes that are running foreign OSs since
# we are not going to deal with them anyway later in the process.
#
if ($waitfor{$pc} == 0) {
print STDERR "Not waiting for $pc to come alive. Foreign OS.\n";
next;
}
if (WaitTillAlive($pc) == 0) {
print STDERR "Yippie! $pc is alive and well\n";
next;
......
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