Code

bugfix at trigger_action_faireboot: running install jobs in queue are deleted when...
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 14:34:23 +0000 (14:34 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 14:34:23 +0000 (14:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9359 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/server/events/gosaTriggered.pm

index 6aa63e244e4f862d33b1b216a0fb085cc2715c89..3dcb9daf3377905a42fea3704e3ec032ada5fc17 100755 (executable)
@@ -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();
 
index d16dd1bbba9e17ff8461ee9dc1ebf96e1ba076f8..55731c401ea4494ba639468b0c755cab3361635d 100644 (file)
@@ -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/<header>gosa_trigger_action_faireboot<\/header>/<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;
 }