From: rettenbe Date: Wed, 30 Jul 2008 09:43:40 +0000 (+0000) Subject: clean up gosa-si-server and GosaPackages X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d03caf88abb0309608014fb9efca0a1f8be7ad0a;p=gosa.git clean up gosa-si-server and GosaPackages git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12082 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index c3608750a..76eb6718b 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -490,7 +490,7 @@ sub send_msg_to_target { # opensocket my $socket = &open_socket($address); if( !$socket ) { - daemon_log("ERROR: cannot send ".$msg_header."msg to $address , host not reachable", 1); + daemon_log("WARNING: cannot send ".$msg_header."msg to $address , host not reachable", 3); if ($REGISTERED == 1) { $REGISTERED = 0; # if server is not available, cause reregistering daemon_log("INFO: cause reregistering at gosa-si-server", 5); diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index e377f705d..f44f5f631 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -216,6 +216,7 @@ my $max_children = 2; "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"], }, "server" => { + "ip" => [\$server_ip, "0.0.0.0"], "port" => [\$server_port, "20081"], "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ], "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'], @@ -924,7 +925,7 @@ sub send_msg_to_target { # opensocket my $socket = &open_socket($address); if( !$socket ) { - daemon_log("$session_id ERROR: cannot send ".$header."msg to $address , host not reachable", 1); + daemon_log("$session_id WARNING: cannot send ".$header."msg to $address , host not reachable", 3); $error++; } diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index ad5d12b50..d4104f6a3 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -20,44 +20,20 @@ use lib "/usr/lib/gosa-si/server/GosaPackages"; BEGIN{} END{} -my ($server_ip, $server_port, $server_passwd, $max_clients); -my ($gosa_ip, $gosa_mac_address, $gosa_port, $gosa_passwd, $network_interface); -my ($job_queue_timeout, $job_queue_file_name); - -my %cfg_defaults = ( -"server" => { - "ip" => [\$server_ip, "0.0.0.0"], - "port" => [\$server_port, "20081"], - "key" => [\$server_passwd, ""], - "max-clients" => [\$max_clients, 100], - }, -"GOsaPackages" => { - "ip" => [\$gosa_ip, "0.0.0.0"], - "port" => [\$gosa_port, "20082"], - "key" => [\$gosa_passwd, "none"], - "job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'], - }, -); - +my $network_interface; +my $gosa_mac_address; ## START ########################## -# read configfile and import variables -&read_configfile(); -$network_interface= &get_interface_for_ip($server_ip); +$network_interface= &get_interface_for_ip($main::server_ip); $gosa_mac_address= &get_mac($network_interface); # complete addresses -if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); } -our $server_address = "$server_ip:$server_port"; -if( inet_aton($gosa_ip) ){ $gosa_ip = inet_ntoa(inet_aton($gosa_ip)); } -$main::gosa_address = "$gosa_ip:$gosa_port"; - -my $xml = new XML::Simple(); +if( inet_aton($main::server_ip) ){ $main::server_ip = inet_ntoa(inet_aton($main::server_ip)); } +$main::server_address = $main::server_ip.":".$main::server_port; # import local events my ($error, $result, $event_hash) = &import_events($event_dir); - foreach my $log_line (@$result) { if ($log_line =~ / succeed: /) { &main::daemon_log("0 DEBUG: GosaPackages - $log_line", 7); @@ -71,38 +47,12 @@ foreach my $log_line (@$result) { sub get_module_info { my @info = ($main::gosa_address, - $gosa_passwd, + $main::gosa_passwd, ); return \@info; } -#=== FUNCTION ================================================================ -# NAME: read_configfile -# PARAMETERS: cfg_file - string - -# RETURNS: nothing -# DESCRIPTION: read cfg_file and set variables -#=============================================================================== -sub read_configfile { - my $cfg; - if( defined( $main::cfg_file) && ( (-s $main::cfg_file) > 0 )) { - if( -r $main::cfg_file ) { - $cfg = Config::IniFiles->new( -file => $main::cfg_file ); - } else { - print STDERR "Couldn't read config file!"; - } - } else { - $cfg = Config::IniFiles->new() ; - } - foreach my $section (keys %cfg_defaults) { - foreach my $param (keys %{$cfg_defaults{ $section }}) { - my $pinfo = $cfg_defaults{ $section }{ $param }; - ${@$pinfo[0]} = $cfg->val( $section, $param, @$pinfo[1] ); - } - } -} - - #=== FUNCTION ================================================================ # NAME: get_mac # PARAMETERS: interface name (i.e. eth0) @@ -167,7 +117,7 @@ sub process_incoming_msg { foreach my $out_msg ( @msg_l ) { # substitute in all outgoing msg GOSA of $server_address - $out_msg =~ s/GOSA<\/source>/$server_address<\/source>/g; + $out_msg =~ s/GOSA<\/source>/$main::server_address<\/source>/g; $out_msg =~ s/<\/xml>/$session_id<\/session_id><\/xml>/; if (defined $out_msg){ push(@out_msg_l, $out_msg); @@ -268,7 +218,7 @@ sub process_job_msg { $error ++; $out_msg = "". "
answer
". - "$server_address". + "$main::server_address". "GOSA". "1". "no mac address specified, neither in target-tag nor in macaddres-tag". @@ -320,7 +270,7 @@ sub process_job_msg { } else { &main::daemon_log("$session_id INFO: GosaPackages: $header job successfully added to job queue", 5); } - $out_msg = "
answer
$server_addressGOSA$res
"; + $out_msg = "
answer
$main::server_addressGOSA$res
"; } my @out_msg_l = ( $out_msg );