Commit 60563956 authored by Chad Barb's avatar Chad Barb

Added Alloc State machine library calls.

(NodeSetAllocState, NodeGetAllocState)
parent f0e01a7e
......@@ -74,18 +74,28 @@ use Exporter;
TB_ASSIGN_TOOFEWNODES TB_OPSPID
TBDB_TBEVENT_NODESTATE TBDB_TBEVENT_NODEOPMODE TBDB_TBEVENT_CONTROL
TBDB_NODESTATE_ISUP TBDB_NODESTATE_REBOOTING TBDB_NODESTATE_REBOOTED
TBDB_NODESTATE_SHUTDOWN TBDB_NODESTATE_BOOTING TBDB_NODESTATE_TBSETUP
TBDB_NODESTATE_RELOADSETUP TBDB_NODESTATE_RELOADING
TBDB_NODESTATE_RELOADDONE TBDB_NODESTATE_UNKNOWN
TBDB_NODEOPMODE_NORMAL TBDB_NODEOPMODE_DELAYING
TBDB_NODEOPMODE_UNKNOWNOS TBDB_NODEOPMODE_RELOADING
TBDB_NODEOPMODE_NORMALv1 TBDB_NODEOPMODE_MINIMAL
TBDB_NODEOPMODE_RELOAD TBDB_NODEOPMODE_DELAY
TBDB_NODEOPMODE_BOOTWHAT
TBDB_NODEOPMODE_UNKNOWN
TBDB_ALLOCSTATE_FREE_CLEAN TBDB_ALLOCSTATE_FREE_DIRTY
TBDB_ALLOCSTATE_DOWN TBDB_ALLOCSTATE_RELOAD_TO_FREE
TBDB_ALLOCSTATE_RELOAD_PENDING TBDB_ALLOCSTATE_RES_RELOAD
TBDB_ALLOCSTATE_RES_REBOOT_DIRTY TBDB_ALLOCSTATE_RES_REBOOT_CLEAN
TBDB_ALLOCSTATE_RES_READY TBDB_ALLOCSTATE_UNKNOWN
TBDB_EXPT_WORKDIR
TBSetNodeEventState TBGetNodeEventState
TBSetNodeAllocState TBGetNodeAllocState
TBSetNodeOpMode TBGetNodeOpMode
TB_OSID_MBKERNEL TB_OSID_PXEBOOT TB_OSID_FRISBEE
TBBootWhat TBNodeStateTimeout
......@@ -369,6 +379,17 @@ sub TBDB_NODEOPMODE_DELAY { "DELAY"; }
sub TBDB_NODEOPMODE_BOOTWHAT { "_BOOTWHAT_"; } # A redirection opmode
sub TBDB_NODEOPMODE_UNKNOWN { "UNKNOWN"; }
sub TBDB_ALLOCSTATE_FREE_CLEAN() { "FREE_CLEAN"; }
sub TBDB_ALLOCSTATE_FREE_DIRTY() { "FREE_DIRTY"; }
sub TBDB_ALLOCSTATE_DOWN() { "DOWN"; }
sub TBDB_ALLOCSTATE_RELOAD_TO_FREE() { "RELOAD_TO_FREE"; }
sub TBDB_ALLOCSTATE_RELOAD_PENDING() { "RELOAD_PENDING"; }
sub TBDB_ALLOCSTATE_RES_RELOAD() { "RES_RELOAD"; }
sub TBDB_ALLOCSTATE_RES_DIRTY_REBOOT() { "RES_DIRTY_REBOOT"; }
sub TBDB_ALLOCSTATE_RES_CLEAN_REBOOT() { "RES_CLEAN_REBOOT"; }
sub TBDB_ALLOCSTATE_RES_READY() { "RES_READY"; }
sub TBDB_ALLOCSTATE_UNKNOWN() { "UNKNOWN"; };
sub TBDB_TBCONTROL_RESET { "RESET"; }
sub TBDB_TBCONTROL_RELOADDONE { "RELOADDONE"; }
sub TBDB_TBCONTROL_TIMEOUT { "TIMEOUT"; }
......@@ -1785,6 +1806,49 @@ sub TBGetNodeOpMode($$)
return 1;
}
#
# Set alloc state for a node.
#
# usage: TBSetNodeAllocState(char *node, char *state)
# Returns 1 if okay.
# Returns 0 if failed.
#
sub TBSetNodeAllocState($$)
{
my ($node, $state) = @_;
my $now = time();
return DBQueryFatal("update nodes set allocstate='$state', " .
"allocstate_timestamp=$now where node_id='$node'");
}
#
# Get alloc state for a node.
#
# usage: TBGetNodeAllocState(char *node, char \*state)
# Returns 1 if okay (and sets state).
# Returns 0 if failed.
#
sub TBGetNodeAllocState($$)
{
my ($node, $state) = @_;
my $query_result =
DBQueryFatal("select allocstate from nodes where node_id='$node'");
if ($query_result->numrows == 0) {
return 0;
}
my @row = $query_result->fetchrow_array();
if (defined($row[0])) {
$$state = $row[0];
}
else {
$$state = TBDB_ALLOCSTATE_UNKNOWN;
}
return 1;
}
#
# Is a node remote?
#
......
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