From 215428623609cf09b9879bf53e79b2afa5d5f345 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 3 Aug 2007 13:27:53 +0000 Subject: * fixed several default-system and -client related bugs introduced yesterday, which rendered the slxconfig-demuxer pretty useless git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1311 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/ConfigDB.pm | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'config-db') diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm index e9779747..7bcce91d 100644 --- a/config-db/OpenSLX/ConfigDB.pm +++ b/config-db/OpenSLX/ConfigDB.pm @@ -2012,19 +2012,17 @@ sub emptyDatabase $self->removeGroup(\@groupIDs); my @clientIDs = map { $_->{id} } - grep { $_->{id} > 0 } $self->fetchClientByFilter(); + grep { $_->{name} ne '<<>>' } $self->fetchClientByFilter(); $self->removeClient(\@clientIDs); my @sysIDs = map { $_->{id} } - grep { $_->{id} > 0 } $self->fetchSystemByFilter(); + grep { $_->{name} ne '<<>>' } $self->fetchSystemByFilter(); $self->removeSystem(\@sysIDs); - my @exportIDs = map { $_->{id} } - grep { $_->{id} > 0 } $self->fetchExportByFilter(); + my @exportIDs = map { $_->{id} } $self->fetchExportByFilter(); $self->removeExport(\@exportIDs); - my @vendorOSIDs = map { $_->{id} } - grep { $_->{id} > 0 } $self->fetchVendorOSByFilter(); + my @vendorOSIDs = map { $_->{id} } $self->fetchVendorOSByFilter(); $self->removeVendorOS(\@vendorOSIDs); return; } @@ -2059,10 +2057,10 @@ sub mergeDefaultAttributesIntoSystem my $self = shift; my $system = shift; - my $defaultSystem = $self->fetchSystemByID(0); + my $defaultSystem = $self->fetchSystemByFilter({name => '<<>>'}); mergeAttributes($system, $defaultSystem); - my $defaultClient = $self->fetchClientByID(0); + my $defaultClient = $self->fetchClientByFilter({name => '<<>>'}); pushAttributes($system, $defaultClient); return; } @@ -2105,7 +2103,7 @@ sub mergeDefaultAndGroupAttributesIntoClient # merge configuration from default client: vlog(3, _tr('merging from default client...')); - my $defaultClient = $self->fetchClientByID(0); + my $defaultClient = $self->fetchClientByFilter({name => '<<>>'}); mergeAttributes($client, $defaultClient); return; } @@ -2146,7 +2144,8 @@ sub aggregatedSystemIDsOfClient } # add all systems inherited from default client - push @systemIDs, $self->fetchSystemIDsOfClient(0); + my $defaultClient = $self->fetchClientByFilter({name => '<<>>'}); + push @systemIDs, $self->fetchSystemIDsOfClient($defaultClient->{id}); return _unique(@systemIDs); } @@ -2176,12 +2175,13 @@ sub aggregatedClientIDsOfSystem my $system = shift; # add all clients directly linked to system: + my $defaultClient = $self->fetchClientByFilter({name => '<<>>'}); my @clientIDs = $self->fetchClientIDsOfSystem($system->{id}); - if (grep { $_ == 0; } @clientIDs) { + if (grep { $_ == $defaultClient->{id}; } @clientIDs) { # add *all* client-IDs if the system is being referenced by # the default client, as that means that all clients should offer - #this system for booting: + # this system for booting: push @clientIDs, map { $_->{id} } $self->fetchClientByFilter(undef, 'id'); } @@ -2195,7 +2195,8 @@ sub aggregatedClientIDsOfSystem } # add all clients inherited from default system - push @clientIDs, $self->fetchClientIDsOfSystem(0); + my $defaultSystem = $self->fetchSystemByFilter({name => '<<>>'}); + push @clientIDs, $self->fetchClientIDsOfSystem($defaultSystem->{id}); return _unique(@clientIDs); } @@ -2342,7 +2343,7 @@ sub mergeAttributes foreach my $key (grep { isAttribute($_) } keys %$source) { my $sourceVal = $source->{$key} || ''; my $targetVal = $target->{$key} || ''; - if (length($sourceVal) > 0 && length($targetVal) == 0) { + if (length($sourceVal) && !length($targetVal)) { vlog(3, _tr("merging %s (val=%s)", $key, $sourceVal)); $target->{$key} = $sourceVal; } @@ -2379,7 +2380,7 @@ sub pushAttributes foreach my $key (grep { isAttribute($_) } keys %$source) { my $sourceVal = $source->{$key} || ''; - if (length($sourceVal) > 0) { + if (length($sourceVal)) { vlog(3, _tr("pushing %s (val=%s)", $key, $sourceVal)); $target->{$key} = $sourceVal; } @@ -2410,7 +2411,7 @@ sub externalIDForSystem { my $system = shift; - return "default" if $system->{id} == 0; + return "default" if $system->{name} eq '<<>>'; my $name = $system->{name}; $name =~ tr[/][_]; @@ -2440,7 +2441,7 @@ sub externalIDForClient { my $client = shift; - return "default" if $client->{id} == 0; + return "default" if $client->{name} eq '<<>>'; my $mac = lc($client->{mac}); # PXE seems to expect MACs being all lowercase -- cgit v1.2.3-55-g7522