From 833976f5259f66197b14be3631c371bc3d616301 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Wed, 11 Apr 2012 09:20:20 +0000 Subject: [PATCH] use 'USERID' and its password as the account to create link between MN and hdwr_svr for NGP git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@12194 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/FSPUtils.pm | 5 +++- xCAT-server/lib/xcat/plugins/blade.pm | 35 +++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/perl-xCAT/xCAT/FSPUtils.pm b/perl-xCAT/xCAT/FSPUtils.pm index df6c2c15e..488c5d2fc 100644 --- a/perl-xCAT/xCAT/FSPUtils.pm +++ b/perl-xCAT/xCAT/FSPUtils.pm @@ -126,6 +126,7 @@ sub fsp_api_action { #get the HMC/password from passwd table or ppcdirect table. if( $action =~ /^add_connection$/) { my $tmp_node; + $user = 'HMC'; if( $$attrs[4] =~ /^cec$/ || $$attrs[4] =~ /^frame$/ ) { #for redundant FSPs/BPAs, we only need to get the one node's HMC/passwd my $children = xCAT::DBobjUtils->getchildren($fsp_name); @@ -136,15 +137,17 @@ sub fsp_api_action { $tmp_node = $$children[0]; } elsif ($$attrs[4] =~ /^blade$/) { $tmp_node = $$attrs[5]; + $user = 'USERID'; } else { $tmp_node = $fsp_name; } - ($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,'HMC'); + ($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,$user); if ( !$password) { $res = "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'."; return ([$node_name, $res, -1]); } + $user = 'HMC'; } my $cmd; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index e47b4889b..9d35e7cab 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -3975,12 +3975,12 @@ sub telnetcmds { my @unhandled; my %handled = (); my $result; - my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg USERID HMC); + my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg USERID); # most of these commands should be able to be done # through SNMP, but they produce various errors. foreach my $cmd (@_) { - if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|HMC|=/) { + if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|=/) { if (($cmd =~ /^textid/) and ($nodeid > 0)) { push @unhandled,$cmd; next; @@ -4054,7 +4054,7 @@ sub telnetcmds { elsif (/^rscanfsp$/) { $result = rscanfsp($t,$mpa,$handled{$_},$mm); } elsif (/^solcfg$/) { $result = solcfg($t,$handled{$_},$mm); } elsif (/^network_reset$/) { $result = network($t,$handled{$_},$mpa,$mm,$node,$nodeid,1); } - elsif (/^(USERID|HMC)$/) {$result = passwd($t, $mpa, $1, $handled{$_}, $mm);} + elsif (/^(USERID)$/) {$result = passwd($t, $mpa, $1, $handled{$_}, $mm);} push @data, "$_: @$result"; $Rc |= shift(@$result); push @cfgtext,@$result; @@ -4246,7 +4246,20 @@ sub passwd { if (!grep(/OK/i, @data)) { return ([1, @data]); } - if ($user eq "HMC") { + { + @data = (); + my $snmp_cmd = "users -n $user -ap sha -pp des -ppw $pass -T system:$mm"; + @data = $t->cmd($snmp_cmd); + if (!grep(/OK/i, @data)) { + $cmd = "users -n $user -op $pass -p $oldpass -T system:$mm"; + my @back_pwd = $t->cmd($cmd); + if (!grep(/OK/i, @back_pwd)) { + #if we update password backward failed, we should update the mpa table for further use# + $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); + } + return ([1, @data]); + } + $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; my $blades = &get_blades_for_mpa($mpa); @@ -4277,20 +4290,6 @@ sub passwd { my $fblades = join (',',@failed_blades); return ([1, "Update password of HMC for '$fblades' failed. Please recreate the DFM connections for them."]); } - } else { - @data = (); - my $snmp_cmd = "users -n $user -ap sha -pp des -ppw $pass -T system:$mm"; - @data = $t->cmd($snmp_cmd); - if (!grep(/OK/i, @data)) { - $cmd = "users -n $user -op $pass -p $oldpass -T system:$mm"; - my @back_pwd = $t->cmd($cmd); - if (!grep(/OK/i, @back_pwd)) { - #if we update password backward failed, we should update the mpa table for further use# - $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); - } - return ([1, @data]); - } - $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); } } else { return ([1, "Update password for $user in 'mpa' table failed"]);