Commit d7532d24 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Minor hacks to support FBSD-STD and RHL-STD as generic OSIDs. These

have been added as OSIDs so that the parser accepts them. os_setup
maps them into whatever equiv OSID is loaded on the target node,
according to the OS slot of the osid table entry. If no mapping can be
made (no equiv OS loaded, as defined by the partitions table) os_setup
fails. I've also changed the web page node control form so that the
only OSIDs you can set for a node are the ones loaded (partitions
table) or OSKit kernels (osid table entry has a path).
parent 02fec050
......@@ -40,7 +40,7 @@ my $nodereboot = "$TB/bin/node_reboot";
my $ping = "/sbin/ping";
my $dbg = 0;
my @nodes = ();
my %osid = ();
my %osids = ();
my %waitfor = ();
my %canfail = ();
my $db_result;
......@@ -119,11 +119,13 @@ if ($db_result->numrows < 1) {
}
for ($i = 0; $i < $db_result->numrows; $i++) {
my %row = $db_result->fetchhash();
my $node = $row{'node_id'};
my %row = $db_result->fetchhash();
my $node = $row{'node_id'};
my $osid = $row{'def_boot_osid'};
my $bootpath = 0;
push(@nodes, $node);
$osid{$node} = $row{'def_boot_osid'};
$osids{$node} = $osid;
#
# Make sure the files specified in the paths exist. We mount the
......@@ -144,12 +146,13 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
# Path must begin with $TFTP
if (! ($path =~ /^\/$TFTP\//)) {
die("File $path for node $node must reside in $TFTP\n");
die("*** File $path for node $node must reside in $TFTP\n");
}
if (! -e $path) {
die("File $path for node $node does not exist!");
die("*** File $path for node $node does not exist!");
}
$bootpath = 1;
}
}
if (defined($row{'next_boot_path'})) {
......@@ -166,11 +169,11 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
# Path must begin with $TFTP
if (! ($path =~ /^\/$TFTP\//)) {
die("File $path for node $node must reside in $TFTP\n");
die("*** File $path for node $node must reside in $TFTP\n");
}
if (! -e $path) {
die("File $path for node $node does not exist!");
die("*** File $path for node $node does not exist!");
}
}
}
......@@ -183,7 +186,7 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
#
foreach my $delta (split(":", $row{'deltas'})) {
if (! -e $delta) {
die("Delta file $delta for node $node does not exist!");
die("*** Delta file $delta for node $node does not exist!");
}
}
#
......@@ -191,7 +194,7 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
#
foreach my $rpm (split(":", $row{'rpms'})) {
if (! -e $rpm) {
die("RPM $rpm for node $node does not exist!");
die("*** RPM $rpm for node $node does not exist!");
}
}
......@@ -202,14 +205,94 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
my ($dir, $tar) = split(" ", $tarspec);
if (! -e $tar) {
die("Tarfile $tar for node $node does not exist!");
die("*** Tarfile $tar for node $node does not exist!");
}
}
#
# If there is a path specified, then we don't worry anymore about it.
# The user must know what is going on. The OSID might have a path
# associated with it, which means the same thing; we don't worry about
# it.
#
if (! $bootpath) {
#
# These checks are not necessary if the front end and web page
# are doing the right thing, but lets be careful anyway.
#
if (! $osid) {
die("*** $node has no bootpath and no def_boot_osid set!\n");
}
#
# Grab the info for this OSID. This is part of the image check.
#
my $osid_result =
DBQueryFatal("select * from os_info where osid='$osid'");
if ($osid_result->numrows == 0) {
die("*** No such OSID $osid is defined!\n");
}
my %osid_row = $osid_result->fetchhash();
#
# If there is an actual path, its an OSKit kernel not an image.
#
if (defined($osid_row{'path'}) && $osid_row{'path'} ne "") {
goto osid_okay;
}
#
# Make sure this OSID is actually loaded on the machine.
#
my $p_result =
DBQueryFatal("select * from partitions ".
"where node_id='$node' and osid='$osid'");
#
# If not loaded, then see if the user was looking for the generic
# name of the OS that is loaded.
#
if ($p_result->numrows == 0) {
#
# If its a specific Version, and its not loaded on the machine,
# its currently an error. Later we might reload.
#
if (defined($osid_row{'version'}) && $osid_row{'version'} ne "") {
die("*** OSID $osid is not currently loaded on $node!\n");
}
#
# A non-specific version. Try to map it.
#
my $o_result =
DBQueryFatal("select o1.* from os_info as o1 ".
"left join partitions as p on o1.osid=p.osid ".
"left join os_info as o2 on o2.OS=o1.OS ".
"where p.node_id='$node' and o2.osid='$osid'");
if ($o_result->numrows == 0) {
die("*** No mapping can be made for $osid on $node!\n".
" Perhaps the disk needs reloading?\n");
}
else {
my %o_row = $o_result->fetchhash();
my $n_osid = $o_row{'osid'};
print "Mapping $osid on $node to $n_osid.\n";
DBQueryFatal("update nodes set def_boot_osid='$n_osid' ".
"where node_id='$node'");
$osids{$node} = $n_osid;
}
}
}
osid_okay:
#
# If pingable, then the node is "waitable".
#
if (OSFeatureSupported($osid{$node}, "ping")) {
if (OSFeatureSupported($osids{$node}, "ping")) {
$waitfor{$node} = 1;
}
else {
......@@ -227,7 +310,7 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
$canfail{$node} = 0;
}
print STDOUT "$node - $osid{$node} - $waitfor{$node} - $canfail{$node}\n"
print STDOUT "$node - $osids{$node} - $waitfor{$node} - $canfail{$node}\n"
if $dbg;
}
......@@ -238,7 +321,7 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
#
if (!$TESTMODE) {
if (system("$nodereboot @nodes")) {
die("Failed to reboot some nodes!");
die("*** Failed to reboot some nodes!");
}
}
......
......@@ -47,20 +47,26 @@ if (isset($def_boot_osid) && strcmp($def_boot_osid, "None") == 0) {
}
#
# Now change the information.
# Create an update string, that is slightly different if an admin; we allow
# admin people to set next_boot parameters. Ordinary folks cannot.
#
$insert_result = mysql_db_query($TBDBNAME,
$query_string =
"UPDATE nodes SET ".
"def_boot_osid=\"$def_boot_osid\", ".
"def_boot_path=\"$def_boot_path\", ".
"def_boot_cmd_line=\"$def_boot_cmd_line\", ".
"startupcmd='$startupcmd', ".
"rpms='$rpms' ";
if ($isadmin) {
$query_string = "$query_string, ".
"next_boot_osid=\"$next_boot_osid\", ".
"next_boot_path=\"$next_boot_path\", ".
"next_boot_cmd_line=\"$next_boot_cmd_line\", ".
"startupcmd='$startupcmd', ".
"rpms='$rpms' ".
"WHERE node_id=\"$node_id\"");
"next_boot_cmd_line=\"$next_boot_cmd_line\" ";
}
$query_string = "$query_string WHERE node_id=\"$node_id\"";
$insert_result = mysql_db_query($TBDBNAME, $query_string);
if (! $insert_result) {
$err = mysql_error();
TBERROR("Database Error changing node setup for $node_id: $err", 1);
......
......@@ -63,17 +63,24 @@ $rpms = $row[rpms];
$startupcmd = $row[startupcmd];
#
# Get the OSID list.
# Get the OSID list. These are either OSIDs that are currently loaded on
# the node as indicated by the partitions table, or OSIDs with non-null
# paths (which means they are OSKit kernels). The list is pruned using the
# pid of the user when not an admin type, of course.
#
if ($isadmin) {
$osid_result = mysql_db_query($TBDBNAME,
"SELECT * FROM os_info order by osid");
"select o.*,p.osid from os_info as o ".
"left join partitions as p on o.osid=p.osid ".
"where p.node_id='$node_id' or o.path!='' order by o.osid");
}
else {
$osid_result = mysql_db_query($TBDBNAME,
"select distinct o.* from os_info as o ".
"left join proj_memb as p on o.pid IS NULL or p.pid=o.pid ".
"where p.uid='$uid' order by o.pid,o.osid");
"select distinct o.*,p.osid from os_info as o ".
"left join proj_memb as m on o.pid IS NULL or m.pid=o.pid ".
"left join partitions as p on o.osid=p.osid ".
"where m.uid='$uid' and p.node_id='$node_id' or o.path!='' ".
"order by o.pid,o.osid");
}
if (! $osid_result) {
$err = mysql_error();
......@@ -110,6 +117,9 @@ echo "<tr>
echo "<tr>
<td>*Def Boot OSID:</td>";
echo " <td><select name=\"def_boot_osid\">\n";
if ($def_boot_osid) {
echo "<option selected value='$def_boot_osid'>$def_boot_osid</option>\n";
}
while ($row = mysql_fetch_array($osid_result)) {
$osid = $row[osid];
$pid = $row[pid];
......@@ -118,7 +128,7 @@ echo " <td><select name=\"def_boot_osid\">\n";
echo "<option ";
if ($def_boot_osid == $osid) {
echo "selected ";
continue;
}
echo "value=\"$osid\">$pid - $osid</option>\n";
}
......@@ -144,44 +154,45 @@ echo "<tr>
value=\"$def_boot_cmd_line\"></td>
</tr>\n";
mysql_data_seek($osid_result, 0);
echo "<tr>
<td>Next Boot OSID:</td>";
echo " <td><select name=\"next_boot_osid\">\n";
echo " <option value=\"\">No OSID</option>\n";
while ($row = mysql_fetch_array($osid_result)) {
$osid = $row[osid];
$pid = $row[pid];
if (!$pid)
$pid = "testbed";
echo "<option ";
if ($next_boot_osid == $osid) {
echo "selected ";
}
echo "value=\"$osid\">$pid - $osid</option>\n";
}
echo " </select>";
echo " </td>
</tr>\n";
echo "<tr>
<td>Next Boot Path:</td>
<td class=\"left\">
<input type=\"text\" name=\"next_boot_path\" size=\"40\"
value=\"$next_boot_path\"></td>
</tr>\n";
echo "<tr>
<td>Next Boot Command Line:</td>
<td class=\"left\">
<input type=\"text\" name=\"next_boot_cmd_line\" size=\"40\"
value=\"$next_boot_cmd_line\"></td>
</tr>\n";
if ($isadmin) {
mysql_data_seek($osid_result, 0);
echo "<tr>
<td>Next Boot OSID:</td>";
echo " <td><select name=\"next_boot_osid\">\n";
echo " <option value=\"\">No OSID</option>\n";
while ($row = mysql_fetch_array($osid_result)) {
$osid = $row[osid];
$pid = $row[pid];
if (!$pid)
$pid = "testbed";
echo "<option ";
if ($next_boot_osid == $osid) {
echo "selected ";
}
echo "value=\"$osid\">$pid - $osid</option>\n";
}
echo " </select>";
echo " </td>
</tr>\n";
echo "<tr>
<td>Next Boot Path:</td>
<td class=\"left\">
<input type=\"text\" name=\"next_boot_path\" size=\"40\"
value=\"$next_boot_path\"></td>
</tr>\n";
echo "<tr>
<td>Next Boot Command Line:</td>
<td class=\"left\">
<input type=\"text\" name=\"next_boot_cmd_line\" size=\"40\"
value=\"$next_boot_cmd_line\"></td>
</tr>\n";
}
echo "<tr>
<td>Startup Command[1]:</td>
......
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