fix bug 3780: Incorrect password selected for blade

This commit is contained in:
zhaoertao 2013-09-13 00:44:47 -07:00
parent 0b9bccf4df
commit cf14e652d1

View File

@ -19,7 +19,6 @@ use xCAT::Utils;
use xCAT::TableUtils;
use xCAT::NetworkUtils;
use xCAT::ServiceNodeUtils;
use xCAT::PasswordUtils;
use xCAT::IMMUtils;
use xCAT::Usage;
use IO::Socket;
@ -4310,11 +4309,11 @@ sub process_request {
return;
}
}
#my $bladeuser = 'USERID';
#my $bladepass = 'PASSW0RD';
my $bladeuser = 'USERID';
my $bladepass = 'PASSW0RD';
my $blademaxp = 64;
#my $sitetab = xCAT::Table->new('site');
#my $mpatab = xCAT::Table->new('mpa');
my $mpatab = xCAT::Table->new('mpa');
my $mptab = xCAT::Table->new('mp');
my $tmp;
my @entries = xCAT::TableUtils->get_site_attribute("blademaxp");
@ -4326,19 +4325,19 @@ sub process_request {
# ($tmp)=$sitetab->getAttribs({'key'=>'blademaxp'},'value');
# if (defined($tmp)) { $blademaxp=$tmp->{value}; }
#}
#if ($request->{environment}->[0]->{XCAT_BLADEUSER}) {
# $bladeuser=$request->{environment}->[0]->{XCAT_BLADEUSER}->[0];
# $bladepass=$request->{environment}->[0]->{XCAT_BLADEPASS}->[0];
#} else {
#my $passtab = xCAT::Table->new('passwd');
# if ($passtab) {
# ($tmp)=$passtab->getAttribs({'key'=>'blade'},'username','password');
# if (defined($tmp)) {
# $bladeuser = $tmp->{username};
# $bladepass = $tmp->{password};
# }
# }
#}
if ($request->{environment}->[0]->{XCAT_BLADEUSER}) {
$bladeuser=$request->{environment}->[0]->{XCAT_BLADEUSER}->[0];
$bladepass=$request->{environment}->[0]->{XCAT_BLADEPASS}->[0];
} else {
my $passtab = xCAT::Table->new('passwd');
if ($passtab) {
($tmp)=$passtab->getAttribs({'key'=>'blade'},'username','password');
if (defined($tmp)) {
$bladeuser = $tmp->{username};
$bladepass = $tmp->{password};
}
}
}
if ($request->{command}->[0] eq "findme") {
my $mptab = xCAT::Table->new("mp");
unless ($mptab) { return 2; }
@ -4457,25 +4456,24 @@ sub process_request {
my @nodes=split(',', $2);
my @ids=split(',', $3);
my @mptypes=split(',', $4);
#my $user=$bladeuser;
#my $pass=$bladepass;
my $user=$bladeuser;
my $pass=$bladepass;
my $ent;
#if (defined($mpatab)) {
# my @user_array = $mpatab->getNodeAttribs($mpa, qw(username password));
# foreach my $entry (@user_array) {
# if ($entry->{username}) {
# if ($entry->{username} =~ /^USERID$/ or $entry->{username} !~ /^HMC$/) {
# $ent = $entry;
# last;
# }
# }
# }
# if (defined($ent->{password})) { $pass = $ent->{password}; }
# if (defined($ent->{username})) { $user = $ent->{username}; }
#}
my $authdata = xCAT::PasswordUtils::getIPMIAuth(noderange=>[$mpa]);
$mpahash{$mpa}->{username} = $authdata->{$mpa}->{username};
$mpahash{$mpa}->{password} = $authdata->{$mpa}->{password};
if (defined($mpatab)) {
my @user_array = $mpatab->getNodeAttribs($mpa, qw(username password));
foreach my $entry (@user_array) {
if ($entry->{username}) {
if ($entry->{username} =~ /^USERID$/) {
$ent = $entry;
last;
}
}
}
if (defined($ent->{password})) { $pass = $ent->{password}; }
if (defined($ent->{username})) { $user = $ent->{username}; }
}
$mpahash{$mpa}->{username} = $user;
$mpahash{$mpa}->{password} = $pass;
my $nodehmtab = xCAT::Table->new('nodehm');
my $hmdata = $nodehmtab->getNodesAttribs(\@nodes, ['node', 'mgt']);
for (my $i=0; $i<@nodes; $i++) {