delete the using and implementation of getNodeSpecAttribs
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12017 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
7421eba5ba
commit
19bc3d77c4
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user