Commit 8934efbd authored by Robert Ricci's avatar Robert Ricci

Add two new functions, TBNodeType (to get the type and class of a

node), and TBNodeTypeProcInfo (to get the processor and speed for a
given node type.)
parent 41b95692
......@@ -165,6 +165,8 @@ use vars qw(@ISA @EXPORT);
TBLeaderMailList ExpGroup TBExptSetSwapUID TBExptSetThumbNail
TBNodeAllocCheck TBPlabNodeUsername MarkPhysNodeDown
TBNodeType TBNodeTypeProcInfo
TBExptRemoveVirtualState TBExptBackupVirtualState
TBExptRestoreVirtualState
......@@ -2960,6 +2962,51 @@ sub TBExptClearBackupState($$)
if (-e $vstateDir);
}
#
# Return a node's type and class, in a two-element array
# If the caller asked for a scalar, give them only the type
# Returns undef if the node doesn't exist
#
sub TBNodeType($)
{
my ($node) = @_;
my $result = DBQueryFatal("SELECT n.type, class FROM nodes AS n " .
"LEFT JOIN node_types " .
" AS nt ON n.type = nt.type " .
"WHERE n.node_id='$node'");
if ($result->num_rows() != 1) {
return undef;
}
my ($type, $class) = $result->fetchrow();
if (!$class) {
return undef;
}
if (wantarray) {
return ($type, $class);
} else {
return $type;
}
}
#
# Return a node's type CPU type and speed, in a two-element array
# Returns undef if the type can't be found
#
sub TBNodeTypeProcInfo($)
{
my ($type) = @_;
my $result = DBQueryFatal("SELECT proc, speed FROM node_types " .
"WHERE type='$type'");
if ($result->num_rows() != 1) {
return undef;
}
my ($proc, $speed) = $result->fetchrow();
return ($proc, $speed);
}
#
# Remove the virtual state of an experiment from the DB,
# returning the number of queries which didn't work.
......
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