diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 4c4df6b605e2450557345e8be92173070f3c9225..d73b3c7630b1b65a00ccb0a060de25ce07bba640 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
$foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
- $wake_on_lan_passwd,
+ $wake_on_lan_passwd, $job_synchronization, $modified_jobs_loop_delay,
);
# additional variable which should be globaly accessable
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"plainname DEFAULT 'none'",
+ "siserver DEFAULT 'none'",
+ "modified DEFAULT '0'",
);
# holds all other gosa-si-server
"domain" => [\$server_domain, ""],
"key" => [\$ServerPackages_key, "none"],
"key-lifetime" => [\$foreign_servers_register_delay, 120],
+ "job-synchronization-enabled" => [\$job_synchronization, "true"],
+ "synchronization-loop" => [\$modified_jobs_loop_delay, 5],
}
);
sub check_outgoing_xml_validity {
- my ($msg) = @_;
+ my ($msg, $session_id) = @_;
my $msg_hash;
eval{
}
};
if($@) {
- daemon_log("WARNING: outgoing msg is not gosa-si envelope conform", 5);
- daemon_log("$@ ".(defined($msg) && length($msg)>0)?$msg:"Empty Message", 8);
+ daemon_log("$session_id WARNING: outgoing msg is not gosa-si envelope conform: ", 5);
+ daemon_log("$@ ".(defined($msg) && length($msg)>0)?$msg:"Empty Message", 5);
$msg_hash = undef;
}
if ($done) {
# if a job or a gosa message comes from a foreign server, fake module to GosaPackages
# so gosa-si-server knows how to process this kind of messages
- if ($header =~ /^gosa_/ || $header =~ /job_/) {
+ if ($header =~ /^gosa_/ || $header =~ /^job_/) {
$module = "GosaPackages";
}
$sql = "SELECT * FROM $foreign_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')";
$res = $foreign_clients_db->select_dbentry($sql);
if (keys(%$res) > 0) {
- my $hostname = $res->{1}->{'hostname'};
+ my $hostname = $res->{1}->{'hostname'};
+ my ($host_ip, $host_port) = split(/:/, $hostname);
+ my $local_address = &get_local_ip_for_remote_ip($host_ip).":$server_port";
my $regserver = $res->{1}->{'regserver'};
my $sql = "SELECT * FROM $known_server_tn WHERE hostname='$regserver'";
my $res = $known_server_db->select_dbentry($sql);
foreach my $answer ( @{$answer_l} ) {
# check outgoing msg to xml validity
- my $answer_hash = &check_outgoing_xml_validity($answer);
+ my $answer_hash = &check_outgoing_xml_validity($answer, $session_id);
if( not defined $answer_hash ) { next; }
$answer_header = @{$answer_hash->{'header'}}[0];
$kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay);
+
}
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} ) {
}
+# if a job got an update or was modified anyway, send to all other si-server an update message
+# of this jobs
+sub watch_for_modified_jobs {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE ((siserver='localhost') AND (modified='1'))";
+ my $res = $job_db->select_dbentry( $sql_statement );
+
+ # if db contains no jobs which should be update, do nothing
+ if (keys %$res != 0) {
+
+ if ($job_synchronization eq "true") {
+ # 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");
+
+ # update all other SI-server
+ &inform_all_other_si_server($update_msg);
+ }
+
+ # 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' ";
+ $res = $job_db->update_dbentry($sql_statement);
+ }
+
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
+}
+
+
sub watch_for_new_jobs {
if($watch_for_new_jobs_in_progress == 0) {
$watch_for_new_jobs_in_progress = 1;
my ($kernel,$heap) = @_[KERNEL, HEAP];
- # check gosa job queue for jobs with executable timestamp
+ # check gosa job quaeue for jobs with executable timestamp
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
my $res = $job_db->exec_statement( $sql_statement );
}
+
sub watch_for_new_messages {
my ($kernel,$heap) = @_[KERNEL, HEAP];
my @coll_user_msg; # collection list of outgoing messages
@@ -2984,11 +3021,8 @@ daemon_log("0 INFO: found foreign server in config file and DNS: $all_foreign_se
my $act_timestamp = &get_time();
foreach my $foreign_server (@foreign_server_list) {
- #######################################
- # TODO for jan
# do not add myself to known_server_db
- # work around!!!
- if ($foreign_server eq '10.89.1.31:20081') { next; }
+ if (&is_local($foreign_server)) { next; }
######################################
my $res = $known_server_db->add_dbentry( {table=>$known_server_tn,
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
+ watch_for_modified_jobs => \&watch_for_modified_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
watch_for_old_known_clients => \&watch_for_old_known_clients,
create_packages_list_db => \&run_create_packages_list_db,