diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 30fda8d1e..8c58dfa2e 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3151,26 +3151,30 @@ sub noderangecontainsMn { my ($class, @noderange)=@_; # check if any node in the noderange is the Management Node return the - # name - my $mname; + # name + my @mnames; # management node names in the database, members of __mgmtnode my $tab = xCAT::Table->new('nodelist'); my @nodelist=$tab->getAllNodeAttribs(['node','groups']); foreach my $n (@nodelist) { if (defined($n->{'groups'})) { my @groups=split(",",$n->{'groups'}); if ((grep (/__mgmtnode/,@groups))) { # this is the MN - $mname=$n->{'node'}; - last; + push @mnames,$n->{'node'}; } } } - if ($mname) { # if Management Node defined in the database - if (grep(/^$mname$/, @noderange)) { # if MN in the noderange - return $mname; - } else { - return ; + my @MNs; # management node names found the noderange + if (@mnames) { # if any Management Node defined in the database + foreach my $mn (@mnames) { + if (grep(/^$mn$/, @noderange)) { # if MN in the noderange + push @MNs, $mn; + } + } + if (@MNs) { # management nodes in the noderange + return @MNs; } } + return; # if no MN in the noderange, return nothing } =head3 filter_nodes