Code

Updated locales
[gosa.git] / gosa-si / gosa-si-server
index 8e7f37918bb0331802da5a19d64f2114f7c1e6e5..81c0618e4a2f547bc6ce5d2ff5d9790bbfdf9e71 100755 (executable)
@@ -325,6 +325,8 @@ usage: $prg [-hvf] [-c config] [-d number]
                           32 : ldap connectivity
                           64 : database status and connectivity
                          128 : main process 
+                         256 : creation of packages_list_db
+                         512 : ARP debug information
 EOF
        exit(0);
 }
@@ -996,7 +998,7 @@ sub send_msg_to_target {
             if($new_status eq "down"){
                 daemon_log("$session_id WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
             } else {
-                daemon_log("$session_id INFO: set '$address' from status '$act_status' to '$new_status'", 5);
+                daemon_log("$session_id DEBUG: set '$address' from status '$act_status' to '$new_status'", 138);
             }
         }
     }
@@ -1017,7 +1019,7 @@ sub send_msg_to_target {
             if($new_status eq "down"){
                 daemon_log("$session_id WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
             } else {
-                daemon_log("$session_id INFO: set '$address' from status '$act_status' to '$new_status'", 5);
+                daemon_log("$session_id DEBUG: set '$address' from status '$act_status' to '$new_status'", 138);
             }
         }
     }
@@ -1054,8 +1056,17 @@ sub update_jobdb_status_for_send_msgs {
                     ||($job_header eq "trigger_action_reinstall") 
                     ||($job_header eq "trigger_activate_new")
                     ) {
-                &reactivate_job_with_delay($session_id, $job_target, $job_header, 30 );
-
+                                               if ($job_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i) {
+                                                       &reactivate_job_with_delay($session_id, $job_target, $job_header, 30 );
+                                               } else {
+                                                       # If we don't have the mac adress at this time, we use the plainname
+                                                       my $plainname_result = $job_db->select_dbentry("SELECT plainname from jobs where id=$jobdb_id");
+                                                       my $plainname = $job_target;
+                                                       if ((keys(%$plainname_result) > 0) ) {
+                                                               $plainname = $plainname_result->{1}->{$job_target};
+                                                       }
+                                                       &reactivate_job_with_delay($session_id, $plainname, $job_header, 30 );
+                                               }
             # For all other messages
             } else {
                 my $sql_statement = "UPDATE $job_queue_tn ".
@@ -1097,7 +1108,7 @@ sub reactivate_job_with_delay {
     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 LIKE 'target' AND headertag='$header')"; 
+    my $sql = "UPDATE $job_queue_tn Set timestamp='$delay_timestamp', status='waiting' WHERE (macaddress LIKE '$target' OR plainname LIKE '$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);
@@ -1140,7 +1151,15 @@ sub msg_to_decrypt {
        }
        # msg is from a gosa-si-client
        if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
-               ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $msg_source, $session_id);
+               if (not defined $msg_source) 
+               {
+                       # Only needed, to be compatible with older gosa-si-server versions
+                       ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $heap->{'remote_ip'}, $session_id);
+               }
+               else
+               {
+                       ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $msg_source, $session_id);
+               }
        }
        # an error occurred
        if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
@@ -1598,7 +1617,7 @@ sub process_task {
 
                 # Target of msg is a mac address
                 elsif( $answer_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) {
-                    daemon_log("$session_id INFO: target is mac address '$answer_target', looking for host in known_clients and foreign_clients", 5);
+                    daemon_log("$session_id DEBUG: target is mac address '$answer_target', looking for host in known_clients and foreign_clients", 138);
 
                     # Looking for macaddress in known_clients
                     my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$answer_target'";
@@ -1712,26 +1731,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);
@@ -3122,7 +3143,7 @@ sub parse_package_info {
     $repo_dirs{ "${repo_path}/pool" } = 1;
 
     foreach $package ("Packages.gz"){
-        daemon_log("$session_id DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
+        daemon_log("$session_id DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 266);
         get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section", $session_id );
         parse_package( "$outdir/$dist/$section", $dist, $path, $session_id );
     }
@@ -3140,9 +3161,9 @@ sub get_package {
     # This is ugly, but I've no time to take a look at "how it works in perl"
     if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
         system("gunzip -cd '$dest' > '$dest.in'");
-        daemon_log("$session_id DEBUG: run command: gunzip -cd '$dest' > '$dest.in'", 7);
+        daemon_log("$session_id DEBUG: run command: gunzip -cd '$dest' > '$dest.in'", 266);
         unlink($dest);
-        daemon_log("$session_id DEBUG: delete file '$dest'", 7); 
+        daemon_log("$session_id DEBUG: delete file '$dest'", 266); 
     } else {
         daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' into '$dest' failed!", 1);
     }
@@ -3249,7 +3270,7 @@ sub cleanup_and_extract {
 
                if( -f "$dir/DEBIAN/templates" ) {
 
-                       daemon_log("0 DEBUG: Found debconf templates in '$package' - $newver", 7);
+                       daemon_log("0 DEBUG: Found debconf templates in '$package' - $newver", 266);
 
                        my $tmpl= ""; {
                                local $/=undef;