Read userid/password from database before connect fork
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1259 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
4a043a683e
commit
755293fea9
@ -239,18 +239,24 @@ sub resolve_hcp {
|
||||
####################################
|
||||
# Process each node
|
||||
####################################
|
||||
foreach ( @$noderange ) {
|
||||
my ($ent) = $db->getAttribs( {hcp=>$_},"hcp" );
|
||||
foreach my $hcp ( @$noderange ) {
|
||||
my ($ent) = $db->getAttribs( {hcp=>$hcp},"hcp" );
|
||||
|
||||
if ( !defined( $ent )) {
|
||||
my $msg = sprintf( "$_: $errmsg{NODE_UNDEF}", $tab );
|
||||
my $msg = sprintf( "$hcp: $errmsg{NODE_UNDEF}", $tab );
|
||||
send_msg( $request, 1, $msg );
|
||||
next;
|
||||
}
|
||||
################################
|
||||
# Get userid and password
|
||||
################################
|
||||
my @cred = xCAT::PPCdb::credentials( $hcp, $request->{hwtype} );
|
||||
$request->{$hcp}{cred} = \@cred;
|
||||
|
||||
################################
|
||||
# Save values
|
||||
################################
|
||||
push @nodegroup,[$_];
|
||||
push @nodegroup,[$hcp];
|
||||
}
|
||||
return( \@nodegroup );
|
||||
|
||||
@ -322,6 +328,13 @@ sub preprocess_nodes {
|
||||
$nodehash{$hcp}{$mtms}{$node} = $d;
|
||||
}
|
||||
##########################################
|
||||
# Get userid and password
|
||||
##########################################
|
||||
while (my ($hcp,$hash) = each(%nodehash) ) {
|
||||
my @cred = xCAT::PPCdb::credentials( $hcp, $request->{hwtype} );
|
||||
$request->{$hcp}{cred} = \@cred;
|
||||
}
|
||||
##########################################
|
||||
# Group the nodes - we will fork one
|
||||
# process per nodegroup array element.
|
||||
##########################################
|
||||
|
@ -5,7 +5,6 @@ use strict;
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(SUCCESS RC_ERROR EXPECT_ERROR NR_ERROR);
|
||||
use xCAT::PPCdb;
|
||||
use Expect;
|
||||
|
||||
|
||||
@ -91,12 +90,8 @@ sub connect {
|
||||
##################################################
|
||||
# Get userid/password
|
||||
##################################################
|
||||
my @cred = xCAT::PPCdb::credentials( $server, $hwtype );
|
||||
|
||||
##################################################
|
||||
# ssh to remote host
|
||||
##################################################
|
||||
my $parameters = "$cred[0]\@$server";
|
||||
my $cred = $req->{$server}{cred};
|
||||
my $parameters = "@$cred[0]\@$server";
|
||||
|
||||
##################################################
|
||||
# Redirect STDERR to variable
|
||||
@ -131,7 +126,7 @@ sub connect {
|
||||
while ( $retry-- ) {
|
||||
my $success = 0;
|
||||
my $pwd_sent = 0;
|
||||
$expect_log = undef;
|
||||
$expect_log = undef;
|
||||
|
||||
$ssh = new Expect;
|
||||
|
||||
@ -172,7 +167,7 @@ sub connect {
|
||||
[ $pwd_prompt,
|
||||
sub {
|
||||
if ( ++$pwd_sent == 1 ) {
|
||||
$ssh->send( "$cred[1]\r" );
|
||||
$ssh->send( "@$cred[1]\r" );
|
||||
$ssh->exp_continue();
|
||||
}
|
||||
} ],
|
||||
@ -206,8 +201,8 @@ sub connect {
|
||||
$prompt{$hwtype},
|
||||
$hwtype,
|
||||
$server,
|
||||
$cred[0],
|
||||
$cred[1],
|
||||
@$cred[0],
|
||||
@$cred[1],
|
||||
\$expect_log,
|
||||
$timeout );
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use HTML::Form;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##########################################
|
||||
# Globals
|
||||
##########################################
|
||||
@ -236,7 +237,7 @@ sub connect {
|
||||
##################################
|
||||
# Get userid/password
|
||||
##################################
|
||||
my @cred = xCAT::PPCdb::credentials( $server, "fsp" );
|
||||
my $cred = $req->{$server}{cred};
|
||||
|
||||
##################################
|
||||
# Redirect STDERR to variable
|
||||
@ -275,8 +276,8 @@ sub connect {
|
||||
# Submit logon
|
||||
##################################
|
||||
my $res = $ua->post( $url,
|
||||
[ user => $cred[0],
|
||||
password => $cred[1],
|
||||
[ user => @$cred[0],
|
||||
password => @$cred[1],
|
||||
lang => "0",
|
||||
submit => "Log in" ]
|
||||
);
|
||||
@ -306,7 +307,7 @@ sub connect {
|
||||
##############################
|
||||
return( $ua,
|
||||
$server,
|
||||
$cred[0],
|
||||
@$cred[0],
|
||||
\$lwp_log );
|
||||
}
|
||||
##############################
|
||||
|
Loading…
Reference in New Issue
Block a user