diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index c52ff9f46..515b04c3d 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -799,7 +799,14 @@ sub credentials { if ( $user_specified) { # need regx #($ent) = $tab->getAttribs( {hcp=>$server,username=>$user},qw(password)); - ($ent) = $tab->getNodeSpecAttribs( $server, {username=>$user},qw(password)); + #($ent) = $tab->getNodeSpecAttribs( $server, {username=>$user},qw(password)); + my @output = $tab->getNodeAttribs($server, qw(username password)); + foreach my $tmp_entry (@output) { + if ($tmp_entry->{username} =~ /^$user$/) { + $ent = $tmp_entry; + last; + } + } } else { @@ -817,7 +824,14 @@ sub credentials { if ( $user_specified) { # need regx #($ent) = $tab->getAllAttribs( {hcp=>$defaultgrp{$hwtype},username=>$user},qw(password)); - ($ent) = $tab->getNodeSpecAttribs( $defaultgrp{$hwtype}, {username=>$user},qw(password)); + #($ent) = $tab->getNodeSpecAttribs( $defaultgrp{$hwtype}, {username=>$user},qw(password)); + my @output = $tab->getNodeAttribs( $defaultgrp{$hwtype}, qw(username password)); + foreach my $tmp_entry (@output) { + if ($tmp_entry->{username} =~ /^$user$/) { + $ent = $tmp_entry; + last; + } + } } else { diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 14f81f1ee..7486c8af9 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -2342,51 +2342,51 @@ sub getNodeAttribs #-------------------------------------------------------------------------- -sub getNodeSpecAttribs { - my $self = shift; - my $node = shift; - my %options = (); - my @attribs = (); - my @keys = (); - if (ref $_[0] eq 'HASH') { - %options = %{shift()}; - @attribs = @_; - foreach my $key (keys %options) { - if (!grep(/^$key$/, @attribs)) { - push @attribs, $key; - } - } - } else { - @attribs = @_; - } - if ((keys (%options)) == 0) { - my $ent = $self->getNodeAttribs($node, \@attribs); - return $ent; - } else { - my $nodekey = "node"; - if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) { - $nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}; - } - $options{$nodekey} = $node; - my $ent = $self->getAttribs(\%options, \@attribs); - if ($ent) { - return $ent; - } - my ($nodeghash) = $self->{nodelist}->getAttribs({node=>$node}, "groups"); - unless(defined($nodeghash) && defined($nodeghash->{groups})) { - return undef; - } - my @nodegroups = split(/,/, $nodeghash->{groups}); - foreach my $group (@nodegroups) { - $options{$nodekey} = $group; - my $g_ret = $self->getAttribs(\%options, \@attribs); - if ($g_ret) { - return $g_ret; - } - } - } - return undef; -} +#sub getNodeSpecAttribs { +# my $self = shift; +# my $node = shift; +# my %options = (); +# my @attribs = (); +# my @keys = (); +# if (ref $_[0] eq 'HASH') { +# %options = %{shift()}; +# @attribs = @_; +# foreach my $key (keys %options) { +# if (!grep(/^$key$/, @attribs)) { +# push @attribs, $key; +# } +# } +# } else { +# @attribs = @_; +# } +# if ((keys (%options)) == 0) { +# my $ent = $self->getNodeAttribs($node, \@attribs); +# return $ent; +# } else { +# my $nodekey = "node"; +# if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) { +# $nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}; +# } +# $options{$nodekey} = $node; +# my $ent = $self->getAttribs(\%options, \@attribs); +# if ($ent) { +# return $ent; +# } +# my ($nodeghash) = $self->{nodelist}->getAttribs({node=>$node}, "groups"); +# unless(defined($nodeghash) && defined($nodeghash->{groups})) { +# return undef; +# } +# my @nodegroups = split(/,/, $nodeghash->{groups}); +# foreach my $group (@nodegroups) { +# $options{$nodekey} = $group; +# my $g_ret = $self->getAttribs(\%options, \@attribs); +# if ($g_ret) { +# return $g_ret; +# } +# } +# } +# return undef; +#} #-------------------------------------------------------------------------- =head3 getNodeAttribs_nosub diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 030b8589b..0f97bfd19 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4237,7 +4237,8 @@ sub passwd { } my $mpatab = xCAT::Table->new('mpa'); if ($mpatab) { - my ($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>$user},qw(password)); + #my ($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>$user},qw(password)); + my ($ent)=$mpatab->getAttribs({mpa=>$mpa, username=>$user},qw(password)); my $oldpass = 'PASSW0RD'; if (defined($ent->{password})) {$oldpass = $ent->{password}}; my $cmd = "users -n $user -op $oldpass -p $pass -T system:$mm";