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

Some minor changes, plus endless hours of PERL confusion. Anyway, add

a bootstatus field to the nodes table. os_setup sets this to one of
okay, failed, unknown. This is to be used with the still to be defined
method of specifying certain nodes that can fail reboot on experiment
creation. Right now sharks are wired to this, and this information is
presented in the web page. Its also essential for the batch system,
which needs to consider nodes that failed to reboot, or else batch
experiments would never end. Might still need a way for an experiment
to tell the batch system its done though.
parent 438ed993
......@@ -15,7 +15,8 @@ my $DBNAME = "@TBDBNAME@";
my $TBOPS = "@TBOPSEMAIL@";
#
# Set up for querying the database.
# Set up for querying the database. Note that fork causes a reconnect
# to the DB in the child.
#
my $DB = Mysql->connect("localhost", $DBNAME, "script", "none");
......@@ -24,6 +25,21 @@ my $DB = Mysql->connect("localhost", $DBNAME, "script", "none");
#
my $DBErrorString = "";
#
# Define exported "constants". Basically, these are just perl subroutines
# that look like constants cause you do not need to call a perl subroutine
# with parens. That is, FOO and FOO() are the same thing.
#
sub NODERELOADING_PID() { "testbed"; }
sub NODERELOADING_EID() { "reloading"; }
sub NODEDEAD_PID() { "emulab-ops"; }
sub NODEDEAD_EID() { "hwdown"; }
sub NODEBOOTSTATUS_OKAY() { "okay" ; }
sub NODEBOOTSTATUS_FAILED() { "failed"; }
sub NODEBOOTSTATUS_UNKNOWN() { "unknown"; }
sub NODESTARTSTATUS_NOSTATUS() { "none"; }
#
# Test admin status. Optional argument is the UID or Name to test. If not
# provided, then test the current UID.
......@@ -184,9 +200,13 @@ sub ExpLeader($$)
sub MarkNodeDown($)
{
my($node) = $_[0];
my($pid, $eid);
$pid = NODERELOADING_PID;
$eid = NODERELOADING_EID;
my $query_result =
DBQueryFatal("update reserved set pid='emulab-ops', eid='hwdown' ".
DBQueryFatal("update reserved set pid='$pid', eid='$eid' ".
"where node_id='$node'");
if ($query_result->num_rows < 1) {
......@@ -194,13 +214,26 @@ sub MarkNodeDown($)
}
}
#
# Set the boot status for a node.
#
# usage: SetNodeBootStatus(char *status)
#
sub SetNodeBootStatus($$)
{
my($node, $bstat) = @_;
DBQueryFatal("update nodes set bootstatus='$bstat' ".
"where node_id='$node'");
}
#
# Check if a particular feature is supported by an OSID.
#
# usage: OSFeatureSupported(char *osid, char *feature)
# returns 1 if supported, 0 if not.
#
sub OSFeatureSupported {
sub OSFeatureSupported($$) {
my($osid, $feature) = @_;
my $query_result =
......@@ -263,6 +296,23 @@ sub DBQueryFatal($)
return $result;
}
#
# Same as above, but just send email on error. This info is useful
# to the TB system, but the caller has to retain control.
#
sub DBQueryWarn($)
{
my($query) = $_[0];
my($result);
$result = DBQuery($query);
if (! $result) {
DBWarn("DB Query failed");
}
return $result;
}
#
# Warn and send email after a failed DB query. First argument is the error
# message to display. The contents of $DBErrorString is also printed.
......
......@@ -908,6 +908,7 @@ foreach $pair (@nodepairs) {
if (! $dbh->do("UPDATE nodes set def_boot_osid=\"$osid\"," .
" def_boot_cmd_line=\"$cmdline\"," .
" startstatus=\"none\"," .
" bootstatus=\"unknown\"," .
" ready=0," .
" rpms=\"$rpms\"," .
" deltas=\"$deltas\"," .
......@@ -929,6 +930,7 @@ foreach $pair (@nodepairs) {
if (! $dbh->do("UPDATE nodes set def_boot_osid=\"" .
$delayosids{$type} . "\"," .
" startstatus=\"none\"," .
" bootstatus=\"unknown\"," .
" ready=0" .
" where node_id=\"$pnode\"")) {
print STDERR "$0: *** Could not update nodes table." .
......
......@@ -28,9 +28,16 @@ my $DBNAME = "@TBDBNAME@";
my $TBOPS = "@TBOPSEMAIL@";
my $TFTP = "/tftpboot";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
my $nodereboot = "$TB/bin/node_reboot";
my $ping = "/sbin/ping";
my $dbg = 1;
my $dbg = 0;
my @nodes = ();
my %osid = ();
my %waitfor = ();
......@@ -53,13 +60,6 @@ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$| = 1; #Turn off line buffering on output
#
# Testbed Support libraries
#
push(@INC, "$TB/lib");
require libdb;
require libtestbed;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
......@@ -255,13 +255,16 @@ foreach my $node ( @nodes ) {
#
if ($waitfor{$node} == 0) {
print STDOUT "Not waiting for $node to come alive. Foreign OS.\n";
SetNodeBootStatus($node, NODEBOOTSTATUS_UNKNOWN);
next;
}
if (WaitTillAlive($node) == 0) {
print STDOUT "$node is alive and well\n";
SetNodeBootStatus($node, NODEBOOTSTATUS_OKAY);
next;
}
SetNodeBootStatus($node, NODEBOOTSTATUS_FAILED);
print STDOUT "$node may be down. This has been reported to testbed-ops.\n";
print STDOUT "Please end this experiment, and try again.\n";
......
......@@ -315,9 +315,10 @@ function SHOWNODES($pid, $eid) {
<td align=center>Default<br>OSID</td>
<td align=center>Default<br>Path</td>
<td align=center>Default<br>Cmdline</td>
<td align=center>Boot<br>Status[1]</td>
<td align=center>Startup<br>Command</td>
<td align=center>Startup<br>Status[1]</td>
<td align=center>Ready<br>Status[2]</td>
<td align=center>Startup<br>Status[2]</td>
<td align=center>Ready<br>Status[3]</td>
</tr>\n";
$query_result = mysql_db_query($TBDBNAME,
......@@ -339,6 +340,7 @@ function SHOWNODES($pid, $eid) {
$startupcmd = $row[startupcmd];
$startstatus = $row[startstatus];
$readystatus = $row[ready];
$bootstatus = $row[bootstatus];
if (!$def_boot_cmd_line)
$def_boot_cmd_line = "NULL";
......@@ -372,6 +374,7 @@ function SHOWNODES($pid, $eid) {
echo " <td>$def_boot_path</td>
<td>$def_boot_cmd_line</td>
<td align=center>$bootstatus</td>
<td>$startupcmd</td>
<td align=center>$startstatus</td>
<td align=center>$readylabel</td>
......@@ -381,8 +384,12 @@ function SHOWNODES($pid, $eid) {
echo "<h4><blockquote><blockquote><blockquote><blockquote>
<dl COMPACT>
<dt>[1]
<dd>Exit value of the node startup command.
<dd>Node has rebooted successfully after experiment
creation.
<dt>[2]
<dd>Exit value of the node startup command. A value of
666 indicates a testbed internal error.
<dt>[3]
<dd>User application ready status, reported via TMCC.
</dl>
</blockquote></blockquote></blockquote></blockquote></h4>\n";
......
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