lstree implementation.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11303 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
sjing 2011-12-27 03:42:20 +00:00
parent 77107e1575
commit 998cd2919a

View File

@ -5747,4 +5747,43 @@ sub sendoutput {
}
}
##########################################################################
# generate hardware tree, called from lstree.
##########################################################################
sub genhwtree
{
my $nodelist = shift; # array ref
my $callback = shift;
my %hwtree;
my $bmchash;
# read ipmi.bmc
my $ipmitab = xCAT::Table->new('ipmi');
if ($ipmitab)
{
$bmchash = $ipmitab->getNodesAttribs($nodelist, ['bmc']);
}
else
{
my $rsp = {};
$rsp->{data}->[0] = "Can not open ipmi table.\n";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
}
foreach my $node (@$nodelist)
{
if ($bmchash->{$node}->[0]->{'bmc'})
{
push @{$hwtree{$bmchash->{$node}->[0]->{'bmc'}}}, $node;
}
}
return \%hwtree;
}
1;