bb4828eea566963e833bacfcb49c4807b394bbb6
1 package gosaTriggered;
2 use Exporter;
3 @ISA = qw(Exporter);
4 my @events = (
5 "get_events",
6 "get_login_usr_for_client",
7 "get_client_for_login_usr",
8 "gen_smb_hash",
9 "trigger_reload_ldap_config",
10 "ping",
11 "network_completition",
12 "set_activated_for_installation",
13 "new_key_for_client",
14 "detect_hardware",
15 "get_login_usr",
16 "get_login_client",
17 "trigger_action_localboot",
18 "trigger_action_faireboot",
19 "trigger_action_reboot",
20 "trigger_action_activate",
21 "trigger_action_lock",
22 "trigger_action_halt",
23 "trigger_action_update",
24 "trigger_action_reinstall",
25 "trigger_action_memcheck",
26 "trigger_action_sysinfo",
27 "trigger_action_instant_update",
28 "trigger_action_rescan",
29 "trigger_action_wake",
30 "recreate_fai_server_db",
31 "recreate_fai_release_db",
32 "send_user_msg",
33 "get_available_kernel",
34 );
35 @EXPORT = @events;
37 use strict;
38 use warnings;
39 use GOSA::GosaSupportDaemon;
40 use Data::Dumper;
41 use Crypt::SmbHash;
42 use Net::ARP;
43 use Net::Ping;
44 use Socket;
46 BEGIN {}
48 END {}
50 ### Start ######################################################################
52 #&main::read_configfile($main::cfg_file, %cfg_defaults);
54 sub get_events {
55 return \@events;
56 }
58 sub send_user_msg {
59 my ($msg, $msg_hash, $session_id) = @_ ;
60 my $header = @{$msg_hash->{'header'}}[0];
61 my $source = @{$msg_hash->{'source'}}[0];
62 my $target = @{$msg_hash->{'target'}}[0];
64 #my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
65 my $subject = @{$msg_hash->{'subject'}}[0];
66 my $from = @{$msg_hash->{'from'}}[0];
67 my $to = @{$msg_hash->{'to'}}[0];
68 my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
69 #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
70 my $message = @{$msg_hash->{'message'}}[0];
72 # keep job queue uptodate if necessary
73 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
74 if( defined $jobdb_id) {
75 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
76 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
77 my $res = $main::job_db->exec_statement($sql_statement);
78 }
80 # error handling
81 if (not $delivery_time =~ /^\d{14}$/) {
82 my $error_string = "delivery_time '$delivery_time' is not a valid timestamp, please use format 'yyyymmddhhmmss'";
83 &main::daemon_log("$session_id ERROR: $error_string", 1);
84 return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
85 }
87 # add incoming message to messaging_db
88 my $new_msg_id = 1;
89 my $new_msg_id_sql = "SELECT MAX(id) FROM $main::messaging_tn";
90 my $new_msg_id_res = $main::messaging_db->exec_statement($new_msg_id_sql);
91 if (defined @{@{$new_msg_id_res}[0]}[0] ) {
92 $new_msg_id = int(@{@{$new_msg_id_res}[0]}[0]);
93 $new_msg_id += 1;
94 }
96 my $func_dic = {table=>$main::messaging_tn,
97 primkey=>[],
98 id=>$new_msg_id,
99 subject=>$subject,
100 message_from=>$from,
101 message_to=>$to,
102 flag=>"n",
103 direction=>"in",
104 delivery_time=>$delivery_time,
105 message=>$message,
106 timestamp=>&get_time(),
107 };
108 my $res = $main::messaging_db->add_dbentry($func_dic);
109 if (not $res == 0) {
110 &main::daemon_log("$session_id ERROR: gosaTriggered.pm: cannot add message to message_db: $res", 1);
111 } else {
112 &main::daemon_log("$session_id INFO: gosaTriggered.pm: message with subject '$subject' successfully added to message_db", 5);
113 }
115 return;
116 }
118 sub send_user_msg_OLD {
119 my ($msg, $msg_hash, $session_id) = @_ ;
120 my @out_msg_l;
121 my @user_list;
122 my @group_list;
124 my $header = @{$msg_hash->{'header'}}[0];
125 my $source = @{$msg_hash->{'source'}}[0];
126 my $target = @{$msg_hash->{'target'}}[0];
127 my $message = @{$msg_hash->{'message'}}[0];
128 if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
129 if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
131 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
132 if( defined $jobdb_id) {
133 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
134 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
135 my $res = $main::job_db->exec_statement($sql_statement);
136 }
138 # error handling
139 if( not @user_list && not @group_list ) {
140 &main::daemon_log("$session_id WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3);
141 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
142 "<error_string>no user-tag or a group-tag specified in 'send_user_msg'</error_string></xml>");
143 }
144 if( not defined $message ) {
145 &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3);
146 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
147 "<error_string>no message-tag specified in 'send_user_msg'</error_string></xml>");
149 }
151 # resolve groups to users
152 my $ldap_handle = &main::get_ldap_handle($session_id);
153 if( @group_list ) {
154 if( not defined $ldap_handle ) {
155 &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
156 return ();
157 }
158 foreach my $group (@group_list) { # Perform search
159 my $mesg = $ldap_handle->search(
160 base => $main::ldap_base,
161 scope => 'sub',
162 attrs => ['memberUid'],
163 filter => "(&(objectClass=posixGroup)(cn=$group)(memberUid=*))");
164 if($mesg->code) {
165 &main::daemon_log($mesg->error, 1);
166 return ();
167 }
168 my $entry= $mesg->entry(0);
169 my @users= $entry->get_value("memberUid");
170 foreach my $user (@users) { push(@user_list, $user); }
171 }
172 }
174 # drop multiple users in @user_list
175 my %seen = ();
176 foreach my $user (@user_list) {
177 $seen{$user}++;
178 }
179 @user_list = keys %seen;
181 # build xml messages sended to client where user is logged in
182 foreach my $user (@user_list) {
183 my $sql_statement = "SELECT * FROM $main::login_users_tn WHERE user='$user'";
184 my $db_res = $main::login_users_db->select_dbentry($sql_statement);
186 if(0 == keys(%{$db_res})) {
188 } else {
189 while( my($hit, $content) = each %{$db_res} ) {
190 my $out_hash = &create_xml_hash('send_user_msg', $main::server_address, $content->{'client'});
191 &add_content2xml_hash($out_hash, 'message', $message);
192 &add_content2xml_hash($out_hash, 'user', $user);
193 if( exists $msg_hash->{'jobdb_id'} ) {
194 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
195 }
196 my $out_msg = &create_xml_string($out_hash);
197 push(@out_msg_l, $out_msg);
198 }
199 }
200 }
202 return @out_msg_l;
203 }
206 sub recreate_fai_server_db {
207 my ($msg, $msg_hash, $session_id) = @_ ;
208 my $out_msg;
210 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
211 if( defined $jobdb_id) {
212 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
213 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
214 my $res = $main::job_db->exec_statement($sql_statement);
215 }
217 $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names);
218 &main::create_fai_server_db("new_fai_server",undef,"dont", $session_id);
219 $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn);
221 my @out_msg_l = ( $out_msg );
222 return @out_msg_l;
223 }
226 sub recreate_fai_release_db {
227 my ($msg, $msg_hash, $session_id) = @_ ;
228 my $out_msg;
230 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
231 if( defined $jobdb_id) {
232 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
233 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
234 my $res = $main::job_db->exec_statement($sql_statement);
235 }
237 $main::fai_release_db->create_table("new_fai_release", \@main::fai_release_col_names);
238 &main::create_fai_release_db("new_fai_release", $session_id);
239 $main::fai_release_db->move_table("new_fai_release", $main::fai_release_tn);
241 my @out_msg_l = ( $out_msg );
242 return @out_msg_l;
243 }
246 sub get_login_usr_for_client {
247 my ($msg, $msg_hash, $session_id) = @_ ;
248 my $header = @{$msg_hash->{'header'}}[0];
249 my $source = @{$msg_hash->{'source'}}[0];
250 my $target = @{$msg_hash->{'target'}}[0];
251 my $client = @{$msg_hash->{'client'}}[0];
253 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
254 if( defined $jobdb_id) {
255 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
256 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
257 my $res = $main::job_db->exec_statement($sql_statement);
258 }
260 $header =~ s/^gosa_//;
262 my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress LIKE '$client'";
263 my $res = $main::known_clients_db->select_dbentry($sql_statement);
265 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
266 $out_msg .= &db_res2xml($res);
267 $out_msg .= "</xml>";
269 my @out_msg_l = ( $out_msg );
270 return @out_msg_l;
271 }
274 sub get_client_for_login_usr {
275 my ($msg, $msg_hash, $session_id) = @_ ;
276 my $header = @{$msg_hash->{'header'}}[0];
277 my $source = @{$msg_hash->{'source'}}[0];
278 my $target = @{$msg_hash->{'target'}}[0];
280 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
281 if( defined $jobdb_id) {
282 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
283 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
284 my $res = $main::job_db->exec_statement($sql_statement);
285 }
287 my $usr = @{$msg_hash->{'usr'}}[0];
288 $header =~ s/^gosa_//;
290 my $sql_statement = "SELECT * FROM known_clients WHERE login LIKE '%$usr%'";
291 my $res = $main::known_clients_db->select_dbentry($sql_statement);
293 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
294 $out_msg .= &db_res2xml($res);
295 $out_msg .= "</xml>";
296 my @out_msg_l = ( $out_msg );
297 return @out_msg_l;
299 }
302 sub ping {
303 my ($msg, $msg_hash, $session_id) = @_ ;
304 my $out_msg = $msg;
305 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
306 if( defined $jobdb_id) {
307 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
308 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
309 my $res = $main::job_db->exec_statement($sql_statement);
310 }
312 $out_msg =~ s/<header>gosa_/<header>/;
314 my @out_msg_l = ( $out_msg );
315 return @out_msg_l;
316 }
318 sub gen_smb_hash {
319 my ($msg, $msg_hash, $session_id) = @_ ;
320 my $source = @{$msg_hash->{source}}[0];
321 my $target = @{$msg_hash->{target}}[0];
322 my $password = @{$msg_hash->{password}}[0];
324 my %data= ('hash' => join(q[:], ntlmgen $password));
325 my $out_msg = &build_msg("gen_smb_hash", $target, 'GOSA', \%data );
326 return ( $out_msg );
327 }
330 sub network_completition {
331 my ($msg, $msg_hash, $session_id) = @_ ;
332 my $source = @{$msg_hash->{source}}[0];
333 my $target = @{$msg_hash->{target}}[0];
334 my $name = @{$msg_hash->{hostname}}[0];
336 # Can we resolv the name?
337 my %data;
338 if (inet_aton($name)){
339 my $address = inet_ntoa(inet_aton($name));
340 my $p = Net::Ping->new('tcp');
341 my $mac= "";
342 if ($p->ping($address, 1)){
343 $mac = Net::ARP::arp_lookup("", $address);
344 }
346 %data= ('ip' => $address, 'mac' => $mac);
347 } else {
348 %data= ('ip' => '', 'mac' => '');
349 }
351 my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data );
353 return ( $out_msg );
354 }
357 sub detect_hardware {
358 my ($msg, $msg_hash, $session_id) = @_ ;
359 # just forward msg to client, but dont forget to split off 'gosa_' in header
360 my $source = @{$msg_hash->{source}}[0];
361 my $target = @{$msg_hash->{target}}[0];
362 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
363 if( defined $jobdb_id) {
364 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
365 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
366 my $res = $main::job_db->exec_statement($sql_statement);
367 }
369 my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
370 if( defined $jobdb_id ) {
371 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
372 }
373 my $out_msg = &create_xml_string($out_hash);
375 my @out_msg_l = ( $out_msg );
376 return @out_msg_l;
378 }
381 sub trigger_reload_ldap_config {
382 my ($msg, $msg_hash, $session_id) = @_ ;
383 my $target = @{$msg_hash->{target}}[0];
385 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
386 if( defined $jobdb_id) {
387 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
388 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
389 my $res = $main::job_db->exec_statement($sql_statement);
390 }
392 my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target);
393 if( defined ) {
394 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
395 }
396 my $out_msg = &create_xml_string($out_hash);
397 my @out_msg_l;
398 push(@out_msg_l, $out_msg);
399 return @out_msg_l;
400 }
403 sub set_activated_for_installation {
404 my ($msg, $msg_hash, $session_id) = @_;
405 my $header = @{$msg_hash->{header}}[0];
406 my $source = @{$msg_hash->{source}}[0];
407 my $target = @{$msg_hash->{target}}[0];
408 my @out_msg_l;
410 # update status of job
411 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
412 if( defined $jobdb_id) {
413 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
414 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
415 my $res = $main::job_db->exec_statement($sql_statement);
416 }
418 # create set_activated_for_installation message for delivery
419 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
420 if( defined $jobdb_id ) {
421 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
422 }
423 my $out_msg = &create_xml_string($out_hash);
424 push(@out_msg_l, $out_msg);
426 return @out_msg_l;
427 }
430 sub trigger_action_faireboot {
431 my ($msg, $msg_hash, $session_id) = @_;
432 my $macaddress = @{$msg_hash->{target}}[0];
433 my $source = @{$msg_hash->{source}}[0];
435 my @out_msg_l;
436 $msg =~ s/<header>gosa_trigger_action_faireboot<\/header>/<header>trigger_action_faireboot<\/header>/;
437 push(@out_msg_l, $msg);
439 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
440 &main::change_fai_state('install', \@{$msg_hash->{target}}, $session_id);
442 # delete all jobs from jobqueue which correspond to fai
443 my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
444 "status='processing')";
445 $main::job_db->del_dbentry($sql_statement );
447 return @out_msg_l;
448 }
451 sub trigger_action_lock {
452 my ($msg, $msg_hash, $session_id) = @_;
453 my $macaddress = @{$msg_hash->{target}}[0];
454 my $source = @{$msg_hash->{source}}[0];
456 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
457 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
458 if( defined $jobdb_id) {
459 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
460 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
461 my $res = $main::job_db->exec_statement($sql_statement);
462 }
464 my @out_msg_l;
465 return @out_msg_l;
466 }
469 sub trigger_action_activate {
470 my ($msg, $msg_hash, $session_id) = @_;
471 my $macaddress = @{$msg_hash->{target}}[0];
472 my $source = @{$msg_hash->{source}}[0];
474 &main::change_goto_state('active', \@{$msg_hash->{target}}, $session_id);
475 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
476 if( defined $jobdb_id) {
477 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
478 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
479 my $res = $main::job_db->exec_statement($sql_statement);
480 }
482 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $macaddress);
483 if( exists $msg_hash->{'jobdb_id'} ) {
484 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
485 }
486 my $out_msg = &create_xml_string($out_hash);
488 return ( $out_msg );
489 }
492 sub trigger_action_localboot {
493 my ($msg, $msg_hash, $session_id) = @_;
494 $msg =~ s/<header>gosa_trigger_action_localboot<\/header>/<header>trigger_action_localboot<\/header>/;
495 &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
496 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
497 if( defined $jobdb_id) {
498 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
499 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
500 my $res = $main::job_db->exec_statement($sql_statement);
501 }
503 my @out_msg_l = ($msg);
504 return @out_msg_l;
505 }
508 sub trigger_action_halt {
509 my ($msg, $msg_hash, $session_id) = @_;
510 $msg =~ s/<header>gosa_trigger_action_halt<\/header>/<header>trigger_action_halt<\/header>/;
512 &main::change_fai_state('halt', \@{$msg_hash->{target}}, $session_id);
513 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
514 if( defined $jobdb_id) {
515 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
516 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
517 my $res = $main::job_db->exec_statement($sql_statement);
518 }
520 my @out_msg_l = ($msg);
521 return @out_msg_l;
522 }
525 sub trigger_action_reboot {
526 my ($msg, $msg_hash, $session_id) = @_;
527 $msg =~ s/<header>gosa_trigger_action_reboot<\/header>/<header>trigger_action_reboot<\/header>/;
529 &main::change_fai_state('reboot', \@{$msg_hash->{target}}, $session_id);
530 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
531 if( defined $jobdb_id) {
532 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
533 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
534 my $res = $main::job_db->exec_statement($sql_statement);
535 }
537 my @out_msg_l = ($msg);
538 return @out_msg_l;
539 }
542 sub trigger_action_memcheck {
543 my ($msg, $msg_hash, $session_id) = @_ ;
544 $msg =~ s/<header>gosa_trigger_action_memcheck<\/header>/<header>trigger_action_memcheck<\/header>/;
546 &main::change_fai_state('memcheck', \@{$msg_hash->{target}}, $session_id);
547 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
548 if( defined $jobdb_id) {
549 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
550 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
551 my $res = $main::job_db->exec_statement($sql_statement);
552 }
554 my @out_msg_l = ($msg);
555 return @out_msg_l;
556 }
559 sub trigger_action_reinstall {
560 my ($msg, $msg_hash, $session_id) = @_;
561 $msg =~ s/<header>gosa_trigger_action_reinstall<\/header>/<header>trigger_action_reinstall<\/header>/;
563 &main::change_fai_state('reinstall', \@{$msg_hash->{target}}, $session_id);
565 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
566 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
567 my @out_msg_l = ($wake_msg, $msg);
568 return @out_msg_l;
569 }
572 sub trigger_action_update {
573 my ($msg, $msg_hash, $session_id) = @_;
574 $msg =~ s/<header>gosa_trigger_action_update<\/header>/<header>trigger_action_update<\/header>/;
576 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
578 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
579 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
580 my @out_msg_l = ($wake_msg, $msg);
581 return @out_msg_l;
582 }
585 sub trigger_action_instant_update {
586 my ($msg, $msg_hash, $session_id) = @_;
587 $msg =~ s/<header>gosa_trigger_action_instant_update<\/header>/<header>trigger_action_instant_update<\/header>/;
589 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
591 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
592 if( defined $jobdb_id) {
593 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
594 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
595 my $res = $main::job_db->exec_statement($sql_statement);
596 }
598 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
599 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
600 my @out_msg_l = ($wake_msg, $msg);
601 return @out_msg_l;
602 }
605 sub trigger_action_sysinfo {
606 my ($msg, $msg_hash, $session_id) = @_;
607 $msg =~ s/<header>gosa_trigger_action_sysinfo<\/header>/<header>trigger_action_sysinfo<\/header>/;
609 &main::change_fai_state('sysinfo', \@{$msg_hash->{target}}, $session_id);
610 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
611 if( defined $jobdb_id) {
612 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
613 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
614 my $res = $main::job_db->exec_statement($sql_statement);
615 }
617 my @out_msg_l = ($msg);
618 return @out_msg_l;
619 }
622 sub new_key_for_client {
623 my ($msg, $msg_hash, $session_id) = @_;
625 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
626 if( defined $jobdb_id) {
627 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
628 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
629 my $res = $main::job_db->exec_statement($sql_statement);
630 }
632 $msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
633 my @out_msg_l = ($msg);
634 return @out_msg_l;
635 }
638 sub trigger_action_rescan {
639 my ($msg, $msg_hash, $session_id) = @_;
641 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
642 if( defined $jobdb_id) {
643 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
644 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
645 my $res = $main::job_db->exec_statement($sql_statement);
646 }
649 $msg =~ s/<header>gosa_trigger_action_rescan<\/header>/<header>trigger_action_rescan<\/header>/;
650 my @out_msg_l = ($msg);
651 return @out_msg_l;
652 }
655 sub trigger_action_wake {
656 my ($msg, $msg_hash, $session_id) = @_;
658 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
659 if( defined $jobdb_id) {
660 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
661 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
662 my $res = $main::job_db->exec_statement($sql_statement);
663 }
666 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
667 my $out_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
668 my @out_msg_l = ($out_msg);
669 return @out_msg_l;
670 }
673 sub get_available_kernel {
674 my ($msg, $msg_hash, $session_id) = @_;
676 my $source = @{$msg_hash->{'source'}}[0];
677 my $target = @{$msg_hash->{'target'}}[0];
678 my $release= @{$msg_hash->{'release'}}[0];
680 my @kernel;
681 # Get Kernel packages for release
682 my $sql_statement = "SELECT * FROM $main::packages_list_tn WHERE distribution='$release' AND package LIKE 'linux\-image\-%'";
683 my $res_hash = $main::packages_list_db->select_dbentry($sql_statement);
684 my %data;
685 my $i=1;
687 foreach my $package (keys %{$res_hash}) {
688 $data{"answer".$i++}= $data{"answer".$i++}= ${$res_hash}{$package}->{'package'};
689 }
690 $data{"answer".$i++}= "default";
692 my $out_msg = &build_msg("get_available_kernel", $target, "GOSA", \%data);
693 return ( $out_msg );
694 }
697 1;