summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d0591ff)
raw | patch | inline | side by side (parent: d0591ff)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Jul 2008 12:29:39 +0000 (12:29 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Jul 2008 12:29:39 +0000 (12:29 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11608 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index b6d603042a055468665e565c493edd3b3c7f547e..50709127a1de039652cfa991bdf44108bcfffc14 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
sub watch_for_done_jobs {
my ($kernel,$heap) = @_[KERNEL, HEAP];
- my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE status='done'";
+ my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((status='done') AND (modified='0'))";
my $res = $job_db->select_dbentry( $sql_statement );
while( my ($id, $hit) = each %{$res} ) {
# make out of the db result a gosa-si message
my $update_msg = &db_res2si_msg ($res, "foreign_job_updates", "KNOWN_SERVER", "MY_LOCAL_ADDRESS");
-
- # determine all other si-server a foreign_job_updates message should be send
- my $sql_statement= "SELECT * FROM $known_server_tn";
- my $res = $known_server_db->select_dbentry( $sql_statement );
- while( my ($hit_num, $hit) = each %$res ) {
- my $act_update_msg = $update_msg;
- my $act_target_address = $hit->{hostname};
- my $act_target_key = $hit->{hostkey};
- my ($act_target_ip, $act_target_port) = split(/:/, $act_target_address);
- my $act_source_address = &get_local_ip_for_remote_ip($act_target_ip).":$act_target_port";
-
- $act_update_msg =~ s/<target>KNOWN_SERVER<\/target>/<target>$act_target_address<\/target>/g;
- $act_update_msg =~ s/<source>MY_LOCAL_ADDRESS<\/source>/<source>$act_source_address<\/source>/g;
- &send_msg_to_target($act_update_msg, $act_target_address, $act_target_key, "foreign_job_updates" , "J");
- }
+
+ # update all other SI-server
+ &inform_all_other_si_server($update_msg);
+
+# # determine all other si-server a foreign_job_updates message should be send
+# my $sql_statement= "SELECT * FROM $known_server_tn";
+# my $res = $known_server_db->select_dbentry( $sql_statement );
+# while( my ($hit_num, $hit) = each %$res ) {
+# my $act_update_msg = $update_msg;
+# my $act_target_address = $hit->{hostname};
+# my $act_target_key = $hit->{hostkey};
+# my ($act_target_ip, $act_target_port) = split(/:/, $act_target_address);
+# my $act_source_address = &get_local_ip_for_remote_ip($act_target_ip).":$act_target_port";
+#
+# $act_update_msg =~ s/<target>KNOWN_SERVER<\/target>/<target>$act_target_address<\/target>/g;
+# $act_update_msg =~ s/<source>MY_LOCAL_ADDRESS<\/source>/<source>$act_source_address<\/source>/g;
+# &send_msg_to_target($act_update_msg, $act_target_address, $act_target_key, "foreign_job_updates" , "J");
+# }
# set jobs all jobs to modified = 0, wait until the next modification for updates of other si-server
$sql_statement = "UPDATE $job_queue_tn SET modified='0' ";
index 7db50cd1ae06c6e4f20c3f4ac761bc7becacfca1..06b041023b58b6abe106bd91fcc21717bda162f1 100644 (file)
xmlmessage=>'none',
macaddress=>$macaddress,
plainname=>'none',
+ siserver=>'localhost',
+ modified=>'1',
};
my $hd_res = $main::job_db->add_dbentry($func_dic);
&main::daemon_log("$session_id INFO: add '$macaddress' to job queue as an installing job", 5);
index 686846d85d3dbc5687305cf5186394fb777580e9..5f6b4657ba4edc65801888fd70498656cc1704b3 100644 (file)
macaddress=>$macaddress,
plainname=>$plain_name,
siserver=>"localhost",
- modified=>"0",
+ modified=>"1",
};
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {
index 33c9ec47d741532fc1548a18599757a98c6ee4f4..88b2c60eaf1cec4108165a756c2a5d7a451d80d2 100644 (file)
"get_interfaces",
"is_local",
"run_as",
+ "inform_all_other_si_server",
);
@EXPORT = @functions;
use strict;
}
+#=== FUNCTION ================================================================
+# NAME: inform_other_si_server
+# PARAMETERS: message
+# RETURNS: nothing
+# DESCRIPTION: Sends message to all other SI-server found in known_server_db.
+#===============================================================================
+sub inform_all_other_si_server {
+ my ($msg) = @_;
+
+ # determine all other si-server from known_server_db
+ my $sql_statement= "SELECT * FROM $main::known_server_tn";
+ my $res = $main::known_server_db->select_dbentry( $sql_statement );
+
+ while( my ($hit_num, $hit) = each %$res ) {
+ my $act_target_address = $hit->{hostname};
+ my $act_target_key = $hit->{hostkey};
+
+ # determine the source address corresponding to the actual target address
+ my ($act_target_ip, $act_target_port) = split(/:/, $act_target_address);
+ my $act_source_address = &main::get_local_ip_for_remote_ip($act_target_ip).":$act_target_port";
+
+ # fill into message the correct target and source addresses
+ my $act_msg = $msg;
+ $act_msg =~ s/<target>\w*<\/target>/<target>$act_target_address<\/target>/g;
+ $act_msg =~ s/<source>\w*<\/source>/<source>$act_source_address<\/source>/g;
+
+ # send message to the target
+ &main::send_msg_to_target($act_msg, $act_target_address, $act_target_key, "foreign_job_updates" , "J");
+ }
+
+ return;
+}
+
1;
index 5ca8590146640ce38f4633afd63df61399b0954e..70da956b5d6a72b08945a84a2a5f55607593f3aa 100644 (file)
&main::daemon_log("$session_id DEBUG: there are more than one processing job in queue for host '$macaddress', ".
"delete entries", 7);
- my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'";
- my ($err) = $main::job_db->del_dbentry($sql_statement);
- if (not defined $err) {
- &main::daemon_log("$session_id ERROR: can not delete multiple processing queue entries for host '$macaddress': ".Dumper($err), 1);
- }
+ # set job to status 'done', job will be deleted automatically
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='done', modified='1'".
+ "WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->update_dbentry( $sql_statement );
+
}
# in case of no and more than one running jobs in queue, add one single job
if ($content eq "savelog 0") {
&main::daemon_log("$session_id DEBUG: got savelog from host '$target' - job done", 7);
- my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
- my $res = $main::job_db->del_dbentry($sql_statement);
+
+ # set job to status 'done', job will be deleted automatically
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='done', modified='1'".
+ "WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->update_dbentry( $sql_statement );
} else {
-
- my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content', modified='1' ".
- "WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
- my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
-
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
+ "WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->update_dbentry($sql_statement);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
}
-# -----------------------> Update hier
-# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
-# <header>CLMSG_TASKBEGIN</header>
-# macaddress auslesen, Client im LDAP lokalisieren
-# FAIstate auf "error" setzen
return;
}
index 850fa8ea788824bfb628fb60a22f9d97e8c56dd3..6d969a18094412354ae8f7bc803f8b18180d6c9c 100644 (file)
&main::change_goto_state('locked', \@{$msg_hash->{macaddress}}, $session_id);
&main::change_fai_state('install', \@{$msg_hash->{macaddress}}, $session_id);
- # delete all jobs from jobqueue which correspond to fai
- my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
- "status='processing')";
- $main::job_db->del_dbentry($sql_statement );
-
+ # set job to status 'done', job will be deleted automatically
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='done', modified='1'".
+ "WHERE (macaddress='$macaddress' AND status='processing')";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->update_dbentry( $sql_statement );
+
return @out_msg_l;
}
index 7620f5885abe913813b81e7f626402560b0a82fa..bcf4ced0dccfcab890814db618e94d2bd18e97ab 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><target>00:01:6c:9d:b9:fa</target><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133908</timestamp> </xml>";
- $data = "<xml> <header>job_ping2</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>job_ping</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>20130101000000</timestamp> </xml>";
# jobdb delete
#$data = "<xml> <header>gosa_delete_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase><id>3</id></phrase></clause></where></xml>";