From 3040642fd0b7d6f3906de62d23967567151d7c93 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 4 Nov 2008 14:57:54 +0000 Subject: [PATCH] test upload git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12897 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 75 +++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 11c142f85..f5191fbda 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -1004,32 +1004,82 @@ sub send_msg_to_target { sub update_jobdb_status_for_send_msgs { - my ($answer, $error) = @_; + my ($session_id, $answer, $error) = @_; if( $answer =~ /(\d+)<\/jobdb_id>/ ) { my $jobdb_id = $1; + + $answer =~ /
(.*)<\/header>/; + my $job_header = $1; + + $answer =~ /(.*)<\/target>/; + my $job_target = $1; - # sending msg faild + # sending msg failed if( $error ) { -daemon_log("D \n$error\n$answer"); + # JUST FOR TESTING + daemon_log("D \n$error\n$answer"); + + # set jobs to done, jobs do not need to deliver their message in any case + if (($job_header eq "trigger_action_localboot") + ||($job_header eq "trigger_action_lock") + ||($job_header eq "trigger_action_halt") + ) { + my $sql_statement = "UPDATE $job_queue_tn SET status='done' WHERE id=$jobdb_id"; + 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") + ) { + &reactivate_job_with_delay($session_id, $job_target, $job_header, 30 ); - if ((not $answer =~ /
trigger_action_reinstall<\/header>/) || (not $answer =~ /
trigger_action_update<\/header>/)) { + # for all other messages + } else { my $sql_statement = "UPDATE $job_queue_tn ". "SET status='error', result='can not deliver msg, please consult log file' ". "WHERE id=$jobdb_id"; my $res = $job_db->update_dbentry($sql_statement); + } # sending msg was successful } else { - 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); + # set jobs localboot, lock, activate, halt, reboot and wake to done + # jobs reinstall, update, inst_update do themself setting to done + if (($job_header eq "trigger_action_localboot") + ||($job_header eq "trigger_action_lock") + ||($job_header eq "trigger_action_activate") + ||($job_header eq "trigger_action_halt") + ||($job_header eq "trigger_action_reboot") + ||($job_header eq "trigger_action_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); + } } } } +sub reactivate_job_with_delay { + my ($session_id, $target, $header, $delay) = @_ ; + # Sometimes the client is still booting or does not wake up, in this case reactivate the job (if it exists) with a delay of n sec + + if (not defined $delay) { $delay = 30 } ; + my $delay_timestamp = &calc_timestamp(&get_time(), "plus", $delay); + + my $sql = "UPDATE $job_queue_tn Set timestamp='$delay_timestamp', status='waiting' WHERE (macaddress='$target' AND headertag='$header')"; + my $res = $job_db->update_dbentry($sql); + daemon_log("$session_id INFO: '$header'-job will be reactivated at '$delay_timestamp' ". + "cause client '$target' is currently not available", 5); + daemon_log("$session_id $sql", 7); + return; +} + sub sig_handler { my ($kernel, $signal) = @_[KERNEL, ARG0] ; @@ -1509,14 +1559,7 @@ sub process_task { # No mac to ip matching found if( $found_ip_flag == 0) { daemon_log("$session_id WARNING: no host found in known_clients or foreign_clients with mac address '$answer_target'", 3); - - # Sometimes the client is still booting or does not wake up, in this case reactivate the job (if it exists) with a delay of 30 sec - my $delay_timestamp = &calc_timestamp(&get_time(), "plus", 30); - my $sql = "UPDATE $job_queue_tn Set timestamp='$delay_timestamp', status='waiting' WHERE (macaddress='$answer_target' AND headertag='$answer_header')"; - my $res = $job_db->update_dbentry($sql); - daemon_log("$session_id INFO: '$answer_header'-job will be reactivated at '$delay_timestamp' ". - "cause client '$answer_target' is currently not available", 5); - daemon_log("$session_id $sql", 7); + &reactivate_job_with_delay($session_id, $answer_target, $answer_header, 30); } # Answer is for one specific host -- 2.30.2