From: rettenbe Date: Mon, 10 Nov 2008 16:21:24 +0000 (+0000) Subject: fixes problems with wake_up and reboot X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5acd9b56f209a516fba909d2a594635e580a1e48;p=gosa.git fixes problems with wake_up and reboot git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12990 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 84de9b733..3424cd828 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -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 =~ /(\d+)<\/jobdb_id>/ ) { my $jobdb_id = $1; $answer =~ /
(.*)<\/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 = "
gosa_ping
$server_address $host_name
"; 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/\S+<\/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); } } } diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index abd944807..978e0ce8d 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -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