From 0134bd9690ce51481ab33eee3df1303008f7c32f Mon Sep 17 00:00:00 2001 From: janw Date: Wed, 4 Mar 2009 14:06:50 +0000 Subject: [PATCH] Merged from gosa-lhm: changeset:13492 changeset:13493 changeset:13494 changeset:13495 changeset:13496 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13497 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/modules/ClientPackages.pm | 4 ++-- gosa-si/modules/DBsqlite.pm | 16 ++++++++++------ gosa-si/server/events/databases.pm | 10 +++------- gosa-si/server/events/gosaTriggered.pm | 23 ++++++++++++++++------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/gosa-si/modules/ClientPackages.pm b/gosa-si/modules/ClientPackages.pm index 99bb35069..7ae02e44d 100644 --- a/gosa-si/modules/ClientPackages.pm +++ b/gosa-si/modules/ClientPackages.pm @@ -456,10 +456,10 @@ sub here_i_am { $nu_clients --; } - # number of actual activ clients + # number of current active clients my $act_nu_clients = $nu_clients; - &main::daemon_log("$session_id INFO: number of actual activ clients: $act_nu_clients", 5); + &main::daemon_log("$session_id INFO: number of current active 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) { diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 65d289615..c9ebc440f 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -62,12 +62,12 @@ sub create_table { # Save full column description for creation of database push(@col_names_creation, $col_name); my @t = split(" ", $col_name); - $col_name = $t[0]; + my $column_name = $t[0]; # Save column name internally for select_dbentry - push(@col_names, $col_name); + push(@col_names, $column_name); } - $col_names->{ $table_name } = $col_names_ref; + $col_names->{ $table_name } = \@col_names; my $col_names_string = join(", ", @col_names_creation); my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )"; $self->lock(); @@ -370,12 +370,14 @@ sub exec_statementlist { sub count_dbentries { my ($self, $table)= @_; my $error= 0; - my $answer= -1; + my $count= -1; - my $sql_statement= "SELECT * FROM $table"; + my $sql_statement= "SELECT count() FROM $table"; my $db_answer= &select_dbentry($self, $sql_statement); + if(defined($db_answer) && defined($db_answer->{1}) && defined($db_answer->{1}->{'count()'})) { + $count = $db_answer->{1}->{'count()'}; + } - my $count = keys(%{$db_answer}); return $count; } @@ -386,6 +388,7 @@ sub move_table { my $sql_statement_drop = "DROP TABLE IF EXISTS $to"; my $sql_statement_alter = "ALTER TABLE $from RENAME TO $to"; + $self->lock(); eval { $self->{dbh}->do($sql_statement_drop); }; @@ -411,6 +414,7 @@ sub move_table { &main::daemon_log("ERROR: $sql_statement_alter failed with $@", 1); } } + $self->unlock(); return; } diff --git a/gosa-si/server/events/databases.pm b/gosa-si/server/events/databases.pm index 687050582..ac934d53b 100644 --- a/gosa-si/server/events/databases.pm +++ b/gosa-si/server/events/databases.pm @@ -80,7 +80,7 @@ sub query_db { return @out_msg_l; } -sub count_fai_releas{ return &count_db( @_ ); } +sub count_fai_release{ return &count_db( @_ ); } sub count_fai_server{ return &count_db( @_ ); } sub count_packages_list{ return &count_db( @_ ); } sub count_jobdb{ return &count_db( @_ ); } @@ -103,14 +103,10 @@ sub count_db { $db = $main::fai_server_db; } elsif( $header =~ /count_fai_release/ ) { $table = $main::fai_release_tn; - $db = $main::fai_server_db; + $db = $main::fai_release_db; } - - # prepare sql statement and execute query - my $res_hash = $db->select_dbentry("SELECT * FROM $table"); - - my $count = keys(%{$res_hash}); + my $count = $db->count_dbentries($table); my $out_xml= "
answer
$target$source$count$session_id
"; my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; if (defined $forward_to_gosa) { diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 73a4e95b6..8742aec16 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -848,6 +848,7 @@ sub trigger_activate_new { ); if($ldap_mesg->count == 1) { $ogroup_entry= $ldap_mesg->pop_entry(); + &main::daemon_log("$session_id DEBUG: A GosaGroupOfNames with cn '$ogroup' was found in base '".$main::ldap_base."'!", 5); } elsif ($ldap_mesg->count == 0) { &main::daemon_log("$session_id ERROR: A GosaGroupOfNames with cn '$ogroup' was not found in base '".$main::ldap_base."'!", 1); $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id"); @@ -901,8 +902,7 @@ sub trigger_activate_new { return undef; } else { &main::daemon_log("$session_id 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 = '".(&calc_timestamp(&get_time(), 'plus', 10))."' WHERE id = $jobdb_id"); + $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting', timestamp = '".(&calc_timestamp(&get_time(), 'plus', 10))."' WHERE id = $jobdb_id"); return undef; } } @@ -936,6 +936,8 @@ sub trigger_activate_new { my $oclass_result = $ldap_entry->update($ldap_handle); if ($oclass_result->code() != 0) { &main::daemon_log("$session_id ERROR: Adding the ObjectClass '$oclass' failed (code '".$oclass_result->code()."') with '".$oclass_result->{'errorMessage'}."'!", 1); + } else { + &main::daemon_log("$session_id DEBUG: Adding the ObjectClass '$oclass' to '".($ldap_entry->dn())."' succeeded!", 5); } } } @@ -949,6 +951,8 @@ sub trigger_activate_new { my $replace_result = $ldap_entry->update($ldap_handle); if ($replace_result->code() != 0) { &main::daemon_log("$session_id ERROR: Setting the FAIstate to install failed with code '".$replace_result->code()."') and message '".$replace_result->{'errorMessage'}."'!", 1); + } else { + &main::daemon_log("$session_id DEBUG: Setting the FAIstate to install for '".($ldap_entry->dn())."' succeeded!", 5); } } } else { @@ -958,6 +962,8 @@ sub trigger_activate_new { my $add_result = $ldap_entry->update($ldap_handle); if ($add_result->code() != 0) { &main::daemon_log("$session_id ERROR: Setting the FAIstate to install failed with code '".$add_result->code()."') and message '".$add_result->{'errorMessage'}."'!", 1); + } else { + &main::daemon_log("$session_id DEBUG: Setting the FAIstate to install for '".($ldap_entry->dn())."' succeeded!", 5); } } @@ -967,8 +973,7 @@ sub trigger_activate_new { # $ldap_entry = Net::LDAP::Entry->new(); # $ldap_entry->dn("cn=$mac,$base"); &main::daemon_log("$session_id 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 = '".(&calc_timestamp(&get_time(), 'plus', 10))."' WHERE id = $jobdb_id"); + $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting', timestamp = '".(&calc_timestamp(&get_time(), 'plus', 60))."' WHERE id = $jobdb_id"); return undef; } else { &main::daemon_log("$session_id ERROR: More than one system with mac address '$mac' was found in base '".$main::ldap_base."'!", 1); @@ -986,6 +991,8 @@ sub trigger_activate_new { my $ogroup_result = $ogroup_entry->update($ldap_handle); if ($ogroup_result->code() != 0) { &main::daemon_log("$session_id ERROR: Updating the ObjectGroup '$ogroup' failed (code '".$ogroup_result->code()."') with '".$ogroup_result->{'errorMessage'}."'!", 1); + } else { + &main::daemon_log("$session_id DEBUG: Updating the ObjectGroup '$ogroup' for member '".($ldap_entry->dn())."' succeeded!", 5); } } else { &main::daemon_log("$session_id DEBUG: System with mac address '$mac' is already a member of ObjectGroup '$ogroup'.", 5); @@ -1001,6 +1008,7 @@ sub trigger_activate_new { if ($activate_result->code() != 0) { &main::daemon_log("$session_id ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1); } else { + &main::daemon_log("$session_id DEBUG: Activating system '".$ldap_entry->dn()."' succeeded!", 5); $activate_client = 1; } } else { @@ -1014,11 +1022,13 @@ sub trigger_activate_new { if ($activate_result->code() != 0) { &main::daemon_log("$session_id ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1); } else { + &main::daemon_log("$session_id DEBUG: Activating system '".$ldap_entry->dn()."' succeeded!", 5); $activate_client = 1; } } if($activate_client == 1) { + &main::daemon_log("$session_id DEBIG: Activating system with mac address '$mac'!", 5); # Create delivery list my @out_msg_l; @@ -1034,10 +1044,9 @@ sub trigger_activate_new { # Return delivery list of messages return @out_msg_l; - } else { + } else { &main::daemon_log("$session_id 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 = '".(&calc_timestamp(&get_time(), 'plus', 10))."' WHERE id = $jobdb_id"); + $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting', timestamp = '".(&calc_timestamp(&get_time(), 'plus', 60))."' WHERE id = $jobdb_id"); } return undef; } -- 2.30.2