summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 19cdb36)
raw | patch | inline | side by side (parent: 19cdb36)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 15 Feb 2008 09:23:37 +0000 (09:23 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 15 Feb 2008 09:23:37 +0000 (09:23 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8924 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history | |
gosa-si/tests/sqlite-check.pl | [deleted file] | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 9b0374de264db0b450c8f716dd700f741b50a421..27de3ab341ee1a12ad2ad98bf5a3c441f7166097 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use POSIX;
use Time::HiRes qw( gettimeofday );
-use POE qw(Component::Server::TCP);
+use POE qw(Component::Server::TCP Wheel::FollowTail);
use IO::Socket::INET;
use NetAddr::IP;
use Data::Dumper;
my $event_hash;
my @servers;
my $gotoHardwareChecksum;
+my $gosa_si_client_fifo;
+my %files_to_watch;
$verbose= 1;
# globalise variables which are used in imported events
# default variables
our $REGISTERED = 0;
+# path to fifo for non-gosa-si-client messages to gosa-si-server
+$gosa_si_client_fifo = "/tmp/gosa-si-client-fifo";
+%files_to_watch = (fifo => $gosa_si_client_fifo);
+
# in function register_at_gosa_si_server, after which period of seconds a new registration should be tried if a registration was
# not successful until now
my $delay_set_time = 5;
}
+sub generic_file_reset {
+ my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
+
+ my $service = $heap->{services}->{$wheel_id};
+ daemon_log("INFO: '$service' watching reset", 5);
+ return;
+}
+
+sub generic_file_error {
+ my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
+ @_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
+
+ my $service = $heap->{services}->{$wheel_id};
+ daemon_log("ERROR: '$service' watcher $operation error $errno: $error_string", 1);
+ daemon_log("ERROR: shutting down '$service' file watcher", 1);
+
+ delete $heap->{services}->{$wheel_id};
+ delete $heap->{watchers}->{$wheel_id};
+ return;
+}
+
+sub fifo_got_record {
+ my $file_record = $_[ARG0];
+ print STDERR "$file_record\n";
+
+ my $clmsg_hash = &create_xml_hash("CLMSG_$file_record", $client_address, $server_address);
+ my $clmsg = &create_xml_string($clmsg_hash);
+ &send_msg_to_target($clmsg, $server_address, $server_key);
+ return;
+}
+
+
sub _start {
- my ($kernel) = $_[KERNEL];
+ my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('client_session');
+
+ # force a registration at a gosa-si-server
$kernel->yield('register_at_gosa_si_server');
+
+ # install all file watcher defined
+ while( my($file_name, $file) = each %files_to_watch ) {
+ my $file_watcher = POE::Wheel::FollowTail->new(
+ Filename => $file,
+ InputEvent => $file_name."_record",
+ ResetEvent => "file_reset",
+ ErrorEvent => "file_error",
+ );
+ $heap->{services}->{ $file_watcher->ID } = $file_name;
+ $heap->{watchers}->{ $file_watcher->ID } = $file_watcher;
+ }
}
}
+# open fifo for non-gosa-si-client-msgs to gosa-si-server
+POSIX::mkfifo("$gosa_si_client_fifo", "0600");
POE::Session->create(
_start => \&_start,
register_at_gosa_si_server => \®ister_at_gosa_si_server,
trigger_new_key => \&trigger_new_key,
+
+ # handle records from each defined file differently
+ fifo_record => \&fifo_got_record,
+
+ # handle file resets and errors the same way for each file
+ file_reset => \&generic_file_reset,
+ file_error => \&generic_file_error,
}
);
index 1a40c23a0f1d270f2b0e7ca3bdcd14033b0370dc..ccdcea1517ec4f27a3cbe1f20292858873d0e0a8 100644 (file)
}
+#=== FUNCTION ================================================================
+# NAME: create_xml_string
+# PARAMETERS: xml_hash - hash - hash from function create_xml_hash
+# RETURNS: xml_string - string - xml string representation of the hash
+# DESCRIPTION: transform the hash to a string using XML::Simple module
+#===============================================================================
+sub create_xml_string {
+ my ($xml_hash) = @_ ;
+ my $xml_string = $xml->XMLout($xml_hash, RootName => 'xml');
+ #$xml_string =~ s/[\n]+//g;
+ #daemon_log("create_xml_string:",7);
+ #daemon_log("$xml_string\n", 7);
+ return $xml_string;
+}
+
+
sub transform_msg2hash {
my ($msg) = @_ ;
my $hash = $xml->XMLin($msg, ForceArray=>1);
}
-#=== FUNCTION ================================================================
-# NAME: send_msg_hash2address
-# PARAMETERS: msg_hash - hash - xml_hash created with function create_xml_hash
-# PeerAddr string - socket address to send msg
-# PeerPort string - socket port, if not included in socket address
-# RETURNS: nothing
-# DESCRIPTION: ????
-#===============================================================================
-#sub send_msg_hash2address ($$$){
-# my ($msg_hash, $address, $passwd) = @_ ;
-#
-# # fetch header for logging
-# my $header = @{$msg_hash->{header}}[0];
-#
-# # generate xml string
-# my $msg_xml = &create_xml_string($msg_hash);
-#
-# # create ciphering object
-# my $act_cipher = &create_ciphering($passwd);
-#
-# # encrypt xml msg
-# my $crypted_msg = &encrypt_msg($msg_xml, $act_cipher);
-#
-# # opensocket
-# my $socket = &open_socket($address);
-# if(not defined $socket){
-# daemon_log("cannot send '$header'-msg to $address , server not reachable", 5);
-# return 1;
-# }
-#
-# # send xml msg
-# print $socket $crypted_msg."\n";
-#
-# close $socket;
-#
-# daemon_log("send '$header'-msg to $address", 1);
-# daemon_log("message:\n$msg_xml", 8);
-# return 0;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: get_content_from_xml_hash
-# PARAMETERS: xml_ref - ref - reference of the xml hash
-# element - string - key of the value you want
-# RETURNS: value - string - if key is either header, target or source
-# value - list - for all other keys in xml hash
-# DESCRIPTION:
-#===============================================================================
-#sub get_content_from_xml_hash {
-# my ($xml_ref, $element) = @_ ;
-# #my $result = $main::xml_ref->{$element};
-# #if( $element eq "header" || $element eq "target" || $element eq "source") {
-# # return @$result[0];
-# #}
-# my @result = $xml_ref->{$element};
-# return \@result;
-#}
-
-
#=== FUNCTION ================================================================
# NAME: add_content2xml_hash
# PARAMETERS: xml_ref - ref - reference to a hash from function create_xml_hash
}
-#=== FUNCTION ================================================================
-# NAME: create_xml_string
-# PARAMETERS: xml_hash - hash - hash from function create_xml_hash
-# RETURNS: xml_string - string - xml string representation of the hash
-# DESCRIPTION: transform the hash to a string using XML::Simple module
-#===============================================================================
-sub create_xml_string {
- my ($xml_hash) = @_ ;
- my $xml_string = $xml->XMLout($xml_hash, RootName => 'xml');
- #$xml_string =~ s/[\n]+//g;
- #daemon_log("create_xml_string:",7);
- #daemon_log("$xml_string\n", 7);
- return $xml_string;
-}
-
-
#=== FUNCTION ================================================================
# NAME: encrypt_msg
# PARAMETERS: msg - string - message to encrypt
diff --git a/gosa-si/tests/sqlite-check.pl b/gosa-si/tests/sqlite-check.pl
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/perl
-#===============================================================================
-#
-# FILE: DBD-SQlite.pl
-#
-# USAGE: ./DBD-SQlite.pl
-#
-# DESCRIPTION:
-#
-# OPTIONS: ---
-# REQUIREMENTS: ---
-# BUGS: ---
-# NOTES: ---
-# AUTHOR: (), <>
-# COMPANY:
-# VERSION: 1.0
-# CREATED: 20.12.2007 08:54:52 CET
-# REVISION: ---
-#===============================================================================
-
-use strict;
-use warnings;
-use GOSA::DBsqlite;
-
-
-print "START\n";
-my $res;
-my $db_name;
-
-
-$db_name = "/var/lib/gosa-si/jobs.db";
-if (-e $db_name) {
- print "\n############################################################\n";
- my $table_name = "jobs";
- print "$db_name\n";
- print "$table_name\n";
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
-$db_name = "/var/lib/gosa-si/clients.db";
-if (-e $db_name) {
- print "\n############################################################\n";
-# $db_name =~ /\/([^\/]*?)\.db$/;
-# my $table_name = $1;
- my $table_name = "known_clients";
- print "$db_name\n";
- print "$table_name\n";
-
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
-$db_name = "/var/lib/gosa-si/servers.db";
-if (-e $db_name) {
- print "\n############################################################\n";
-# $db_name =~ /\/([^\/]*?)\.db$/;
-# my $table_name = $1;
- my $table_name = "known_server";
- print "$db_name\n";
- print "$table_name\n";
-
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
-$db_name = "/var/lib/gosa-si/bus-server.db";
-if (-e $db_name) {
- print "\n############################################################\n";
-# $db_name =~ /\/([^\/]*?)\.db$/;
-# my $table_name = $1;
- my $table_name = "bus_known_server";
- print "$db_name\n";
- print "$table_name\n";
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-$db_name = "/var/lib/gosa-si/bus-clients.db";
-if (-e $db_name) {
- print "\n############################################################\n";
-# $db_name =~ /\/([^\/]*?)\.db$/;
-# my $table_name = $1;
- my $table_name = "bus_known_clients";
- print "$db_name\n";
- print "$table_name\n";
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-print "\nFINISH\n";