Code

add gosa-si-client event set_activated_for_installation
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Feb 2008 15:41:46 +0000 (15:41 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Feb 2008 15:41:46 +0000 (15:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8734 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/client/events/registered.pm
gosa-si/gosa-si-server
gosa-si/new-gosa-si-client
gosa-si/server/events/set_activated_for_installation
gosa-si/tests/client.php

index 6cfd7ede962a92d7b82be05a0200df7cd4517ed3..fb3e751e2c0ab9edfb8495317fb71b1b0fec2152 100644 (file)
@@ -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;
+}
 
 
 
index 16beffc07c0e8cb99bcceb2e49a2c3fde505526e..8280d8ad5810da3dcd46b023904548d1439032bd 100755 (executable)
@@ -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 {
index 590a7f23fda7e5c8cfbbe8bd90037675c9363b75..d8cf9db2884841195eb6ccaa9b6d28de5fc5acb7 100755 (executable)
@@ -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") {
index 4f402d55da8753503f17fe39e675abea11caaada..7ec09dad02812b078707da31f1df1e34d09da412 100755 (executable)
@@ -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;
index cbfc25cd329b0c0ed64ba83dfa555aa7a401fe1d..e48d08b98888a20f178f7fe6057d47ee8ee145e1 100755 (executable)
@@ -36,10 +36,10 @@ if($sock->connected()){
 #$data = "<xml> <header>gosa_count_jobdb</header></xml>";
 
 # clear
-$data = "<xml> <header>gosa_clear_jobdb</header> </xml>";
+#$data = "<xml> <header>gosa_clear_jobdb</header> </xml>";
 
 # set gosa-si-client to 'activated'
-#$data = "<xml> <header>gosa_set_activated_for_installation</header> <target>127.0.0.1:20083</target> <source>127.0.0.1:20081</source> </xml>";
+$data = "<xml> <header>gosa_set_activated_for_installation</header> <target>10.89.1.31:20083</target> <source>127.0.0.1:20081</source> </xml>";
 
 
     $sock->write($data);