summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fea919d)
raw | patch | inline | side by side (parent: fea919d)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 4 Feb 2008 16:27:25 +0000 (16:27 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 4 Feb 2008 16:27:25 +0000 (16:27 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8742 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/installation.pm | [new file with mode: 0644] | patch | blob |
gosa-si/modules/GosaPackages.pm | patch | blob | history | |
gosa-si/server/events/installation.pm | [new file with mode: 0644] | patch | blob |
gosa-si/server/events/ping | [deleted file] | patch | blob | history |
gosa-si/server/events/set_activated_for_installation | [deleted file] | patch | blob | history |
diff --git a/gosa-si/client/events/installation.pm b/gosa-si/client/events/installation.pm
--- /dev/null
@@ -0,0 +1,39 @@
+package installation;
+use Exporter;
+@ISA = qw(Exporter);
+my @events = qw(get_events set_activated_for_installation);
+@EXPORT = @events;
+
+use strict;
+use warnings;
+use Data::Dumper;
+use Fcntl;
+
+BEGIN {}
+
+END {}
+
+### Start ######################################################################
+
+
+sub get_events {
+ return \@events;
+}
+
+sub set_activated_for_installation {
+ my ($msg, $msg_hash) = @_ ;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+
+ my $Datei = "/tmp/set_activated_for_installation";
+ open(DATEI, ">$Datei");
+ print DATEI "$msg\n";
+ close DATEI;
+
+ return;
+}
+
+
+
+1;
index b58fe246aa2c96c232cdd0f533e4d0f66437466c..1a219a9899e3fe3e16819cf0de95535a4826b0ff 100644 (file)
use GOSA::DBsqlite;
use MIME::Base64;
+my $event_dir = "/usr/lib/gosa-si/server/events";
+use lib "/usr/lib/gosa-si/server/events";
+
BEGIN{}
END{}
my ($job_queue_timeout, $job_queue_file_name);
my $gosa_server;
+my $event_hash;
my %cfg_defaults =
("general" =>
"server_port" => [\$server_port, "20081"],
"server_passwd" => [\$server_passwd, ""],
"max_clients" => [\$max_clients, 100],
- "server_event_dir" => [\$server_event_dir, '/usr/lib/gosa-si/server/events'],
},
"bus" =>
{"bus_activ" => [\$bus_activ, "on"],
my $xml = new XML::Simple();
+# import events
+&import_events();
+
## FUNCTIONS #################################################################
sub get_module_info {
}
+sub import_events {
+ if (not -e $event_dir) {
+ daemon_log("ERROR: cannot find directory or directory is not readable: $event_dir", 1);
+ }
+ opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n";
+
+ while (defined (my $event = readdir (DIR))) {
+ if( $event eq "." || $event eq ".." ) { next; }
+
+ eval{ require $event; };
+ if( $@ ) {
+ daemon_log("import of event module '$event' failed", 1);
+ daemon_log("$@", 8);
+ next;
+ }
+
+ $event =~ /(\S*?).pm$/;
+ my $event_module = $1;
+ my $events_l = eval( $1."::get_events()") ;
+ foreach my $event_name (@{$events_l}) {
+ $event_hash->{$event_name} = $event_module;
+ }
+
+ }
+}
+
+
#=== FUNCTION ================================================================
# NAME: process_incoming_msg
# PARAMETERS: crypted_msg - string - incoming crypted message
$out_msg = &process_job_msg($msg, $msg_hash);
}
elsif ($header =~ /^gosa_/) {
- $out_msg = &process_gosa_msg($msg, $header);
+ $out_msg = &process_gosa_msg($msg, $msg_hash);
}
else {
&main::daemon_log("ERROR: $header is not a valid GosaPackage-header, need a 'job_' or a 'gosa_' prefix");
sub process_gosa_msg {
- my ($msg, $header) = @_ ;
+ my ($msg, $msg_hash) = @_ ;
my $out_msg;
+
+ my $header = @{$msg_hash->{'header'}}[0];
$header =~ s/gosa_//;
# decide wether msg is a core function or a event handler
$out_msg = &send_msg("trigger_wake", $server_address, "KNOWN_SERVER", \%data);
} else {
# msg could not be assigned to core function
- # fetch all available eventhandler under $server_event_dir
- opendir (DIR, $server_event_dir) or &main::daemon_log("ERROR cannot open $server_event_dir: $!\n", 1) and return;
- while (defined (my $file = readdir (DIR))) {
- if (not $file eq $header) {
- next;
- }
- # try to deliver incoming msg to eventhandler
- my $cmd = File::Spec->join($server_event_dir, $header)." '$msg'";
- &main::daemon_log("GosaPackages: execute event_handler $header", 3);
- &main::daemon_log("GosaPackages: cmd: $cmd", 8);
-
- $out_msg = "";
- open(PIPE, "$cmd 2>&1 |");
- while(<PIPE>) {
- $out_msg.=$_;
- }
- close(PIPE);
- &main::daemon_log("GosaPackages: answer of cmd: $out_msg", 5);
- last;
- }
+ # maybe it is an eventa
+ if( exists $event_hash->{$header} ) {
+ # a event exists with the header as name
+ &main::daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ no strict 'refs';
+ $out_msg = &{$event_hash->{$header}."::$header"}($msg, $msg_hash);
+ }
+
+# opendir (DIR, $server_event_dir) or &main::daemon_log("ERROR cannot open $server_event_dir: $!\n", 1) and return;
+# while (defined (my $file = readdir (DIR))) {
+# if (not $file eq $header) {
+# next;
+# }
+# # try to deliver incoming msg to eventhandler
+# my $cmd = File::Spec->join($server_event_dir, $header)." '$msg'";
+# &main::daemon_log("GosaPackages: execute event_handler $header", 3);
+# &main::daemon_log("GosaPackages: cmd: $cmd", 8);
+#
+# $out_msg = "";
+# open(PIPE, "$cmd 2>&1 |");
+# while(<PIPE>) {
+# $out_msg.=$_;
+# }
+# close(PIPE);
+# &main::daemon_log("GosaPackages: answer of cmd: $out_msg", 5);
+# last;
+# }
}
# if delivery not possible raise error and return
diff --git a/gosa-si/server/events/installation.pm b/gosa-si/server/events/installation.pm
--- /dev/null
@@ -0,0 +1,35 @@
+package installation;
+use Exporter;
+@ISA = qw(Exporter);
+my @events = qw(get_events set_activated_for_installation );
+@EXPORT = @events;
+
+use strict;
+use warnings;
+use GOSA::GosaSupportDaemon;
+
+
+BEGIN {}
+
+END {}
+
+### Start ######################################################################
+
+#&main::read_configfile($main::cfg_file, %cfg_defaults);
+
+sub get_events {
+ return \@events;
+}
+
+sub set_activated_for_installation {
+ my ($msg, $msg_hash) = @_;
+
+ my $header = @{$msg_hash->{header}}[0];
+ my $source = @{$msg_hash->{source}}[0];
+ my $target = @{$msg_hash->{target}}[0];
+
+ my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
+ my $out_msg = &create_xml_string($out_hash);
+
+ return $out_msg;
+}
diff --git a/gosa-si/server/events/ping b/gosa-si/server/events/ping
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use GosaSupportDaemon;
-
-
-# transform msg to hash
-my $hash = &transform_msg2hash($ARGV[0]);
-
-# extract from hash all what you need
-my $header = @{$hash->{header}}[0];
-my $source = @{$hash->{source}}[0];
-my $target = @{$hash->{target}}[0];
-my $jobdb_id = @{$hash->{jobdb_id}}[0];
-
-# and do what ever you want
-
-
-my $out_hash = &create_xml_hash("got_ping", "10.89.1.155:10001", "10.89.1.155:10000");
-if (defined $jobdb_id) {
- &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
-}
-my $out_xml = &create_xml_string($out_hash);
-print $out_xml;
-
diff --git a/gosa-si/server/events/set_activated_for_installation b/gosa-si/server/events/set_activated_for_installation
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-#===============================================================================
-#
-# FILE: set_activated_for_installation.pl
-#
-# USAGE: ./set_activated_for_installation.pl
-#
-# DESCRIPTION:
-#
-# OPTIONS: ---
-# REQUIREMENTS: ---
-# BUGS: ---
-# NOTES: ---
-# AUTHOR: (), <>
-# COMPANY:
-# VERSION: 1.0
-# CREATED: 28.01.2008 17:31:37 CET
-# REVISION: ---
-#===============================================================================
-
-use strict;
-use warnings;
-
-use GOSA::GosaSupportDaemon;
-
-
-# transform msg to hash
-my $hash = &transform_msg2hash($ARGV[0]);
-
-# extract from hash all what you need
-my $header = @{$hash->{header}}[0];
-my $source = @{$hash->{source}}[0];
-my $target = @{$hash->{target}}[0];
-
-my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
-my $out_msg = &create_xml_string($out_hash);
-print $out_msg;