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
This commit is contained in:
jbjohnso 2012-06-19 14:35:27 +00:00
parent 8403898633
commit 7ba4186fff
2 changed files with 31 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;