From 5d261928ec2cc66bb3bdac22074ee2f6b0ae760b Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 5 Mar 2008 14:34:23 +0000 Subject: [PATCH] bugfix at trigger_action_faireboot: running install jobs in queue are deleted when faireboot git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9359 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 16 ++++++++++++++-- gosa-si/server/events/gosaTriggered.pm | 12 +++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 6aa63e244..3dcb9daf3 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -122,11 +122,10 @@ my $login_users_file_name; my @login_users_col_names = ('client', 'user', 'timestamp'); # holds all fai server, the debian release and tag -my $fai_server_file_name; our $fai_server_db; our $fai_server_tn = "fai_server"; +my $fai_server_file_name; our @fai_server_col_names = ('timestamp', 'server', 'release', 'tag'); -our $fai_release_db; our $fai_release_tn = "fai_release"; our @fai_release_col_names = ('timestamp', 'release', 'class'); @@ -138,6 +137,12 @@ our @packages_list_col_names = ('distribution', 'package', 'version', 'section', my $outdir = "/tmp/packages_list_db"; my $arch = "i386"; +# holds all messages which should be delivered to a user +our $messaging_db; +our $messaging_tn = "messaging"; +our @messaging_col_names = ('subject', 'from', 'to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER', ); +my $messaging_file_name; + %cfg_defaults = ( "general" => { "log-file" => [\$log_file, "/var/run/".$prg.".log"], @@ -153,6 +158,7 @@ my $arch = "i386"; "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'], "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai.db'], "packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'], + "messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'], "source-list" => [\$sources_list, '/etc/apt/sources.list'], "ldap-uri" => [\$ldap_uri, ""], "ldap-base" => [\$ldap_base, ""], @@ -1152,6 +1158,7 @@ sub watch_for_new_jobs { my $jobdb_id = $hit->{id}; my $macaddress = $hit->{'macaddress'}; my $job_msg = $hit->{'xmlmessage'}; + daemon_log("DEBUG: its time to execute $job_msg", 7); my $header = $hit->{'headertag'}; my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$macaddress'"; my $res_hash = $known_clients_db->select_dbentry( $sql_statement ); @@ -1518,6 +1525,11 @@ unlink($packages_list_file_name); $packages_list_db = GOSA::DBsqlite->new($packages_list_file_name); $packages_list_db->create_table($packages_list_tn, \@packages_list_col_names); +# connect to messaging_db +$messaging_db = GOSA::DBsqlite->new($messaging_file_name); +$messaging_db->create_table($messaging_tn, \@messaging_col_names); + + # create xml object used for en/decrypting $xml = new XML::Simple(); diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index d16dd1bbb..55731c401 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -290,8 +290,18 @@ sub set_activated_for_installation { sub trigger_action_faireboot { my ($msg, $msg_hash) = @_; + my $macaddress = @{$msg_hash->{target}}[0]; + my $source = @{$msg_hash->{source}}[0]; + + my @out_msg_l; $msg =~ s/
gosa_trigger_action_faireboot<\/header>/
trigger_action_faireboot<\/header>/; - my @out_msg_l = ($msg); + push(@out_msg_l, $msg); + + # delete all jobs from jobqueue which correspond to fai + my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ". + "status='processing' AND headertag='trigger_action_install')"; + $main::job_db->del_dbentry($sql_statement ); + return @out_msg_l; } -- 2.30.2