diff options
| author | Oliver Tappe | 2008-05-24 18:25:22 +0200 |
|---|---|---|
| committer | Oliver Tappe | 2008-05-24 18:25:22 +0200 |
| commit | da7455266023274dd1aca1fb9854a6bbe8985f67 (patch) | |
| tree | 4df4005fe5fddc52fc9ffd315fa1664b2827d91b /os-plugins/OpenSLX | |
| parent | * fixed a problem with a failing child process passing the death gate by thro... (diff) | |
| download | core-da7455266023274dd1aca1fb9854a6bbe8985f67.tar.gz core-da7455266023274dd1aca1fb9854a6bbe8985f67.tar.xz core-da7455266023274dd1aca1fb9854a6bbe8985f67.zip | |
* heavily redesigned and improved the checking of attributes: instead of dying
on the first error, we now collect all errors and return them. The caller can
now decide what to do - die or just print a warning or whatever.
* slxconfig now dies with the list of all attribute problems if there were any
* slxconfig-demuxer prints warnings for all attribute problems that were found
(checking for each system & client in turn)
* adjusted desktop plugin to API changes concerning the attribute checks
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1796 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX')
| -rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Base.pm | 5 | ||||
| -rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Engine.pm | 41 |
2 files changed, 38 insertions, 8 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm index 8c314ff5..a07ec125 100644 --- a/os-plugins/OpenSLX/OSPlugin/Base.pm +++ b/os-plugins/OpenSLX/OSPlugin/Base.pm @@ -187,7 +187,8 @@ sub getDefaultAttrsForVendorOS Checks if the stage3 values given in B<$stage3Attrs> are allowed and makes sense. -If all values are ok, this method returns 1 - if not, it dies with an appropriate message. +This method returns an array-ref of problems found. If there were no problems, +this methods returns undef. Plugins may override this implementation to do checks that for instance look at the stage1 vendor-OS-attributes given in B<$vendorOSAttrs>. @@ -206,7 +207,7 @@ sub checkStage3AttrValues # this default implementation does no further checks (thus relying on the # attributte regex check that is done in the AttributeRoster) - return 1; + return; } =back diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index ada0af79..75ba3154 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -157,8 +157,8 @@ sub installPlugin # as the attrs may be changed by the plugin during installation, we # have to find a way to pass them back to this process (remember; # installation takes place in a forked process in order to do a chroot). - # We simply serialize the attributes into a temp and deserialize it - # in the calling process. + # We simply serialize the attributes into a temp file and deserialize + # it in the calling process. my $serializedAttrsFile = "$self->{'plugin-temp-path'}/serialized-attrs"; my $chrootedSerializedAttrsFile @@ -458,8 +458,8 @@ install/remove a plugin into/from a vendor-OS: Checks if the stage3 values given in B<$stage3Attrs> are allowed and make sense. -If all values are ok, this method returns 1 - if not, it dies with an -appropriate message. +If all values are ok, this method returns 1 - if not, it extends the given +problems array-ref with the problems that were found (and returns undef). This method chroots into the vendor-OS and then asks the plugin itself to check the attributes. @@ -470,16 +470,45 @@ sub checkStage3AttrValues { my $self = shift; my $stage3Attrs = shift; - + my $problemsOut = shift; + + # as the attrs may be changed by the plugin during installation, we + # have to find a way to pass them back to this process (remember; + # installation takes place in a forked process in order to do a chroot). + # We simply serialize the attributes into a temp file and deserialize + # it in the calling process. + my $serializedProblemsFile + = "$self->{'plugin-temp-path'}/serialized-problems"; + my $chrootedSerializedProblemsFile + = "$self->{'chrooted-plugin-temp-path'}/serialized-problems"; + + mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); + + # HACK: do a dummy serialization here in order to get Storable + # completely loaded (otherwise it will complain in the chroot about + # missing modules). + store [], $serializedProblemsFile; + $self->_callChrootedFunctionForPlugin( sub { # let plugin check by itself - $self->{plugin}->checkStage3AttrValues( + my $problems = $self->{plugin}->checkStage3AttrValues( $stage3Attrs, $self->{'vendorOS-attrs'} ); + + # serialize list of problems (executed inside chroot) + store($problems, $chrootedSerializedProblemsFile) if $problems; } ); + # now retrieve (deserialize) the found problems and pass them on + my $problems = retrieve $serializedProblemsFile; + rmtree([ $self->{'plugin-temp-path'} ]); + if ($problems && ref($problems) eq 'ARRAY' && @$problems) { + push @$problemsOut, @$problems; + return; + } + return 1; } |
