-Provide a means for nodels to display group inheritence
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5395 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
8eabe3293a
commit
f3daa4d8e0
@ -1898,9 +1898,11 @@ sub getNodesAttribs {
|
||||
return dbc_call($self,'getNodesAttribs',@_);
|
||||
}
|
||||
my $nodelist = shift;
|
||||
my %options=();
|
||||
my @attribs;
|
||||
if (ref $_[0]) {
|
||||
@attribs = @{shift()};
|
||||
%options = @_;
|
||||
} else {
|
||||
@attribs = @_;
|
||||
}
|
||||
@ -1925,7 +1927,7 @@ sub getNodesAttribs {
|
||||
}
|
||||
my $rethash;
|
||||
foreach (@$nodelist) {
|
||||
my @nodeentries=$self->getNodeAttribs($_,\@attribs);
|
||||
my @nodeentries=$self->getNodeAttribs($_,\@attribs,%options);
|
||||
$rethash->{$_} = \@nodeentries; #$self->getNodeAttribs($_,\@attribs);
|
||||
}
|
||||
$self->_clear_cache;
|
||||
@ -2047,13 +2049,15 @@ sub getNodeAttribs
|
||||
}
|
||||
my $node = shift;
|
||||
my @attribs;
|
||||
my %options = ();
|
||||
if (ref $_[0]) {
|
||||
@attribs = @{shift()};
|
||||
%options = @_;
|
||||
} else {
|
||||
@attribs = @_;
|
||||
}
|
||||
my $datum;
|
||||
my @data = $self->getNodeAttribs_nosub($node, \@attribs);
|
||||
my @data = $self->getNodeAttribs_nosub($node, \@attribs,%options);
|
||||
#my ($datum, $extra) = $self->getNodeAttribs_nosub($node, \@attribs);
|
||||
#if ($extra) { return undef; } # return (undef,"Ambiguous query"); }
|
||||
defined($data[0])
|
||||
@ -2166,11 +2170,16 @@ sub getNodeAttribs_nosub
|
||||
my $self = shift;
|
||||
my $node = shift;
|
||||
my $attref = shift;
|
||||
my %options = @_;
|
||||
my @data;
|
||||
my $datum;
|
||||
my @tents;
|
||||
my $return = 0;
|
||||
@tents = $self->getNodeAttribs_nosub_returnany($node, $attref);
|
||||
@tents = $self->getNodeAttribs_nosub_returnany($node, $attref,%options);
|
||||
my $nodekey = "node";
|
||||
if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) {
|
||||
$nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}
|
||||
}
|
||||
foreach my $tent (@tents) {
|
||||
$datum={};
|
||||
foreach (@$attref)
|
||||
@ -2179,12 +2188,18 @@ sub getNodeAttribs_nosub
|
||||
{
|
||||
$return = 1;
|
||||
$datum->{$_} = $tent->{$_};
|
||||
if ($options{withattribution} and $_ ne $nodekey) {
|
||||
$datum->{'!!xcatgroupattribution!!'}->{$_} = $tent->{'!!xcatsourcegroup!!'};
|
||||
}
|
||||
} else { #attempt to fill in gapped attributes
|
||||
unless (scalar(@$attref) <= 1) {
|
||||
my $sent = $self->getNodeAttribs($node, [$_]);
|
||||
my $sent = $self->getNodeAttribs($node, [$_],%options);
|
||||
if ($sent and defined($sent->{$_})) {
|
||||
$return = 1;
|
||||
$datum->{$_} = $sent->{$_};
|
||||
if ($options{withattribution} and $_ ne $nodekey) {
|
||||
$datum->{'!!xcatgroupattribution!!'}->{$_} = $sent->{'!!xcatgroupattribution!!'}->{$_};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2228,6 +2243,7 @@ sub getNodeAttribs_nosub_returnany
|
||||
my $self = shift;
|
||||
my $node = shift;
|
||||
my @attribs = @{shift()};
|
||||
my %options = @_;
|
||||
my @results;
|
||||
|
||||
#my $recurse = ((scalar(@_) == 1) ? shift : 1);
|
||||
@ -2254,7 +2270,8 @@ sub getNodeAttribs_nosub_returnany
|
||||
if ($data != undef)
|
||||
{
|
||||
foreach (@results) {
|
||||
if ($_->{node}) { $_->{node} = $node; }
|
||||
if ($_->{$nodekey}) { $_->{$nodekey} = $node; }
|
||||
if ($options{withattribution}) { $_->{'!!xcatsourcegroup!!'} = $group; }
|
||||
};
|
||||
return @results;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ B<nodels> - lists the nodes, and their attributes, from the xCAT database.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<nodels> [I<noderange>] [B<-H> | B<--with-fieldname>] [I<table.column> | I<shortname>] [I<...>]
|
||||
B<nodels> [I<noderange>] [B<-b> | B<--blame>] [B<-H> | B<--with-fieldname>] [I<table.column> | I<shortname>] [I<...>]
|
||||
|
||||
B<nodels> [I<noderange>] [B<-H> | B<--with-fieldname>] [I<table>]
|
||||
|
||||
@ -73,6 +73,10 @@ Command Version.
|
||||
|
||||
Force display of table name and column name context for each result
|
||||
|
||||
=item B<-b|--blame>
|
||||
|
||||
For values inherited from groups, display which groups provided the inheritence
|
||||
|
||||
=item B<-?|-h|--help>
|
||||
|
||||
Display usage message.
|
||||
|
@ -1130,7 +1130,7 @@ sub nodels
|
||||
my $exitcode = shift @_;
|
||||
my %rsp;
|
||||
push @{$rsp{data}}, "Usage:";
|
||||
push @{$rsp{data}}, " nodels [noderange] [-H|--with-fieldname] [table.attribute | shortname] [...]";
|
||||
push @{$rsp{data}}, " nodels [noderange] [-b|--blame] [-H|--with-fieldname] [table.attribute | shortname] [...]";
|
||||
push @{$rsp{data}}, " nodels {-v|--version}";
|
||||
push @{$rsp{data}}, " nodels [-?|-h|--help]";
|
||||
if ($exitcode) { $rsp{errorcode} = $exitcode; }
|
||||
@ -1143,8 +1143,9 @@ sub nodels
|
||||
@ARGV=();
|
||||
}
|
||||
my $NOTERSE;
|
||||
my $ATTRIBUTION;
|
||||
|
||||
if (!GetOptions('h|?|help' => \$HELP, 'H|with-fieldname' => \$NOTERSE, 'v|version' => \$VERSION,) ) { $nodels_usage->(1); return; }
|
||||
if (!GetOptions('h|?|help' => \$HELP, 'H|with-fieldname' => \$NOTERSE, 'b|blame' => \$ATTRIBUTION, 'v|version' => \$VERSION,) ) { $nodels_usage->(1); return; }
|
||||
|
||||
# Help
|
||||
if ($HELP) { $nodels_usage->(0); return; }
|
||||
@ -1280,7 +1281,7 @@ sub nodels
|
||||
if (grep /^$nodekey$/,@cols) {
|
||||
$removenodecol=0;
|
||||
}
|
||||
my $rechash=$tabh->getNodesAttribs($nodes,\@cols);
|
||||
my $rechash=$tabh->getNodesAttribs($nodes,\@cols,withattribution=>$ATTRIBUTION);
|
||||
foreach $node (@$nodes)
|
||||
{
|
||||
my @cols;
|
||||
@ -1290,6 +1291,7 @@ sub nodels
|
||||
|
||||
foreach (keys %$rec)
|
||||
{
|
||||
if ($_ eq '!!xcatgroupattribution!!') { next; }
|
||||
if ($_ eq $nodekey and $removenodecol) { next; }
|
||||
$satisfiedreqs{$_}=1;
|
||||
my %datseg=();
|
||||
@ -1309,7 +1311,11 @@ sub nodels
|
||||
unless ($terse > 0) {
|
||||
$datseg{data}->[0]->{desc} = [$labels{$_}];
|
||||
}
|
||||
$datseg{data}->[0]->{contents} = [$rec->{$_}];
|
||||
if ($rec->{'!!xcatgroupattribution!!'} and $rec->{'!!xcatgroupattribution!!'}->{$_}) {
|
||||
$datseg{data}->[0]->{contents} = [$rec->{$_}." (inherited from group ".$rec->{'!!xcatgroupattribution!!'}->{$_}.")"];
|
||||
} else {
|
||||
$datseg{data}->[0]->{contents} = [$rec->{$_}];
|
||||
}
|
||||
$datseg{name} = [$node]; #{}->{contents} = [$rec->{$_}];
|
||||
push @{$noderecs{$node}}, \%datseg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user