Commit 9f16769a authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

More support for OSKit kernels (or foreign OSs in general). Both

os_setup and ifc_setup read the features list from the database for
the currently assigned OS. os_setup will not enter a ping wait for the
node to come back alive if the node does not support ping! ifc_setup
will not try and and do ifconfig stuff if the OS does not support ifconfig.
parent 81f954da
......@@ -134,6 +134,15 @@ while (<IN>) {
if ($node =~ /^([-\@\w.]+)$/) {
$node = $1;
}
#
# Lets see if the OS that is supposed to be running on the machine
# even supports ifconfig. Skip it if not. User has to deal with it.
#
if (OSFeatureSupported(CurrentNodeOS($node), "ifconfig") == 0) {
print STDERR "$node does not support ifconfig. Skipping ...\n";
next;
}
print STDERR "Pinging $node ... \n" if $dbg;
if (-e $ping) {
......@@ -234,3 +243,35 @@ while (<IN>) {
close(IN);
print "End of input file.\nDone.\n";
exit 0;
sub OSFeatureSupported {
local($os) = $_[0];
local($feature) = $_[1];
$db_result = $DB->query("select osfeatures from disk_images ".
"where image_id='$os'");
if ($db_result->numrows < 1) {
return 0;
}
foreach $osfeature (split(',', $db_result->fetchrow_array())) {
if ($feature eq $osfeature) {
return 1;
}
}
return 0;
}
sub CurrentNodeOS {
local($node_id) = $_[0];
$db_result = $DB->query("select def_boot_image_id from nodes ".
"where node_id='$node_id'");
if ($db_result->numrows < 1) {
die("Node $node_id is not in the nodes table");
}
@row = $db_result->fetchrow_array();
return $row[0];
}
......@@ -16,6 +16,7 @@ $ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
my $PROJROOT = "/proj";
my $TFTPROOT = "/tftpboot";
my $dbh = Mysql->connect("localhost","tbdb","script","none");
my $db_result= "";
......@@ -101,5 +102,18 @@ if (! chown($uid, $gid, "$PROJROOT/$pid/exp")) {
die("Could not chown $PROJROOT/$pid/exp to $uid/$gid: $!\n");
}
#
# Make a few subdirs. If this gets long, make it a loop.
#
if (! mkdir("$TFTPROOT/proj/$pid", 0770)) {
die("Could not make directory $TFTPROOT/proj/$pid: $!\n");
}
if (! chmod(0777, "$TFTPROOT/proj/$pid")) {
die("Could not chmod directory $TFTPROOT/proj/$pid: $!\n");
}
if (! chown($uid, $gid, "$TFTPROOT/proj/$pid")) {
die("Could not chown $TFTPROOT/proj/$pid to $uid/$gid: $!\n");
}
exit(0);
......@@ -5,7 +5,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.
# with command lines or disk images. Only does neboot type stuff and
# hardwires the path to /tftpboot/proj/$pid/$imagepaths{$os}
#
#
......@@ -158,14 +159,14 @@ while (<IN>) {
if ($imagepaths{$os}) {
if ($imageparts{$os} ne "mb") {
die("Improper local OS spec: $os. ".
"Partition can only be 'mb' right now.");
"Partition can currently only be 'mb' (multiboot)");
}
#
# 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}";
$nodepath{$node} = "/tftpboot/proj/$pid/$imagepaths{$os}";
$waitfor{$node} = 0;
next;
}
......@@ -186,11 +187,17 @@ while (<IN>) {
}
@row = $db_result->fetchrow_array();
$nodepath{$node} = $row[1];
if ($row[1]) {
$waitfor{$node} = 0;
#
# See if the OS that is going to be booted supports a ping feature.
# This is the only way we can tell if the machine has come back alive.
# If not, then we effectively do not support the os for anything at all.
#
if (OSFeatureSupported($os, "ping")) {
$waitfor{$node} = 1;
}
else {
$waitfor{$node} = 1;
$waitfor{$node} = 0;
}
}
......@@ -360,3 +367,21 @@ sub WaitTillDead {
print STDERR "$pc is still alive.\n" if $dbg;
return 1;
}
sub OSFeatureSupported {
local($os) = $_[0];
local($feature) = $_[1];
$db_result = $DB->query("select osfeatures from disk_images ".
"where image_id='$os'");
if ($db_result->numrows < 1) {
return 0;
}
foreach $osfeature (split(',', $db_result->fetchrow_array())) {
if ($feature eq $osfeature) {
return 1;
}
}
return 0;
}
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