From 7ee8876bfd32841bf39ae245ff42da57480b76b3 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 24 Aug 2012 16:50:07 +0000 Subject: [PATCH] add routine to divide nodelist into service and non-service nodes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13607 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/ServiceNodeUtils.pm | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/ServiceNodeUtils.pm b/perl-xCAT/xCAT/ServiceNodeUtils.pm index 2ecb64cce..6da66bc1d 100644 --- a/perl-xCAT/xCAT/ServiceNodeUtils.pm +++ b/perl-xCAT/xCAT/ServiceNodeUtils.pm @@ -181,7 +181,7 @@ sub isServiceReq Error: 1 - error Example: - @allSN=xCAT::ServiceNodeUtils->get_AllSN + @allSN=xCAT::ServiceNodeUtils->getAllSN Comments: none @@ -684,4 +684,45 @@ sub getSNformattedhash } return \%newsnhash; } +#----------------------------------------------------------------------------- + +=head3 + + getSNandCPnodes - Take an array of nodes and returns + an array of the service + nodes and an array of the computenode . + + Arguments: + none + Returns: + array of Service Nodes and/or array of compute nodesarray of compute nodes empty array, if none + Globals: + none + Error: + 1 - error + Example: + xCAT::ServiceNodeUtils->getSNandCPnodes(\@nodes,\@SN,\@CN); + Comments: + none + +=cut + +#----------------------------------------------------------------------------- +sub getSNandCPnodes +{ + + my ($class, $nodes,$sn,$cn) = @_; + my @nodelist = @$nodes; + # get the list of all Service nodes + @allSN=xCAT::ServiceNodeUtils->getAllSN; + foreach $node (@nodelist) { + if (grep(/^$node$/, @allSN)) { # it is a SN + push (@$sn,$node); + } else { # a CN + push (@$cn,$node); + } + } + + return ; +} 1;