From 998cd2919a4504876373c1ee920249c111def65a Mon Sep 17 00:00:00 2001 From: sjing Date: Tue, 27 Dec 2011 03:42:20 +0000 Subject: [PATCH] lstree implementation. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11303 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/ipmi.pm | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 767be3ba9..ade6c4092 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -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;