summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4da93d4)
raw | patch | inline | side by side (parent: 4da93d4)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 10 Sep 2008 08:47:51 +0000 (08:47 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 10 Sep 2008 08:47:51 +0000 (08:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12388 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history | |
gosa-si/server/events/gosaTriggered.pm | patch | blob | history |
index 25061bb90736b9201431d58a65848a8cdeca1e52..93e70a722e11eb06c86919f66a7e4e1cb53b7e33 100644 (file)
sub get_time {
+ # Add an optional offset in seconds
+ my $offset = shift || 0;
my ($seconds, $minutes, $hours, $monthday, $month,
- $year, $weekday, $yearday, $sommertime) = localtime(time);
+ $year, $weekday, $yearday, $sommertime) = localtime(time+$offset);
$hours = $hours < 10 ? $hours = "0".$hours : $hours;
$minutes = $minutes < 10 ? $minutes = "0".$minutes : $minutes;
$seconds = $seconds < 10 ? $seconds = "0".$seconds : $seconds;
index 96413597ab5e5f52b46295c31304a9f58cd5f46a..d3d7ce930600e349f85527ef8bd4632f9bc835a2 100644 (file)
if(!(defined($base) && (length($base) > 0))) {
# Subtract the ObjectGroup cn
$base = $1 if $ogroup_entry->dn =~ /cn=$ogroup,ou=groups,(.*)$/;
+ &main::daemon_log("DEBUG: New base for system with mac address '$mac' is '$base'", 5);
}
}
# TODO: Find a way to guess an ip address for hosts with no ldap entry (MAC->ARP->IP)
if($ldap_mesg->count == 1) {
- &main::daemon_log("DEBUG: One system with mac address '$mac' was found in base '".$main::ldap_base."'!", 6);
+ &main::daemon_log("DEBUG: One system with mac address '$mac' was found in base '".$main::ldap_base."'!", 5);
# Get the entry from LDAP
$ldap_entry= $ldap_mesg->pop_entry();
deleteoldrdn => 1,
newsuperior => $base,
);
+ # To prevent replication problems just re-queue the job with 10 seconds in the future
+ my $moddn_result = $ldap_entry->update($ldap_handle);
+ if ($moddn_result->code() != 0) {
+ &main::daemon_log("ERROR: Moving the system with mac address '$mac' to new base '$base' failed (code '".$moddn_result->code()."') with '".$moddn_result->{'errorMessage'}."'!", 1);
+ &main::daemon_log("INFO: System with mac address '$mac' was moved to base '".$main::ldap_base."'! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ }
}
} elsif ($ldap_mesg->count == 0) {
&main::daemon_log("WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
$main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
- $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time()."' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(60)."' WHERE id = $jobdb_id");
return undef;
}
objectClass => $oclass,
);
my $oclass_result = $ldap_entry->update($ldap_handle);
+ if ($oclass_result->code() != 0) {
+ &main::daemon_log("ERROR: Adding the ObjectClass '$oclass' failed (code '".$oclass_result->code()."') with '".$oclass_result->{'errorMessage'}."'!", 1);
+ }
}
}
'FAIstate' => 'install'
);
my $replace_result = $ldap_entry->update($ldap_handle);
+ if ($replace_result->code() != 0) {
+ &main::daemon_log("ERROR: Setting the FAIstate to install failed with code '".$replace_result->code()."') and message '".$replace_result->{'errorMessage'}."'!", 1);
+ }
}
} else {
$ldap_entry->add(
'FAIstate' => 'install'
);
my $add_result = $ldap_entry->update($ldap_handle);
+ if ($add_result->code() != 0) {
+ &main::daemon_log("ERROR: Setting the FAIstate to install failed with code '".$add_result->code()."') and message '".$add_result->{'errorMessage'}."'!", 1);
+ }
}
# $ldap_entry->dn("cn=$mac,$base");
&main::daemon_log("WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
$main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
- $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time()."' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
return undef;
} else {
&main::daemon_log("ERROR: More than one system with mac address '$mac' was found in base '".$main::ldap_base."'!", 1);
my @out_msg_l = ($out_msg);
return @out_msg_l;
- }
+ } else {
+ &main::daemon_log("WARNING: Activating system with mac address '$mac' failed! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ }
return undef;
}