summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c0b150)
raw | patch | inline | side by side (parent: 3c0b150)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Feb 2008 13:03:07 +0000 (13:03 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Feb 2008 13:03:07 +0000 (13:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8953 594d385d-05f5-0310-b6e9-bd551577e9d8
index 80589e863fe2c5d9dcb1a189e4fdb24eceddc894..ac3a66018d847be379dcb04d214755173c02a3ab 100644 (file)
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $target = @{$msg_hash->{'target'}}[0];
+ my $session_id = @{$msg_hash->{'session_id'}}[0];
+
# switch target and source and send msg back
my $out_hash = &main::create_xml_hash("got_ping", $target, $source);
+ &add_content2xml_hash($out_hash, "session_id", $session_id);
my $out_msg = &main::create_xml_string($out_hash);
return $out_msg;
index 09d25d16f4cc1e58b8e83f9971779ebc03aa3b76..db7db14168514248928513703cf9f242e0bb3c2f 100644 (file)
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/installation.pm usr/lib/gosa-si/server/events
+server/events/gosaTriggered.pm usr/lib/gosa-si/server/events
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 570906585df085ba9d7546697b33dac252526a7b..590d9668e4a5a62e2d38a884aa684464a417ecdc 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
sub client_input {
no strict "refs";
- my ($heap,$input,$wheel) = @_[HEAP, ARG0, ARG1];
+ my ($kernel, $session, $heap,$input,$wheel) = @_[KERNEL, SESSION, HEAP, ARG0, ARG1];
+ my $session_id = $session->ID;
my ($msg, $msg_hash, $module);
my $error = 0;
my $answer_l;
# process incoming msg
if( $error == 0) {
daemon_log("Processing module ".$module, 5);
- $answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $heap->{'remote_ip'});
+ $answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $session_id);
if ( 0 > @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
}
}
elsif( $answer_target eq "GOSA" ) {
+ $answer =~ /<session_id>(\d)<\/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;
+ $client_answer = $gosa_answer."session_id=$1";
}
elsif( $answer_target eq "KNOWN_SERVER" ) {
# answer is for all server in known_server
}
if( $client_answer ) {
- $heap->{client}->put($client_answer);
+
+ if( $client_answer =~ /session_id=(\d+)/ ) {
+ my $session_id = $1;
+ my $session_reference = $kernel->ID_id_to_session($1);
+ my $session_heap = $session_reference->get_heap();
+ $session_heap->{client}->put( $client_answer );
+ }
+ else {
+ $heap->{client}->put($client_answer);
+ }
+
}
return;
index bc067c3372f5f0ec5ab041d37eeade76f8aca9df..d53227ef60c4467badc27f69601791d618b304ab 100644 (file)
# DESCRIPTION: handels the proceeded distribution to the appropriated functions
#===============================================================================
sub process_incoming_msg {
- my ($msg, $msg_hash) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{header}}[0];
- my $out_msg;
-
+ my @msg_l;
+ my @out_msg_l;
+
&main::daemon_log("GosaPackages: receive '$header'", 1);
if ($header =~ /^job_/) {
- $out_msg = &process_job_msg($msg, $msg_hash);
+ @msg_l = &process_job_msg($msg, $msg_hash, $session_id);
}
elsif ($header =~ /^gosa_/) {
- $out_msg = &process_gosa_msg($msg, $msg_hash);
+ @msg_l = &process_gosa_msg($msg, $msg_hash, $session_id);
}
else {
&main::daemon_log("ERROR: $header is not a valid GosaPackage-header, need a 'job_' or a 'gosa_' prefix");
}
- # keep job queue uptodate and save result and status
- if (defined ($out_msg) && $out_msg =~ /<jobdb_id>(\d*?)<\/jobdb_id>/) {
- my $job_id = $1;
- my $sql = "UPDATE '".$main::job_queue_table_name.
- "' SET status='done', result='".$out_msg.
- "' WHERE id='$job_id'";
- my $res = $main::job_db->exec_statement($sql);
- }
+ foreach my $out_msg ( @msg_l ) {
- # substitute in all outgoing msg <source>GOSA</source> of <source>$server_address</source>
- $out_msg =~ s/<source>GOSA<\/source>/<source>$server_address<\/source>/g;
+ # keep job queue uptodate and save result and status
+ if (defined ($out_msg) && $out_msg =~ /<jobdb_id>(\d*?)<\/jobdb_id>/) {
+ my $job_id = $1;
+ my $sql = "UPDATE '".$main::job_queue_table_name.
+ "' SET status='done', result='".$out_msg.
+ "' WHERE id='$job_id'";
+ my $res = $main::job_db->exec_statement($sql);
+ }
+
+ # substitute in all outgoing msg <source>GOSA</source> of <source>$server_address</source>
+ $out_msg =~ s/<source>GOSA<\/source>/<source>$server_address<\/source>/g;
+
+ if (defined $out_msg){
+ push(@out_msg_l, $out_msg);
+ }
- my @out_msg_l;
- if (defined $out_msg){
- push(@out_msg_l, $out_msg);
}
+
return \@out_msg_l;
}
sub process_gosa_msg {
- my ($msg, $msg_hash) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
my $out_msg;
-
+ my @out_msg_l;
+
my $header = @{$msg_hash->{'header'}}[0];
$header =~ s/gosa_//;
# 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);
+ @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
}
}
# if delivery not possible raise error and return
- if (not defined $out_msg) {
+ if( not @out_msg_l ) {
&main::daemon_log("ERROR: GosaPackages: no event handler or core function defined for $header", 1);
- } elsif ($out_msg eq "") {
+ } elsif( 0 == @out_msg_l) {
&main::daemon_log("ERROR: GosaPackages got not answer from event_handler $header", 1);
+ } elsif( $out_msg ) {
+ push(@out_msg_l, $out_msg);
}
- return $out_msg;
+
+ return @out_msg_l;
}
sub process_job_msg {
my ($msg, $msg_hash)= @_ ;
+ my $out_msg;
+ my @out_msg_l;
my $header = @{$msg_hash->{header}}[0];
$header =~ s/job_//;
if (not $res == 0) {
&main::daemon_log("ERROR: GosaPackages: process_job_msg: $res", 1);
}
+ else {
+ &main::daemon_log("INFO: GosaPackages: $header job successfully added to job queue", 5);
+ }
- &main::daemon_log("GosaPackages: $header job successfully added to job queue", 3);
- return "<xml><header>answer</header><source>$server_address</source><target>GOSA</target><answer1>$res</answer1></xml>";
+ $out_msg = "<xml><header>answer</header><source>$server_address</source><target>GOSA</target><answer1>$res</answer1></xml>";
+ push( @out_msg_l, $out_msg );
+
+ return @out_msg_l;
}
index 9c5ad6086a36696cf5a091cdfd37bbeab5e719d5..f84e3277bdfea68c38ee25898b21a97990a40409 100644 (file)
}
}
-# if( $error == 0) {
-# if( 0 == @out_msg_l ) {
-# push(@out_msg_l, $msg);
-# }
-# }
-
return \@out_msg_l;
}
#===============================================================================
sub got_ping {
my ($msg_hash) = @_;
-
+
my $source = @{$msg_hash->{source}}[0];
my $target = @{$msg_hash->{target}}[0];
my $header = @{$msg_hash->{header}}[0];
+ my $session_id = @{$msg_hash->{'session_id'}}[0];
+ my $act_time = &get_time;
+ my @out_msg_l;
+ my $out_msg;
+
+ # check known_clients_db
+ my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$source'";
+ my $query_res = $main::known_clients_db->select_dbentry( $sql_statement );
+ if( 1 == keys %{$query_res} ) {
+ my $sql_statement= "UPDATE known_clients ".
+ "SET status='$header', timestamp='$act_time' ".
+ "WHERE hostname='$source'";
+ my $res = $main::known_clients_db->update_dbentry( $sql_statement );
+ }
- if(exists $main::known_daemons->{$source}) {
- &main::add_content2known_daemons(hostname=>$source, status=>$header);
- } else {
- &main::add_content2known_clients(hostname=>$source, status=>$header);
- }
+ # check known_server_db
+ $sql_statement = "SELECT * FROM known_server WHERE hostname='$source'";
+ $query_res = $main::known_server_db->select_dbentry( $sql_statement );
+ if( 1 == keys %{$query_res} ) {
+ my $sql_statement= "UPDATE known_server ".
+ "SET status='$header', timestamp='$act_time' ".
+ "WHERE hostname='$source'";
+ my $res = $main::known_server_db->update_dbentry( $sql_statement );
+ }
+
+ # create out_msg
+ my $out_hash = &create_xml_hash($header, $source, "GOSA");
+ &add_content2xml_hash($out_hash, "session_id", $session_id);
+ $out_msg = &create_xml_string($out_hash);
+ push(@out_msg_l, $out_msg);
- return;
+ return @out_msg_l;
}
-
#=== FUNCTION ================================================================
# NAME: new_passwd
# PARAMETERS: msg_hash - ref - hash from function create_xml_hash
@servers= sort (@servers);
foreach $server (@servers){
- # Conversation for backward compatibility
- if ($server !=~ /^ldap[^:]+:\/\// ) {
- if ($server =~ /^([^:]+):(.*)$/ ) {
- $server= "1:dummy:ldap://$1/$2";
- }
- }
+ # Conversation for backward compatibility
+ if ($server !=~ /^ldap[^:]+:\/\// ) {
+ if ($server =~ /^([^:]+):(.*)$/ ) {
+ $server= "1:dummy:ldap://$1/$2";
+ }
+ }
$base= $server;
$server =~ s%^[^:]+:[^:]+:(ldap.*://[^/]+)/.*$%$1%;
index 98391deab9b9a3b268ca473b87e8a2e51b261295..d0e189b53bee2d63bb2baf7b41ec68df027539b7 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
/* Prepare a hunge bunch of data to be send */
# add
-#$data = "<xml> <header>job_ping</header> <source>10.89.1.155:20083</source><mac>00:1B:77:04:8A:6C</mac> <timestamp>19700101000001</timestamp> </xml>";
+$data = "<xml> <header>gosa_ping</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target> </xml>";
#$data = "<xml> <header>job_sayHello</header> <source>10.89.1.155:20083</source><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";
#$data = "<xml> <header>job_ping</header> <source>10.89.1.155:20083</source> <target>10.89.1.155:20081</target><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";
#$data = "<xml> <header>gosa_import_events</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_trigger_action_localboot</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> <timeout>-1</timeout></xml>";
+#$data = "<xml> <header>gosa_trigger_action_localboot</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> <timeout>-1</timeout></xml>";