Code

add logging of hardware detection to corefunctions
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Feb 2008 09:21:26 +0000 (09:21 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Feb 2008 09:21:26 +0000 (09:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8765 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/client.conf
gosa-si/client/events/corefunctions.pm
gosa-si/gosa-si-client
gosa-si/gosa-si-server
gosa-si/modules/SIPackages.pm
gosa-si/server/events/installation.pm
gosa-si/tests/client.php

index 18260f97904f17826e5b5fc77a1ecd9c5752b3e1..fdb3ba7533898a2a68bd2e94b4e25f822fd2faf3 100644 (file)
@@ -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
index e00b7516378bc7e9166735e53e01da007be23aea..888fc8c798f0eb1c49be5c0266965754654692a4 100644 (file)
@@ -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, 
index 3d627c9b070a20ee51c733819ab2fe9c56be833b..a3e742b1545a0a5ad23428328a471699b8328f43 100755 (executable)
@@ -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);
+        }
     }
 
     ########
index e03855aa65a5631a58ed04801192914f9f18e27c..8ce80bc1a4d7c6944b58f3ddb47bd9eeaae0089d 100755 (executable)
@@ -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} ) {
index 0af55bcae77dc8fd71ea961561a13e719f84f79a..eec28447a0b57adf2e2f8eb9161a271046183a3e 100644 (file)
@@ -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;
 }
index c6ac910fbcacfd130349ef61f7d1b3b0efd3fb53..b12e20ca2b4d20b697f449bd46f51b83da946f80 100644 (file)
@@ -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) = @_;
 
index ff33d537da1f0d0a9d94983d494941b2a33f16b5..40df353ea5f4261a4e7e74ab491a868ef1e627d6 100755 (executable)
@@ -41,11 +41,12 @@ if($sock->connected()){
 # set gosa-si-client to 'activated'
 #$data = "<xml> <header>gosa_set_activated_for_installation</header> <target>10.89.1.31:20083</target> <source>127.0.0.1:20081</source> </xml>";
 
+$data = "<xml> <header>gosa_detect_hardware</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_reboot</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_reinstall</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_softupdate</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_halt</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
+#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
 
 
     $sock->write($data);