From 714a84d540919f10d5c8b901541b5162feddf558 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 20 Feb 2008 16:29:41 +0000 Subject: [PATCH] fai msgs are forwarded into gosa jobqueue git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8996 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/debian/gosa-si-server.install | 2 +- gosa-si/gosa-si-client | 1 + gosa-si/gosa-si-server | 47 ++++++++++++++++++--------- gosa-si/modules/GosaPackages.pm | 3 ++ gosa-si/modules/SIPackages.pm | 3 ++ gosa-si/tests/client.php | 6 ++-- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/gosa-si/debian/gosa-si-server.install b/gosa-si/debian/gosa-si-server.install index d483ae2bb..b30cc9ce1 100644 --- a/gosa-si/debian/gosa-si-server.install +++ b/gosa-si/debian/gosa-si-server.install @@ -7,4 +7,4 @@ modules/GosaPackages.pm usr/lib/gosa-si/modules modules/ArpHandler.pm usr/lib/gosa-si/modules modules/oui.txt usr/lib/gosa-si/modules server/events/gosaTriggered.pm usr/lib/gosa-si/server/events -server/events/siTriggered.pm usr/lib/gosa-si/server/events +server/events/siTriggered.pm usr/lib/gosa-si/server/events diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index b4f6a4358..fee7b7199 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -1191,6 +1191,7 @@ sub fifo_got_record { } my $clmsg_hash = &create_xml_hash("CLMSG_$header", $client_address, $server_address, $content); + &add_content2xml_hash($clmsg_hash, "macaddress", $client_mac_address); my $clmsg = &create_xml_string($clmsg_hash); &send_msg_to_target($clmsg, $server_address, $server_key); return; diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 3bf04aff5..5e61e9a55 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -87,9 +87,9 @@ $bus_activ = "true"; $no_arp = 0; -# name of table for storing gosa jobs -our $job_queue_table_name = 'jobs'; +# holds all gosa jobs our $job_db; +our $job_queue_table_name = 'jobs'; # holds all other gosa-sd as well as the gosa-sd-bus our $known_server_db; @@ -459,6 +459,7 @@ sub check_outgoing_xml_validity { $target =~ /^GOSA$/i || $target =~ /^\*$/ || $target =~ /KNOWN_SERVER/i || + $target =~ /JOBDB/i || $target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ){ die "target '$target' is not a complete ip-address with port or a valid target name or a mac-address"; } @@ -926,6 +927,8 @@ sub client_input { # deliver msg to all targets foreach my $answer_target ( @answer_target_l ) { + + # targets of msg are all gosa-si-clients in known_clients_db if( $answer_target eq "*" ) { # answer is for all clients my $sql_statement= "SELECT * FROM known_clients"; @@ -936,19 +939,8 @@ sub client_input { &send_msg_to_target($answer, $host_name, $host_key, $answer_header); } } - elsif( $answer_target eq "GOSA" ) { - $answer =~ /(\d+)<\/session_id>/; - my $session_id = $1; - my $add_on = ""; - if( defined $session_id ) { - $add_on = ".session_id=$session_id"; - } - - # answer is for GOSA and has to returned to connected client - my $gosa_answer = &encrypt_msg($answer, $GosaPackages_key); - $client_answer = $gosa_answer.$add_on; - } + # targets of msg are all gosa-si-server in known_server_db elsif( $answer_target eq "KNOWN_SERVER" ) { # answer is for all server in known_server my $sql_statement= "SELECT * FROM known_server"; @@ -960,6 +952,29 @@ sub client_input { &send_msg_to_target($answer, $host_name, $host_key, $answer_header); } } + + # target of msg is GOsa + elsif( $answer_target eq "GOSA" ) { + $answer =~ /(\d+)<\/session_id>/; + my $session_id = $1; + my $add_on = ""; + if( defined $session_id ) { + $add_on = ".session_id=$session_id"; + } + # answer is for GOSA and has to returned to connected client + my $gosa_answer = &encrypt_msg($answer, $GosaPackages_key); + $client_answer = $gosa_answer.$add_on; + } + + # target of msg is job queue at this host + elsif( $answer_target eq "JOBDB") { + $answer =~ /
(\S+)<\/header>/; + my $header; + if( defined $1 ) { $header = $1; } + &send_msg_to_target($answer, $server_address, $GosaPackages_key, $header); + } + + # target of msg is a mac address elsif( $answer_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) { daemon_log("target is mac address '$answer_target', looking for host in known_clients", 3); my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$answer_target'"; @@ -988,9 +1003,9 @@ sub client_input { } } - } else { - # ... answer is for one specific host + # answer is for one specific host + } else { # get encrypt_key my $encrypt_key = &get_encrypt_key($answer_target); if( not defined $encrypt_key ) { diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 1668c10fe..e2e7b3fc3 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -513,6 +513,9 @@ sub update_status_jobdb_entry { $out_xml = "
answer
$server_addressGOSA0
"; } my @out_msg_l = ( $out_xml ); + +print STDERR $out_xml."\n"; + return @out_msg_l; } diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 3d74d38b6..c9231d2aa 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -445,6 +445,9 @@ sub process_incoming_msg { my $header = @{$msg_hash->{header}}[0]; my @target_l = @{$msg_hash->{target}}; + # skip PREFIX + $header =~ s/^CLMSG_//; + &main::daemon_log("SIPackages: msg to process: $header", 3); &main::daemon_log("$msg", 8); diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index e38d71736..dbaeb8f3a 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -16,15 +16,15 @@ if($sock->connected()){ /* Prepare a hunge bunch of data to be send */ # add -$data = "
gosa_network_completition
GOSAGOSAws-muc-2
"; +#$data = "
gosa_network_completition
GOSAGOSAws-muc-2
"; #$data = "
job_sayHello
10.89.1.155:2008300:1B:77:04:8A:6C 20130102133900
"; -#$data = "
job_ping
10.89.1.155:20083 10.89.1.155:2008100:1B:77:04:8A:6C 20130102133900
"; +#$data = "
job_ping
10.89.1.155:20083 10.89.1.155:2008100:01:6c:9d:b9:fa 20130102133900
"; # delete #$data = "
gosa_delete_jobdb_entry
3
"; # update -#$data = "
gosa_update_status_jobdb_entry
waiting processing update
"; +$data = "
gosa_update_status_jobdb_entry
waiting processing update
"; # query #$data = "
gosa_query_jobdb
andgt0le5
"; -- 2.30.2