From 24ac5b5ecf7c0b2199d98b7722b59543899028d9 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Fri, 13 Apr 2012 03:10:34 +0000 Subject: [PATCH] delete username HMC from usage page of rspconfig git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12231 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Usage.pm | 1 - xCAT-server/lib/perl/xCAT/SSHInteract.pm | 19 ++++++++------ xCAT-server/lib/xcat/plugins/blade.pm | 32 +++++++++++++----------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 17a1a701e..1af42c952 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -114,7 +114,6 @@ my %usage = ( rspconfig [textid=name] rspconfig [frame=number] rspconfig [USERID=passwd] - rspconfig [HMC=passwd] rspconfig [sshcfg=| snmpcfg=| pd1=| diff --git a/xCAT-server/lib/perl/xCAT/SSHInteract.pm b/xCAT-server/lib/perl/xCAT/SSHInteract.pm index 186573621..aa3661226 100644 --- a/xCAT-server/lib/perl/xCAT/SSHInteract.pm +++ b/xCAT-server/lib/perl/xCAT/SSHInteract.pm @@ -53,15 +53,18 @@ sub new { if ($nokeycheck) { delete $args{"-nokeycheck"}; } my $self = Net::Telnet->new(%args); _startssh($self,$pty,$username,$host,"-nokeycheck"=>$nokeycheck); - $self->waitfor("-match" => '/password:/i', -errmode => "return") or die "Unable to reach host ",$self->lastline; - $self->print($password); - my $nextline = $self->getline(); - if ($nextline eq "\n") { + my ($prematch,$match) = $self->waitfor([Match => $args{prompt},'/password:/i',]); + if ($match =~ /password:/i) { + #$self->waitfor("-match" => '/password:/i', -errmode => "return") or die "Unable to reach host ",$self->lastline; + $self->print($password); + my $nextline = $self->getline(); + if ($nextline eq "\n") { $nextline = $self->get(); - } - if ($nextline =~ /^password:/ or $nextline =~ /Permission denieid, please try again/) { - die "Incorrect Password"; - } + } + if ($nextline =~ /^password:/ or $nextline =~ /Permission denieid, please try again/) { + die "Incorrect Password"; + } + } return bless($self,$class); } 1; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index e45920619..95c1fe0b9 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -3978,17 +3978,17 @@ sub clicmds { my @unhandled; my %handled = (); my $result; - my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg userpassword USERID HMC); + my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg userpassword USERID); # most of these commands should be able to be done # through SNMP, but they produce various errors. - foreach my $cmd (@{$args{cmds}}) { - if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|HMC|=/) { + foreach my $cmd (@{$args{args}}) { + if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|userpassword|=/) { if (($cmd =~ /^textid/) and ($nodeid > 0)) { push @unhandled,$cmd; next; } - my ($command,$value) = split /=/,$cmd; + my ($command,$value) = split /=/,$cmd,2; #$command =~ /^swnet/) allows for swnet1, swnet2, etc. if (grep(/^$command$/,@tcmds) || $command =~ /^swnet/) { @@ -4099,7 +4099,7 @@ sub clicmds { 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); $reset=1; } - elsif (/^(USERID|HMC)$/) {$result = passwd($t, $mpa, $1, "=".$handled{$_}, $mm);} + elsif (/^(USERID)$/) {$result = passwd($t, $mpa, $1, "=".$handled{$_}, $mm);} elsif (/^userpassword$/) {$result = passwd($t, $mpa, $1, $handled{$_}, $mm);} push @data, "$_: @$result"; $Rc |= shift(@$result); @@ -4303,8 +4303,19 @@ sub passwd { if (!grep(/OK/i, @data)) { return ([1, @data]); } - if ($user eq "HMC") { - $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); + @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)) { + $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); + } + return ([1, @data]); + } + $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); + if ($user eq "USERID") { my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; my $blades = &get_blades_for_mpa($mpa); if (!defined($blades)) { @@ -4337,13 +4348,6 @@ sub passwd { } else { #TODO: add new user if name mismatches what MM alread understands.. #additionally, may have to delete USERID in this event - @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)) { - return ([1, @data]); - } - $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); } } else { return ([1, "Update password for $user in 'mpa' table failed"]);