From 7ba4186fffeef46e8f69d691c5a2b94771ab9238 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 19 Jun 2012 14:35:27 +0000 Subject: [PATCH] Enhance slpdiscover to reconigure CMMs even if their password is not default if user provides an alternative git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13125 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/blade.pm | 4 +++ xCAT-server/lib/xcat/plugins/slpdiscover.pm | 30 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index e9153a937..f2cecbe4c 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4024,7 +4024,11 @@ sub clicmds { $curruser="USERID"; $currpass = "PASSW0RD"; $nokeycheck=1; + } else { + if ($args{curruser}) { $curruser = $args{curruser}; $nokeycheck=1; } + if ($args{currpass}) { $currpass = $args{currpass}; $nokeycheck=1; } } + if ($args{nokeycheck}) { $nokeycheck=1; } diff --git a/xCAT-server/lib/xcat/plugins/slpdiscover.pm b/xCAT-server/lib/xcat/plugins/slpdiscover.pm index 107c8dcf0..980038a98 100644 --- a/xCAT-server/lib/xcat/plugins/slpdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/slpdiscover.pm @@ -8,6 +8,8 @@ use xCAT::MacMap; use xCAT_plugin::bmcconfig; my $defaultbladeuser; my $defaultbladepass; +my $currentbladepass; +my $currentbladeuser; my $mpahash; sub handled_commands { @@ -101,6 +103,16 @@ sub process_request { my $mpatab=xCAT::Table->new("mpa",-create=>0); my @mpaentries; $mpahash={}; + if (ref $request->{environment} and ref $request->{environment}->[0]->{XCAT_CURRENTPASS}) { + $currentbladepass=$request->{environment}->[0]->{XCAT_CURRENTPASS}->[0]; + } else { + $currentbladepass="PASSW0RD"; + } + if (ref $request->{environment} and ref $request->{environment}->[0]->{XCAT_CURRENTUSER}) { + $currentbladeuser=$request->{environment}->[0]->{XCAT_CURRENTUSER}->[0]; + } else { + $currentbladeuser="USERID"; + } if ($mpatab) { @mpaentries = $mpatab->getAllNodeAttribs([qw/mpa username password/]); foreach (@mpaentries) { @@ -274,9 +286,10 @@ sub do_blade_setup { %exargs = ( nokeycheck=>1 ); #still not at the 'right' ip, so the known hosts shouldn't be bothered } else { @cmds = qw/snmpcfg=enable sshcfg=enable textid=*/; # initnetwork=*/; defer initnetwork until after chassis members have been configured - %exargs = ( defaultcfg=>1 ); + %exargs = ( curruser=>$currentbladeuser, currpass=>$currentbladepass ); } my $result; + $@=""; my $rc = eval { $result = xCAT_plugin::blade::clicmds( $nodename, $localuser, @@ -288,12 +301,23 @@ sub do_blade_setup { cmds=>\@cmds ); 1; }; - if (not $rc) { - sendmsg([1,"Failed to set up Management module due to $@"],$callback,$nodename); + my $errmsg=$@; + if ($errmsg) { + if ($errmsg =~ /Incorrect Password/) { + sendmsg([1,"Failed to set up Management module due to Incorrect Password (You may try the environment variables XCAT_CURRENTUSER and/or XCAT_CURRENTPASS to try a different value)"],$callback,$nodename); + }else { + sendmsg([1,"Failed to set up Management module due to $errmsg"],$callback,$nodename); + } + return 0; } if ($result) { if ($result->[0]) { + if ($result->[2] =~ /Incorrect Password/) { + sendmsg([1,"Failed to set up Management module due to Incorrect Password (You may try the environment variables XCAT_CURRENTUSER and/or XCAT_CURRENTPASS to try a different value)"],$callback,$nodename); + return 0; + } sendmsg([$result->[0],$result->[2]],$callback,$nodename); + return 0; } } return $rc;