summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX/OSPlugin
diff options
context:
space:
mode:
authorOliver Tappe2008-05-20 15:26:55 +0200
committerOliver Tappe2008-05-20 15:26:55 +0200
commitbeab72fc0ec3a6d857f4c64e3d08dcbf9c457c61 (patch)
treebef314bb7d5ac0e9a65748fbece3b7686523f48f /os-plugins/OpenSLX/OSPlugin
parent* more work at desktop plugin (GDM & KDM should now work on SUSE & Ubuntu) (diff)
downloadcore-beab72fc0ec3a6d857f4c64e3d08dcbf9c457c61.tar.gz
core-beab72fc0ec3a6d857f4c64e3d08dcbf9c457c61.tar.xz
core-beab72fc0ec3a6d857f4c64e3d08dcbf9c457c61.zip
* added support to slxconfig for checking the given attribute values against
their respective regex, an appropriate complaint is shown if the value doesn't match git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1778 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Base.pm40
1 files changed, 38 insertions, 2 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm
index eee7ae4f..b4a3ad02 100644
--- a/os-plugins/OpenSLX/OSPlugin/Base.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Base.pm
@@ -172,8 +172,6 @@ sub getAttrInfo
Returns a hash-ref with the default attribute values for the given vendor-OS.
-
-
=cut
sub getDefaultAttrsForVendorOS
@@ -184,6 +182,44 @@ sub getDefaultAttrsForVendorOS
return $self->getAttrInfo();
}
+=item checkValueForKey()
+
+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.
+
+Plugins may override this implementation to do additional checks that look
+at the vendor-OS (stage1-)attributes.
+
+=cut
+
+sub checkValueForKey
+{
+ my $self = shift;
+ my $key = shift;
+ my $value = shift;
+
+ # undefined values are always allowed
+ return 1 if !defined $value;
+
+ # the default implementation checks the value against the regex of the
+ # attribute (if any)
+ my $attrInfo
+ = $self->getAttrInfo()->{$key}
+ || die _tr('attribute "%s" is unknown!', $key);
+
+ my $regex = $attrInfo->{content_regex};
+ return 1 if !$regex;
+
+ return 1 if $value =~ m{$regex};
+
+ die _tr(
+ "value given for attribute %s is not allowed.\nAllowed values are: %s",
+ $key, $attrInfo->{content_descr}
+ );
+}
+
+
=back
=head2 Vendor-OS Interface