Code

fixes problems with wake_up and reboot
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 Nov 2008 16:21:24 +0000 (16:21 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 Nov 2008 16:21:24 +0000 (16:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12990 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/server/events/gosaTriggered.pm

index 84de9b7330930296a7f250706784bea817939e41..3424cd828a03a8bdf14a5437d832ecffc58b8d70 100755 (executable)
@@ -980,6 +980,7 @@ sub send_msg_to_target {
 
 sub update_jobdb_status_for_send_msgs {
     my ($session_id, $answer, $error) = @_;
+    &daemon_log("$session_id DEBUG: try to update job status", 7);
     if( $answer =~ /<jobdb_id>(\d+)<\/jobdb_id>/ ) {
         my $jobdb_id = $1;
         $answer =~ /<header>(.*)<\/header>/; 
@@ -996,12 +997,14 @@ sub update_jobdb_status_for_send_msgs {
                     ||($job_header eq "trigger_action_halt")
                     ) {
                 my $sql_statement = "UPDATE $job_queue_tn SET status='done' WHERE id=$jobdb_id";
+               &daemon_log("$session_id DEBUG: $sql_statement", 7);
                 my $res = $job_db->update_dbentry($sql_statement);
 
             # reactivate jobs, jobs need to deliver their message
             } elsif (($job_header eq "trigger_action_activate")
                     ||($job_header eq "trigger_action_update")
                     ||($job_header eq "trigger_action_reinstall")
+                   ||($job_header eq "trigger_activate_new")
                     ) {
                 &reactivate_job_with_delay($session_id, $job_target, $job_header, 30 );
 
@@ -1011,8 +1014,7 @@ sub update_jobdb_status_for_send_msgs {
                     "SET status='error', result='can not deliver msg, please consult log file' ".
                     "WHERE id=$jobdb_id";
                 my $res = $job_db->update_dbentry($sql_statement);
-                &daemon_log("D \n$sql_statement\n$answer", 1);
-
+               &daemon_log("$session_id DEBUG: $sql_statement", 7);
             }
 
         # sending msg was successful
@@ -1025,14 +1027,20 @@ sub update_jobdb_status_for_send_msgs {
                     ||($job_header eq "trigger_action_halt")
                     ||($job_header eq "trigger_action_reboot")
                     ||($job_header eq "trigger_action_wake")
+                   ||($job_header eq "trigger_wake")
                     ) {
 
                 my $sql_statement = "UPDATE $job_queue_tn ".
                     "SET status='done' ".
                     "WHERE id=$jobdb_id AND status='processed'";
                 my $res = $job_db->update_dbentry($sql_statement);
-            }
+               &daemon_log("$session_id DEBUG: $sql_statement", 7);
+            } else {
+               &daemon_log("$session_id WARNING: sending message succeed but cannot update job status.", 3);
+           }
         }
+    } else {
+          &daemon_log("$session_id ERROR: cannot update job status, msg has no jobdb_id-tag: $answer", 1);
     }
 }
 
@@ -1094,7 +1102,7 @@ sub msg_to_decrypt {
             my $host_key = $hit->{'hostkey'};
             my $ping_msg = "<xml> <header>gosa_ping</header> <source>$server_address</source> <target>$host_name</target></xml>";
             my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping", $session_id);
-            &update_jobdb_status_for_send_msgs($ping_msg, $error);
+            &update_jobdb_status_for_send_msgs($session_id, $ping_msg, $error);
         }
         $error++;
     }
@@ -1437,7 +1445,7 @@ sub process_task {
                         my $host_name = $hit->{hostname};
                         my $host_key = $hit->{hostkey};
                         my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
-                        &update_jobdb_status_for_send_msgs($answer, $error);
+                        &update_jobdb_status_for_send_msgs($session_id, $answer, $error);
                     }
                 }
 
@@ -1451,7 +1459,7 @@ sub process_task {
                         my $host_key = $hit->{hostkey};
                         $answer =~ s/<target>\S+<\/target>/<target>$host_name<\/target>/g;
                         my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
-                        &update_jobdb_status_for_send_msgs($answer, $error);
+                        &update_jobdb_status_for_send_msgs($session_id, $answer, $error);
                     }
                 }
 
@@ -1473,7 +1481,7 @@ sub process_task {
                     my $header;
                     if( defined $1 ) { $header = $1; }
                     my $error = &send_msg_to_target($answer, $server_address, $GosaPackages_key, $header, $session_id);
-                    &update_jobdb_status_for_send_msgs($answer, $error);
+                    &update_jobdb_status_for_send_msgs($session_id, $answer, $error);
                 }
 
                 # Target of msg is a mac address
@@ -1488,7 +1496,7 @@ sub process_task {
                         $answer =~ s/$answer_target/$host_name/g;
                         daemon_log("$session_id INFO: found host '$host_name', associated to '$answer_target'", 5);
                         my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
-                        &update_jobdb_status_for_send_msgs($answer, $error);
+                        &update_jobdb_status_for_send_msgs($session_id, $answer, $error);
                         $found_ip_flag++ ;
                     }   
                     if ($found_ip_flag == 0) {
@@ -1515,7 +1523,7 @@ sub process_task {
                             if (defined $reg_server_key) {
                                 $answer =~ s/$answer_target/$host_name/g;
                                 my $error = &send_msg_to_target($answer, $reg_server, $reg_server_key, $answer_header, $session_id);
-                                &update_jobdb_status_for_send_msgs($answer, $error);
+                                &update_jobdb_status_for_send_msgs($session_id, $answer, $error);
                                 $found_ip_flag++ ;
                             }
                         }
@@ -1535,7 +1543,7 @@ sub process_task {
                         next;
                     }
                     my $error = &send_msg_to_target($answer, $answer_target, $encrypt_key, $answer_header,$session_id);
-                    &update_jobdb_status_for_send_msgs($answer, $error);
+                    &update_jobdb_status_for_send_msgs($session_id,$answer, $error);
                 }
             }
         }
index abd9448075cd1006eb4d712720a03ff3de5268bd..978e0ce8d56e3c56d07e4e5dcc16920ee3d6ad5c 100644 (file)
@@ -746,6 +746,10 @@ sub trigger_action_wake {
     foreach (@{$msg_hash->{macaddress}}) {
         &add_content2xml_hash($out_hash, 'macaddress', $_);
     }
+    if( defined $jobdb_id) {
+        &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
+    }
+
     my $out_msg = &create_xml_string($out_hash);
     
     # invoke trigger wake for this gosa-si-server