From d3004ddae953d662722c06fcea5e5c1a1e0cd850 Mon Sep 17 00:00:00 2001 From: chenglch Date: Thu, 17 Mar 2016 02:27:17 -0400 Subject: [PATCH] fix lsdef performance issue Previously lsdef command access nodelist table for each node with getNodeAttribs. This patch will use getNodesAttribs to fetch the attributes for multiple nodes at one time. --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 47a21f174..40285f360 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3343,16 +3343,12 @@ sub defls # $newhash{$_->{node}} = 1; # } #} - - foreach my $n (keys %defhash) { - #if ($newhash{$n} eq 1) { - my ($hidhash) = $listtab->getNodeAttribs($n ,['hidden']); - if ($hidhash) { - if ( $hidhash->{hidden} eq 1) { - delete $defhash{$n}; - } - } - #} + my @def_nodes = keys %defhash; + my $hidden_nodes = $listtab->getNodesAttribs(\@def_nodes, ['hidden']); + foreach my $n (keys %{$hidden_nodes}) { + if (defined($hidden_nodes->{$n}->[0]->{'hidden'}) && $hidden_nodes->{$n}->[0]->{'hidden'} eq 1) { + delete $defhash{$n}; + } } } }