From 814b400c018413a681a64b3b144fb8c7ddd23547 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 18 May 2011 13:16:45 +0000 Subject: [PATCH] add options to also supply list of files to reorg. This is DB2 only git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9630 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/tools/reorgtbls | 53 +++++++++++++++++++------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/xCAT-server/share/xcat/tools/reorgtbls b/xCAT-server/share/xcat/tools/reorgtbls index e189b918f..71f1c90f0 100755 --- a/xCAT-server/share/xcat/tools/reorgtbls +++ b/xCAT-server/share/xcat/tools/reorgtbls @@ -29,26 +29,50 @@ use warnings; # Then use runsqlcmd to run the reorg on the list of tables, # allow read/write by other applications during reorg # -GetOptions( 'V|verbose' => \$::VERBOSE ); - -my $cmd="$::XCATROOT/sbin/runsqlcmd \"select tabname from syscat.tables where TABSCHEMA='XCATDB';\""; -my @tablist = xCAT::Utils->runcmd($cmd, 0); -if ($::RUNCMD_RC != 0) -{ - `logger -txcat " reorgdb2table:error in select tabname from syscat.tables"`; exit 1; +my $tablelist; +my $help; +my $cmd; +my @tablist; +GetOptions( 'V|verbose' => \$::VERBOSE, + 't=s' => \$tablelist, + 'h|help' => \$help,); +if ($help) { + print "DB2 Table Reorganization utility.\n"; + print + "This script can be set as a cron job or run on the command line to reorg the xcatdb DB2 database tables.\n"; + print "Usage:\n"; + print "\t--V - Verbose mode\n"; + print "\t--h - usage\n"; + print + "\t--t -comma delimitated list of tables.\n Without this flag it reorgs all tables in the xcatdb database .\n"; + print "\n"; + exit 0; +} +if ($tablelist) { # input list of tables + @tablist=split(/\,/, $tablelist); +} else { # get all tables + $cmd="$::XCATROOT/sbin/runsqlcmd \"select tabname from syscat.tables where TABSCHEMA='XCATDB';\""; + @tablist = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + `logger -txcat " reorgdb2table:error in select tabname from syscat.tables"` ; + exit 1; + } } # reorg each table my $foundheader=0; foreach my $table (@tablist) { chomp $table; - # skip lines untils we find the header - if ($foundheader==0) { - if ( !($table =~ /TABNAME/)) { - next; - } else { - $foundheader=1; - next; + # skip lines untils we find the header unless -t option + if (!($tablelist)) { + if ($foundheader==0) { + if ( !($table =~ /TABNAME/)) { + next; + } else { + $foundheader=1; + next; + } } } # skip blanks and -- lines @@ -60,6 +84,7 @@ foreach my $table (@tablist) { { next; } + $table =~ tr/a-z/A-Z/; # convert to upper if ($::VERBOSE) { print " Reorg of table $table\n"; }