summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3b7034)
raw | patch | inline | side by side (parent: f3b7034)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 4 Nov 2008 14:57:54 +0000 (14:57 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 4 Nov 2008 14:57:54 +0000 (14:57 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12897 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 11c142f85564dc4c27537fc00f4f721afb3ef8fd..f5191fbda5267e9ee31781f42579c5f970ea45df 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
sub update_jobdb_status_for_send_msgs {
- my ($answer, $error) = @_;
+ my ($session_id, $answer, $error) = @_;
if( $answer =~ /<jobdb_id>(\d+)<\/jobdb_id>/ ) {
my $jobdb_id = $1;
+
+ $answer =~ /<header>(.*)<\/header>/;
+ my $job_header = $1;
+
+ $answer =~ /<target>(.*)<\/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 =~ /<header>trigger_action_reinstall<\/header>/) || (not $answer =~ /<header>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] ;
# 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