summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aecf54f)
raw | patch | inline | side by side (parent: aecf54f)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 17 Mar 2008 14:29:22 +0000 (14:29 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 17 Mar 2008 14:29:22 +0000 (14:29 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9899 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/SIPackages.pm | patch | blob | history | |
gosa-si/server/events/clMessages.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index ca0420dd627a43fd55f5e93fc99133e553cefee2..8ef8e039b532f17b5fe8bcd27ed72ea476eb1501 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;
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
-my @job_queue_col_names = ("id INTEGER", "timestamp", "status", "result", "progress INTEGER",
- "headertag", "targettag", "xmlmessage", "macaddress");
+my @job_queue_col_names = ("id INTEGER",
+ "timestamp",
+ "status DEFAULT 'none'",
+ "result DEFAULT 'none'",
+ "progress DEFAULT 'none'",
+ "headertag DEFAULT 'none'",
+ "targettag DEFAULT 'none'",
+ "xmlmessage DEFAULT 'none'",
+ "macaddress DEFAULT 'none'",
+ );
# holds all other gosa-sd as well as the gosa-sd-bus
our $known_server_db;
"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_server_db', $fai_server_tn );
#$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
}
-
sub sig_handler {
- my ($kernel, $signal) = @_[KERNEL, ARG0] ;
- daemon_log("0 INFO got signal '$signal'", 7);
- $kernel->sig_handled();
- return;
+ my ($kernel, $signal) = @_[KERNEL, ARG0] ;
+ daemon_log("0 INFO got signal '$signal'", 1);
+ $kernel->sig_handled();
+ return;
}
-
sub next_task {
my ($session, $heap) = @_[SESSION, HEAP];
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 );
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');
}
close (CONFIG);
- find(\&cleanup_and_extract, keys( %repo_dirs ) );
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);
parse_package( "$outdir/$dist/$section", $dist, $path );
}
}
-
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 %fileinfo = (
- 'package' => $package,
- 'dist' => $dist,
- 'version' => $vers,
- );
-
- $repo_files{ "${srvdir}/$file" } = \%fileinfo;
-}
-
-sub cleanup_and_extract {
-
- my %templates = ();
- my $fileinfo = $repo_files{ $File::Find::name };
-
- if( defined $fileinfo ) {
-
- my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
- system( "mkdir -p '$dir'" );
-
- system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
- if( -f "$dir/DEBIAN/templates" ) {
- my $package = $fileinfo->{ 'package' };
- my $newver = $fileinfo->{ 'version' };
-
- daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5);
- if( exists $templates{ "$fileinfo->{ 'dist' }/$package" } ) {
- my $oldver = $templates{ "$fileinfo->{ 'dist' }/$package" };
- my $ret = system( "dpkg --compare-versions '$oldver' gt '$newver'" );
- if( ! $ret ) {
- daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - keeping tmpl v'$oldver'", 5);
- return;
- }
- else {
- daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - overwriting tmpl v'$oldver'", 5);
- }
- }
- $templates{ "$fileinfo->{ 'dist' }/$package" } = $newver;
- move( "$dir/DEBIAN/templates", "$dir/$package.templates" );
- }
- }
-}
+#
+#sub store_fileinfo {
+# my( $package, $file, $dist, $path, $vers ) = @_;
+#
+# my %fileinfo = (
+# 'package' => $package,
+# 'dist' => $dist,
+# 'version' => $vers
+# );
+#
+# $repo_files{ "${srvdir}${path}/$file" } = \%fileinfo;
+#}
#==== MAIN = main ==============================================================
index 83245316007fec667035780972e76137acc6c2f2..7ee752072f553f6f864efb872c32985b4e4a3829 100644 (file)
BEGIN{}
END {}
-my ($server_ip, $server_port, $SIPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface);
+my ($server_ip, $server_mac_address, $server_port, $SIPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface);
my ($bus_activ, $bus_key, $bus_ip, $bus_port);
my $server;
my $event_hash;
},
"server" => {
"ip" => [\$server_ip, "0.0.0.0"],
- "mac-address" => [\$main::server_mac_address, "00:00:00:00:00"],
+ "mac-address" => [\$server_mac_address, "00:00:00:00:00"],
"port" => [\$server_port, "20081"],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
# if server_ip is not an ip address but a name
if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
$network_interface= &get_interface_for_ip($server_ip);
-$main::server_mac_address= &get_mac($network_interface);
+$server_mac_address= &get_mac($network_interface);
&import_events();
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
- &main::refresh_ldap_handle();
+ &main::refresh_ldap_handle();
if( defined($main::ldap_handle) ) {
- &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5);
+ &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $server_mac_address",5);
# Perform search for Unit Tag
$mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
- filter => "(macaddress=$main::server_mac_address)"
+ filter => "(macaddress=$server_mac_address)"
);
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
- $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
- $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
if ($mesg->count == 1) {
my $entry= $mesg->entry(0);
my $unit_tag= $entry->get_value("gosaUnitTag");
- $main::ldap_server_dn= $mesg->entry(0)->dn;
if(defined($unit_tag) && length($unit_tag) > 0) {
&main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5);
$main::gosa_unit_tag= $unit_tag;
my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
# A configured MAC Address should always override a guessed value
- if ($main::server_mac_address and length($main::server_mac_address) > 0) {
- $result= $main::server_mac_address;
+ if ($server_mac_address and length($server_mac_address) > 0) {
+ $result= $server_mac_address;
}
socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
if ($header eq 'new_key') {
@out_msg_l = &new_key($msg_hash)
} elsif ($header eq 'here_i_am') {
- @out_msg_l = &here_i_am($msg_hash, $session_id)
+ @out_msg_l = &here_i_am($msg, $msg_hash, $session_id)
} else {
if( exists $event_hash->{$header} ) {
# a event exists with the header as name
# DESCRIPTION: process this incoming message
#===============================================================================
sub here_i_am {
- my ($msg_hash, $session_id) = @_;
+ my ($msg, $msg_hash, $session_id) = @_;
my @out_msg_l;
my $out_hash;
push(@out_msg_l, $new_ldap_config_out);
}
- my $hardware_config_out = &hardware_config($source, $gotoHardwareChecksum);
+ my $hardware_config_out = &hardware_config($msg, $msg_hash, $session_id);
if( $hardware_config_out ) {
push(@out_msg_l, $hardware_config_out);
}
# DESCRIPTION:
#===============================================================================
sub hardware_config {
- my ($address, $gotoHardwareChecksum) = @_ ;
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $address = @{$msg_hash->{source}}[0];
+ my $header = @{$msg_hash->{header}}[0];
+ my $gotoHardwareChecksum = @{$msg_hash->{gotoHardwareChecksum}}[0];
my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'";
my $res = $main::known_clients_db->select_dbentry( $sql_statement );
if( not $hit_counter == 1 ) {
&main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
}
-
my $macaddress = $res->{1}->{macaddress};
my $hostkey = $res->{1}->{hostkey};
$data{'goto_secret'}= $goto_secret;
}
- &main::daemon_log("Send detect_hardware message to $address", 4);
+ # set status = hardware_detection at jobqueue if entry exists
+ my $func_dic = {table=>$main::job_queue_tn,
+ primkey=>['id'],
+ timestamp=>&get_time,
+ status=>'processing',
+ result=>'none',
+ progress=>'hardware-detection',
+ headertag=>$header,
+ targettag=>$address,
+ xmlmessage=>$msg,
+ macaddress=>$macaddress,
+ };
+ 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);
# Send information
+ &main::daemon_log("$session_id INFO: Send detect_hardware message to $address", 5);
return &build_msg("detect_hardware", $server_address, $address, \%data);
}
index dfac6725555c7010e51e5952778697f663a9ff64..e197b73d51135f164e2993af60bdf32734e9b496 100644 (file)
"LOGOUT",
"CURRENTLY_LOGGED_IN",
"save_fai_log",
- "goto_activation_start",
);
@EXPORT = @events;
}
-sub goto_activation_start {
- my ($msg, $msg_hash, $session_id) = @_;
- my $header = @{$msg_hash->{'header'}}[0];
- my $macaddress = @{$msg_hash->{'macaddress'}}[0];
-
- my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', progress='goto-activation' ".
- "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'", 5);
-
-}
-
-
sub save_fai_log {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
-#########
-# testing
my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-########
# clean up header
$header =~ s/CLMSG_//g;
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header"."$content' ".
+ "SET status='processing', progress='goto-activation' ".
"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);
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
- my $content = @{$msg_hash->{$header}}[0];
+ my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-########
# clean up header
$header =~ s/CLMSG_//g;
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
# clean up header
$header =~ s/CLMSG_//g;
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
# clean up header
$header =~ s/CLMSG_//g;
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'target'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
- my $content = @{$msg_hash->{$header}}[0];
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
# clean up header
$header =~ s/CLMSG_//g;
&main::change_fai_state('localboot', \@{$msg_hash->{'macaddress'}}, $session_id);
} 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);
+####################
+# under construction
+ #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',
+ macaddress=>'$macaddress',
+ );
+ my ($res, $error_str) = $main::job_db->add_dbentry( \%add_hash );
+ if ($res != 0) {
+ &main::daemon_log("$session_id ERROR: can not add entry to $main::job_queue_tn: $error_str");
+ } else {
+ &main::daemon_log("$session_id INFO: '$header' at '$macaddress' - '$content'", 5);
+ }
+# under construction
+####################
# -----------------------> Update hier
# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
- my $content = @{$msg_hash->{$header}}[0];
+ my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
# clean up header
$header =~ s/CLMSG_//g;
$header =~ s/CLMSG_//g;
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
- my $content = @{$msg_hash->{$header}}[0];
- if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
+ my $content = @{$msg_hash->{$header}}[0];
+ if(ref($content) eq "HASH") { $content = ""; }
# set fai_state to localboot
&main::change_fai_state('error', \@{$msg_hash->{'macaddress'}}, $session_id);
$header =~ s/CLMSG_//g;
# test whether content is an empty hash or a string which is required
-# TODO eval ändern auf if(ref($content) eq "HASH") dann ... else, dann...
-#########
-# testing
my $content = @{$msg_hash->{$header}}[0];
if(ref($content) eq "HASH") { $content = ""; }
- #eval{ if( 0 == keys(%$content) ) { $content = ""; } };
- #if( $@ ) { $content = "$content"; }
-# testing
-#########
my $sql_statement = "UPDATE $main::job_queue_tn ".
"SET status='processing', result='$header "."$content' ".