#!/usr/bin/perl # $Id: check 36 2012-11-20 15:23:18Z spillner $ # $Date: 2012-11-20 16:23:18 +0100 (Tue, 20 Nov 2012) $ # -----------+------------+------------------------------------------------ # 2012-11-20 | silver | - change some comments ;o) # -----------+------------+------------------------------------------------ # 2012-10-22 | silver | - change db table contend. add column source # -----------+------------+------------------------------------------------ # 2012-09-19 | silver | - changes in storeContend # | | - store inaccurate file from storeContend in # | | @wrongs # | | - use svn Rev keyword in SQL database version # | | - store files with return code 0 (means err) # | | in @wrongs # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | - create storeWork # | | - changes on table working # | | - rename storePack to storePackage # | | - create storeProfile # | | - create storeWork # | | - create storeContend # -----------+------------+------------------------------------------------ # 2012-09-15 | silver | - add parameter DEBUG to config file # | | - change var rev, use svn # | | - create storePack # | | - use sub ref hash to select sub depended from # | | parameter -t # -----------+------------+------------------------------------------------ # 2012-09-14 | silver | - change config file, add db relevant data # | | - add module My::Crypt # | | - use database, changes on database # | | - changes in createPreps # -----------+------------+------------------------------------------------ # 2012-09-09 | silver | - change call WayOut, remove param leave # -----------+------------+------------------------------------------------ # 2012-09-08 | silver | - insert sub getAttribs # | | - check parameter -t # | | - check parameter -o # -----------+------------+------------------------------------------------ # 2012-08-28 | silver | second perl version, begin # | | - use module My::Subs # | | - partial creating readout command line params # | | - create printUsage # -----------+------------+------------------------------------------------ # Note : config file #### snipp ################################################################ # LOG_CATEGORY = DEBUG, Logfile # LOG_FILE = xml2 # LOG_EXT = log # LOG_MODE = append # LOG_MAIN = DEBUG # LOG_LOGGER = main # DEBUG = 0 # DB_NAME = reporting # DB_HOST = localhost # DB_USER = reporting # DB_PASS = fGFddCH5SHiKYxHIcsUl8Hr8Aq+3ELjDqcQ3XyJ3uRCsN28rDB0lf/xbZoxDV+Ys5CWCEqZy # DB_VER = $Rev: 36 $ #### snapp ################################################################ # TODO : # - (solved: 2012-09-04) check allowed values in parameter -o # - (solved: 2012-09-08) check allowed values in parameter -t # - open xml file # - depend from type (host, package, profile, log) read contend # - read step by step # - open database connection for every record # - write data into database # * package new: # - create db entry # - info # * package exist: # - same revision # + ignore package # + info # - newer revision # + create new package entry # + actualize profiles # + info # - older revision (from log files) # + create package entry # + info # - close database connection for every record ######## begin code ####################################################### use strict; use warnings; use Config::File qw(read_config_file); use Getopt::Tiny; use My::Subs qw(:my_const :my_fkt); use My::Crypt; use Switch 'Perl5', 'Perl6'; use XML::DOM; my $ver = 'v2'; my $rev = '$Rev: 36 $'; my $WORKING_DIR = $ENV{HOME}. "/.wpkg"; my $CONFIG_FILE = $WORKING_DIR . "/xml2.conf"; my $site = ""; my $logger = ""; my @oses = ('XP32', 'W732', 'W764'); my @types = ('package', 'host', 'profile', 'log'); my @wrongs; # stores files with problems my %ret; # return values my $ret_ref = \%ret; my $fkt_ref; # hash with refs to working subs $fkt_ref->{package} = \&storePackage; $fkt_ref->{profile} = \&storeProfile; $fkt_ref->{host} = \&storeHost; $fkt_ref->{log} = \&storeLog; #### database objects ##################################################### my @toClose = (); # stores database objects to close our $SqlSthTools = ""; # get version and last usage our $SqlSthLast = ""; # write last usage into db our $SqlSthPacks = ""; # write packe data into db our $SqlSthRes = ""; # result set our $SqlSthWorking = ""; # stores file info into database our $SqlSthProfile = ""; our $SqlSthContend = ""; our $SqlSthHost = ""; unless (-e $CONFIG_FILE) { # check if config file exist printRet(254); exit 254; # no, exit } print "$CONFIG_FILE exist, read ...\n"; $site = &read_config_file($CONFIG_FILE); #read config file # build log file name $site->{"LOG_FILENAME"} = $WORKING_DIR . "/" . $site->{LOG_FILE} . "." . $site->{LOG_EXT}; $logger = initLogger($site); # initialize log system $logger->info(DIV2); $logger->info("==> start"); $logger->info(DIV2); $logger->debug("===> config file begin"); # log configuration while ( my($key, $value) = each(%$site) ) { $logger->debug("$key => $value"); } $logger->debug("===> config file end"); my $crypt = My::Crypt->new( debug => 0 ); # decrypt password my $dec = $crypt->decrypt($site->{DB_PASS}, 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0F'); $site->{"DB_PASS"} = $dec; # store in site array #### prepare usage off Getopt::Tiny ####################################### my $path; #Getopt::Tiny - working folder my $ostype; #Getopt::Tiny - type of operating system my $fltype; #Getopt::Tiny - type of document (package, host, profile, log) my $backup; #store backup folder for finished log files my $vers; #Getopt::Tiny - flag for version print my $help; #Getopt::Tiny - print help screen my $printR; # print return codes # begin usage info my (%flags) = ( 'p' => \$path, # , working path 'o' => \$ostype, # , type of operating system (ignored by -t LOG) 't' => \$fltype, # , document type (package, host, profile, log) 'b' => \$backup, # , stores backup folder for log files ); my (%switches) = ( 'v' => \$vers, # print program version 'h' => \$help, # print this screen 'r' => \$printR # print return codes ); # end usage info getopt(\@ARGV, \%flags, \%switches); # read command line #### check command line parameter ######################################### if($vers) { # print program version $logger->debug("call parameter: -v"); print "$0, Version $ver, $rev\n"; &WayOut('0', $logger); } if($help) { #print help screen $logger->debug("call parameter: -h"); &printUsage(); &WayOut('0', $logger); } if($printR) { #print return codes $logger->debug("call parameter: -r"); &printAllRet; &WayOut('0', $logger); } if($fltype) { chomp($fltype); $fltype = lc($fltype); # file type in lower chars if( grep /^$fltype$/, @types) { # check allowed types $site->{FILETYP} = $fltype; # ok, store } else { &WayOut('249', $logger); # wrong type, exit } $logger->debug("call parameter -t $site->{FILETYP}"); } else { &WayOut('253', $logger); # parameter is missing } if($path) { chomp($path); if(! -e $path) { &WayOut('250', $logger); } $site->{"PATH"} = $path; # only for logging $logger->debug("call parameter -p $site->{PATH}"); if( -d $site->{PATH}) { $logger->info("folder detected!"); } } else { &WayOut('253', $logger); } if($site->{FILETYP} eq 'log') { $logger->info("parameter -o ignored"); } else { if($ostype) { chomp($ostype); $ostype =uc($ostype); $logger->debug("call parameter -o $ostype"); #check for allowed values if( grep /^$ostype$/, @oses) { $site->{OS} = $ostype; # ok, store value } else { &WayOut('252', $logger); # wrong value } } else { &WayOut('253', $logger); # parameter is missing } } if($site->{FILETYP} eq 'log') { # read backup path if($backup) { chomp($backup); $site->{"BACKUP"} = $backup; $logger->debug("call parameter -b $site->{BACKUP}"); } else { $logger->info("parameter -b required"); &WayOut('253', $logger); } } if($site->{DEBUG} eq '1') { while ( my($key, $value) = each(%$site) ) { # only for debugging $logger->debug("$key => $value"); } } #### begin ################################################################ my $dbh = &openDatabase(\$site, $logger); # open database &createPreps($site->{FILETYP}, \$dbh, \$logger); # create prep. statements ###### test database connection ########################################### my @result = (); # stores results from sql statements $SqlSthTools->execute('version'); # check database version if($DBI::err) { $logger->error("$DBI::state: $DBI::errstr"); &WayOut('246', $logger); } else { @result = $SqlSthTools->fetchrow_array(); $logger->info("database version $result[0]"); if($result[0] ne $site->{DB_VER}) { $logger->info("database version missmatch! Is: $result[0] Must: $site->{DB_VER}"); &WayOut('246', $logger); } } @result = (); $SqlSthTools->execute('lastrun'); # print last usage if($DBI::err) { $logger->error("$DBI::state: $DBI::errstr"); &WayOut('246', $logger); } else { @result = $SqlSthTools->fetchrow_array(); my $readable_time = localtime($result[0]); $logger->info("last usage $readable_time"); } @result = (); $SqlSthLast->execute('lastrun'); # store time in lastrun field if($DBI::err) { $logger->error("$DBI::state: $DBI::errstr"); &WayOut('246', $logger); } else { @result = $SqlSthLast->fetchrow_array(); } ###### database test end ################################################## my @files; # stores working files my @contend; # stores files for 2. run if(-d $site->{PATH}) { # path points to folder my $fldr = $site->{PATH}; # get all file names in folder @files = <$fldr/*.xml>; } else { # path points to a single file @files = $site->{PATH}; } foreach my $fl (@files) { # for all files in path %ret = &getAttribs($site->{FILETYP}, $fl, \$logger); while ( my($key, $value) = each(%ret) ) { # log all return values $logger->debug("$key -> $value"); } if($ret_ref->{ec} eq '251') { # missing field in xml file? unshift(@wrongs, $fl); # store file name in error array } if($ret_ref->{ec} eq '250') { # file not redeable or does not exist $logger->error("$fl: return code $ret_ref->{ec}"); &WayOut('250', $logger); # go out } # select sub depended from FILETYP my $help = &{ $fkt_ref->{$fltype} }($ret_ref, \$logger); my $desc ="db error"; if($help < 0) { $desc = "$fltype $help: exist, skipped"; # do not store file name } elsif($help > 0) { $desc = "$fltype $help: inserted"; push @contend, $fl; # store file name for 2. run } elsif($help == 0) { # something is wrong, log unshift(@wrongs, $fl); $desc = "$fltype $help: error, not stored"; } $logger->debug("$fl: result $desc"); &storeWork($fl, $desc, \$logger); } given ($fltype) { when("package") { $logger->debug("no 2. run"); } when("profile") { $logger->debug("2. run required!"); my $sp_ret = 0; foreach my $cont (@contend) { $sp_ret = &storeContend($cont, $site->{OS}, \$logger); if($sp_ret == 255) { unshift(@wrongs, $cont); # store file in error array } } } when("host") { $logger->debug("no 2. run"); } when("log") { $logger->debug("no 2. run"); } } if(@wrongs > 0) { # print file names with problems $logger->info("found files with errors. Check logfile."); foreach my $wrong (@wrongs) { $logger->debug("wrong: $wrong"); } } else { $logger->info("found no files with errors."); } &closeDatabase(\@toClose, \$dbh); &WayOut('0', $logger); # program end # === subs ================================================================ # ------------------------------------------------------------------------- # Name : 'printUsage' # Title : usage display # Note : # Author : silver # INPUT : # OUTPUT : # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-08-28 | silver | first version # -----------+------------+------------------------------------------------ sub printUsage { print DIV2 . "\n"; print "$0, Version $ver, $rev\n"; print DIV2 . "\n"; print "\n"; print "command line parameter\n"; print DIV2 . "\n"; Getopt::Tiny::usage(__FILE__, \%flags, \%switches, 'files'); print "\n"; print DIV2 . "\n"; print "\n"; &printAllRet; } # ------------------------------------------------------------------------- # Name : 'getAttribs' # Title : read XML contend # Note : - depend from file type define XML fields # - read fields # - store field count in return hash # counter -> # - store results in hash: => # - return result hash # Author : silver # INPUT : $f_FileType - file type # $f_fl - xml file # $f_lgr - logger ref # OUTPUT : result array # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-08 | silver | - check values in return hash, set error code # -----------+------------+------------------------------------------------ # 2012-09-04 | silver | first version # -----------+------------+------------------------------------------------ # TODO : # - (solved: 2012-09-08) check attribs in return hash for contend sub getAttribs { my $f_FileType = shift; my $f_fl = shift; my $f_lgr = shift; my %attribs; my $attribs_ref = \%attribs; my $parser = new XML::DOM::Parser; my $SubName = (caller(0))[3]; $$f_lgr->debug("$SubName: work on $f_fl"); if(! -r $f_fl) { $attribs_ref->{ec} = '250'; } else { given ($f_FileType) { # when("package") { %attribs = ("name"=>"", "revision"=>"", "priority"=>"", "id"=>"", "bla"=>""); } when("package") { %attribs = ("name"=>"", "revision"=>"", "priority"=>"", "id"=>""); } when("profile") { %attribs = ("id"=>"", "revision"=>""); } when("host") { %attribs = ("name"=>"", "profile-id"=>"", "revision"=>""); } when("log") { %attribs = ("hostname"=>"", "architecture"=>"", "os"=>""); } } if($f_FileType eq 'log') { $f_FileType = 'wpkg'; } my $doc = $parser->parsefile($f_fl); foreach my $values ( $doc->getElementsByTagName($f_FileType) ) { while ( my($key, $value) = each(%attribs) ) { my $val = $values->getAttributeNode($key); if($val) { $attribs_ref->{$key} = $val->getValue; } else { $attribs_ref->{$key} = "no_value"; } } } $attribs_ref->{ec} = '0'; # set error code to OK my $cnt = grep $_ eq "no_value", values %attribs; # check attribs contend if($cnt == 1) { $attribs_ref->{ec} = '251'; # missing attribute or value }; } if($f_FileType eq 'package') { $attribs_ref->{version} = &getVersion($f_fl); # only for logging } undef $parser; return %attribs; } # ------------------------------------------------------------------------- # Name : 'getVersion' # Title : read XML contend # Note : # Author : silver # INPUT : $Fl - xml file # OUTPUT : program version # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-09 | silver | first version # -----------+------------+------------------------------------------------ # TODO : # - store fields in hash sub getVersion { my $fl = shift; # read file name my @fields = ('variable', [ 'name', 'value' ]); # fill searched fields my $parser = new XML::DOM::Parser; my @f; # dummy array my $retval = "no_version"; # start with error ;o) my $doc = $parser->parsefile($fl); # read all variables from file foreach my $values ( $doc->getElementsByTagName('package') ) { my $field_len = @fields; for(my $i = 0; $i < $field_len; $i += 2) { my $field = $fields[$i]; my $attributes = $fields[$i + 1]; foreach my $branch ( $values->getElementsByTagName($field) ) { foreach my $attribute ( @$attributes ) { if(my $val = $branch->getAttributeNode($attribute)) { push @f, $val->getValue; } } } } for(my $i = 0; $i < @f; $i++) { # loop over array and find version if($f[$i] eq "version") { $retval = $f[$i + 1]; # fill retval with founded version } } } return $retval; } # ------------------------------------------------------------------------- # Name : 'createPreps' # Title : create prepared statements for db access # Note : - create common prepared commands # - create file type specific prepared commands # - store every created command in array # Author : silver # INPUT : $type - kind of file # $dbhi - database handle ref # $lgr - logger ref # OUTPUT : # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-19 | silver | - change $SqlSthContend add return value # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | - add $SqlSthWorking # | | - add $SqlSthContend # | | - add $SqlSthProfile # -----------+------------+------------------------------------------------ # 2012-09-14 | silver | - change input params: add database handle and # | | logger handle # | | - create prepared statements # | | $SqlSthTools # | | $SqlSthLast # | | $SqlSthPacks # -----------+------------+------------------------------------------------ # 2012-09-11 | silver | first version # -----------+------------+------------------------------------------------ # TODO : # - create error handler sub createPreps { my $f_FileType = shift; my $f_dbhi = shift; my $f_lgr = shift; my $SubName = (caller(0))[3]; #### prepared commands ever required #################################### my $Sql = "SELECT `value` FROM `tools` WHERE `property`=?"; $SqlSthTools = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthTools; $Sql = "UPDATE `tools` SET `value`=unix_timestamp() WHERE `property`=?"; $SqlSthLast = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthLast; $Sql = 'SELECT @res'; $SqlSthRes = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthRes; $Sql = 'CALL sp_addWorking(?,?,@res)'; $SqlSthWorking = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthWorking; #### file type specific prepared commands ############################### given ($f_FileType) { when("package") { $Sql = 'CALL sp_addPackage(?,?,?,?,?,?,@res)'; $SqlSthPacks = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthPacks; } when("profile") { $Sql = 'CALL sp_addProfile(?,?,?,@res)'; $SqlSthProfile = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthProfile; $Sql = 'CALL sp_addContend(?,?,?,?,?,@res)'; $SqlSthContend = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthContend; } when("host") { $Sql = 'CALL sp_addHost(?,?,?,?,@res)'; $SqlSthHost = $$f_dbhi->prepare($Sql); push @toClose, \$SqlSthHost; } when("log") { $$f_lgr->info("$SubName: not implemented yet!"); } } } # ------------------------------------------------------------------------- # Name : 'storeWork' # Title : stores working file infos in database # Note : # Author : silver # INPUT : $f_file - file name # $f_status - working status # $f_lgr - logger ref # OUTPUT : ok # 0 error # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storeWork { my $f_file = shift; # get file name my $f_status = shift; # get working status my $f_lgr = shift; # get ref to logger handler my @f_res = (); my $SubName = (caller(0))[3]; $SqlSthWorking->execute($f_file, $f_status); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); $$f_lgr->debug("$SubName: $f_file: id $f_res[0]"); } return $f_res[0]; } # ------------------------------------------------------------------------- # Name : 'storePackage' # Title : stores package infos in database # Note : # Author : silver # INPUT : $f_vals - hash ref to values # $f_lgr - logger ref # OUTPUT : table id # ok # 0 error # - package exist, skipped # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | - remove error in reference use (logger) # -----------+------------+------------------------------------------------ # 2012-09-15 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storePackage { my $f_vals = shift; # get ref to value hash my $f_lgr = shift; # get ref to logger handler my $SubName = (caller(0))[3]; my @f_res = (); my $f_desc = "db error"; $SqlSthPacks->execute($f_vals->{name}, $f_vals->{revision}, $f_vals->{priority}, $f_vals->{id}, $f_vals->{version}, $site->{OS}); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); } return $f_res[0]; } # ------------------------------------------------------------------------- # Name : 'storeProfile' # Title : stores profile infos in database # Note : first run, second run required # Author : silver # INPUT : $f_vals - hash ref to values # $f_lgr - logger ref # OUTPUT : table id # ok # 0 error # - profile exist, skipped # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storeProfile { my $f_vals = shift; # get ref to value hash my $f_lgr = shift; # get ref to logger handler my $SubName = (caller(0))[3]; my @f_res = (); my $f_desc = "db error"; $SqlSthProfile->execute($f_vals->{id}, $f_vals->{revision}, $site->{OS}); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); } return $f_res[0]; } # ------------------------------------------------------------------------- # Name : 'storeContend' # Title : stores profile contend in database # Note : second run over profile # Author : silver # INPUT : $f_file - name of file # $f_sys - kind of OS # $f_lgr - logger ref # OUTPUT : # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-19 | silver | - check return value from sp # -----------+------------+------------------------------------------------ # 2012-09-16 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storeContend { my $f_file = shift; # file name my $f_sys = shift; # os code my $f_lgr = shift; # ref to logger my $SubName = (caller(0))[3]; # get function name for logging my %attribs; # prepare named hash for values to store my $attribs_ref = \%attribs; my $parser = new XML::DOM::Parser; # start parser my $f_val = ""; my @depends = (); my @package = (); my @f_res = (); my $retval = 0; $$f_lgr->debug("second run on $f_file"); %attribs = ("id"=>"no_value", "revision"=>"no_value"); # attributes to #search my @fields = ('depends', [ 'profile-id' ], # fields to store 'package', [ 'package-id' ]); my $doc = $parser->parsefile($f_file); # read profile contend foreach my $values ( $doc->getElementsByTagName("profile") ) { while ( my ($key, $value) = each(%attribs) ) { my $val = $values->getAttributeNode($key); # read keys selective if($val) { $attribs_ref->{$key} = $val->getValue; } } my $field_len = @fields; # depend from entry name (depends or package) fill arrays for(my $i = 0; $i < $field_len; $i += 2) { # select fields to store my $field = $fields[$i]; my $attributes = $fields[$i + 1]; foreach my $branch ( $values->getElementsByTagName($field) ) { foreach my $attribute ( @$attributes ) { if(my $value = $branch->getAttributeNode($attribute)) { $f_val = $value->getValue; if($field eq 'depends') { push @depends, $f_val; } elsif($field eq 'package') { push @package, $f_val; } } } } } } undef $parser; # destroy parser foreach (@package) { # run over array and store every value $$f_lgr->debug("$SubName: $attribs_ref->{id}, $attribs_ref->{revision}, $_, 0, $site->{OS}"); $SqlSthContend->execute($attribs_ref->{id}, $attribs_ref->{revision}, $_, 0, $site->{OS}); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); if($f_res[0] == 255) { $retval = $f_res[0]; } } } foreach (@depends) { $$f_lgr->debug("$SubName: $attribs_ref->{id}, $attribs_ref->{revision}, 0, $_, $site->{OS}"); $SqlSthContend->execute($attribs_ref->{id}, $attribs_ref->{revision}, 0, $_, $site->{OS}); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); if($f_res[0] == 255) { $retval = $f_res[0]; } } } return $retval; } # ------------------------------------------------------------------------- # Name : 'storeHost' # Title : stores host infos in database # Note : # Author : silver # INPUT : $f_vals - hash ref to values # $f_lgr - logger ref # OUTPUT : table id # ok # 0 error # - package exist, skipped # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-09-19 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storeHost { my $f_vals = shift; # get ref to value hash my $f_lgr = shift; # get ref to logger handler my $SubName = (caller(0))[3]; my @f_res = (); my $f_desc = "db error"; $SqlSthHost->execute($f_vals->{name}, $f_vals->{revision}, $site->{OS}, $f_vals->{"profile-id"}); if($DBI::err) { # check for db errors $$f_lgr->error("$SubName: $DBI::state: $DBI::errstr"); &WayOut('248', $$f_lgr); } else { $SqlSthRes->execute(); # no error, get return value from db @f_res = $SqlSthRes->fetchrow_array(); } return $f_res[0]; } # ------------------------------------------------------------------------- # Name : 'storeLog' # Title : stores log infos in database # Note : # Author : silver # INPUT : $f_vals - hash ref to values # $f_lgr - logger ref # OUTPUT : table id # ok # 0 error # - package exist, skipped # CHANGE : # # History : # When | Who | Description of changes # -----------+------------+------------------------------------------------ # 2012-11-20 | silver | first version # -----------+------------+------------------------------------------------ # TODO : sub storeLog { my $f_vals = shift; # get ref to value hash my $f_lgr = shift; # get ref to logger handler my $SubName = (caller(0))[3]; my $os = $f_vals->{os}; $$f_lgr->debug("found XP") if $os =~ /xp professional/; return 0; }