diff options
author | Oliver Tappe | 2008-05-22 22:01:34 +0200 |
---|---|---|
committer | Oliver Tappe | 2008-05-22 22:01:34 +0200 |
commit | 2a614b1103699d60e7e2999030d64e2adc9a6955 (patch) | |
tree | 0e0ffd2962e5835f08e3749d258cd36d9e3a7a79 /config-db/OpenSLX | |
parent | * supress lib error while giving vmware its own font config (diff) | |
download | core-2a614b1103699d60e7e2999030d64e2adc9a6955.tar.gz core-2a614b1103699d60e7e2999030d64e2adc9a6955.tar.xz core-2a614b1103699d60e7e2999030d64e2adc9a6955.zip |
* attributes set via slxconfig are now being checked not only against the respective
regex, but the corresponding plugin is being invoked to do a check of its own, too
(where it has the chance to look at the vendor-OS attributes and determine the
possible stage3-values from their state).
* listing a vendor-OS in verbose mode now shows the vendor-OS attributes (stage1 &
stage3), too
* used Clone::clone instead of Storable::dclone since the latter is not capable of
cloning compiled regexes
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1783 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/OpenSLX')
-rw-r--r-- | config-db/OpenSLX/AttributeRoster.pm | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/config-db/OpenSLX/AttributeRoster.pm b/config-db/OpenSLX/AttributeRoster.pm index 331ac70c..13c7640d 100644 --- a/config-db/OpenSLX/AttributeRoster.pm +++ b/config-db/OpenSLX/AttributeRoster.pm @@ -17,6 +17,7 @@ use strict; use warnings; use OpenSLX::Basics; +use OpenSLX::OSPlugin::Engine; use OpenSLX::OSPlugin::Roster; use OpenSLX::Utils; @@ -370,6 +371,8 @@ sub _init # and add all plugin attributes, too OpenSLX::OSPlugin::Roster->addAllStage3AttributesToHash(\%AttributeInfo); + + return 1; } =item C<getAttrInfo()> @@ -495,43 +498,57 @@ sub getClientAttrs keys %AttributeInfo } -=item C<checkValueForKey()> +=item C<checkValues()> -Checks if the given value is allowed (and makes sense) for the given key. -If the value is ok, this method returns 1 - if not, it dies with an appropriate -message. +Checks if the given stage3 attribute values are allowed (and make sense). +If all values are ok, this method returns 1 - if not, it dies with an +appropriate message. =cut -sub checkValueForKey +sub checkValues { - my $class = shift; - my $key = shift; - my $value = shift; + my $class = shift; + my $stage3Attrs = shift || {}; + my $vendorOSName = shift or die ('need vendor-OS-name!'); $class->_init() if !%AttributeInfo; - # undefined values are always allowed - return 1 if !defined $value; - - # check the value against the regex of the attribute (if any) - my $attrInfo = $AttributeInfo{$key} - || die _tr('attribute "%s" is unknown!', $key); - my $regex = $attrInfo->{content_regex}; - if ($regex && $value !~ m{$regex}) { - die _tr( - "value given for attribute %s is not allowed.\nAllowed values are: %s", - $key, $attrInfo->{content_descr} - ); + my %attrsByPlugin; + foreach my $key (sort keys %{$stage3Attrs}) { + my $value = $stage3Attrs->{$key}; + if ($key =~ m{^(.+)::.+?$}) { + my $pluginName = $1; + $attrsByPlugin{$pluginName} ||= {}; + $attrsByPlugin{$pluginName}->{$key} = $value; + } + + # undefined values are always allowed + next if !defined $value; + + # check the value against the regex of the attribute (if any) + my $attrInfo = $AttributeInfo{$key} + || die _tr('attribute "%s" is unknown!', $key); + my $regex = $attrInfo->{content_regex}; + if ($regex && $value !~ $regex) { + die _tr( + "the value '%s' for attribute %s is not allowed.\nAllowed values are: %s", + $value, $key, $attrInfo->{content_descr} + ); + } } - # let plugin check by itself - if ($key =~ m{^(.+)::.+?$}) { - my $pluginName = $1; - my $plugin - = OpenSLX::OSPlugin::Roster->getPlugin($pluginName) - || die _tr('unable to load plugin "%s"', $pluginName); - $plugin->checkValueForKey($key, $value); + # now give each plugin a chance to check it's own attributes by itself + foreach my $pluginName (sort keys %attrsByPlugin) { + # create & start OSPlugin-engine for vendor-OS and current plugin + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize($pluginName, $vendorOSName); + if (!$engine->{'plugin-path'}) { + warn _tr('unable to create engine for plugin "%s"!', $pluginName); + next; + } + $engine->checkStage3AttrValues($attrsByPlugin{$pluginName}); } } + 1; |