Code

new event module logHandling.pm
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Mar 2008 16:43:26 +0000 (16:43 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Mar 2008 16:43:26 +0000 (16:43 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9978 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/modules/GosaPackages.pm
gosa-si/server/events/clMessages.pm
gosa-si/server/events/logHandling.pm [new file with mode: 0644]
gosa-si/tests/client.php

index b616de5ba26a40210210df2b5bef94be229a4479..7e50aef0295095b5006510d5a43037591a22f2d4 100644 (file)
@@ -229,8 +229,8 @@ sub import_events {
 
     while (defined (my $event = readdir (DIR))) {
         if( $event eq "." || $event eq ".." ) { next; }   
-        if( $event eq "siTriggered.pm" ) { next; }      # SI specific events not needed in GosaPackages.pm
-        if( $event eq "clMessages.pm" ) { next; }                    # SI specific events not needed in GosaPackages.pm
+        if( $event eq "siTriggered.pm" ) { next; }                  # SI specific events not needed in GosaPackages.pm
+        if( $event eq "clMessages.pm" ) { next; }                   # SI specific events not needed in GosaPackages.pm
 
         eval{ require $event; };
         if( $@ ) {
@@ -246,7 +246,7 @@ sub import_events {
             $event_hash->{$event_name} = $event_module;
         }
         my $events_string = join( ", ", @{$events_l});
-        &main::daemon_log("G DEBUG: GosaPackages imported events $events_string", 8);
+        &main::daemon_log("G DEBUG: GosaPackages from '$1' imported events $events_string", 8);
     }
 }
 
index 698dad28e6684cde40c197b9d741b2d3ec5cc9ec..c606822f5b46a50956a35afa732e48557208bd21 100644 (file)
@@ -95,7 +95,7 @@ sub save_fai_log {
 
     my $time = &get_time;
     $time = substr($time, 0, 8)."_".substr($time, 8, 6);
-    $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install-$time" );
+    $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install_$time" );
     mkdir($client_fai_log_dir, 0755);
 
     my @all_logs = split(/log_file:/, $all_logs); 
diff --git a/gosa-si/server/events/logHandling.pm b/gosa-si/server/events/logHandling.pm
new file mode 100644 (file)
index 0000000..8b9af8f
--- /dev/null
@@ -0,0 +1,146 @@
+package logHandling;
+use Exporter;
+@ISA = qw(Exporter);
+my @events = (
+    "get_events",
+#    "show_log_by_mac",
+#    "show_log_by_date",
+#    "show_log_by_date_and_mac",
+#    "get_log_by_date",
+#    "get_log_by_mac",
+#    "get_log_by_date_and_mac",
+#    "get_recent_log_by_mac",
+#    "delete_log_by_date_and_mac",
+    );
+@EXPORT = @events;
+
+use strict;
+use warnings;
+use GOSA::GosaSupportDaemon;
+use Data::Dumper;
+use File::Spec;
+
+BEGIN {}
+
+END {}
+
+### Start ######################################################################
+
+#&main::read_configfile($main::cfg_file, %cfg_defaults);
+
+sub get_events {
+    return \@events
+}
+
+sub show_log_by_date {
+    my ($msg, $msg_hash, $session_id) = @_;
+    my $header = @{$msg_hash->{header}}[0];
+    $header =~ s/gosa_//;
+    my $target = @{$msg_hash->{target}}[0];
+    my $source = @{$msg_hash->{source}}[0];
+
+    my $date_l =  $msg_hash->{date};
+
+    if (not -d $main::client_fai_log_dir) {
+        &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1); 
+        return;
+    }
+
+    # build out_msg
+    my $out_hash = &create_xml_hash($header, $target, $source);
+    
+    # fetch mac directory
+    opendir(DIR, $main::client_fai_log_dir); 
+    my @avail_macs = readdir(DIR);
+    closedir(DIR);   
+   
+}
+
+sub show_log_by_mac {
+    my ($msg, $msg_hash, $session_id) = @_;
+    my $header = @{$msg_hash->{header}}[0];
+    $header =~ s/gosa_//;
+    my $target = @{$msg_hash->{target}}[0];
+    my $source = @{$msg_hash->{source}}[0];
+    my $mac_l = $msg_hash->{mac};
+
+    if (not -d $main::client_fai_log_dir) {
+        &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1); 
+        return;
+    }
+
+    # build out_msg
+    my $out_hash = &create_xml_hash($header, $target, $source);
+    foreach my $mac (@{$mac_l}) {
+        my $act_log_dir = File::Spec->catdir($main::client_fai_log_dir, $mac);
+        if (not -d $act_log_dir) { next; }
+        $mac =~ s/:/_/g;
+
+        # fetch mac directory
+        opendir(DIR, $act_log_dir); 
+        my @install_dates = readdir(DIR);
+        closedir(DIR);   
+        foreach my $date (@install_dates) {
+            if ($date eq ".." || $date eq ".") { next; }
+            &add_content2xml_hash($out_hash, "mac_$mac", $date);
+        }
+    }
+
+    my $out_msg = &create_xml_string($out_hash);
+    return ($out_msg);
+}
+
+
+sub show_log_by_date_and_mac {
+    my ($msg, $msg_hash, $session_id) = @_ ;
+    my $date_l = $msg_hash->{date};
+    my $mac_l = $msg_hash->{mac};
+
+    print STDERR "###########################################################\n"; 
+    print STDERR "date:".Dumper($date_l); 
+    print STDERR "mac: ".Dumper($mac_l); 
+    print STDERR "client_fai_log_dir: $main::client_fai_log_dir\n"; 
+
+    if (not -d $main::client_fai_log_dir) {
+        &main::daemon_log("$session_id ERROR: client fai log directory '$main::client_fai_log_dir' do not exist", 1); 
+        return;
+    }
+
+    # fetch mac directory
+    opendir(DIR, $main::client_fai_log_dir); 
+    my @avail_macs = readdir(DIR);
+    closedir(DIR);   
+    
+    foreach my $avail_mac (@avail_macs) {
+        if (not $avail_mac =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) { 
+            next; 
+        }
+
+        print STDERR "mac: $avail_mac\n"; 
+        # fetch date directory
+        my $mac_log_dir = File::Spec->catdir($main::client_fai_log_dir, $avail_mac);
+        opendir(DIR, $mac_log_dir); 
+        my @avail_dates = readdir(DIR);
+        closedir(DIR);
+        #print STDERR "\@avail_dates:".Dumper(@avail_dates); 
+    }
+
+    return;
+}
+
+
+sub get_log_by_date {}
+sub get_log_by_mac {}
+sub get_log_by_date_and_mac {}
+sub fetch_log {}
+
+sub get_recent_log_by_mac {
+
+}
+
+
+sub delete_log_by_date_and_mac {
+
+}
+
+1;
index 5b81853b0f5928c0e3a19ee0dc8ad6b5964f5f7c..e3d7a1d7dca78d8dfc274e4a4ea777b7dbf0f2a7 100755 (executable)
@@ -28,7 +28,7 @@ if($sock->connected()){
 #$data = "<xml> <header>gosa_gen_smb_hash</header> <source>GOSA</source><target>GOSA</target><password>tester</password></xml>";
 
 # Reload ldap config
-$data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target></xml>";
+#$data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target></xml>";
 
 # jobdb update  
 #$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase> <id>1</id></phrase></clause></where> <update><timestamp>19700101000000</timestamp></update></xml>";
@@ -63,21 +63,6 @@ $data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</so
 #$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
 
 
-# to test
-#    "trigger_reload_ldap_config",
-#    "network_completition",
-#    "trigger_action_localboot",
-#    "trigger_action_faireboot",
-#    "trigger_action_reboot",
-#    "trigger_action_halt",
-#    "trigger_action_update", 
-#    "trigger_action_reinstall",
-#    "trigger_action_memcheck", 
-#    "trigger_action_sysinfo",
-#    "trigger_action_instant_update",
-#    "trigger_action_rescan",
-#    "trigger_action_wake",
-
 # get_login_usr_for_client
 #$data = "<xml> <header>gosa_get_login_usr_for_client</header> <target>GOSA</target> <source>GOSA</source> <client>00:01:6c:9d:b9:fa</client></xml>";
 
@@ -93,6 +78,12 @@ $data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</so
 #$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <user>cajus.pollmeier</user> <message>kaffeepause</message> </xml>"; 
 
 
+################
+# logHandling.pm
+$data = "<xml> <header>gosa_show_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac> </xml>"; 
+
+
+
     $sock->write($data);
     $answer = "nothing";
        $answer = $sock->read();