From 7bb245ceefc3dc97444f0b832cb3edb39590e7d0 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 9 Apr 2010 13:37:51 +0000 Subject: [PATCH] expand getAllAttribsWhere to accetp ALL to return all attributes in the table git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5731 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index b3ac8dd48..1e53ae2b6 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -2394,6 +2394,9 @@ sub getAllEntries Example: $nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'node','group'); + returns node and group attributes + $nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'ALL'); + returns all attributes Comments: none @@ -2435,16 +2438,27 @@ sub getAllAttribsWhere while (my $data = $query->fetchrow_hashref()) { my %newrow = (); - foreach (@attribs) - { + if ($attribs[0] eq "ALL") { # want all attributes + foreach (keys %$data){ + + if ($data->{$_} =~ /^$/) + { + $data->{$_} = undef; + } + } + push @results, $data; + } else { # want specific attributes + foreach (@attribs) + { unless ($data->{$_} =~ /^$/ || !defined($data->{$_})) { #The reason we do this is to undef fields in rows that may still be returned.. $newrow{$_} = $data->{$_}; } - } - if (keys %newrow) - { - push(@results, \%newrow); + } + if (keys %newrow) + { + push(@results, \%newrow); + } } } $query->finish();