From 5dea7ec50434d0d9bd1449c5a458d7f2b48e1ffc Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 4 Jan 2008 00:28:45 +0000 Subject: more work at refactoring of the way attributes are handled: * finished and integrated support for declaring known attributes from within plugins (they need to install a AttrInfo module) * implemented support for checking which attributes are applicable to systems and clients respectively * adjusted slxconfig to new attribute handling (systems only at the moment) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1442 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/DBSchema.pm | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'config-db/OpenSLX/DBSchema.pm') diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm index 9b692b59..54596c9f 100644 --- a/config-db/OpenSLX/DBSchema.pm +++ b/config-db/OpenSLX/DBSchema.pm @@ -23,10 +23,13 @@ $VERSION = 0.2; @ISA = qw(Exporter); @EXPORT = qw( - $DbSchema %DbSchemaHistory + $DbSchema %DbSchemaHistory %AttributeInfo ); -our ($DbSchema, %DbSchemaHistory); +our ($DbSchema, %DbSchemaHistory, %AttributeInfo); + + +use OpenSLX::Basics; use POSIX qw(locale_h); my $lang = setlocale(LC_MESSAGES); @@ -254,12 +257,22 @@ $DbSchema = { 'name' => 'ramfs_fsmods', 'value' => '', }, + { + 'system_id' => 0, + 'name' => 'ramfs_miscmods', + 'value' => '', + }, { 'system_id' => 0, 'name' => 'ramfs_nicmods', 'value' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32', }, + { + 'system_id' => 0, + 'name' => 'ramfs_screen', + 'value' => '', + }, { 'system_id' => 0, 'name' => 'sane_scanner', @@ -448,7 +461,7 @@ $DbSchema = { foreach my $key (keys %$system) { next if substr($key, 0, 5) ne 'attr_'; my $attrValue = $system->{$key} || ''; - next if !length($attrValue); + next if $system->{id}>0 && !length($attrValue); my $newAttrName = substr($key, 5); $configDB->setSystemAttr( $system->{id}, $newAttrName, $attrValue @@ -516,4 +529,26 @@ $DbSchema = { ], ); + +################################################################################ +### +### Load all available AttrInfo modules and build the complete hash containing +### info about all known attributes from that. +### +################################################################################ + +%AttributeInfo = (); + +my $libPath = "$openslxConfig{'base-path'}/lib"; +foreach my $module (glob("$libPath/OpenSLX/AttrInfo/*.pm")) { + next if $module !~ m{/([^/]+)\.pm$}; + my $class = "OpenSLX::AttrInfo::$1"; + vlog(2, "loading attr-info from module '$module'"); + my $instance = instantiateClass($class); + my $attrInfo = $instance->AttrInfo(); + foreach my $attr (keys %$attrInfo) { + $AttributeInfo{$attr} = $attrInfo->{$attr}; + } +} + 1; -- cgit v1.2.3-55-g7522