From 84ab9da2cf5c486b6a97305352c12e201763979a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 7 Aug 2012 14:55:24 +0000 Subject: [PATCH] add check to see if the Management Node is contained in the defined noderange array input git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13447 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 6d83a9e62..f3e0fbe85 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -6452,5 +6452,45 @@ sub pingNodeStatus { return %status; } +#------------------------------------------------------------------------------- + +=head3 noderangecontainsMN + Returns: + returns nothing, if ManagementNode is not the input noderange + returns name of MN, if Management Node is in the input noderange + Globals: + none + Error: + none + Input: + array of nodes in the noderange + Example: + my $mn=xCAT::Utils->noderangecontainsMN($noderange); + Comments: +=cut + +#------------------------------------------------------------------------------- +sub noderangecontainsMn +{ + my ($class, @noderange)=@_; + # check if any node in the noderange is the Management Node return the + # name + my $mname; + my $tab = xCAT::Table->new('nodetype'); + my @nodelist=$tab->getAllNodeAttribs(['node','nodetype']); + foreach my $n (@nodelist) { + if ($n->{'nodetype'} eq "mn") { # this is the MN + $mname=$n->{'node'}; + last; + } + } + if (grep(/$mname/, @noderange)) { # if MN in the noderange + return $mname; + } else { + return ; + } +} + + 1;