From a98a295d2365509fcd8e3e7bcf1bc1c5fc6f34f0 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 18 Sep 2012 12:57:53 +0000 Subject: [PATCH] new interface to getAllSN due to MN in servicenode table, also added use strict back in loss on the split and fixed the errors git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13840 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/ServiceNodeUtils.pm | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/ServiceNodeUtils.pm b/perl-xCAT/xCAT/ServiceNodeUtils.pm index 6da66bc1d..fc8e97b51 100644 --- a/perl-xCAT/xCAT/ServiceNodeUtils.pm +++ b/perl-xCAT/xCAT/ServiceNodeUtils.pm @@ -17,6 +17,7 @@ if ($^O =~ /^aix/i) { } use lib "$::XCATROOT/lib/perl"; +use strict; #----------------------------------------------------------------------------- =head3 readSNInfo @@ -173,7 +174,8 @@ sub isServiceReq Returns an array of all service nodes from service node table Arguments: - none + ALL" - will also return the management node in the array, if + if has been defined in the servicenode table Returns: array of Service Nodes or empty array, if none Globals: @@ -181,7 +183,8 @@ sub isServiceReq Error: 1 - error Example: - @allSN=xCAT::ServiceNodeUtils->getAllSN + @SN=xCAT::ServiceNodeUtils->getAllSN + @allSN=xCAT::ServiceNodeUtils->getAllSN("ALL") Comments: none @@ -190,7 +193,8 @@ sub isServiceReq #----------------------------------------------------------------------------- sub getAllSN { - + + my ($class, $options) = @_; require xCAT::Table; # reads all nodes from the service node table my @servicenodes; @@ -205,7 +209,21 @@ sub getAllSN my @nodes = $servicenodetab->getAllNodeAttribs(['tftpserver']); foreach my $nodes (@nodes) { - push @servicenodes, $nodes->{node}; + push @servicenodes, $nodes->{node}; + } + # if did not input "ALL" and there is a MN, remove it + my @newservicenodes; + if ((!defined($options)) || ($options ne "ALL")) { + my $mname = xCAT::Utils->noderangecontainsMn(@servicenodes); + if ($mname) { # if there is a MN + foreach my $nodes (@servicenodes) { + if ($mname ne ($nodes)){ + push @newservicenodes, $nodes; + } + } + $servicenodetab->close; + return @newservicenodes; # return without the MN in the array + } } $servicenodetab->close; return @servicenodes; @@ -714,8 +732,8 @@ sub getSNandCPnodes my ($class, $nodes,$sn,$cn) = @_; my @nodelist = @$nodes; # get the list of all Service nodes - @allSN=xCAT::ServiceNodeUtils->getAllSN; - foreach $node (@nodelist) { + my @allSN=xCAT::ServiceNodeUtils->getAllSN; + foreach my $node (@nodelist) { if (grep(/^$node$/, @allSN)) { # it is a SN push (@$sn,$node); } else { # a CN