From 00b7d766d7ce444cfdec32276f64374b8e8ac0d9 Mon Sep 17 00:00:00 2001 From: yinle Date: Tue, 18 Jan 2011 14:18:55 +0000 Subject: [PATCH] FSP/BPA redundancy: add -S flag to nodels to hide the FSP/BPA nodes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8694 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 39 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 22d4f482d..b80fc7075 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -1491,7 +1491,7 @@ sub nodels my $exitcode = shift @_; my %rsp; push @{$rsp{data}}, "Usage:"; - push @{$rsp{data}}, " nodels [noderange] [-b|--blame] [-H|--with-fieldname] [table.attribute | shortname] [...]"; + push @{$rsp{data}}, " nodels [noderange] [-b|--blame] [-H|--with-fieldname] [table.attribute | shortname] [-S][...]"; push @{$rsp{data}}, " nodels {-v|--version}"; push @{$rsp{data}}, " nodels [-?|-h|--help]"; if ($exitcode) { $rsp{errorcode} = $exitcode; } @@ -1505,8 +1505,9 @@ sub nodels } my $NOTERSE; my $ATTRIBUTION; + my $HIDDEN; - if (!GetOptions('h|?|help' => \$HELP, 'H|with-fieldname' => \$NOTERSE, 'b|blame' => \$ATTRIBUTION, 'v|version' => \$VERSION,) ) { $nodels_usage->(1); return; } + if (!GetOptions('h|?|help' => \$HELP, 'H|with-fieldname' => \$NOTERSE, 'b|blame' => \$ATTRIBUTION, 'v|version' => \$VERSION, 'S' => \$HIDDEN) ) { $nodels_usage->(1); return; } # Help if ($HELP) { $nodels_usage->(0); return; } @@ -1746,14 +1747,34 @@ sub nodels { my @attribs = ("node"); my @ents = $nodelisttab->getAllAttribs(@attribs); - my @nodes; + my @nodes; foreach (@ents) { - if ($_->{node}) { - push @nodes, $_->{node}; - } - } - @nodes = sort {$a cmp $b} @nodes; - foreach (@nodes) { + if ($_->{node}) { + push @nodes, $_->{node}; + } + } + #-S will make nodels not show FSPs and BPAs + my @newnodes = (); + if (defined($HIDDEN)) + { + my $listtab = xCAT::Table->new( 'nodelist' ); + if ($listtab) { + my $listHash = $listtab->getNodesAttribs(\@nodes, ['hidden']); + foreach my $rnode(@nodes) { + unless (defined($listHash->{$rnode}->[0]->{hidden})){ + push (@newnodes, $rnode); + } elsif ($listHash->{$rnode}->[0]->{hidden} ne 1) { + push (@newnodes, $rnode); + } + } + } + @nodes = (); + foreach (@newnodes) { + push (@nodes, $_); + } + } + @nodes = sort {$a cmp $b} @nodes; + foreach (@nodes) { my $rsp; #if ($_) #{