summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e65b722)
raw | patch | inline | side by side (parent: e65b722)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Mar 2008 15:35:27 +0000 (15:35 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Mar 2008 15:35:27 +0000 (15:35 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9399 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 3dcb9daf3377905a42fea3704e3ec032ada5fc17..7c8fa0ee9ef3babab9c7d40973a6e80ea4cc11d8 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
my $fai_server_file_name;
our @fai_server_col_names = ('timestamp', 'server', 'release', 'tag');
our $fai_release_tn = "fai_release";
-our @fai_release_col_names = ('timestamp', 'release', 'class');
+our @fai_release_col_names = ('timestamp', 'release', 'class', 'type');
# holds all packages available from different repositories
our $packages_list_db;
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_release_db', $fai_release_tn );
#$kernel->yield('create_packages_list_db', $sources_list );
}
my $mesg= $ldap_handle->search(
base => $main::ldap_base,
scope => 'sub',
- attrs => ['cn', 'FAIdebianRelease'],
- filter => "(&(FAIdebianRelease=*)(objectClass=FAIclass))",
+ attrs => [],
+ filter => "(&(objectClass=organizationalUnit)(ou=fai))",
);
if($mesg->{'resultCode'} == 0 &&
$mesg->count != 0) {
- foreach my $entry (@{$mesg->{entries}}) {
- if($entry->exists('FAIdebianRelease') && $entry->exists('cn')) {
- $result= $fai_server_db->add_dbentry( {
- table => $table_name,
- primkey => ['release', 'class'],
- release => $entry->get_value('FAIdebianRelease'),
- class => $entry->get_value('cn'),
- } );
+ # Walk through all possible FAI container ou's
+ foreach my $ou (@{$mesg->{entries}}) {
+ my $tmp_classes= resolve_fai_classes($ou->dn);
+ #daemon_log(Dumper($tmp_classes),1);
+ last;
+ #$result= $fai_server_db->add_dbentry( {
+ # table => $table_name,
+ # primkey => ['release', 'class'],
+ # release => $tmp_release,
+ # class => $entry->get_value('cn'),
+ # } );
+ }
+
+ }
+ exit(0);
+ }
+
+ return $result;
+}
+
+sub resolve_fai_classes {
+ my $result;
+ my $fai_base= shift;
+ my $fai_hash= shift;
+ my @possible_fai_classes= ("FAIscript", "FAIhook", "FAIpartitionTable", "FAItemplate", "FAIvariable", "FAIprofile", "FAIpackageList");
+ my $fai_filter= "(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))";
+ my $fai_classes;
+
+ #daemon_log("Searching in base $fai_base",6);
+ my $mesg= $ldap_handle->search(
+ base => $fai_base,
+ scope => 'sub',
+ attrs => ['cn','objectClass','FAIstate'],
+ filter => $fai_filter,
+ );
+
+ if($mesg->{'resultCode'} == 0 &&
+ $mesg->count != 0) {
+ foreach my $entry (@{$mesg->{entries}}) {
+ if($entry->exists('cn') && (!($entry->get_value('cn') eq 'LAST')) ) {
+ my $tmp_dn= $entry->dn();
+
+ # Skip classname and ou dn parts for class
+ my $tmp_release = ($1) if $tmp_dn =~ /^[^,]+,[^,]+,(.*?),$fai_base$/;
+
+ # Skip classes without releases
+ if((!defined($tmp_release)) || length($tmp_release)==0) {
+ next;
+ }
+
+ my $tmp_cn= $entry->get_value('cn');
+ my $tmp_state= $entry->get_value('FAIstate');
+
+ my $tmp_type;
+ # Get FAI type
+ for my $oclass(@{$entry->get_value('objectClass', asref => 1)}) {
+ if(grep $_ eq $oclass, @possible_fai_classes) {
+ $tmp_type= $oclass;
+ last;
+ }
+ }
+
+ if($tmp_release =~ /^.*?,.*?$/ && (!($tmp_release =~ /^.*?\\,.*?$/))) {
+ # A Subrelease
+ my @sub_releases = split(/,/, $tmp_release);
+
+ # Walk through subreleases and build hash tree
+ my $hash;
+ while(my $tmp_sub_release = pop @sub_releases) {
+ $hash .= "\{'$tmp_sub_release'\}->";
+ }
+ eval('push @{$fai_classes->'.$hash.'{$tmp_cn}->{$tmp_type}}, (defined($tmp_state) && length($tmp_state)>0)?$tmp_state:"";');
+ } else {
+ # A branch, no subrelease
+ push @{$fai_classes->{$tmp_release}->{$tmp_cn}->{$tmp_type}}, (defined($tmp_state) && length($tmp_state)>0)?$tmp_state:"";
}
}
}
- }
-
+
+ # The hash is complete, now we can honor the copy-on-write based missing entries
+ foreach my $release (keys %$fai_classes) {
+ # Prepare the classes
+ my $tmp_classes;
+
+ # Get the classes from the branch
+ foreach my $class (keys %{$fai_classes->{$release}}) {
+ # Skip subreleases
+ if($class =~ /^ou=.*$/) {
+ next;
+ } else {
+ my $text = Data::Dumper->new([$fai_classes->{$release}->{$class}])->Purity(1)->Terse(1)->Deepcopy(1)->Dump();
+ $tmp_classes->{$class => "nix"};
+ eval "$tmp_classes->{$class}->$text;";
+ daemon_log("eval $tmp_classes->{$class}->$text;",1);
+ daemon_log(Dumper($tmp_classes),1);
+ exit(1);
+ }
+ }
+
+ if(ref $fai_classes->{$release} eq 'HASH') {
+ foreach my $sub_release (keys %{$fai_classes->{$release}}) {
+ if($sub_release =~ /^ou=.*$/) {
+
+ }
+ }
+ }
+ }
+
+ $result= $fai_classes;
+ }
+
return $result;
}
+sub get_fai_classes {
+ my $result;
+ my $fai_release = shift || return;
+ my $fai_classes = shift || return;
+
+ #daemon_log("Searching classes for release $fai_release",1);
+ foreach my $class (keys %{$fai_classes->{$fai_release}}) {
+ # Skip subreleases
+ if($class =~ /^ou=.*$/) {
+ next;
+ } else {
+ $result->{$class}= $fai_classes->{$fai_release}->{$class};
+ }
+ }
+
+ return $result;
+}
sub create_packages_list_db {
my ($sources_file) = $_[ARG0] ;