80f793e8df2c28c28bc444bb70c449edbee0643d
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 $func_dic = {table=>$main::messaging_tn,
89 primkey=>['id'],
90 subject=>$subject,
91 message_from=>$from,
92 message_to=>$to,
93 flag=>"n",
94 direction=>"in",
95 delivery_time=>$delivery_time,
96 message=>$message,
97 timestamp=>&get_time(),
98 };
99 my $res = $main::messaging_db->add_dbentry($func_dic);
100 if (not $res == 0) {
101 &main::daemon_log("$session_id ERROR: gosaTriggered.pm: cannot add message to message_db: $res", 1);
102 } else {
103 &main::daemon_log("$session_id INFO: gosaTriggered.pm: message with subject '$subject' successfully added to message_db", 5);
104 }
106 return;
107 }
109 sub send_user_msg_OLD {
110 my ($msg, $msg_hash, $session_id) = @_ ;
111 my @out_msg_l;
112 my @user_list;
113 my @group_list;
115 my $header = @{$msg_hash->{'header'}}[0];
116 my $source = @{$msg_hash->{'source'}}[0];
117 my $target = @{$msg_hash->{'target'}}[0];
118 my $message = @{$msg_hash->{'message'}}[0];
119 if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
120 if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
122 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
123 if( defined $jobdb_id) {
124 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
125 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
126 my $res = $main::job_db->exec_statement($sql_statement);
127 }
129 # error handling
130 if( not @user_list && not @group_list ) {
131 &main::daemon_log("$session_id WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3);
132 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
133 "<error_string>no user-tag or a group-tag specified in 'send_user_msg'</error_string></xml>");
134 }
135 if( not defined $message ) {
136 &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3);
137 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
138 "<error_string>no message-tag specified in 'send_user_msg'</error_string></xml>");
140 }
142 # resolve groups to users
143 my $ldap_handle = &main::get_ldap_handle($session_id);
144 if( @group_list ) {
145 if( not defined $ldap_handle ) {
146 &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
147 return ();
148 }
149 foreach my $group (@group_list) { # Perform search
150 my $mesg = $ldap_handle->search(
151 base => $main::ldap_base,
152 scope => 'sub',
153 attrs => ['memberUid'],
154 filter => "(&(objectClass=posixGroup)(cn=$group)(memberUid=*))");
155 if($mesg->code) {
156 &main::daemon_log($mesg->error, 1);
157 return ();
158 }
159 my $entry= $mesg->entry(0);
160 my @users= $entry->get_value("memberUid");
161 foreach my $user (@users) { push(@user_list, $user); }
162 }
163 }
165 # drop multiple users in @user_list
166 my %seen = ();
167 foreach my $user (@user_list) {
168 $seen{$user}++;
169 }
170 @user_list = keys %seen;
172 # build xml messages sended to client where user is logged in
173 foreach my $user (@user_list) {
174 my $sql_statement = "SELECT * FROM $main::login_users_tn WHERE user='$user'";
175 my $db_res = $main::login_users_db->select_dbentry($sql_statement);
177 if(0 == keys(%{$db_res})) {
179 } else {
180 while( my($hit, $content) = each %{$db_res} ) {
181 my $out_hash = &create_xml_hash('send_user_msg', $main::server_address, $content->{'client'});
182 &add_content2xml_hash($out_hash, 'message', $message);
183 &add_content2xml_hash($out_hash, 'user', $user);
184 if( exists $msg_hash->{'jobdb_id'} ) {
185 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
186 }
187 my $out_msg = &create_xml_string($out_hash);
188 push(@out_msg_l, $out_msg);
189 }
190 }
191 }
193 return @out_msg_l;
194 }
197 sub recreate_fai_server_db {
198 my ($msg, $msg_hash, $session_id) = @_ ;
199 my $out_msg;
201 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
202 if( defined $jobdb_id) {
203 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
204 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
205 my $res = $main::job_db->exec_statement($sql_statement);
206 }
208 $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names);
209 &main::create_fai_server_db("new_fai_server",undef,"dont");
210 $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn);
212 my @out_msg_l = ( $out_msg );
213 return @out_msg_l;
214 }
217 sub recreate_fai_release_db {
218 my ($msg, $msg_hash, $session_id) = @_ ;
219 my $out_msg;
221 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
222 if( defined $jobdb_id) {
223 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
224 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
225 my $res = $main::job_db->exec_statement($sql_statement);
226 }
228 $main::fai_server_db->create_table("new_fai_release", \@main::fai_release_col_names);
229 &main::create_fai_release_db("new_fai_release", $session_id);
230 $main::fai_server_db->move_table("new_fai_release", $main::fai_release_tn);
232 my @out_msg_l = ( $out_msg );
233 return @out_msg_l;
234 }
237 sub get_login_usr_for_client {
238 my ($msg, $msg_hash, $session_id) = @_ ;
239 my $header = @{$msg_hash->{'header'}}[0];
240 my $source = @{$msg_hash->{'source'}}[0];
241 my $target = @{$msg_hash->{'target'}}[0];
242 my $client = @{$msg_hash->{'client'}}[0];
244 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
245 if( defined $jobdb_id) {
246 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
247 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
248 my $res = $main::job_db->exec_statement($sql_statement);
249 }
251 $header =~ s/^gosa_//;
253 my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress LIKE '$client'";
254 my $res = $main::known_clients_db->select_dbentry($sql_statement);
256 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
257 $out_msg .= &db_res2xml($res);
258 $out_msg .= "</xml>";
260 my @out_msg_l = ( $out_msg );
261 return @out_msg_l;
262 }
265 sub get_client_for_login_usr {
266 my ($msg, $msg_hash, $session_id) = @_ ;
267 my $header = @{$msg_hash->{'header'}}[0];
268 my $source = @{$msg_hash->{'source'}}[0];
269 my $target = @{$msg_hash->{'target'}}[0];
271 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
272 if( defined $jobdb_id) {
273 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
274 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
275 my $res = $main::job_db->exec_statement($sql_statement);
276 }
278 my $usr = @{$msg_hash->{'usr'}}[0];
279 $header =~ s/^gosa_//;
281 my $sql_statement = "SELECT * FROM known_clients WHERE login LIKE '%$usr%'";
282 my $res = $main::known_clients_db->select_dbentry($sql_statement);
284 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
285 $out_msg .= &db_res2xml($res);
286 $out_msg .= "</xml>";
287 my @out_msg_l = ( $out_msg );
288 return @out_msg_l;
290 }
293 sub ping {
294 my ($msg, $msg_hash, $session_id) = @_ ;
295 my $out_msg = $msg;
296 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
297 if( defined $jobdb_id) {
298 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
299 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
300 my $res = $main::job_db->exec_statement($sql_statement);
301 }
303 $out_msg =~ s/<header>gosa_/<header>/;
305 my @out_msg_l = ( $out_msg );
306 return @out_msg_l;
307 }
309 sub gen_smb_hash {
310 my ($msg, $msg_hash, $session_id) = @_ ;
311 my $source = @{$msg_hash->{source}}[0];
312 my $target = @{$msg_hash->{target}}[0];
313 my $password = @{$msg_hash->{password}}[0];
315 my %data= ('hash' => join(q[:], ntlmgen $password));
316 my $out_msg = &build_msg("gen_smb_hash", $target, 'GOSA', \%data );
317 return ( $out_msg );
318 }
321 sub network_completition {
322 my ($msg, $msg_hash, $session_id) = @_ ;
323 my $source = @{$msg_hash->{source}}[0];
324 my $target = @{$msg_hash->{target}}[0];
325 my $name = @{$msg_hash->{hostname}}[0];
327 # Can we resolv the name?
328 my %data;
329 if (inet_aton($name)){
330 my $address = inet_ntoa(inet_aton($name));
331 my $p = Net::Ping->new('tcp');
332 my $mac= "";
333 if ($p->ping($address, 1)){
334 $mac = Net::ARP::arp_lookup("", $address);
335 }
337 %data= ('ip' => $address, 'mac' => $mac);
338 } else {
339 %data= ('ip' => '', 'mac' => '');
340 }
342 my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data );
344 return ( $out_msg );
345 }
348 sub detect_hardware {
349 my ($msg, $msg_hash, $session_id) = @_ ;
350 # just forward msg to client, but dont forget to split off 'gosa_' in header
351 my $source = @{$msg_hash->{source}}[0];
352 my $target = @{$msg_hash->{target}}[0];
353 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
354 if( defined $jobdb_id) {
355 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
356 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
357 my $res = $main::job_db->exec_statement($sql_statement);
358 }
360 my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
361 if( defined $jobdb_id ) {
362 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
363 }
364 my $out_msg = &create_xml_string($out_hash);
366 my @out_msg_l = ( $out_msg );
367 return @out_msg_l;
369 }
372 sub trigger_reload_ldap_config {
373 my ($msg, $msg_hash, $session_id) = @_ ;
374 my $target = @{$msg_hash->{target}}[0];
376 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
377 if( defined $jobdb_id) {
378 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
379 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
380 my $res = $main::job_db->exec_statement($sql_statement);
381 }
383 my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target);
384 if( defined ) {
385 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
386 }
387 my $out_msg = &create_xml_string($out_hash);
388 my @out_msg_l;
389 push(@out_msg_l, $out_msg);
390 return @out_msg_l;
391 }
394 sub set_activated_for_installation {
395 my ($msg, $msg_hash, $session_id) = @_;
396 my $header = @{$msg_hash->{header}}[0];
397 my $source = @{$msg_hash->{source}}[0];
398 my $target = @{$msg_hash->{target}}[0];
399 my @out_msg_l;
401 # create set_activated_for_installation message
402 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
403 if( defined $jobdb_id) {
404 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
405 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
406 my $res = $main::job_db->exec_statement($sql_statement);
407 }
409 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
410 if( defined $jobdb_id ) {
411 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
412 }
413 my $out_msg = &create_xml_string($out_hash);
414 push(@out_msg_l, $out_msg);
416 # create new_ldap_config message, client is waiting for that piece of information
417 my $new_ldap_config_out = &main::new_ldap_config($source, $session_id);
418 push(@out_msg_l, $new_ldap_config_out);
421 return @out_msg_l;
422 }
425 sub trigger_action_faireboot {
426 my ($msg, $msg_hash, $session_id) = @_;
427 my $macaddress = @{$msg_hash->{target}}[0];
428 my $source = @{$msg_hash->{source}}[0];
430 my @out_msg_l;
431 $msg =~ s/<header>gosa_trigger_action_faireboot<\/header>/<header>trigger_action_faireboot<\/header>/;
432 push(@out_msg_l, $msg);
434 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
435 &main::change_fai_state('install', \@{$msg_hash->{target}}, $session_id);
437 # delete all jobs from jobqueue which correspond to fai
438 my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
439 "status='processing')";
440 $main::job_db->del_dbentry($sql_statement );
442 return @out_msg_l;
443 }
446 sub trigger_action_lock {
447 my ($msg, $msg_hash, $session_id) = @_;
448 my $macaddress = @{$msg_hash->{target}}[0];
449 my $source = @{$msg_hash->{source}}[0];
451 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
452 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
453 if( defined $jobdb_id) {
454 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
455 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
456 my $res = $main::job_db->exec_statement($sql_statement);
457 }
459 my @out_msg_l;
460 return @out_msg_l;
461 }
464 sub trigger_action_activate {
465 my ($msg, $msg_hash, $session_id) = @_;
466 my $macaddress = @{$msg_hash->{target}}[0];
467 my $source = @{$msg_hash->{source}}[0];
469 &main::change_goto_state('active', \@{$msg_hash->{target}}, $session_id);
470 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
471 if( defined $jobdb_id) {
472 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
473 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
474 my $res = $main::job_db->exec_statement($sql_statement);
475 }
477 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $macaddress);
478 if( exists $msg_hash->{'jobdb_id'} ) {
479 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
480 }
481 my $out_msg = &create_xml_string($out_hash);
483 return ( $out_msg );
484 }
487 sub trigger_action_localboot {
488 my ($msg, $msg_hash, $session_id) = @_;
489 $msg =~ s/<header>gosa_trigger_action_localboot<\/header>/<header>trigger_action_localboot<\/header>/;
490 &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
491 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
492 if( defined $jobdb_id) {
493 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
494 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
495 my $res = $main::job_db->exec_statement($sql_statement);
496 }
498 my @out_msg_l = ($msg);
499 return @out_msg_l;
500 }
503 sub trigger_action_halt {
504 my ($msg, $msg_hash, $session_id) = @_;
505 $msg =~ s/<header>gosa_trigger_action_halt<\/header>/<header>trigger_action_halt<\/header>/;
507 &main::change_fai_state('halt', \@{$msg_hash->{target}}, $session_id);
508 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
509 if( defined $jobdb_id) {
510 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
511 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
512 my $res = $main::job_db->exec_statement($sql_statement);
513 }
515 my @out_msg_l = ($msg);
516 return @out_msg_l;
517 }
520 sub trigger_action_reboot {
521 my ($msg, $msg_hash, $session_id) = @_;
522 $msg =~ s/<header>gosa_trigger_action_reboot<\/header>/<header>trigger_action_reboot<\/header>/;
524 &main::change_fai_state('reboot', \@{$msg_hash->{target}}, $session_id);
525 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
526 if( defined $jobdb_id) {
527 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
528 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
529 my $res = $main::job_db->exec_statement($sql_statement);
530 }
532 my @out_msg_l = ($msg);
533 return @out_msg_l;
534 }
537 sub trigger_action_memcheck {
538 my ($msg, $msg_hash, $session_id) = @_ ;
539 $msg =~ s/<header>gosa_trigger_action_memcheck<\/header>/<header>trigger_action_memcheck<\/header>/;
541 &main::change_fai_state('memcheck', \@{$msg_hash->{target}}, $session_id);
542 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
543 if( defined $jobdb_id) {
544 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
545 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
546 my $res = $main::job_db->exec_statement($sql_statement);
547 }
549 my @out_msg_l = ($msg);
550 return @out_msg_l;
551 }
554 sub trigger_action_reinstall {
555 my ($msg, $msg_hash, $session_id) = @_;
556 $msg =~ s/<header>gosa_trigger_action_reinstall<\/header>/<header>trigger_action_reinstall<\/header>/;
558 &main::change_fai_state('reinstall', \@{$msg_hash->{target}}, $session_id);
560 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
561 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
562 my @out_msg_l = ($wake_msg, $msg);
563 return @out_msg_l;
564 }
567 sub trigger_action_update {
568 my ($msg, $msg_hash, $session_id) = @_;
569 $msg =~ s/<header>gosa_trigger_action_update<\/header>/<header>trigger_action_update<\/header>/;
571 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
573 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
574 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
575 my @out_msg_l = ($wake_msg, $msg);
576 return @out_msg_l;
577 }
580 sub trigger_action_instant_update {
581 my ($msg, $msg_hash, $session_id) = @_;
582 $msg =~ s/<header>gosa_trigger_action_instant_update<\/header>/<header>trigger_action_instant_update<\/header>/;
584 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
586 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
587 if( defined $jobdb_id) {
588 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
589 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
590 my $res = $main::job_db->exec_statement($sql_statement);
591 }
593 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
594 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
595 my @out_msg_l = ($wake_msg, $msg);
596 return @out_msg_l;
597 }
600 sub trigger_action_sysinfo {
601 my ($msg, $msg_hash, $session_id) = @_;
602 $msg =~ s/<header>gosa_trigger_action_sysinfo<\/header>/<header>trigger_action_sysinfo<\/header>/;
604 &main::change_fai_state('sysinfo', \@{$msg_hash->{target}}, $session_id);
605 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
606 if( defined $jobdb_id) {
607 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
608 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
609 my $res = $main::job_db->exec_statement($sql_statement);
610 }
612 my @out_msg_l = ($msg);
613 return @out_msg_l;
614 }
617 sub new_key_for_client {
618 my ($msg, $msg_hash, $session_id) = @_;
620 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
621 if( defined $jobdb_id) {
622 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
623 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
624 my $res = $main::job_db->exec_statement($sql_statement);
625 }
627 $msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
628 my @out_msg_l = ($msg);
629 return @out_msg_l;
630 }
633 sub trigger_action_rescan {
634 my ($msg, $msg_hash, $session_id) = @_;
636 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
637 if( defined $jobdb_id) {
638 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
639 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
640 my $res = $main::job_db->exec_statement($sql_statement);
641 }
644 $msg =~ s/<header>gosa_trigger_action_rescan<\/header>/<header>trigger_action_rescan<\/header>/;
645 my @out_msg_l = ($msg);
646 return @out_msg_l;
647 }
650 sub trigger_action_wake {
651 my ($msg, $msg_hash, $session_id) = @_;
653 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
654 if( defined $jobdb_id) {
655 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
656 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
657 my $res = $main::job_db->exec_statement($sql_statement);
658 }
661 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
662 my $out_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
663 my @out_msg_l = ($out_msg);
664 return @out_msg_l;
665 }
668 sub get_available_kernel {
669 my ($msg, $msg_hash, $session_id) = @_;
671 my $source = @{$msg_hash->{'source'}}[0];
672 my $target = @{$msg_hash->{'target'}}[0];
673 my $release= @{$msg_hash->{'release'}}[0];
675 my @kernel;
676 # Get Kernel packages for release
677 my $sql_statement = "SELECT * FROM $main::packages_list_tn WHERE distribution='$release' AND package LIKE 'linux\-image\-%'";
678 my $res_hash = $main::packages_list_db->select_dbentry($sql_statement);
679 foreach my $package (keys %{$res_hash}) {
680 push @kernel, %{$res_hash}->{$package}->{'package'};
681 }
683 my %data = ('available-kernel' => \@kernel);
685 my $out_msg = &build_msg("get_available_kernel", $target, "GOSA", \%data);
686 return ( $out_msg );
687 }
690 1;