From 1d89fb6e1ba7195fb8042d0b1c7059860319e860 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 23 May 2013 08:23:21 +0000 Subject: [PATCH] enhancement of "rspconfig noderange USERID=" git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16408 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/IMMUtils.pm | 31 +++++++++++++++++---------- xCAT-server/lib/xcat/plugins/blade.pm | 2 +- xCAT-server/lib/xcat/plugins/ipmi.pm | 11 +++++++--- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/IMMUtils.pm b/xCAT-server/lib/perl/xCAT/IMMUtils.pm index d4065a872..3ebb1a215 100644 --- a/xCAT-server/lib/perl/xCAT/IMMUtils.pm +++ b/xCAT-server/lib/perl/xCAT/IMMUtils.pm @@ -67,18 +67,26 @@ sub setupIMM { #ok, with all ip addresses in hand, time to enable IPMI and set all the ip addresses (still static only, TODO: dhcp my $ssh; - eval {$ssh = new xCAT::SSHInteract(-username=>$args{cliusername}, - -password=>$args{clipassword}, - -host=>$sship, - -nokeycheck=>1, - -output_record_separator=>"\r", - Timeout=>15, - Errmode=>'return', - Prompt=>'/> $/');}; - my $errmsg = $@; - if ($errmsg) { - exit(0); + eval {$ssh = new xCAT::SSHInteract(-username=>$args{cliusername}, + -password=>$args{clipassword}, + -host=>$sship, + -nokeycheck=>1, + -output_record_separator=>"\r", + Timeout=>15, + Errmode=>'return', + Prompt=>'/> $/');}; + my $errmsg = $@; + if ($errmsg) { + if ($errmsg =~ /Login Failed/) { + $errmsg = "Login failed"; + } elsif ($errmsg =~ /Incorrect Password/) { + $errmsg = "Incorrect Password"; + } else { + $errmsg = "Failed"; } + sendmsg(":$errmsg", $callback, $node); + exit(0); + } if ($ssh and $ssh->atprompt) { #we are in and good to issue commands $ssh->cmd("accseccfg -pe 0 -rc 0 -ci 0 -lf 0 -lp 0"); #disable the more insane password rules, this isn't by and large a human used interface $ssh->cmd("users -1 -n ".$ipmiauthmap->{$node}->{username}." -p ".$ipmiauthmap->{$node}->{password}." -a super"); #this gets ipmi going @@ -97,6 +105,7 @@ sub setupIMM { $ssh->close(); $ipmitab->setNodeAttribs($node,{bmcid=>$nodedata->{macaddress}}); } + sendmsg(":Succeeded", $callback,$node); exit(0); } diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 3d7e34c9e..c98d77f16 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -5012,7 +5012,7 @@ sub passwd { } else { return ([1, "Update password for $user in 'mpa' table failed"]); } - return ([0, "Success"]); + return ([0, "Succeeded"]); } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index dfea49739..d7c883586 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -6120,11 +6120,16 @@ sub process_request { } if ($updatepasswd) { splice(@{$request->{arg}}, $index, 1); - @exargs=($request->{arg}); + @exargs=@{$request->{arg}}; foreach (@donargs) { - xCAT::IMMUtils::setupIMM($_->[0],curraddr=>$_->[1],skipbmcidcheck=>1,skipnetconfig=>1,cliusername=>$_->[2],clipassword=>$_->[3],callback=>$callback); + my $cliuser = $authdata->{$_->[0]}->{cliusername}; + my $clipass = $authdata->{$_->[0]}->{clipassword}; + xCAT::IMMUtils::setupIMM($_->[0],curraddr=>$_->[1],skipbmcidcheck=>1,skipnetconfig=>1,cliusername=>$cliuser,clipassword=>$clipass,callback=>$callback); } - } + if ($#exargs == -1) { + return; + } + } } #get new node status