Code

Ignore test TASKBEGIN messages
[gosa.git] / trunk / gosa-si / server / events / clMessages.pm
index 0d3344db5034c95c7fadfd4ec247595c2c1e1073..9960a59d3155e1576d9d9c9a725335a913e8e989 100644 (file)
@@ -72,6 +72,7 @@ sub save_fai_log {
     my $header = @{$msg_hash->{'header'}}[0];
     my $source = @{$msg_hash->{'source'}}[0];
     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
+    my $fai_action = @{$msg_hash->{'fai_action'}}[0];
     my $all_logs = @{$msg_hash->{$header}}[0];
 
     # if there is nothing to log
@@ -92,7 +93,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, $fai_action ."_".$time );
     mkdir($client_fai_log_dir, 0755);
 
     my @all_logs = split(/log_file:/, $all_logs); 
@@ -101,9 +102,11 @@ sub save_fai_log {
         my ($log_file, $log_string) = split(":", $log);
         my $client_fai_log_file = File::Spec->catfile( $client_fai_log_dir, $log_file);
 
-       open(my $LOG_FILE, ">$client_fai_log_file"); 
+               open(my $LOG_FILE, ">$client_fai_log_file"); 
         print $LOG_FILE &decode_base64($log_string);
         close($LOG_FILE);
+               chown($main::root_uid, $main::adm_gid, $client_fai_log_file);
+        chmod(0440, $client_fai_log_file);
 
     }
     return;
@@ -123,7 +126,7 @@ sub LOGIN {
     my $error_str;
 
     # Invoke set_last_system; message sets ldap attributes 'gotoLastSystemLogin' and 'gotoLastSystem'
-       $res = &set_last_system($msg, $msg_hash, $session_id);
+#    &set_last_system($msg, $msg_hash, $session_id);
 
     # Add user to login_users_db
     my %add_hash = ( table=>$main::login_users_tn, 
@@ -184,7 +187,7 @@ sub CURRENTLY_LOGGED_IN {
     }
 
     # Invoke set_last_system; message sets ldap attributes 'gotoLastSystemLogin' and 'gotoLastSystem'
-       my $res = &set_last_system($msg, $msg_hash, $session_id);
+#    &set_last_system($msg, $msg_hash, $session_id);
     
     # fetch all user currently assigned to the client at login_users_db
     my %currently_logged_in_user = (); 
@@ -503,7 +506,7 @@ sub TASKSKIP {
 
 
 ## @method TASKBEGIN()
-# @details Message reports a starting FAI task. If the task is equal to 'finish', 'faiend' or 'savelog', job at job_queue_db is being set to status 'done' and FAI state is being set to 'localboot'. If task is equal to 'chboot', 'test' or 'confdir', just do nothing. In all other cases, job at job_queue_db is going to be updated or created if not exists. 
+# @details Message reports a starting FAI task. If the task is equal to 'finish', 'faiend' or 'savelog', job at job_queue_db is being set to status 'done' and FAI state is being set to 'localboot'. If task is equal to 'chboot', 'tests' or 'confdir', just do nothing. In all other cases, job at job_queue_db is going to be updated or created if not exists. 
 # @param msg - STRING - xml message with tag 'macaddress'.
 # @param msg_hash - HASHREF - message information parsed into a hash
 # @param session_id - INTEGER - POE session id of the processing of this message
@@ -538,7 +541,7 @@ sub TASKBEGIN {
 
        # TASKBEGIN eq chboot
        } elsif (($content eq 'chboot')
-               || ($content eq 'test')
+               || ($content eq 'tests')
                || ($content eq 'confdir')
                ) {
                # just ignor this client message
@@ -546,6 +549,15 @@ sub TASKBEGIN {
 
        # other TASKBEGIN msgs
     } else {
+               
+               # TASKBEGIN msgs do only occour during a softupdate or a reinstallation 
+               # of a host. Set all waiting update- or reinstall-jobs for host to 
+               # processing so they can be handled correctly by the rest of the function. 
+               &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
+               my $waiting_sql = "UPDATE $main::job_queue_tn SET status='processing' WHERE status='waiting' AND macaddress LIKE '$macaddress' AND (headertag='trigger_action_update' OR headertag='trigger_action_reinstall')";  
+               &main::daemon_log("$session_id DEBUB: $waiting_sql", 7); 
+               my $waiting_res = $main::job_db->update_dbentry($waiting_sql); 
+
                # select processing jobs for host
                my $sql_statement = "SELECT * FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
                &main::daemon_log("$session_id DEBUG: $sql_statement", 7);