summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a19a28b)
raw | patch | inline | side by side (parent: a19a28b)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 18 Mar 2008 15:43:42 +0000 (15:43 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 18 Mar 2008 15:43:42 +0000 (15:43 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9929 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index fa4b860472eb2f333482970fc1d5fc138ab04b1b..1aae6effd35bd4c9a02a2290b0db763d38dcb8a8 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
sub register_at_gosa_si_server {
my ($kernel) = $_[KERNEL];
my $try_to_register = 0;
+
+ # if client is already registered, stop registration process
+ if ($REGISTERED) {
+ $kernel->delay('register_at_gosa_si_server');
- if( not $REGISTERED ) {
- # clear all other triggered events and wait till registration was successful
- $kernel->delay('trigger_new_key');
+ # client is not registered, start registration process
+ } else {
+ # clear all other triggered events and wait till registration was successful
+ $kernel->delay('trigger_new_key');
- # create new passwd and ciphering object for client-server communication
- $server_key = &create_passwd();
+ # create new passwd and ciphering object for client-server communication
+ $server_key = &create_passwd();
- my $events = join( ",", keys %{$event_hash} );
- while(1) {
+ my $events = join( ",", keys %{$event_hash} );
+ while(1) {
- if( $try_to_register >= @servers ) {
- last;
- }
+ if( $try_to_register >= @servers ) { last; }
- # fetch first gosa-si-server from @servers
- my $server = shift(@servers);
+ # fetch first gosa-si-server from @servers
+ my $server = shift(@servers);
- # append shifted gosa-si-server at the end of @servers, so looking for servers never stop if
- # a registration never occured
- push( @servers, $server );
+ # append shifted gosa-si-server at the end of @servers, so looking for servers never stop if
+ # a registration never occured
+ push( @servers, $server );
- # Check if our ip is resolvable - if not: don't try to register
- my $ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
- my $dnsname= gethostbyaddr(inet_aton($ip), AF_INET);
- if(!defined($dnsname)) {
- &write_to_file("goto-error-dns:$ip", $fai_logpath);
- exit(1);
- }
+ # Check if our ip is resolvable - if not: don't try to register
+ my $ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
+ my $dnsname= gethostbyaddr(inet_aton($ip), AF_INET);
+ if(!defined($dnsname)) {
+ &write_to_file("goto-error-dns:$ip", $fai_logpath);
+ exit(1);
+ }
# create registration msg
my $local_ip = &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
# send xml hash to server with general server passwd
my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key);
+
+ # if delivery of registration msg succeed
if($res == 0) {
# reset try_to_register
$try_to_register = 0;
$client_dnsname = $dnsname;
last;
+
+ # delivery of registration msg failed
} else {
$try_to_register++;
-
# wait 1 sec until trying to register again
sleep(1);
next;
}
- }
- if( $try_to_register >= @servers ) {
- &write_to_file("gosa-si-no-server-available", $fai_logpath);
- $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
- }
- else {
- daemon_log("INFO: waiting for msg 'register_at_gosa_si_server'",5);
- $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
- # clear old settings and set it again
- $kernel->delay_set('trigger_new_key', $server_key_lifetime);
- }
+ } # end of while
+
+ # one circle through all servers finished and no registration succeed
+ if ( $try_to_register >= @servers ) {
+ &write_to_file("gosa-si-no-server-available", $fai_logpath);
+ $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
+
+ # delivery of registraion msg succeed, waiting for server response
+ } else {
+ daemon_log("INFO: waiting for msg 'register_at_gosa_si_server'",5);
+ $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
+ # clear old settings and set it again
+ $kernel->delay('trigger_new_key');
+ $kernel->delay_set('trigger_new_key', $server_key_lifetime);
+ }
- } else {
- $kernel->delay('register_at_gosa_si_server');
}
return;
}
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 238fcd6fca51637e5a01176f7cfca1f84b35adef..7653c67f444b051358bafcc6e5e7971182df2453 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
use Cwd;
use File::Spec;
use File::Basename;
-use File::Find;
-use File::Copy;
use File::Path;
use GOSA::DBsqlite;
use GOSA::GosaSupportDaemon;
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
-my ($server);
+my ($server, $server_mac_address);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($xml);
my $sources_list;
my $max_clients;
-my %repo_files=();
-my $repo_path;
-my %repo_dirs=();
# variables declared in config file are always set to 'our'
our (%cfg_defaults, $log_file, $pid_file,
$server_ip, $server_port, $SIPackages_key,
# additional variable which should be globaly accessable
our $server_address;
-our $server_mac_address;
our $bus_address;
our $gosa_address;
our $no_bus;
"packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
- "repo-path" => [\$repo_path, '/srv/www/repository'],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
"ldap-admin-dn" => [\$ldap_admin_dn, ""],
sub _start {
my ($kernel) = $_[KERNEL];
&trigger_db_loop($kernel);
- $kernel->yield('create_fai_server_db', $fai_server_tn );
- $kernel->yield('create_fai_release_db', $fai_release_tn );
+ #$kernel->yield('create_fai_server_db', $fai_server_tn );
+ #$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
}
sub refresh_ldap_handle {
my $mesg;
- daemon_log("DEBUG: Trying to create a connection to URI $ldap_uri", 5);
# Get an ldap handle, if we don't have one
if( ! defined $ldap_handle ){
$ldap_handle = Net::LDAP->new( $ldap_uri );
wake => '',
memcheck => 'memcheck',
sysinfo => 'sysinfo',
+ install => 'install',
);
# Return if this is unknown
my $fh;
open($fh, ">$result") or return undef;
- if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
+ if(defined($ldap_server_dn) && length($ldap_server_dn)>0) {
my $mesg=$ldap_handle->search(
- base => $ldap_server_dn,
- scope => 'base',
- attrs => 'FAIrepository',
- filter => 'objectClass=FAIrepositoryServer'
- );
+ base => $ldap_server_dn,
+ scope => 'base',
+ attrs => 'FAIrepository',
+ );
+
if($mesg->count) {
foreach my $entry(@{$mesg->{'entries'}}) {
my ($server, $tag, $release, $sections)= split /\|/, $entry->get_value('FAIrepository');
daemon_log("INFO: create_packages_list_db: finished", 5);
return;
}
-
sub run_create_packages_list_db {
my ($session, $heap) = @_[SESSION, HEAP];
my $task = POE::Wheel::Run->new(
);
$heap->{task}->{ $task->ID } = $task;
}
-
sub parse_package_info {
my ($baseurl, $dist, $section)= @_;
my ($package);
my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
- $repo_dirs{ "${repo_path}/pool" } = 1;
foreach $package ("Packages.gz"){
daemon_log("DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section" );
parse_package( "$outdir/$dist/$section", $dist, $path );
}
- find(\&cleanup_and_extract, keys( %repo_dirs ) );
}
-
sub get_package {
my ($url, $dest)= @_;
}
return 0;
}
-
sub parse_package {
- my ($path, $dist, $srv_path)= @_;
+ my ($path, $dist, $srv_path )= @_;
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
next;
}
- # Trigger for filename
- if ($line =~ /^Filename:\s/){
- my ($filename) = ($line =~ /^Filename: (.*)$/);
- store_fileinfo( $package, $filename, $dist, $srv_path, $version, $repo_path );
- next;
- }
}
close( $PACKAGES );
$packages_list_db->exec_statementlist(\@sql_list);
}
+
sub store_fileinfo {
- my( $package, $file, $dist, $path, $vers, $srvdir) = @_;
+ my( $package, $file, $dist, $path, $vers, $srvdir) = @_;
- my %fileinfo = (
- 'package' => $package,
- 'dist' => $dist,
- 'version' => $vers,
- );
+ my %fileinfo = (
+ 'package' => $package,
+ 'dist' => $dist,
+ 'version' => $vers,
+ );
- $repo_files{ "${srvdir}/$file" } = \%fileinfo;
+ $repo_files{ "${srvdir}/$file" } = \%fileinfo;
}
+
sub cleanup_and_extract {
my $fileinfo = $repo_files{ $File::Find::name };
index 1e6ad1457ceabc55503ecbf3054c9dc049a91681..7c396167db8d2bb95af7705a0af6d73f5e8e6c70 100644 (file)
$event_hash->{$event_name} = $event_module;
}
my $events_string = join( ", ", @{$events_l});
- &main::daemon_log("G INFO: GosaPackages imported events $events_string", 5);
+ &main::daemon_log("G DEBUG: GosaPackages imported events $events_string", 8);
}
}
index c8078499a6eb9a8bb6ca60e74a83dc711f707c68..0bebf286da63c53ce4ca659835bc181ab3f05d6a 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("S 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";
$event_hash->{$event_name} = $event_module;
}
my $events_string = join( ", ", @{$events_l});
- &main::daemon_log("INFO: SIPackages imported events $events_string", 5);
+ &main::daemon_log("S DEBUG: SIPackages imported events $events_string", 8);
}
}
}
# Build LDAP connection
- &main::refresh_ldap_handle();
+ &main::refresh_ldap_handle();
if( not defined $main::ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
index 5fdcd06ea4f507abeedb2be6945fe4133304a62d..23b302282c6860687ddd9bc61aa09c0d01ea4dc1 100644 (file)
# clean up header
$header =~ s/CLMSG_//g;
- # check if installation finished
+ # TASKBEGIN eq finish or faiend
if (($content eq 'finish') || ($content eq 'faiend')){
- my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='done', result='$header "."$content' ".
- "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 $add_hash = { table=>$main::job_queue_tn,
-# primkey=> ['id'],
-# timestamp=>&get_time,
-# status=>"'processing'",
-# result=>"'$header $content'",
-# progress=>"'none'",
-# headertag=>"'trigger_action_reinstall'",
-# targettag=>"'none'",
-# xmlmessage=>"'none'",
-# macaddress=>"'$macaddress'",
-# };
-# my ($res, $error_str) = $main::job_db->add_dbentry( $add_hash );
-# if ($res != 0) {
-# &main::daemon_log("$session_id ERROR: $res - can not add entry to $main::job_queue_tn: $error_str");
-# } else {
-# &main::daemon_log("$session_id INFO: '$header' at '$macaddress' - '$content'", 5);
-# }
-#
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='done', result='$header "."$content' ".
+ "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);
+
# set fai_state to localboot
&main::change_fai_state('localboot', \@{$msg_hash->{'macaddress'}}, $session_id);
+ # other TASKBEGIN msgs
} 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("$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 $add_hash = { table=>$main::job_queue_tn,
-# primkey=> ['id'],
-# timestamp=>&get_time,
-# status=>"'processing'",
-# result=>"'$header $content'",
-# progress=>"'none'",
-# headertag=>"'trigger_action_reinstall'",
-# targettag=>"'none'",
-# xmlmessage=>"'none'",
-# macaddress=>"'$macaddress'",
-# };
-# my ($res, $error_str) = $main::job_db->add_dbentry( $add_hash );
-# if ($res != 0) {
-# &main::daemon_log("$session_id ERROR: $res - can not add entry to $main::job_queue_tn: $error_str");
-# } else {
-# &main::daemon_log("$session_id INFO: '$header' at '$macaddress' - '$content'", 5);
-# }
-#
+ # select processing jobs for host
+ my $sql_statement = "SELECT * 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->select_dbentry($sql_statement);
+
+ # there is exactly one job entry in queue for this host
+ if (keys(%$res) == 1) {
+ &main::daemon_log("$session_id DEBUG: there is already one processing job in queue for host '$macaddress', run an update for this entry", 7);
+ my $sql_statement = "UPDATE $main::job_queue_tn SET result='$header $content' WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ my $err = $main::job_db->update_dbentry($sql_statement);
+ if (not defined $err) {
+ &main::daemon_log("$session_id ERROR: cannot update job_db entry: ".Dumper($err), 1);
+ }
+
+ # there is no entry or more than one enties
+ } else {
+ # in case of more than one running jobs in queue, delete all jobs
+ if (keys(%$res) > 1) {
+ &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);
+ }
+ }
+
+ # in case of no and more than one running jobs in queue, add on single job
+ &main::daemon_log("$session_id DEBUG: add job to queue for host '$macaddress'", 7);
+ my $func_dic = {table=>$main::job_queue_tn,
+ primkey=>['id'],
+ timestamp=>&get_time,
+ status=>'processing',
+ result=>"$header $content",
+ progress=>'none',
+ headertag=>'trigger_action_reinstall',
+ targettag=>$source,
+ xmlmessage=>'none',
+ macaddress=>$macaddress,
+ };
+ my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
+ if ($err != 0) {
+ &main::daemon_log("$session_id ERROR: cannot add entry to job_db: $error_str", 1);
+ }
+
+ }
+
+ #my $sql_statement = "UPDATE $main::job_queue_tn ".
+ # "SET status='processing', result='$header "."$content' ".
+ # "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>
index e50915fc39c9884215416fda8a36cf740eca6691..2bb2e487ded26b676375b9e90004f224250734f9 100644 (file)
return \@events;
}
-sub query_fai_release { return &query_db( @_ ); }
-sub query_fai_server { return &query_db( @_ ) ; }
+sub query_fai_releases{ return &query_db( @_ ); }
+sub query_fai_server{ return &query_db( @_ ) ; }
sub query_packages_list { return &query_db( @_ ) ; }
sub query_jobdb { return &query_db( @_ ) ; }
sub query_db {
} elsif( $header =~ /query_fai_server/ ) {
$table = $main::fai_server_tn;
$db = $main::fai_server_db;
- } elsif( $header =~ /query_fai_release/ ) {
+ } elsif( $header =~ /count_fai_release/ ) {
$table = $main::fai_release_tn;
$db = $main::fai_server_db;
}
return @out_msg_l;
}
-sub count_fai_release { return &count_db( @_ ); }
-sub count_fai_server { return &count_db( @_ ); }
-sub count_packages_list { return &count_db( @_ ); }
+sub count_fai_releas{ return &count_db( @_ ); }
+sub count_fai_server{ return &count_db( @_ ); }
+sub count_packages_list{ return &count_db( @_ ); }
sub count_jobdb{ return &count_db( @_ ); }
sub count_db {
my ($msg, $msg_hash, $session_id) = @_;
index f069da1d4eb46362f612591af2f2c8e161374f8a..7c15ab22b5fc22faf0f9e4f5933cbe77cc9fc65b 100644 (file)
push(@out_msg_l, $msg);
&main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
- &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
+ &main::change_fai_state('install', \@{$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 ".
index 55e3be017a1bbe648e42800731c77d2aa56ebf2f..53ae3d58fc916564ea2bf1fb035105d9ed7f644d 100644 (file)
my $header = @{$msg_hash->{header}}[0];
my $target = @{$msg_hash->{$header}}[0];
- my $out_msg = &SIPackages::new_ldap_config($target);
+ my $out_msg = &SIPackages::new_ldap_config($target, $session_id);
my @out_msg_l = ( $out_msg );
return @out_msg_l;
}