From 4c8c4ff7013e0b76b5b3b7b4ff876db9689f5329 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 16 Sep 2009 15:38:40 +0000 Subject: [PATCH] -Provide graceful error when tabrestore has an unrecognized column defined git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4147 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 72e12c55f..415375eba 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -289,6 +289,15 @@ sub tabrestore $header =~ s/^#//; $header =~ s/\s+$//; my @colns = split(/,/, $header); + my $tcol; + foreach $tcol (@colns) { #validate the restore data has no invalid column names + unless (grep /^$tcol\z/,@{$xCAT::Schema::tabspec{$table}->{cols}}) { + $cb->({error => "The header line indicates that column '$tcol' should exist, which is not defined in the schema for '$table'",errorcode=>1}); + return; + } + print Dumper(grep /^$tcol\z/,@{$xCAT::Schema::tabspec{$table}->{cols}}); + } + print "We passed it!\n"; my $line; my $rollback = 0;