From d6e1fde72c31c3a08d37a557451fddd8c00c0ffc Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 21 Jan 2011 19:49:32 +0000 Subject: [PATCH] added logEventsToTealDatabase to Util.pm git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8724 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index e309e83d4..a4cef3ffe 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4398,6 +4398,47 @@ sub logEventsToDatabase return (0, ""); } + +#------------------------------------------------------------------------------- + +=head3 logEventsToTealDatabase + Logs the given events info to the TEAL's 'x_tealeventlog' database + Arguments: + arrayref -- A pointer to an array. Each element is a hash that contains an events. + Returns: + (ret code, error message) + +=cut + +#------------------------------------------------------------------------------- +sub logEventsToTealDatabase +{ + my $pEvents = shift; + if (($pEvents) && ($pEvents =~ /xCAT::Utils/)) + { + $pEvents = shift; + } + + if (($pEvents) && (@$pEvents > 0)) + { + my $currtime; + my $tab = xCAT::Table->new("x_tealeventlog", -create => 1, -autocommit => 0); + if (!$tab) + { + return (1, "The x_tealeventlog table cannot be opened."); + } + + foreach my $event (@$pEvents) + { + my @ret = $tab->setAttribs(undef, $event); + if (@ret > 1) { return (1, $ret[1]); } + } + $tab->commit; + } + + return (0, ""); +} + #------------------------------------------------------------------------------- =head3 StartService