From: rettenbe Date: Fri, 1 Feb 2008 15:41:46 +0000 (+0000) Subject: add gosa-si-client event set_activated_for_installation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6b71ae2f487e725002cdbc9a7b2dae0f1e6b2d26;p=gosa.git add gosa-si-client event set_activated_for_installation git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8734 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/registered.pm b/gosa-si/client/events/registered.pm index 6cfd7ede9..fb3e751e2 100644 --- a/gosa-si/client/events/registered.pm +++ b/gosa-si/client/events/registered.pm @@ -1,12 +1,13 @@ package registered; use Exporter; @ISA = qw(Exporter); -@EXPORT = qw(get_events registered); +@EXPORT = qw(get_events registered set_activated_for_installation); use strict; use warnings; use Data::Dumper; +use Fcntl; BEGIN {} @@ -16,7 +17,7 @@ END {} sub get_events { - my @events = ('registered'); + my @events = ('registered', 'set_activated_for_installation'); return \@events; } @@ -35,7 +36,16 @@ sub registered { } +sub set_activated_for_installation { + my ($msg, $msg_hash) = @_ ; + my $Datei = "/tmp/set_activated_for_installation"; + open(DATEI, ">$Datei"); + print DATEI "set_activated_for_installation\n"; + close DATEI; + + return 0; +} diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 16beffc07..8280d8ad5 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -771,7 +771,7 @@ sub client_input { while( my ($hit_num, $hit) = each %{ $query_res } ) { my $host_name = $hit->{hostname}; my $host_key = $hit->{hostkey}; - &send_msg_to_target($answer, $host_name, $host_key); + &send_msg_to_target($answer, $host_name, $host_key, $answer_header); } } elsif( $answer_target eq "GOSA" ) { @@ -787,7 +787,7 @@ sub client_input { my $host_name = $hit->{hostname}; my $host_key = $hit->{hostkey}; $answer =~ s/KNOWN_SERVER/$host_name/g; - &send_msg_to_target($answer, $host_name, $host_key); + &send_msg_to_target($answer, $host_name, $host_key, $answer_header); } } else { diff --git a/gosa-si/new-gosa-si-client b/gosa-si/new-gosa-si-client index 590a7f23f..d8cf9db28 100755 --- a/gosa-si/new-gosa-si-client +++ b/gosa-si/new-gosa-si-client @@ -710,36 +710,36 @@ sub check_key_and_xml_validity { # check header my $header_l = $msg_hash->{'header'}; if( 1 != @{$header_l} ) { - die'header error'; + die 'no or more headers specified'; } my $header = @{$header_l}[0]; if( 0 == length $header) { - die 'header error'; + die 'header has length 0'; } # check source my $source_l = $msg_hash->{'source'}; if( 1 != @{$source_l} ) { - die'source error'; + die 'no or more sources specified'; } my $source = @{$source_l}[0]; if( 0 == length $source) { - die 'source error'; + die 'source has length 0'; } # check target my $target_l = $msg_hash->{'target'}; if( 1 != @{$target_l} ) { - die'target error'; + die 'no or more targets specified '; } my $target = @{$target_l}[0]; if( 0 == length $target) { - die 'target error'; + die 'target has length 0 '; } }; if($@) { - &main::daemon_log("WARNING: do not understand the message:", 5); + &main::daemon_log("WARNING: do not understand the message or msg is not gosa-si envelope conform:", 5); &main::daemon_log("$@", 8); } @@ -748,6 +748,7 @@ sub check_key_and_xml_validity { sub import_events { + if (not -e $event_dir) { daemon_log("ERROR: cannot find directory or directory is not readable: $event_dir", 1); } @@ -791,8 +792,9 @@ sub server_input { my $header = @{$msg_hash->{header}}[0]; my $source = @{$msg_hash->{source}}[0]; - if( $event_hash->{$header} ) { + if( exists $event_hash->{$header} ) { # a event exists with the header as name + daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5); no strict 'refs'; $answer = &{$event_hash->{$header}."::$header"}($msg, $msg_hash); if( $header eq "registered") { diff --git a/gosa-si/server/events/set_activated_for_installation b/gosa-si/server/events/set_activated_for_installation index 4f402d55d..7ec09dad0 100755 --- a/gosa-si/server/events/set_activated_for_installation +++ b/gosa-si/server/events/set_activated_for_installation @@ -32,8 +32,6 @@ 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_hash = &create_xml_hash("set_activated_for_installation", $source, "*"); -&add_content2xml_hash($out_hash, 'target', "GOSA"); +my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target); my $out_msg = &create_xml_string($out_hash); print $out_msg; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index cbfc25cd3..e48d08b98 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -36,10 +36,10 @@ if($sock->connected()){ #$data = "
gosa_count_jobdb
"; # clear -$data = "
gosa_clear_jobdb
"; +#$data = "
gosa_clear_jobdb
"; # set gosa-si-client to 'activated' -#$data = "
gosa_set_activated_for_installation
127.0.0.1:20083 127.0.0.1:20081
"; +$data = "
gosa_set_activated_for_installation
10.89.1.31:20083 127.0.0.1:20081
"; $sock->write($data);