summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: efe073c)
raw | patch | inline | side by side (parent: efe073c)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 13 Mar 2008 17:02:39 +0000 (17:02 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 13 Mar 2008 17:02:39 +0000 (17:02 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9757 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 6bd1998cf08b4ce575a4f2e66ed4e19f67ed2d25..47dc89b4161ee8ba5adb1ade4353fa353b796114 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
# path to directory to store client install log files
our $client_fai_log_dir = "/var/log/fai";
-# queue which stores taskes while max_clients are reached
+# queue which stores taskes until one of the $max_children children are ready to process the task
my @tasks = qw();
+my $max_children = 2;
%cfg_defaults = (
sub check_key_and_xml_validity {
- my ($crypted_msg, $module_key) = @_;
+ my ($crypted_msg, $module_key, $session_id) = @_;
my $msg;
my $msg_hash;
my $error_string;
$msg = &decrypt_msg($crypted_msg, $module_key);
if ($msg =~ /<xml>/i){
- daemon_log("decrypted_msg: \n$msg", 8);
+ $msg =~ s/\s+/ /g; # just for better daemon_log
+ daemon_log("$session_id DEBUG: decrypted_msg: \n$msg", 8);
$msg_hash = $xml->XMLin($msg, ForceArray=>1);
##############
}
};
if($@) {
- daemon_log("WARNING: do not understand the message: $@", 5);
+ daemon_log("$session_id DEBUG: do not understand the message: $@", 7);
$msg = undef;
$msg_hash = undef;
}
sub input_from_known_server {
- my ($input, $remote_ip) = @_ ;
+ my ($input, $remote_ip, $session_id) = @_ ;
my ($msg, $msg_hash, $module);
my $sql_statement= "SELECT * FROM known_server";
next;
}
my $host_key = $hit->{hostkey};
- daemon_log("DEBUG: input_from_known_server: host_name: $host_name", 7);
+ daemon_log("$session_id DEBUG: input_from_known_server: host_name: $host_name", 7);
daemon_log("DEBUG: input_from_known_server: host_key: $host_key", 7);
# check if module can open msg envelope with module key
- my ($tmp_msg, $tmp_msg_hash) = &check_key_and_xml_validity($input, $host_key);
+ my ($tmp_msg, $tmp_msg_hash) = &check_key_and_xml_validity($input, $host_key, $session_id);
if( (!$tmp_msg) || (!$tmp_msg_hash) ) {
- daemon_log("DEBUG: input_from_known_server: deciphering raise error", 7);
+ daemon_log("$session_id DEBUG: input_from_known_server: deciphering raise error", 7);
daemon_log("$@", 8);
next;
}
}
if( (!$msg) || (!$msg_hash) || (!$module) ) {
- daemon_log("DEBUG: Incoming message is not from a known server", 7);
+ daemon_log("$session_id DEBUG: Incoming message is not from a known server", 7);
}
return ($msg, $msg_hash, $module);
sub input_from_known_client {
- my ($input, $remote_ip) = @_ ;
+ my ($input, $remote_ip, $session_id) = @_ ;
my ($msg, $msg_hash, $module);
my $sql_statement= "SELECT * FROM known_clients";
next;
}
my $host_key = $hit->{hostkey};
- &daemon_log("DEBUG: input_from_known_client: host_name: $host_name", 7);
- &daemon_log("DEBUG: input_from_known_client: host_key: $host_key", 7);
+ &daemon_log("$session_id DEBUG: input_from_known_client: host_name: $host_name", 7);
+ &daemon_log("$session_id DEBUG: input_from_known_client: host_key: $host_key", 7);
# check if module can open msg envelope with module key
- ($msg, $msg_hash) = &check_key_and_xml_validity($input, $host_key);
+ ($msg, $msg_hash) = &check_key_and_xml_validity($input, $host_key, $session_id);
if( (!$msg) || (!$msg_hash) ) {
- &daemon_log("DEGUG: input_from_known_client: deciphering raise error", 7);
+ &daemon_log("$session_id DEGUG: input_from_known_client: deciphering raise error", 7);
&daemon_log("$@", 8);
next;
}
}
if( (!$msg) || (!$msg_hash) || (!$module) ) {
- &daemon_log("DEBUG: Incoming message is not from a known client", 7);
+ &daemon_log("$session_id DEBUG: Incoming message is not from a known client", 7);
}
return ($msg, $msg_hash, $module);
sub input_from_unknown_host {
no strict "refs";
- my ($input) = @_ ;
+ my ($input, $session_id) = @_ ;
my ($msg, $msg_hash, $module);
my $error_string;
if( $mod eq 'ArpHandler' ) {
next;
}
- daemon_log("ERROR: no key specified in config file for $mod", 1);
+ daemon_log("$session_id ERROR: no key specified in config file for $mod", 1);
next;
}
- daemon_log("DEBUG: $mod: $module_key", 7);
+ daemon_log("$session_id DEBUG: $mod: $module_key", 7);
# check if module can open msg envelope with module key
- ($msg, $msg_hash) = &check_key_and_xml_validity($input, $module_key);
+ ($msg, $msg_hash) = &check_key_and_xml_validity($input, $module_key, $session_id);
if( (not defined $msg) || (not defined $msg_hash) ) {
next;
}
}
if( (!$msg) || (!$msg_hash) || (!$module)) {
- daemon_log("DEBUG: Incoming message is not from an unknown host", 7);
+ daemon_log("$session_id DEBUG: Incoming message is not from an unknown host", 7);
}
return ($msg, $msg_hash, $module);
sub send_msg_to_target {
- my ($msg, $address, $encrypt_key, $msg_header) = @_ ;
+ my ($msg, $address, $encrypt_key, $msg_header, $session_id) = @_ ;
my $error = 0;
my $header;
my $new_status;
# opensocket
my $socket = &open_socket($address);
if( !$socket ) {
- daemon_log("ERROR: cannot send ".$header."msg to $address , host not reachable", 1);
+ daemon_log("$session_id ERROR: cannot send ".$header."msg to $address , host not reachable", 1);
$error++;
}
# send xml msg
print $socket $crypted_msg."\n";
- daemon_log("INFO: send ".$header."msg to $address", 5);
- daemon_log("DEBUG: message:\n$msg", 9);
+ daemon_log("$session_id INFO: send ".$header."msg to $address", 5);
+ #daemon_log("DEBUG: message:\n$msg", 9);
}
if( $act_status eq "down" ) {
$sql_statement = "DELETE FROM known_clients WHERE hostname='$address'";
$res = $known_clients_db->del_dbentry($sql_statement);
- daemon_log("WARNING: failed 2x to send msg to host '$address', delete host from known_clients", 3);
+ daemon_log("$session_id WARNING: failed 2x to send msg to host '$address', delete host from known_clients", 3);
} else {
$sql_statement = "UPDATE known_clients SET status='$new_status' WHERE hostname='$address'";
$res = $known_clients_db->update_dbentry($sql_statement);
if($new_status eq "down"){
- daemon_log("WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
+ daemon_log("$session_id WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
} else {
- daemon_log("INFO: set '$address' from status '$act_status' to '$new_status'", 5);
+ daemon_log("$session_id INFO: set '$address' from status '$act_status' to '$new_status'", 5);
}
}
}
if( $act_status eq "down" ) {
$sql_statement = "DELETE FROM known_server WHERE hostname='$address'";
$res = $known_server_db->del_dbentry($sql_statement);
- daemon_log("WARNING: failed 2x to a send msg to host '$address', delete host from known_server", 3);
+ daemon_log("$session_id WARNING: failed 2x to a send msg to host '$address', delete host from known_server", 3);
}
else {
$sql_statement = "UPDATE known_server SET status='$new_status' WHERE hostname='$address'";
$res = $known_server_db->update_dbentry($sql_statement);
if($new_status eq "down"){
- daemon_log("WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
+ daemon_log("$session_id WARNING: set '$address' from status '$act_status' to '$new_status'", 3);
}
else {
- daemon_log("INFO: set '$address' from status '$act_status' to '$new_status'", 5);
+ daemon_log("$session_id INFO: set '$address' from status '$act_status' to '$new_status'", 5);
}
}
}
my ($answer, $error) = @_;
if( $answer =~ /<jobdb_id>(\d+)<\/jobdb_id>/ ) {
my $jobdb_id = $1;
+
+ # sending msg faild
if( $error ) {
if (not $answer =~ /<header>trigger_action_reinstall<\/header>/) {
- # sending msg faild
my $sql_statement = "UPDATE $job_queue_tn ".
"SET status='error', result='can not deliver msg, please consult log file' ".
"WHERE id='$jobdb_id'";
my $res = $job_db->update_dbentry($sql_statement);
}
+
+ # sending msg was successful
} else {
- # sending msg was successful
my $sql_statement = "UPDATE $job_queue_tn ".
"SET status='done' ".
"WHERE id='$jobdb_id' AND status='processed'";
sub next_task {
my ($session, $heap) = @_[SESSION, HEAP];
- while ( keys( %{ $heap->{task} } ) < $max_clients ) {
+ while ( keys( %{ $heap->{task} } ) < $max_children ) {
my $next_task = shift @tasks;
last unless defined $next_task;
$heap = $session_reference->get_heap();
}
}
- $heap->{'client'}->put($client_answer);
+
+ if(exists $heap->{'client'}) {
+ $heap->{'client'}->put($client_answer);
+ }
}
$kernel->sig(CHLD => "child_reap");
}
my $client_answer = "";
daemon_log("", 5);
- daemon_log("INFO: Incoming msg with session ID $session_id from '".$heap->{'remote_ip'}."'", 5);
- daemon_log("DEBUG: Incoming msg:\n$input", 9);
+ daemon_log("$session_id INFO: Incoming msg with session ID $session_id from '".$heap->{'remote_ip'}."'", 5);
+ daemon_log("$session_id DEBUG: Incoming msg:\n$input", 9);
####################
# check incoming msg
# msg is from a new client or gosa
- ($msg, $msg_hash, $module) = &input_from_unknown_host($input);
+ ($msg, $msg_hash, $module) = &input_from_unknown_host($input, $session_id);
# msg is from a gosa-si-server or gosa-si-bus
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
- ($msg, $msg_hash, $module) = &input_from_known_server($input, $heap->{'remote_ip'});
+ ($msg, $msg_hash, $module) = &input_from_known_server($input, $heap->{'remote_ip'}, $session_id);
}
# msg is from a gosa-si-client
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
- ($msg, $msg_hash, $module) = &input_from_known_client($input, $heap->{'remote_ip'});
+ ($msg, $msg_hash, $module) = &input_from_known_client($input, $heap->{'remote_ip'}, $session_id);
}
# an error occurred
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
+ # if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
+ # could not understand a msg from its server the client cause a re-registering process
my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my $host_name = $hit->{'hostname'};
my $host_key = $hit->{'hostkey'};
my $ping_msg = "<xml> <header>gosa_ping</header> <source>$server_address</source> <target>$host_name</target></xml>";
- my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping");
+ my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping", $session_id);
&update_jobdb_status_for_send_msgs($ping_msg, $error);
}
$error++;
######################
# process incoming msg
if( $error == 0) {
- daemon_log("INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0]."'", 5);
- daemon_log("DEBUG: Processing module ".$module, 7);
+ daemon_log("$session_id INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0]."'", 5);
+ daemon_log("$session_id DEBUG: Processing module ".$module, 7);
$answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $session_id);
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
- daemon_log("DEBUG: $module: Got answer from module: \n".$answer_str,8);
+ daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
}
}
if( !$answer_l ) { $error++ };
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my $host_name = $hit->{hostname};
my $host_key = $hit->{hostkey};
- my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
}
}
my $host_name = $hit->{hostname};
my $host_key = $hit->{hostkey};
$answer =~ s/KNOWN_SERVER/$host_name/g;
- my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
}
}
# target of msg is GOsa
elsif( $answer_target eq "GOSA" ) {
- my $session_id = ($1) if $answer =~ s/<session_id>(\d+?)<\/session_id>//;
+ my $session_id = ($1) if $answer =~ /<session_id>(\d+?)<\/session_id>/;
my $add_on = "";
if( defined $session_id ) {
$add_on = ".session_id=$session_id";
$answer =~ /<header>(\S+)<\/header>/;
my $header;
if( defined $1 ) { $header = $1; }
- my $error = &send_msg_to_target($answer, $server_address, $GosaPackages_key, $header);
+ my $error = &send_msg_to_target($answer, $server_address, $GosaPackages_key, $header, $session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
}
# 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("INFO: target is mac address '$answer_target', looking for host in known_clients", 5);
+ daemon_log("$session_id INFO: target is mac address '$answer_target', looking for host in known_clients", 5);
my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$answer_target'";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
my $found_ip_flag = 0;
my $host_name = $hit->{hostname};
my $host_key = $hit->{hostkey};
$answer =~ s/$answer_target/$host_name/g;
- daemon_log("INFO: found host '$host_name', associated to '$answer_target'", 5);
- my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ daemon_log("$session_id INFO: found host '$host_name', associated to '$answer_target'", 5);
+ my $error = &send_msg_to_target($answer, $host_name, $host_key, $answer_header, $session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
$found_ip_flag++ ;
}
if( $found_ip_flag == 0) {
- daemon_log("WARNING: no host found in known_clients with mac address '$answer_target'", 3);
+ daemon_log("$session_id WARNING: no host found in known_clients with mac address '$answer_target'", 3);
if( $bus_activ eq "true" ) {
- daemon_log("INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
+ daemon_log("$session_id INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
my $query_res = $known_server_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my $bus_address = $hit->{hostname};
my $bus_key = $hit->{hostkey};
- my $error = &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
+ my $error = &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header, $session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
last;
}
my $encrypt_key = &get_encrypt_key($answer_target);
if( not defined $encrypt_key ) {
# unknown target, forward msg to bus
- daemon_log("WARNING: unknown target '$answer_target'", 3);
+ daemon_log("$session_id WARNING: unknown target '$answer_target'", 3);
if( $bus_activ eq "true" ) {
- daemon_log("INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
+ daemon_log("$session_id INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
my $query_res = $known_server_db->select_dbentry( $sql_statement );
my $res_length = keys( %{$query_res} );
if( $res_length == 0 ){
- daemon_log("WARNING: send '$answer_header' to '$bus_address' failed, ".
+ daemon_log("$session_id WARNING: send '$answer_header' to '$bus_address' failed, ".
"no bus found in known_server", 3);
}
else {
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my $bus_key = $hit->{hostkey};
- my $error = &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
+ my $error = &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header,$session_id );
&update_jobdb_status_for_send_msgs($answer, $error);
}
}
}
next;
}
- my $error = &send_msg_to_target($answer, $answer_target, $encrypt_key, $answer_header);
+ my $error = &send_msg_to_target($answer, $answer_target, $encrypt_key, $answer_header,$session_id);
&update_jobdb_status_for_send_msgs($answer, $error);
}
}
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'};
+ daemon_log("J DEBUG: its time to execute $job_msg", 7);
my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
# expect macaddress is unique!!!!!!
my $target = $res_hash->{1}->{hostname};
- if (not defined $target) {
- &daemon_log("ERROR: no host found for mac address: $macaddress", 1);
- &daemon_log("$hit->{xmlmessage}", 8);
- my $sql_statement = "UPDATE $job_queue_tn ".
- "SET status='error', result='no host found for mac address' ".
- "WHERE id='$jobdb_id'";
- my $res = $job_db->update_dbentry($sql_statement);
- next;
- }
-
+# if (not defined $target) {
+# &daemon_log("ERROR: no host found for mac address: $macaddress", 1);
+# &daemon_log("$hit->{xmlmessage}", 8);
+# my $sql_statement = "UPDATE $job_queue_tn ".
+# "SET status='error', result='no host found for mac address' ".
+# "WHERE id='$jobdb_id'";
+# my $res = $job_db->update_dbentry($sql_statement);
+# next;
+# }
+#
# change header
$job_msg =~ s/<header>job_/<header>gosa_/;
# add sqlite_id
$job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
- my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header);
+ $job_msg =~ /<header>(\S+)<\/header>/;
+ my $header = $1 ;
+ my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
# update status in job queue to 'processing'
$sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
sub change_fai_state {
- my ($st, $targets) = @_;
+ my ($st, $targets, $session_id) = @_;
+ $session_id = 0 if not defined $session_id;
# Set FAI state to localboot
my %mapActions= (
if ($mesg->count) {
my @entries = $mesg->entries;
foreach my $entry (@entries) {
-
# Only modify entry if it is not set to '$state'
if ($entry->get_value("FAIstate") ne "$state"){
-
- daemon_log("INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
+ daemon_log("$session_id INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
my $result;
my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
if (exists $tmp{'FAIobject'}){
# Errors?
if ($result->code){
- daemon_log("Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
+ daemon_log("$session_id Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
}
}
sub change_goto_state {
- my ($st, $targets) = @_;
+ my ($st, $targets, $session_id) = @_;
+ $session_id = 0 if not defined $session_id;
# Switch on or off?
my $state= $st eq 'active' ? 'active': 'locked';
# Only modify entry if it is not set to '$state'
if ($entry->get_value("gotoMode") ne $state){
- daemon_log("INFO: Setting gotoMode to '$state' for ".$entry->dn, 5);
+ daemon_log("$session_id INFO: Setting gotoMode to '$state' for ".$entry->dn, 5);
my $result;
$result= $ldap_handle->modify($entry->dn, changes => [
replace => [ gotoMode => $state ] ]);
# Errors?
if ($result->code){
- &daemon_log("Error: Setting gotoMode to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
+ &daemon_log("$session_id Error: Setting gotoMode to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
}
}
index d5a0a6b4b1f4f8abdef8c2a278e15df2c1948ba0..43c06a3ad147724386fdbfb0381b2a59d423ee5a 100644 (file)
sub import_events {
if (not -e $event_dir) {
- &main::daemon_log("ERROR: cannot find directory or directory is not readable: $event_dir", 1);
+ &main::daemon_log("G ERROR: cannot find directory or directory is not readable: $event_dir", 1);
}
opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n";
eval{ require $event; };
if( $@ ) {
- &main::daemon_log("ERROR: import of event module '$event' failed", 1);
+ &main::daemon_log("G ERROR: import of event module '$event' failed", 1);
&main::daemon_log("$@", 1);
next;
}
$event_hash->{$event_name} = $event_module;
}
my $events_string = join( ", ", @{$events_l});
- &main::daemon_log("INFO: GosaPackages imported events $events_string", 5);
+ &main::daemon_log("G INFO: GosaPackages imported events $events_string", 5);
}
}
my @msg_l;
my @out_msg_l;
- &main::daemon_log("DEBUG: GosaPackages: msg to process '$header'", 7);
+ &main::daemon_log("$session_id DEBUG: GosaPackages: msg to process '$header'", 7);
if ($header =~ /^job_/) {
@msg_l = &process_job_msg($msg, $msg_hash, $session_id);
@msg_l = &process_gosa_msg($msg, $msg_hash, $session_id);
}
else {
- &main::daemon_log("ERROR: $header is not a valid GosaPackage-header, need a 'job_' or a 'gosa_' prefix", 1);
+ &main::daemon_log("$session_id ERROR: $header is not a valid GosaPackage-header, need a 'job_' or a 'gosa_' prefix", 1);
}
foreach my $out_msg ( @msg_l ) {
- # keep job queue up-to-date and save result and status
- if (defined ($out_msg) && $out_msg =~ /<jobdb_id>(\d+)<\/jobdb_id>/) {
- my $job_id = $1;
- my $sql = "UPDATE '".$main::job_queue_tn."'".
- " SET status='processing'".
- " WHERE id='$job_id'";
- my $res = $main::job_db->exec_statement($sql);
- }
+# # keep job queue up-to-date and save result and status
+# if (defined ($out_msg) && $out_msg =~ /<jobdb_id>(\d+)<\/jobdb_id>/) {
+# my $job_id = $1;
+# my $sql = "UPDATE '".$main::job_queue_tn."'".
+# " SET status='processing'".
+# " WHERE id='$job_id'";
+# my $res = $main::job_db->exec_statement($sql);
+# }
# substitute in all outgoing msg <source>GOSA</source> of <source>$server_address</source>
$out_msg =~ s/<source>GOSA<\/source>/<source>$server_address<\/source>/g;
-
+ $out_msg =~ s/<\/xml>/<session_id>$session_id<\/session_id><\/xml>/;
if (defined $out_msg){
push(@out_msg_l, $out_msg);
}
if( exists $event_hash->{$header} ) {
# a event exists with the header as name
- &main::daemon_log("INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
no strict 'refs';
@out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
}
# if incoming 'gosa_'-msg is scheduled from job_queue, than it contains xml-tag 'jobdb_id'
# after procesing this msg, set status of this job in job_queue to done
- if ($msg =~ /<jobdb_id>(\d+)<\/jobdb_id>/) {
- my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='done' ".
- "WHERE id='$1'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
- my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: set job '$1' to status processed", 5);
- }
+# if ($msg =~ /<jobdb_id>(\d+)<\/jobdb_id>/) {
+# my $sql_statement = "UPDATE $main::job_queue_tn ".
+# "SET status='done' ".
+# "WHERE id='$1'";
+# &main::daemon_log("DEBUG: $sql_statement", 7);
+# my $res = $main::job_db->update_dbentry($sql_statement);
+# &main::daemon_log("INFO: set job '$1' to status 'done'", 5);
+# }
# if delivery not possible raise error and return
if( not defined $out_msg_l[0] ) {
- &main::daemon_log("WARNING: GosaPackages got no answer from event handler '$header'", 3);
+# &main::daemon_log("WARNING: GosaPackages got no answer from event handler '$header'", 3);
@out_msg_l = ();
} elsif( $out_msg_l[0] eq 'nohandler') {
- &main::daemon_log("ERROR: GosaPackages: no event handler or core function defined for '$header'", 1);
+ &main::daemon_log("$session_id ERROR: GosaPackages: no event handler or core function defined for '$header'", 1);
@out_msg_l = ();
}
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {
- &main::daemon_log("ERROR: GosaPackages: process_job_msg: $res", 1);
+ &main::daemon_log("$session_id ERROR: GosaPackages: process_job_msg: $res", 1);
} else {
- &main::daemon_log("INFO: GosaPackages: $header job successfully added to job queue", 5);
+ &main::daemon_log("$session_id INFO: GosaPackages: $header job successfully added to job queue", 5);
}
$out_msg = "<xml><header>answer</header><source>$server_address</source><target>GOSA</target><answer1>$res</answer1></xml>";
}
index 5d03cf44cd1058ad148cd6287ceec69a6f878fae..b06f3f2ef0f159201910f7c0ef5bbe2efcb7fb0b 100644 (file)
my $error = 0;
my $host_name;
my $host_key;
- my @out_msg_l = ();
+ my @out_msg_l = ("nohandler");
# process incoming msg
my $header = @{$msg_hash->{header}}[0];
# skip PREFIX
$header =~ s/^CLMSG_//;
- &main::daemon_log("DEBUG: SIPackages: msg to process: $header", 7);
+ &main::daemon_log("$session_id DEBUG: SIPackages: msg to process: $header", 7);
if( 0 == length @target_l){
- &main::daemon_log("ERROR: no target specified for msg $header", 1);
+ &main::daemon_log("$session_id ERROR: no target specified for msg $header", 1);
$error++;
}
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)
+ @out_msg_l = &here_i_am($msg_hash, $session_id)
} else {
if( exists $event_hash->{$header} ) {
# a event exists with the header as name
- &main::daemon_log("INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
no strict 'refs';
@out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
}
}
# if delivery not possible raise error and return
- if( not @out_msg_l ) {
- &main::daemon_log("WARNING: SIPackages got no answer from event handler '$header'", 3);
- } elsif( 0 == @out_msg_l) {
- &main::daemon_log("ERROR: SIPackages: no event handler or core function defined for '$header'", 1);
+ if( not defined $out_msg_l[0] ) {
+ @out_msg_l = ();
+ } elsif( $out_msg_l[0] eq 'nohandler') {
+ &main::daemon_log("$session_id ERROR: SIPackages: no event handler or core function defined for '$header'", 1);
+ @out_msg_l = ();
}
+
}
else {
&main::daemon_log("INFO: msg is not for gosa-si-server '$server_address', deliver it to target '$target'", 5);
# DESCRIPTION: process this incoming message
#===============================================================================
sub here_i_am {
- my ($msg_hash) = @_;
+ my ($msg_hash, $session_id) = @_;
my @out_msg_l;
my $out_hash;
my $db_res= $main::known_clients_db->select_dbentry( $sql_statement );
if ( 1 == keys %{$db_res} ) {
- &main::daemon_log("WARNING: $source is already known as a client", 1);
- &main::daemon_log("WARNING: values for $source are being overwritten", 1);
+ &main::daemon_log("$session_id WARNING: $source is already known as a client", 1);
+ &main::daemon_log("$session_id WARNING: values for $source are being overwritten", 1);
$nu_clients --;
}
# number of actual activ clients
my $act_nu_clients = $nu_clients;
- &main::daemon_log("INFO: number of actual activ clients: $act_nu_clients", 5);
- &main::daemon_log("INFO: number of maximal allowed clients: $max_clients", 5);
+ &main::daemon_log("$session_id INFO: number of actual activ clients: $act_nu_clients", 5);
+ &main::daemon_log("$session_id INFO: number of maximal allowed clients: $max_clients", 5);
if($max_clients <= $act_nu_clients) {
my $out_hash = &create_xml_hash("denied", $server_address, $source);
} );
if ($res != 0) {
- &main::daemon_log("ERROR: cannot add entry to known_clients: $res");
+ &main::daemon_log("$session_id ERROR: cannot add entry to known_clients: $res");
return;
}
&add_content2xml_hash($out_hash, "timestamp", $act_timestamp);
my $new_client_out = &create_xml_string($out_hash);
push(@out_msg_l, $new_client_out);
- &main::daemon_log("INFO: send bus msg that client '$source' has registered at server '$server_address'", 5);
+ &main::daemon_log("$session_id INFO: send bus msg that client '$source' has registered at server '$server_address'", 5);
}
# give the new client his ldap config
# Workaround: Send within the registration response, if the client will get an ldap config later
- my $new_ldap_config_out = &new_ldap_config($source);
+ my $new_ldap_config_out = &new_ldap_config($source, $session_id);
if($new_ldap_config_out && (!($new_ldap_config_out =~ /error/))) {
&add_content2xml_hash($out_hash, "ldap_available", "true");
} elsif($new_ldap_config_out && $new_ldap_config_out =~ /error/){
"SET status='error', result='$new_ldap_config_out' ".
"WHERE status='processing' AND macaddress LIKE '$mac_address'";
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("DEBUG: $sql_statement RESULT: $res", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement RESULT: $res", 7);
}
my $register_out = &create_xml_string($out_hash);
push(@out_msg_l, $register_out);
# DESCRIPTION: send to address the ldap configuration found for dn gotoLdapServer
#===============================================================================
sub new_ldap_config {
- my ($address) = @_ ;
+ my ($address, $session_id) = @_ ;
my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address' OR macaddress LIKE '$address'";
my $res = $main::known_clients_db->select_dbentry( $sql_statement );
# check hit
my $hit_counter = keys %{$res};
if( not $hit_counter == 1 ) {
- &main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
+ &main::daemon_log("$session_id ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
}
$address = $res->{1}->{hostname};
my $hostkey = $res->{1}->{hostkey};
if (not defined $macaddress) {
- &main::daemon_log("ERROR: no mac address found for client $address", 1);
+ &main::daemon_log("$session_id ERROR: no mac address found for client $address", 1);
return;
}
# Build LDAP connection
&main::refresh_ldap_handle();
if( not defined $main::ldap_handle ) {
- &main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
filter => "(&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))");
#$mesg->code && die $mesg->error;
if($mesg->code) {
- &main::daemon_log($mesg->error, 1);
+ &main::daemon_log("$session_id ".$mesg->error, 1);
return;
}
# Sanity check
if ($mesg->count != 1) {
- &main::daemon_log("WARNING: client with mac address $macaddress not found/unique/active - not sending ldap config", 1);
- &main::daemon_log("\tbase: $ldap_base", 1);
- &main::daemon_log("\tscope: sub", 1);
- &main::daemon_log("\tattrs: dn, gotoLdapServer", 1);
- &main::daemon_log("\tfilter: (&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))", 1);
+ &main::daemon_log("$session_id WARNING: client with mac address $macaddress not found/unique/active - not sending ldap config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: dn, gotoLdapServer".
+ "\n\tfilter: (&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))", 1);
return;
}
filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
#$mesg->code && die $mesg->error;
if($mesg->code) {
- &main::daemon_log($mesg->error, 1);
+ &main::daemon_log("$session_id ".$mesg->error, 1);
return;
}
# Sanity check
if ($mesg->count != 1) {
- &main::daemon_log("WARNING: no LDAP information found for client mac $macaddress", 1);
+ &main::daemon_log("$session_id WARNING: no LDAP information found for client mac $macaddress", 1);
return;
}
index cf409c54f7e2a9afcaf3370975de26f9f5437fa4..d72da53347a4ef478fe019696d4628c946f2ddb2 100644 (file)
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
my $all_logs = @{$msg_hash->{$header}}[0];
+ # if there is nothing to log
+ if( ref($all_logs) eq "HASH" ) { return; }
+
my $client_fai_log_dir = $main::client_fai_log_dir;
if (not -d $client_fai_log_dir) {
mkdir($client_fai_log_dir, 0755)
);
my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
if ($res != 0) {
- &main::daemon_log("ERROR: cannot add entry to known_clients: $error_str");
+ &main::daemon_log("$session_id ERROR: cannot add entry to known_clients: $error_str");
return;
}
while( my($hit_id, $hit) = each(%{$db_res}) ) {
$currently_logged_in_user{$hit->{'user'}} = 1;
}
- &main::daemon_log("DEBUG: logged in users from login_user_db: ".join(", ", keys(%currently_logged_in_user)), 7);
+ &main::daemon_log("$session_id DEBUG: logged in users from login_user_db: ".join(", ", keys(%currently_logged_in_user)), 7);
my @logged_in_user = split(/\s+/, $login);
- &main::daemon_log("DEBUG: logged in users reported from client: ".join(", ", @logged_in_user), 7);
+ &main::daemon_log("$session_id DEBUG: logged in users reported from client: ".join(", ", @logged_in_user), 7);
foreach my $user (@logged_in_user) {
my %add_hash = ( table=>$main::login_users_tn,
primkey=> ['client', 'user'],
);
my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
if ($res != 0) {
- &main::daemon_log("ERROR: cannot add entry to known_clients: $error_str");
+ &main::daemon_log("$session_id ERROR: cannot add entry to known_clients: $error_str");
return;
}
# although he is not reported by client
# then delete it from $login_user_db
foreach my $obsolete_user (keys(%currently_logged_in_user)) {
- &main::daemon_log("WARNING: user '$obsolete_user' is currently not logged ".
+ &main::daemon_log("$session_id WARNING: user '$obsolete_user' is currently not logged ".
"in at client '$source' but still found at login_user_db", 3);
my $sql_statement = "DELETE FROM $main::login_users_tn WHERE client='$source' AND user='$obsolete_user'";
my $res = $main::login_users_db->del_dbentry($sql_statement);
- &main::daemon_log("WARNING: delete user '$obsolete_user' at client '$source' from login_user_db", 3);
+ &main::daemon_log("$session_id WARNING: delete user '$obsolete_user' at client '$source' from login_user_db", 3);
}
return;
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header"."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress'", 5);
return;
}
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET progress='$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - $content%", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - $content%", 5);
return;
}
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
return;
}
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
return;
}
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='done', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
# set fai_state to localboot
- &main::change_fai_state('localboot', \@{$msg_hash->{target}});
+ &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
} else {
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
# -----------------------> Update hier
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
# -----------------------> Update hier
# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
# -----------------------> Update hier
# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("DEBUG: $sql_statement", 7);
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("INFO: $header at '$macaddress' - '$content'", 5);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
return;
}
index 31a804d1018a41e12e9afafe9290bc677076380e..43421356e1af2cfe8111dab33fd5281b29d01fce 100644 (file)
if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
# error handling
if( not @user_list && not @group_list ) {
&main::daemon_log("WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3);
my ($msg, $msg_hash, $session_id) = @_ ;
my $out_msg;
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
$main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names);
&main::create_fai_server_db("new_fai_server");
$main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn);
my $target = @{$msg_hash->{'target'}}[0];
my $client = @{$msg_hash->{'client'}}[0];
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
$header =~ s/^gosa_//;
my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress LIKE '$client'";
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $target = @{$msg_hash->{'target'}}[0];
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
my $usr = @{$msg_hash->{'usr'}}[0];
$header =~ s/^gosa_//;
sub ping {
my ($msg, $msg_hash, $session_id) = @_ ;
my $out_msg = $msg;
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
$out_msg =~ s/<header>gosa_/<header>/;
- $out_msg =~ s/<\/xml>/<session_id>$session_id<\/session_id><\/xml>/;
my @out_msg_l = ( $out_msg );
return @out_msg_l;
sub detect_hardware {
- my ($msg, $msg_hash) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
# just forward msg to client, but dont forget to split off 'gosa_' in header
my $source = @{$msg_hash->{source}}[0];
my $target = @{$msg_hash->{target}}[0];
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
- if( exists $msg_hash->{'jobdb_id'} ) {
- &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
+ if( defined $jobdb_id ) {
+ &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
}
my $out_msg = &create_xml_string($out_hash);
sub trigger_reload_ldap_config {
- my ($msg, $msg_hash) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
my $target = @{$msg_hash->{target}}[0];
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target);
- if( exists $msg_hash->{'jobdb_id'} ) {
- &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
+ if( defined ) {
+ &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
}
my $out_msg = &create_xml_string($out_hash);
my @out_msg_l;
sub set_activated_for_installation {
- my ($msg, $msg_hash) = @_;
-
+ my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{header}}[0];
my $source = @{$msg_hash->{source}}[0];
my $target = @{$msg_hash->{target}}[0];
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
- if( exists $msg_hash->{'jobdb_id'} ) {
- &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
+ if( defined $jobdb_id ) {
+ &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
}
my $out_msg = &create_xml_string($out_hash);
my @out_msg_l = ( $out_msg );
sub trigger_action_faireboot {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
my $macaddress = @{$msg_hash->{target}}[0];
my $source = @{$msg_hash->{source}}[0];
$msg =~ s/<header>gosa_trigger_action_faireboot<\/header>/<header>trigger_action_faireboot<\/header>/;
push(@out_msg_l, $msg);
- &main::change_goto_state('locked', \@{$msg_hash->{target}});
- &main::change_fai_state('localboot', \@{$msg_hash->{target}});
+ &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
+ &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
# delete all jobs from jobqueue which correspond to fai
my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
sub trigger_action_lock {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
my $macaddress = @{$msg_hash->{target}}[0];
my $source = @{$msg_hash->{source}}[0];
- &main::change_goto_state('locked', \@{$msg_hash->{target}});
+ &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l;
return @out_msg_l;
sub trigger_action_activate {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
my $macaddress = @{$msg_hash->{target}}[0];
my $source = @{$msg_hash->{source}}[0];
- &main::change_goto_state('active', \@{$msg_hash->{target}});
+ &main::change_goto_state('active', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $macaddress);
if( exists $msg_hash->{'jobdb_id'} ) {
sub trigger_action_localboot {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_localboot<\/header>/<header>trigger_action_localboot<\/header>/;
-
- &main::change_fai_state('localboot', \@{$msg_hash->{target}});
+ &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_halt {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_halt<\/header>/<header>trigger_action_halt<\/header>/;
- &main::change_fai_state('halt', \@{$msg_hash->{target}});
+ &main::change_fai_state('halt', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_reboot {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_reboot<\/header>/<header>trigger_action_reboot<\/header>/;
- &main::change_fai_state('reboot', \@{$msg_hash->{target}});
+ &main::change_fai_state('reboot', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_memcheck {
- my ($msg, $msg_hash) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
$msg =~ s/<header>gosa_trigger_action_memcheck<\/header>/<header>trigger_action_memcheck<\/header>/;
- &main::change_fai_state('memcheck', \@{$msg_hash->{target}});
+ &main::change_fai_state('memcheck', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_reinstall {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_reinstall<\/header>/<header>trigger_action_reinstall<\/header>/;
- &main::change_fai_state('reinstall', \@{$msg_hash->{target}});
+ &main::change_fai_state('reinstall', \@{$msg_hash->{target}}, $session_id);
my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
sub trigger_action_update {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_update<\/header>/<header>trigger_action_update<\/header>/;
- &main::change_fai_state('update', \@{$msg_hash->{target}});
+ &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
sub trigger_action_instant_update {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_instant_update<\/header>/<header>trigger_action_instant_update<\/header>/;
- &main::change_fai_state('update', \@{$msg_hash->{target}});
+ &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
sub trigger_action_sysinfo {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
$msg =~ s/<header>gosa_trigger_action_sysinfo<\/header>/<header>trigger_action_sysinfo<\/header>/;
- &main::change_fai_state('sysinfo', \@{$msg_hash->{target}});
+ &main::change_fai_state('sysinfo', \@{$msg_hash->{target}}, $session_id);
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
my @out_msg_l = ($msg);
return @out_msg_l;
sub new_key_for_client {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
$msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_rescan {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+
$msg =~ s/<header>gosa_trigger_action_rescan<\/header>/<header>trigger_action_rescan<\/header>/;
my @out_msg_l = ($msg);
return @out_msg_l;
sub trigger_action_wake {
- my ($msg, $msg_hash) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+
my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
my $out_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
my @out_msg_l = ($out_msg);
index 256d75e59c8c5e47f1df47d66d922104677d99e4..55e3be017a1bbe648e42800731c77d2aa56ebf2f 100644 (file)
my ($msg, $msg_hash, $session_id) = @_ ;
foreach (@{$msg_hash->{macAddress}}){
- &main::daemon_log("INFO: trigger wake for $_", 5);
+ &main::daemon_log("$session_id INFO: trigger wake for $_", 5);
my $host = $_;
my $ipaddr = '255.255.255.255';
my $port = getservbyname('discard', 'udp');
if ($host =~ m/^$hwaddr_re$/) {
$hwaddr = $host;
} else {
- &main::daemon_log("ERROR: trigger_wake called with non mac address", 1);
+ &main::daemon_log("$session_id ERROR: trigger_wake called with non mac address", 1);
}
# Generate magic sequence
index dbe43c1734830a75ad314ef52389d456bc7c4279..36bf5390bdd2f8174c8437ab53cde565d782f2aa 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# jobdb add
#$data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source><target>GOSA</target><hostname>ws-muc-2</hostname></xml>";
#$data = "<xml> <header>job_sayHello</header> <source>10.89.1.155:20083</source><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133900</timestamp> </xml>";
-#$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>19700101000000</timestamp> </xml>";
+$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>19700101000000</timestamp> </xml>";
# jobdb delete
#$data = "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><connector>and</connector><phrase><operator>gt</operator><ROWID>0</ROWID></phrase><phrase><operator>le</operator><ROWID>5</ROWID></phrase></clause></where></xml>";
#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><phrase><headertag>ping</headertag></phrase></clause></where><limit><from>0</from><to>3</to></limit></xml>";
#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><phrase><HEADERTAG>trigger_action_reinstall</HEADERTAG></phrase></clause></where><limit><from>0</from><to>25</to></limit><orderby>timestamp DESC</orderby></xml>";
-$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
+#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
# jobdb count
#$data = "<xml> <header>gosa_count_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>job_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp></xml>";
#$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
-#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>20130101000000</timestamp> </xml>";
-#$data = "<xml> <header>gosa_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>19700101000000</timestamp> </xml>";
+#$data = "<xml> <header>job_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";