summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 507331e)
raw | patch | inline | side by side (parent: 507331e)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Nov 2008 11:23:11 +0000 (11:23 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Nov 2008 11:23:11 +0000 (11:23 +0000) |
* setting update-job to state error after wol (booting vs. sending msgs race condition)
* importing jobs and activation problem
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12922 594d385d-05f5-0310-b6e9-bd551577e9d8
* importing jobs and activation problem
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12922 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/server/events/gosaTriggered.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index cc6b82f181a75a02cbbd95b5cabfe215801c9037..b09f02411f2e212c99f33ccbc20683d626a61ad7 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;
-
- # sending msg faild
+ $answer =~ /<header>(.*)<\/header>/;
+ my $job_header = $1;
+ $answer =~ /<target>(.*)<\/target>/;
+ my $job_target = $1;
+
+ # sending msg failed
if( $error ) {
- if (not $answer =~ /<header>trigger_action_reinstall<\/header>/) {
+
+ # 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 );
+
+ # 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);
+ &daemon_log("D \n$sql_statement\n$answer", 1);
+
}
# 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] ;
}
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
# update status in job queue to ...
# ... 'processing', for jobs: 'reinstall', 'update'
- if (($header =~ /gosa_trigger_action_reinstall/) || ($header =~ /gosa_trigger_action_update/)) {
+ if (($header =~ /gosa_trigger_action_reinstall/)
+ || ($header =~ /gosa_trigger_activate_new/)
+ || ($header =~ /gosa_trigger_action_update/)) {
my $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id=$jobdb_id";
my $dbres = $job_db->update_dbentry($sql_statement);
}
index 701a1d6f094ab2d4c64023421252fc2660cab01e..5046bd164762cf8f883352c56e074c02d2263917 100644 (file)
my $dhcp_statement= (defined($msg_hash->{'dhcp'}))?@{$msg_hash->{'dhcp'}}[0]:undef;
my $jobdb_id= (defined($msg_hash->{'jobdb_id'}))?@{$msg_hash->{'jobdb_id'}}[0]:undef;
+ # Sanity check for base
+ if (ref($base) eq "HASH") {
+ # Incoming msg has a xml tag 'base' but no content
+ $base = undef;
+ }
+
+ # In case that the client is sleeping, wake it up
+ my %data = ( 'macaddress' => $mac );
+ my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
+ &main::server_server_com::trigger_wake($msg, $msg_hash, $session_id);
+ my $sql_statement= "SELECT * FROM $main::known_server_tn";
+ my $query_res = $main::known_server_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $host_name = $hit->{hostname};
+ my $host_key = $hit->{hostkey};
+ $wake_msg =~ s/<target>\S+<\/target>/<target>$host_name<\/target>/g;
+ my $error = &main::send_msg_to_target($wake_msg, $host_name, $host_key, $header, $session_id);
+ }
+
my $ldap_handle = &main::get_ldap_handle();
my $ldap_entry;
my $ogroup_entry;
} elsif ($ldap_mesg->count == 0) {
&main::daemon_log("$session_id WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
- $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
- $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(60)."' WHERE id = $jobdb_id");
+ my $sql_statement = "UPDATE ".$main::job_queue_tn.
+ " SET status='waiting', timestamp = '".(&calc_timestamp(&get_time(), 'plus', 60))."' ".
+ " WHERE id = $jobdb_id";
+ $main::job_db->exec_statement($sql_statement);
return undef;
}