From: rettenbe Date: Mon, 29 Jun 2009 11:13:16 +0000 (+0000) Subject: new funktionality: periodical jobs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d3ac8452abb9d7dfa0f46bbfd690bffb56773e27;p=gosa.git new funktionality: periodical jobs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13817 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 8e7f37918..46d9fbbf2 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -1712,26 +1712,28 @@ sub watch_for_done_jobs { while( my ($number, $hit) = each %{$res} ) { + # Non periodical jobs can be deleted. + if ($hit->{periodic} eq "none") + { + my $jobdb_id = $hit->{id}; + my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; + my $res = $job_db->del_dbentry($sql_statement); + } + # Periodical jobs should not be deleted but reactivated with new timestamp instead. - if (exists $check_periodic->{$hit->{periodic}}) + else { + my ($p_time, $periodic) = split("_", $hit->{periodic}); my $reactivated_ts = $hit->{timestamp}; my $act_ts = int(&get_time()); while ($act_ts > int($reactivated_ts)) # Redo calculation to avoid multiple jobs in the past { - $reactivated_ts = &calc_timestamp($reactivated_ts, "plus", 1, $hit->{periodic}); + $reactivated_ts = &calc_timestamp($reactivated_ts, "plus", $p_time, $periodic); } my $sql = "UPDATE $job_queue_tn SET status='waiting', timestamp='$reactivated_ts' WHERE id='".$hit->{id}."'"; my $res = $job_db->exec_statement($sql); &daemon_log("J INFO: Update periodical job '".$hit->{headertag}."' for client '".$hit->{targettag}."'. New execution time '$reactivated_ts'.", 5); } - # Non periodical jobs can be deleted. - else - { - my $jobdb_id = $hit->{id}; - my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; - my $res = $job_db->del_dbentry($sql_statement); - } } $kernel->delay_set('watch_for_done_jobs',$job_queue_loop_delay); diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 88b291008..60ee896db 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -280,6 +280,7 @@ sub process_job_msg { # Check if it is a periodical job my $periodic = 'none'; + my $periodic_time = 1; if (exists $msg_hash->{periodic}) { $periodic = $msg_hash->{periodic}[0]; @@ -299,6 +300,34 @@ sub process_job_msg { ""; return ($out_msg); } + + if (exists $msg_hash->{$periodic}) # Check periodical time tag and set value + { + if (ref $msg_hash->{$periodic}[0] eq "HASH") # Periodical time tag is empty + { + &main::daemon_log("$session_id ERROR: Message contains no content of periodical time tag.". + " Please use an integer for this tag (i. e.: hours5)", 1); + $out_msg = "". + "
answer
$main::server_addressGOSA". + "1Message contains no content of periodic time tag". + "
"; + return ($out_msg); + + } + + if (not $msg_hash->{$periodic}[0] =~ /[1-9]+\d*/) # Periodical time tag is not an INT > 0 + { + &main::daemon_log("$session_id ERROR: Message contains invalid periodical time tag '$msg_hash->{$periodic}[0]'.". + " Please use an integer for this tag (i. e.: hours5)", 1); + $out_msg = "". + "
answer
$main::server_addressGOSA". + "1Message contains invalid periodic time tag '$msg_hash->{$periodic}[0]'". + "
"; + return ($out_msg); + } + + $periodic_time = $msg_hash->{$periodic}[0]; + } } # Add job to job queue @@ -316,7 +345,7 @@ sub process_job_msg { plainname=>$plain_name, siserver=>"localhost", modified=>"1", - periodic=>$periodic, + periodic=>$periodic_time."_".$periodic, }; my $res = $main::job_db->add_dbentry($func_dic); if (not $res == 0) { diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index cad44ef30..9b9bdcfe2 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -19,7 +19,7 @@ for($count = 1; $count <= $zahl; $count++) ############################## # periodical jobs $data = "
job_trigger_action_reboot
GOSA00:0c:29:4c:4b:0c00:0c:29:4c:4b:0c20090622000000minutes
"; - + $data = "
job_trigger_action_reboot
GOSA00:0c:29:4c:4b:0c2009062613500000:0c:29:4c:4b:0cminutes5
"; /* Prepare a hunge bunch of data to be send */ # jobdb add #$data = "
gosa_network_completition
GOSAGOSAws-muc-2
";