From cbf519cce397943376b1475b8bb95ec69277b2c7 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 8 Apr 2010 12:06:11 +0000 Subject: [PATCH] make routine of output table code for tabdump and tabprune to share git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5715 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 54 ++++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 9d1123986..b26fb7b40 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -520,8 +520,8 @@ sub tabdump my $tabh = xCAT::Table->new($table); my $tabdump_header = sub { - my $header = "#" . join(",", @_); - push @{$rsp{data}}, $header; + my $header = "#" . join(",", @_); + push @{$rsp{data}}, $header; }; # If the table does not exist yet (because its never been written to), @@ -549,28 +549,28 @@ sub tabdump return; } } - - # Display all the rows of the table in the order of the columns in the schema - $tabdump_header->(@{$tabh->{colnames}}); - foreach $rec (@$recs) - { - my $line = ''; - foreach (@{$tabh->{colnames}}) - { - if (defined $rec->{$_}) - { - $rec->{$_} =~ s/"/""/g; - $line = $line . '"' . $rec->{$_} . '",'; - } - else - { - $line .= ','; - } - } - $line =~ s/,$//; # remove the extra comma at the end - push @{$rsp{data}}, $line; - } - $cb->(\%rsp); + # Display all the rows of the table the order of the columns in the schema + output_table($table,$cb,$tabh,$recs); + #$tabdump_header->(@{$tabh->{colnames}}); + #foreach $rec (@$recs) + #{ + # my $line = ''; + # foreach (@{$tabh->{colnames}}) + # { + # if (defined $rec->{$_}) + # { + # $rec->{$_} =~ s/"/""/g; + # $line = $line . '"' . $rec->{$_} . '",'; + # } + # else + # { + # $line .= ','; + # } + # } + # $line =~ s/,$//; # remove the extra comma at the end + # push @{$rsp{data}}, $line; + #} + #$cb->(\%rsp); } # Prune records from the eventlog or auditlog or all records. @@ -705,7 +705,7 @@ sub tabprune_all { } if ($VERBOSE) { # will output change to std my $recs = $tab->getAllEntries("all"); - tabprune_verbose($table,$cb,$tab,$recs); + output_table($table,$cb,$tab,$recs); } $tab->delEntries(); #Yes, delete *all* entries @@ -802,8 +802,8 @@ sub tabprune_recid { return $rc; } -# If Verbose, return the records that will be deleted to stdout. -sub tabprune_verbose { +# Dump table records to stdout. +sub output_table { my $table = shift; my $cb = shift; my $tabh=shift;