-Check in unoptimized getNodesAttribs function for Table.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1809 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-06-30 13:51:44 +00:00
parent 377d972596
commit 9dec80d60b

View File

@ -13,6 +13,7 @@ BEGIN
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use lib "$::XCATROOT/lib/perl";
my $cachethreshold=16; #How many nodes in 'getNodesAttribs' before switching to full DB retrieval
use DBI;
@ -871,6 +872,50 @@ sub setAttribsWhere
#--------------------------------------------------------------------------
=head3 getNodesAttribs
Description: Retrieves the requested attributes for a node list
Arguments:
Table handle ('self')
List ref of nodes
Attribute type array
Returns:
two layer hash reference (->{nodename}->{attrib}
Globals:
Error:
Example:
my $ostab = xCAT::Table->new('nodetype');
my $ent = $ostab->getNodesAttribs(\@nodes,['profile','os','arch']);
if ($ent) { print $ent->{n1}->{profile}
Comments:
Using this function will clue the table layer into the atomic nature of the request, and allow shortcuts to be taken as appropriate to fulfill the request at scale.
=cut
#--------------------------------------------------------------------------------
sub getNodesAttribs {
my $self = shift;
my $nodelist = shift;
my @attribs;
if (ref $_[0]) {
@attribs = @{shift()};
} else {
@attribs = @_;
}
my $rethash;
foreach (@$nodelist) {
$rethash->{$_} = $self->getNodeAttribs($_,\@attribs);
}
return $rethash;
}
#--------------------------------------------------------------------------
=head3 getNodeAttribs