diff options
Diffstat (limited to 'config-db/OpenSLX')
-rw-r--r-- | config-db/OpenSLX/Basics.pm | 34 | ||||
-rw-r--r-- | config-db/OpenSLX/ConfigDB.pm | 82 |
2 files changed, 57 insertions, 59 deletions
diff --git a/config-db/OpenSLX/Basics.pm b/config-db/OpenSLX/Basics.pm index ea519458..9fecd10a 100644 --- a/config-db/OpenSLX/Basics.pm +++ b/config-db/OpenSLX/Basics.pm @@ -32,12 +32,15 @@ my $loadedTranslationModule; 'db-type' => 'CSV', 'locale' => $ENV{LANG}, # TODO: may need to be improved in order to be portable - 'private-basepath' => '/var/lib/openslx', - 'public-basepath' => '/srv/openslx', - 'shared-basepath' => '/usr/share/openslx', + 'config-path' => '/etc/opt/openslx', + 'openslx-basepath' => '/opt/openslx', + 'private-path' => '/var/opt/openslx', + 'public-path' => '/srv/openslx', 'temp-basepath' => '/tmp', ); -$openslxConfig{'db-basepath'} = "$openslxConfig{'private-basepath'}/db", +$openslxConfig{'db-basepath'} = "$openslxConfig{'private-path'}/db", +$openslxConfig{'bin-path'} = "$openslxConfig{'openslx-basepath'}/bin", +$openslxConfig{'share-path'} = "$openslxConfig{'openslx-basepath'}/share", # specification of cmdline arguments that are shared by all openslx-scripts: my %openslxCmdlineArgs = ( @@ -57,14 +60,21 @@ my %openslxCmdlineArgs = ( # locale to use for translations 'logfile=s' => \$openslxConfig{'locale'}, # file to write logging output to, defaults to STDERR - 'private-basepath=s' => \$openslxConfig{'private-basepath'}, - # basic path to private data (which is accessible for clients and + 'bin-path=s' => \$openslxConfig{'bin-path'}, + # path to binaries and scripts + 'config-path=s' => \$openslxConfig{'config-path'}, + # path to configuration files + 'openslx-basepath=s' => \$openslxConfig{'openslx-basepath'}, + # basic path to project files (binaries, functionality templates and + # distro-specs) + 'private-path=s' => \$openslxConfig{'private-path'}, + # path to private data (which is accessible for clients and # contains all data required for booting the clients) - 'public-basepath=s' => \$openslxConfig{'public-basepath'}, - # basic path to public data (which contains database, vendorOSes + 'public-path=s' => \$openslxConfig{'public-path'}, + # path to public data (which contains database, vendorOSes # and all local extensions [system specific scripts]) - 'shared-basepath=s' => \$openslxConfig{'shared-basepath'}, - # basic path to shared data (functionality templates and distro-specs) + 'share-path=s' => \$openslxConfig{'share-path'}, + # path to sharable data (functionality templates and distro-specs) 'temp-basepath=s' => \$openslxConfig{'temp-basepath'}, # basic path to temporary data (used during demuxing) 'verbose-level=i' => \$openslxConfig{'verbose-level'}, @@ -86,8 +96,8 @@ sub vlog sub openslxInit { # try to read and evaluate config files: - foreach my $f ("/etc/openslx/settings.default", - "/etc/openslx/settings.local", + foreach my $f ("$openslxConfig{'config-path'}/settings.default", + "$openslxConfig{'config-path'}/settings.local", "$ENV{HOME}/.openslx/settings") { next unless open(CONFIG, "<$f"); while(<CONFIG>) { diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm index b9e69d77..3db779e2 100644 --- a/config-db/OpenSLX/ConfigDB.pm +++ b/config-db/OpenSLX/ConfigDB.pm @@ -52,7 +52,7 @@ my @aggregationExports = qw( mergeDefaultAttributesIntoSystem mergeDefaultAndGroupAttributesIntoClient aggregatedSystemIDsOfClient aggregatedClientIDsOfSystem - aggregatedKernelFilesOfSystem aggregatedInitramFilesOfSystem + aggregatedSystemFileInfosOfSystem ); my @supportExports = qw( @@ -146,6 +146,14 @@ sub _unique return grep { !$seenIDs{$_}++; } @_; } +sub _uniqueByKey +{ # return given array filtered to unique key elements + my $key = shift; + + my %seenIDs; + return grep { !$seenIDs{$_->{$key}}++; } @_; +} + ################################################################################ ### data access interface ################################################################################ @@ -418,8 +426,7 @@ sub setClientIDsOfSystem my $systemID = shift; my $clientIDs = _aref(shift); - my %seen; - my @uniqueClientIDs = grep { !$seen{$_}++ } @$clientIDs; + my @uniqueClientIDs = _unique(@$clientIDs); return $confDB->{'meta-db'}->setClientIDsOfSystem($systemID, \@uniqueClientIDs); } @@ -455,8 +462,7 @@ sub setGroupIDsOfSystem my $systemID = shift; my $groupIDs = _aref(shift); - my %seen; - my @uniqueGroupIDs = grep { !$seen{$_}++ } @$groupIDs; + my @uniqueGroupIDs = _unique(@$groupIDs); return $confDB->{'meta-db'}->setGroupIDsOfSystem($systemID, \@uniqueGroupIDs); } @@ -542,8 +548,7 @@ sub setSystemIDsOfClient my $clientID = shift; my $systemIDs = _aref(shift); - my %seen; - my @uniqueSystemIDs = grep { !$seen{$_}++ } @$systemIDs; + my @uniqueSystemIDs = _unique(@$systemIDs); return $confDB->{'meta-db'}->setSystemIDsOfClient($clientID, \@uniqueSystemIDs); } @@ -579,8 +584,7 @@ sub setGroupIDsOfClient my $clientID = shift; my $groupIDs = _aref(shift); - my %seen; - my @uniqueGroupIDs = grep { !$seen{$_}++ } @$groupIDs; + my @uniqueGroupIDs = _unique(@$groupIDs); return $confDB->{'meta-db'}->setGroupIDsOfClient($clientID, \@uniqueGroupIDs); } @@ -641,8 +645,7 @@ sub setClientIDsOfGroup my $groupID = shift; my $clientIDs = _aref(shift); - my %seen; - my @uniqueClientIDs = grep { !$seen{$_}++ } @$clientIDs; + my @uniqueClientIDs = _unique(@$clientIDs); return $confDB->{'meta-db'}->setClientIDsOfGroup($groupID, \@uniqueClientIDs); } @@ -678,8 +681,7 @@ sub setSystemIDsOfGroup my $groupID = shift; my $systemIDs = _aref(shift); - my %seen; - my @uniqueSystemIDs = grep { !$seen{$_}++ } @$systemIDs; + my @uniqueSystemIDs = _unique(@$systemIDs); return $confDB->{'meta-db'}->setSystemIDsOfGroup($groupID, \@uniqueSystemIDs); } @@ -766,9 +768,7 @@ sub aggregatedSystemIDsOfClient # add all systems inherited from default client push @systemIDs, fetchSystemIDsOfClient($confDB, 0); - my %seenIDs; - return grep { !$seenIDs{$_}++; } @systemIDs; - # return unique list + return _unique(@systemIDs); } sub aggregatedClientIDsOfSystem @@ -791,49 +791,37 @@ sub aggregatedClientIDsOfSystem # add all clients inherited from default system push @clientIDs, fetchClientIDsOfSystem($confDB, 0); - my %seenIDs; - return grep { !$seenIDs{$_}++; } @clientIDs; - # return unique list + return _unique(@clientIDs); } -sub aggregatedKernelFilesOfSystem -{ # return aggregated list of kernel-files this system is using - # (as indicated by itself and system's variants) +sub aggregatedSystemFileInfosOfSystem +{ # return aggregated list of hash-refs that contain information about + # the kernel- and initialramfs-files this system is using + # (as indicated by itself and the system's variants) my $confDB = shift; my $system = shift; my $vendorOS = fetchVendorOSesByID($confDB, $system->{vendor_os_id}); return () if !$vendorOS || !length($vendorOS->{path}); my $kernelPath - = "$openslxConfig{'private-basepath'}/stage1/$vendorOS->{path}"; + = "$openslxConfig{'private-path'}/stage1/$vendorOS->{path}"; my @variantIDs = fetchSystemVariantIDsOfSystem($confDB, $system->{id}); my @variants = fetchSystemVariantsByID($confDB, \@variantIDs); - my @kernelFiles = map { "$kernelPath/$_->{kernel}" } - grep { length($_->{kernel}) > 0 } - ($system, @variants); - return _unique(@kernelFiles); -} - -sub aggregatedInitramSetupsOfSystem -{ # return aggregated list of initialramfs-setups this system is using - # (as indicated by itself and system's variants) - my $confDB = shift; - my $system = shift; - - my $vendorOS = fetchVendorOSesByID($confDB, $system->{vendor_os_id}); - return () if !$vendorOS || !length($vendorOS->{path}); - my $kernelPath - = "$openslxConfig{'private-basepath'}/stage1/$vendorOS->{path}"; - - my @variantIDs = fetchSystemVariantIDsOfSystem($confDB, $system->{id}); - my @variants = fetchSystemVariantsByID($confDB, \@variantIDs); - - my @initramFiles = map { "$kernelPath/$_->{initramfs}" } - grep { length($_->{initramfs}) > 0 } - ($system, @variants); - return _unique(@initramFiles); + my @infos; + foreach my $sys ($system, @variants) { + next if !length($sys->{kernel}); + my %info = %$sys; + $info{'kernel-file'} = "$kernelPath/$sys->{kernel}"; + if (!defined $info{'name'}) { + # compose full name and label for system-variant: + $info{'name'} = "$system->{name}-$info{name_addition}"; + $info{'label'} = "$system->{label} $info{label_addition}"; + } + push @infos, \%info; + } + return _uniqueByKey('name', @infos); } ################################################################################ |