Code

add job entries if missing while installation
[gosa.git] / gosa-si / modules / SIPackages.pm
index b06f3f2ef0f159201910f7c0ef5bbe2efcb7fb0b..7ee752072f553f6f864efb872c32985b4e4a3829 100644 (file)
@@ -16,7 +16,6 @@ use NetAddr::IP;
 use Net::LDAP;
 use Socket;
 use Net::hostent;
-use utf8;
 
 my $event_dir = "/usr/lib/gosa-si/server/events";
 use lib "/usr/lib/gosa-si/server/events";
@@ -414,7 +413,7 @@ sub process_incoming_msg {
             if ($header eq 'new_key') {
                 @out_msg_l = &new_key($msg_hash)
             } elsif ($header eq 'here_i_am') {
-                @out_msg_l = &here_i_am($msg_hash, $session_id)
+                @out_msg_l = &here_i_am($msg, $msg_hash, $session_id)
             } else {
                 if( exists $event_hash->{$header} ) {
                     # a event exists with the header as name
@@ -501,7 +500,7 @@ sub new_key {
 #  DESCRIPTION:  process this incoming message
 #===============================================================================
 sub here_i_am {
-    my ($msg_hash, $session_id) = @_;
+    my ($msg, $msg_hash, $session_id) = @_;
     my @out_msg_l;
     my $out_hash;
 
@@ -601,7 +600,7 @@ sub here_i_am {
             push(@out_msg_l, $new_ldap_config_out);
     }
 
-       my $hardware_config_out = &hardware_config($source, $gotoHardwareChecksum);
+       my $hardware_config_out = &hardware_config($msg, $msg_hash, $session_id);
        if( $hardware_config_out ) {
                push(@out_msg_l, $hardware_config_out);
        }
@@ -830,7 +829,10 @@ sub new_ldap_config {
 #  DESCRIPTION:  
 #===============================================================================
 sub hardware_config {
-       my ($address, $gotoHardwareChecksum) = @_ ;
+       my ($msg, $msg_hash, $session_id) = @_ ;
+       my $address = @{$msg_hash->{source}}[0];
+       my $header = @{$msg_hash->{header}}[0];
+       my $gotoHardwareChecksum = @{$msg_hash->{gotoHardwareChecksum}}[0];
 
        my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'";
        my $res = $main::known_clients_db->select_dbentry( $sql_statement );
@@ -840,7 +842,6 @@ sub hardware_config {
        if( not $hit_counter == 1 ) {
                &main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
        }
-
        my $macaddress = $res->{1}->{macaddress};
        my $hostkey = $res->{1}->{hostkey};
 
@@ -890,9 +891,23 @@ sub hardware_config {
                $data{'goto_secret'}= $goto_secret;
        }
 
-       &main::daemon_log("Send detect_hardware message to $address", 4);
+       # set status = hardware_detection at jobqueue if entry exists
+       my $func_dic = {table=>$main::job_queue_tn,
+               primkey=>['id'],
+               timestamp=>&get_time,
+               status=>'processing',
+               result=>'none',
+               progress=>'hardware-detection',
+               headertag=>$header,
+               targettag=>$address,
+               xmlmessage=>$msg,
+               macaddress=>$macaddress,
+       };
+       my $hd_res = $main::job_db->add_dbentry($func_dic);
+       &main::daemon_log("$session_id INFO: add '$macaddress' to job queue as an installing job", 5);
 
        # Send information
+       &main::daemon_log("$session_id INFO: Send detect_hardware message to $address", 5);
        return &build_msg("detect_hardware", $server_address, $address, \%data);
 }