Commit 4dc91148 authored by Leigh B Stoller's avatar Leigh B Stoller

Generate a local event whenever node_status decides to change the status.

parent 87c044fe
...@@ -119,6 +119,7 @@ use vars qw(@ISA @EXPORT); ...@@ -119,6 +119,7 @@ use vars qw(@ISA @EXPORT);
TBDB_TBEVENT_NODESTATE TBDB_TBEVENT_NODEOPMODE TBDB_TBEVENT_CONTROL TBDB_TBEVENT_NODESTATE TBDB_TBEVENT_NODEOPMODE TBDB_TBEVENT_CONTROL
TBDB_TBEVENT_COMMAND TBDB_TBEVENT_EXPTSTATE TBDB_TBEVENT_COMMAND TBDB_TBEVENT_EXPTSTATE
TBDB_TBEVENT_NODESTARTSTATUS TBDB_TBEVENT_NODEACCOUNTS TBDB_TBEVENT_NODESTARTSTATUS TBDB_TBEVENT_NODEACCOUNTS
TBDB_TBEVENT_NODESTATUS
TBDB_NODESTATE_ISUP TBDB_NODESTATE_REBOOTING TBDB_NODESTATE_REBOOTED TBDB_NODESTATE_ISUP TBDB_NODESTATE_REBOOTING TBDB_NODESTATE_REBOOTED
TBDB_NODESTATE_SHUTDOWN TBDB_NODESTATE_BOOTING TBDB_NODESTATE_TBSETUP TBDB_NODESTATE_SHUTDOWN TBDB_NODESTATE_BOOTING TBDB_NODESTATE_TBSETUP
...@@ -478,6 +479,7 @@ sub TBDB_TBEVENT_COMMAND { "TBCOMMAND"; } ...@@ -478,6 +479,7 @@ sub TBDB_TBEVENT_COMMAND { "TBCOMMAND"; }
sub TBDB_TBEVENT_EXPTSTATE { "TBEXPTSTATE"; } sub TBDB_TBEVENT_EXPTSTATE { "TBEXPTSTATE"; }
sub TBDB_TBEVENT_NODESTARTSTATUS{ "TBSTARTSTATUS"; } sub TBDB_TBEVENT_NODESTARTSTATUS{ "TBSTARTSTATUS"; }
sub TBDB_TBEVENT_NODEACCOUNTS { "TBUPDATEACCOUNTS"; } sub TBDB_TBEVENT_NODEACCOUNTS { "TBUPDATEACCOUNTS"; }
sub TBDB_TBEVENT_NODESTATUS { "TBNODESTATUS"; }
# #
# For nodes, we use this set of events. # For nodes, we use this set of events.
......
...@@ -3170,11 +3170,6 @@ sub GetGeniSliverInfo($$;$) ...@@ -3170,11 +3170,6 @@ sub GetGeniSliverInfo($$;$)
sub SetStatus($$) sub SetStatus($$)
{ {
my ($self, $status) = @_; my ($self, $status) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $node_id = $self->node_id(); my $node_id = $self->node_id();
return -1 return -1
...@@ -3184,6 +3179,25 @@ sub SetStatus($$) ...@@ -3184,6 +3179,25 @@ sub SetStatus($$)
return 0; return 0;
} }
#
# Get the status slot for a node.
#
sub GetStatus($)
{
my ($self) = @_;
my $node_id = $self->node_id();
my $query_result =
DBQueryWarn("select status,status_timestamp from node_status ".
"where node_id='$node_id'");
return undef
if (! (defined($query_result) && $query_result->numrows));
my ($status,$stamp) = $query_result->fetchrow_array();
$self->{"DBROW"}->{'node_status'} = $status;
return $status;
}
# #
# #
# #
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2008 University of Utah and the Flux Group. # Copyright (c) 2000-2016 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -34,6 +34,7 @@ use English; ...@@ -34,6 +34,7 @@ use English;
my $TB = "@prefix@"; my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@"; my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@"; my $TBLOGS = "@TBLOGSEMAIL@";
my $BOSSNODE = "@BOSSNODE@";
# un-taint path # un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin'; $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin';
...@@ -52,6 +53,8 @@ $| = 1; ...@@ -52,6 +53,8 @@ $| = 1;
# Load the Testbed support stuff. # Load the Testbed support stuff.
use lib "@prefix@/lib"; use lib "@prefix@/lib";
use libdb; use libdb;
use EmulabConstants;
use event;
# #
# Only root and admins are allowed to use this script # Only root and admins are allowed to use this script
...@@ -181,6 +184,13 @@ while (my ($node,$status,$pid,$remote,$isvirt,$isplab,$timediff) = ...@@ -181,6 +184,13 @@ while (my ($node,$status,$pid,$remote,$isvirt,$isplab,$timediff) =
if (!$debug) { if (!$debug) {
DBQueryFatal("update node_status set status='$newstatus' ". DBQueryFatal("update node_status set status='$newstatus' ".
"where node_id='$node'"); "where node_id='$node'");
#
# Generate local event.
#
event::EventSendWarn(objtype => TBDB_TBEVENT_NODESTATUS,
objname => $node,
eventtype => $newstatus,
host => $BOSSNODE);
} }
} }
......
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