X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fmodules%2FServerPackages.pm;h=d1583017cd59d9fd774238b4f8154b26a7f873c4;hb=c4a05533ba44c82223b7c367711763c3ed904f1d;hp=7a1357dc77e6725210de444cfd9a8c9ed285a722;hpb=a2e99244123a5e5567213b1aed544905a1c50b9d;p=gosa.git diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm index 7a1357dc7..d1583017c 100644 --- a/gosa-si/modules/ServerPackages.pm +++ b/gosa-si/modules/ServerPackages.pm @@ -1,15 +1,18 @@ package ServerPackages; -use Exporter; -@ISA = ("Exporter"); + # Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it. use strict; use warnings; + +use Exporter; use GOSA::GosaSupportDaemon; use Data::Dumper; +our @ISA = ("Exporter"); + my $event_dir = "/usr/lib/gosa-si/server/ServerPackages"; use lib "/usr/lib/gosa-si/server/ServerPackages"; @@ -23,12 +26,21 @@ END {} my ($error, $result, $event_hash) = &import_events($event_dir); foreach my $log_line (@$result) { if ($log_line =~ / succeed: /) { - &main::daemon_log("0 DEBUG: ServerPackages - $log_line", 7); + &main::daemon_log("0 INFO: ServerPackages - $log_line", 5); } else { &main::daemon_log("0 ERROR: ServerPackages - $log_line", 1); } } +# build vice versa event_hash, event_name => module +my $event2module_hash = {}; +while (my ($module, $mod_events) = each %$event_hash) { + while (my ($event_name, $nothing) = each %$mod_events) { + $event2module_hash->{$event_name} = $module; + } + +} + ### FUNCTIONS ##################################################################### sub get_module_info { @@ -55,12 +67,12 @@ sub process_incoming_msg { $msg =~ s/
gosa_(\w+)<\/header>|
job_(\w+)<\/header>/
$1<\/header>/; - &main::daemon_log("$session_id DEBUG: ServerPackages: msg to process '$header'", 7); - if( exists $event_hash->{$header} ) { + &main::daemon_log("$session_id DEBUG: ServerPackages: msg to process '$header'", 26); + if( exists $event2module_hash->{$header} ) { # a event exists with the header as name - &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5); + &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event2module_hash->{$header}."'", 26); no strict 'refs'; - @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id); + @out_msg_l = &{$event2module_hash->{$header}."::$header"}($msg, $msg_hash, $session_id); } else { $sql_events = "SELECT * FROM $main::known_clients_tn WHERE ( (macaddress LIKE '$target') OR (hostname='$target') )"; @@ -108,4 +120,5 @@ sub process_incoming_msg { return \@out_msg_l; } + 1;