From: rettenbe Date: Thu, 7 Feb 2008 09:21:26 +0000 (+0000) Subject: add logging of hardware detection to corefunctions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=df565952f22a39758d0d7d1f56be652352445e60;p=gosa.git add logging of hardware detection to corefunctions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8765 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client.conf b/gosa-si/client.conf index 18260f979..fdb3ba753 100644 --- a/gosa-si/client.conf +++ b/gosa-si/client.conf @@ -1,9 +1,7 @@ [general] log_file = /var/log/gosa-si-client.log pid_file = /var/run/gosa-si-client.pid - -[client] -client_port = 20083 +fai_logpath = /tmp/fai.log [server] server_ip = 10.89.1.31 diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index e00b75163..888fc8c79 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -12,10 +12,13 @@ use GOSA::GosaSupportDaemon; use File::Basename; -my ($ldap_enabled, $ldap_config, $pam_config, $nss_config); +my ($ldap_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath); my %cfg_defaults = ( + "general" => { + "fai_logpath" => [\$fai_logpath, "/var/log/fai/fai.log"], + }, "client" => { "ldap" => [\$ldap_enabled, 1], "ldap_config" => [\$ldap_config, "/etc/ldap/ldap.conf"], @@ -37,6 +40,32 @@ my $server_address = $main::server_address; my $server_key = $main::server_key; my $client_mac_address = $main::client_mac_address; +sub write_to_file { + my ($string, $file) = @_; + my $error = 0; + + if( not defined $file || not -f $file ) { + &main::daemon_log("ERROR: $0: check '-f file' failed: $file", 1); + $error++; + } + if( not defined $string || 0 == length($string)) { + &main::daemon_log("ERROR: $0: empty string to write to file '$file'", 1); + $error++; + } + + if( $error == 0 ) { + + chomp($string); + + open(FILE, ">> $file"); + print FILE $string."\n"; + close(FILE); + } + + return; +} + + sub get_events { return \@events; } @@ -291,6 +320,10 @@ sub new_key { sub detect_hardware { + + + &write_to_file('goto-hardware-detection-start', $fai_logpath); + my $hwinfo= `which hwinfo`; chomp $hwinfo; @@ -397,6 +430,8 @@ sub detect_hardware { &main::daemon_log("Hardware detection done!", 4); + &write_to_file('goto-hardware-detection-stop', $fai_logpath); + return &main::send_msg_hash2address( &main::create_xml_hash("detected_hardware", $main::client_address, $main::server_address, $result), $main::server_address, diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 3d627c9b0..a3e742b15 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -39,7 +39,7 @@ use Net::DNS; my $event_dir = "/usr/lib/gosa-si/client/events"; use lib "/usr/lib/gosa-si/client/events"; -my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file); +my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file, $fai_logpath); my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain, $server_key_lifetime); my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config); my $xml; @@ -59,24 +59,25 @@ our $REGISTERED_FLAG = 1; %cfg_defaults = ( "general" => - {"log_file" => [\$log_file, "/var/run/".$0.".log"], - "pid_file" => [\$pid_file, "/var/run/".$0.".pid"], + {"log_file" => [\$log_file, "/var/run/".$0.".log"], + "pid_file" => [\$pid_file, "/var/run/".$0.".pid"], + "fai_logpath" => [\$fai_logpath, "/var/log/fai/fai.log"], }, "client" => - {"client_port" => [\$client_port, "20083"], - "client_ip" => [\$client_ip, "0.0.0.0"], + {"client_port" => [\$client_port, "20083"], + "client_ip" => [\$client_ip, "0.0.0.0"], "client_mac_address" => [\$client_mac_address, "00:00:00:00:00:00"], - "ldap" => [\$ldap_enabled, 1], - "ldap_config" => [\$ldap_config, "/etc/ldap/ldap.conf"], - "pam_config" => [\$pam_config, "/etc/pam_ldap.conf"], - "nss_config" => [\$nss_config, "/etc/libnss_ldap.conf"], + "ldap" => [\$ldap_enabled, 1], + "ldap_config" => [\$ldap_config, "/etc/ldap/ldap.conf"], + "pam_config" => [\$pam_config, "/etc/pam_ldap.conf"], + "nss_config" => [\$nss_config, "/etc/libnss_ldap.conf"], }, "server" => - {"server_ip" => [\$server_ip, "127.0.0.1"], - "server_port" => [\$server_port, "20081"], - "server_key" => [\$server_key, ""], - "server_timeout" => [\$server_timeout, 10], - "server_domain" => [\$server_domain, ""], + {"server_ip" => [\$server_ip, "127.0.0.1"], + "server_port" => [\$server_port, "20081"], + "server_key" => [\$server_key, ""], + "server_timeout" => [\$server_timeout, 10], + "server_domain" => [\$server_domain, ""], "server_key_lifetime" => [\$server_key_lifetime, 600], }, @@ -949,7 +950,7 @@ sub import_events { eval{ require $event; }; if( $@ ) { - daemon_log("import of event module '$event' failed", 1); + daemon_log("ERROR: import of event module '$event' failed", 1); daemon_log("$@", 8); next; } @@ -1006,7 +1007,10 @@ sub server_input { daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5); no strict 'refs'; $answer = &{$event_hash->{$header}."::$header"}($msg, $msg_hash); - } + } + else { + daemon_log("WARNING: no event '$header' found in event modules under $event_dir", 1); + } } ######## diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index e03855aa6..8ce80bc1a 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -544,7 +544,7 @@ sub input_from_unknown_host { } if( (!$msg) || (!$msg_hash) || (!$module)) { - daemon_log("Incoming message is not from a unknown host", 3); + daemon_log("Incoming message is not from a unknown host", 5); } return ($msg, $msg_hash, $module); @@ -727,7 +727,7 @@ sub client_input { ###################### # process incoming msg if( $error == 0) { - daemon_log("Processing module ".$module, 3); + daemon_log("Processing module ".$module, 5); $answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $heap->{'remote_ip'}); if ( 0 > @{$answer_l} ) { diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 0af55bcae..eec28447a 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -344,10 +344,6 @@ sub register_at_bus { my $msg_hash = &create_xml_hash("here_i_am", $server_address, $bus_address); my $msg = &create_xml_string($msg_hash); -print STDERR "bus_key:$bus_key\n"; -print STDERR "msg:$msg\n"; - - &main::send_msg_to_target($msg, $bus_address, $bus_key, "here_i_am"); return $msg; # my $answer = ""; @@ -420,11 +416,11 @@ sub process_incoming_msg { } } - if( $error == 0) { - if( 0 == @out_msg_l ) { - push(@out_msg_l, $msg); - } - } +# if( $error == 0) { +# if( 0 == @out_msg_l ) { +# push(@out_msg_l, $msg); +# } +# } return \@out_msg_l; } diff --git a/gosa-si/server/events/installation.pm b/gosa-si/server/events/installation.pm index c6ac910fb..b12e20ca2 100644 --- a/gosa-si/server/events/installation.pm +++ b/gosa-si/server/events/installation.pm @@ -1,7 +1,7 @@ package installation; use Exporter; @ISA = qw(Exporter); -my @events = qw(get_events set_activated_for_installation reboot halt softupdate reinstall new_key_for_client); +my @events = qw(get_events set_activated_for_installation reboot halt softupdate reinstall new_key_for_client detect_hardware); @EXPORT = @events; use strict; @@ -21,6 +21,21 @@ sub get_events { return \@events; } + +sub detect_hardware { + my ($msg, $msg_hash) = @_ ; + # just forward msg to client, but dont forget to split off 'gosa_' in header + my $header = @{$msg_hash->{header}}[0]; + my $source = @{$msg_hash->{source}}[0]; + my $target = @{$msg_hash->{target}}[0]; + + my $out_hash = &create_xml_hash("detect_hardware", $source, $target); + my $out_msg = &create_xml_string($out_hash); + + return $out_msg; +} + + sub set_activated_for_installation { my ($msg, $msg_hash) = @_; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index ff33d537d..40df353ea 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -41,11 +41,12 @@ if($sock->connected()){ # set gosa-si-client to 'activated' #$data = "
gosa_set_activated_for_installation
10.89.1.31:20083 127.0.0.1:20081
"; +$data = "
gosa_detect_hardware
10.89.1.31:20083 10.89.1.31:20081
"; #$data = "
gosa_reboot
10.89.1.31:20083 10.89.1.31:20081
"; #$data = "
gosa_reinstall
10.89.1.31:20083 10.89.1.31:20081
"; #$data = "
gosa_softupdate
10.89.1.31:20083 10.89.1.31:20081
"; #$data = "
gosa_halt
10.89.1.31:20083 10.89.1.31:20081
"; -$data = "
gosa_new_key_for_client
00:01:6c:9d:b9:fa 10.89.1.31:20081
"; +#$data = "
gosa_new_key_for_client
00:01:6c:9d:b9:fa 10.89.1.31:20081
"; $sock->write($data);