From ab867292a328cfb010a5d225695cf8f591377618 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Tue, 6 Mar 2012 06:38:47 +0000 Subject: [PATCH] for NGP, fix some bugs found by UT git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11757 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 3 +++ xCAT-server/lib/xcat/plugins/blade.pm | 25 ++++++++++++++++--------- xCAT-server/lib/xcat/plugins/fsp.pm | 8 ++++++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 5f323804e..0982a1de7 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -2901,6 +2901,9 @@ sub getIPaddress require xCAT::Table; my $nodetocheck = shift; my $port = shift; + if (isIpaddr($nodetocheck)) { + return $nodetocheck; + } my $side = "[A|B]"; if (!defined($port)) { $port = "[0|1]"; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 44a2daf2f..40fa3c1e5 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -1787,9 +1787,13 @@ sub getmacs { $mkey="primarynic"; } if ($mkey) { - while ( $nent->{$mkey} =~ /(\d+)/g ) { - push @midxary,$1; - } + while ( $nent->{$mkey} =~ /(\d+)/g ) { + my $nic = $1; + if ($nic !~ /[1234]/) { + return -1, "noderes.$mkey is not correct"; + } + push @midxary,$nic; + } } } else { $nrtab->close; @@ -1804,7 +1808,7 @@ sub getmacs { my @allmacs; foreach my $midx ( @midxary) { - (my $macd,my $mac) = split (/:/,$macs[$midx],2); + (my $macd,my $mac) = split (/:/,$macs[$midx-1],2); $mac =~ s/\s+//g; if ($macd !~ /mac address \d/i) { return 1,"Unable to retrieve MAC address for interface $midx from Management Module"; @@ -3662,8 +3666,12 @@ sub filter_nodes{ push @{$mpnodes}, @mp; push @{$fspnodes}, @commonfsp; - if (@args && ($cmd eq "rspconfig") && (grep /^(network|network=.*)$/, @args)) { - push @{$mpnodes}, @ngpfsp; + if (@args && ($cmd eq "rspconfig")) { + if (!(grep /^(cec_off_policy|pending_power_on_side)/, @args)) { + push @{$mpnodes}, @ngpfsp; + } else { + push @{$fspnodes}, @ngpfsp; + } } elsif($cmd eq "getmacs") { if (@args && (grep /^-D$/,@args)) { push @{$fspnodes}, @ngpfsp; @@ -4173,9 +4181,8 @@ sub passwd { my $pass = shift; my $mm = shift; my $cmd = "users -n $user -p $pass -T system:$mm"; - print "===>$cmd\n"; if (!$pass) { - return ([1, "No param specified"]); + return ([1, "No param specified for '$user'"]); } my @data = $t->cmd($cmd); if (!grep(/OK/i, @data)) { @@ -4363,7 +4370,7 @@ sub swnet { } if (!$value) { - my @data = $t->cmd("ifconfig -T system::$switch"); + my @data = $t->cmd("ifconfig -T system:$switch"); my $s = join('',@data); if ($s =~ /-i\s+(\S+)/) { $ip = $1; } if ($s =~ /-g\s+(\S+)/) { $gateway = $1; } diff --git a/xCAT-server/lib/xcat/plugins/fsp.pm b/xCAT-server/lib/xcat/plugins/fsp.pm index dc2a5dc12..c7c4c1904 100644 --- a/xCAT-server/lib/xcat/plugins/fsp.pm +++ b/xCAT-server/lib/xcat/plugins/fsp.pm @@ -162,8 +162,12 @@ sub filter_nodes{ push @{$mpnodes}, @mp; push @{$fspnodes}, @commonfsp; - if (@args && ($cmd eq "rspconfig") && (grep /^(network|network=.*)$/, @args)) { - push @{$mpnodes}, @ngpfsp; + if (@args && ($cmd eq "rspconfig")) { + if (!(grep /^(cec_off_policy|pending_power_on_side)/, @args)) { + push @{$mpnodes}, @ngpfsp; + } else { + push @{$fspnodes}, @ngpfsp; + } } elsif($cmd eq "getmacs") { if (@args && (grep /^-D$/,@args)) { push @{$fspnodes}, @ngpfsp;