index b33a4987953a2882324e6de02cf92f50cc7757d2..bf4ac091b12ef38025b4a79eb89017d5567254b1 100644 (file)
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 GOSA::GosaSupportDaemon;
+
use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+
+our @ISA = ("Exporter");
my $event_dir = "/usr/lib/gosa-si/server/ServerPackages";
use lib "/usr/lib/gosa-si/server/ServerPackages";
# import local events
my ($error, $result, $event_hash) = &import_events($event_dir);
-if ($error == 0) {
- foreach my $log_line (@$result) {
- &main::daemon_log("0 DEBUG: ServerPackages - $log_line", 7);
- }
-} else {
- foreach my $log_line (@$result) {
+foreach my $log_line (@$result) {
+ if ($log_line =~ / succeed: /) {
+ &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 {
my @info = ($main::server_address,
- $main::foreign_server_key,
+ $main::ServerPackages_key,
+ $event_hash,
);
return \@info;
}
$msg =~ s/<header>gosa_(\w+)<\/header>|<header>job_(\w+)<\/header>/<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') )";
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'knownclienterror') {
&main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
- &main::daemon_log("$session_id WARNING: processing is aborted and message will not be forwarded", 3);
+ &main::daemon_log("$session_id ERROR: processing is aborted and message will not be forwarded", 1);
@out_msg_l = ();
} elsif ($out_msg_l[0] eq 'noeventerror') {
- &main::daemon_log("$session_id WARNING: client '$target' is not registered for event '$header', processing is aborted", 3);
+ &main::daemon_log("$session_id ERROR: client '$target' is not registered for event '$header', processing is aborted", 1);
@out_msg_l = ();
}
return \@out_msg_l;
}
+
1;