From e01282f5eb8f89cb5ec70ccb4b8e1fa3dbbfbe9e Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Mon, 1 Apr 2013 12:51:58 +0000 Subject: [PATCH] Output erros if there is any failure during DB operation, in case DB operation didn't output any error on failures. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15764 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index c30ecdd46..0778aca87 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1145,14 +1145,32 @@ sub addkit xCAT::MsgUtils->message( "I", \%rsp, $callback ); } - $tabs{kit}->setAttribs({kitname => $kithash{kitname} }, \%kithash ); + $rc = $tabs{kit}->setAttribs({kitname => $kithash{kitname} }, \%kithash ); + if($rc){ + my %rsp; + push@{ $rsp{data} }, "Failed to write kit object into xCAT DB"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } foreach my $kitrepoid (keys %kitrepohash) { - $tabs{kitrepo}->setAttribs({kitreponame => $kitrepohash{$kitrepoid}{kitreponame} }, \%{$kitrepohash{$kitrepoid}} ); + $rc = $tabs{kitrepo}->setAttribs({kitreponame => $kitrepohash{$kitrepoid}{kitreponame} }, \%{$kitrepohash{$kitrepoid}} ); + if($rc){ + my %rsp; + push@{ $rsp{data} }, "Failed to write kitrepo $kitrepohash{$kitrepoid}{kitreponame} into xCAT DB"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } } foreach my $kitcompid (keys %kitcomphash) { - $tabs{kitcomponent}->setAttribs({kitcompname => $kitcomphash{$kitcompid}{kitcompname} }, \%{$kitcomphash{$kitcompid}} ); + $rc = $tabs{kitcomponent}->setAttribs({kitcompname => $kitcomphash{$kitcompid}{kitcompname} }, \%{$kitcomphash{$kitcompid}} ); + if($rc){ + my %rsp; + push@{ $rsp{data} }, "Failed to write kitcomponent $kitcomphash{$kitcompid}{kitcompname} xCAT DB"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } } push @kitnames, $kithash{kitname};