The Kelvin HTTP-API should execute some kind of hooks that allow changing the behavior of the user resource. It should be as simple as possible to adapt existing python import hooks (subclasses of ucsschool.importer.utils.import_pyhook.ImportPyHook) to use in the Kelvin API.
/var/lib/ucs-school-import/kelvin-hooks is a volume mounted into the docker container, so it can be accessed from the host. The directory content will be scanned when the Kelvin API server starts. [feature/kelvin e7b0c4515] Bug #50711: host accessable directory for kelvin import hooks
/var/lib/ucs-school-import/kelvin-hooks is a volume mounted into the docker container, so it can be accessed from the host. If it contains hook classes that inherit from ucsschool.importer.utils.import_pyhook.ImportPyHook, they are executed when users are managed through the Kelvin API. The hooks are very similar to the Python hooks for the UCS@school import. The differences are: * Python 3.7 only * Only three types of hooks are executed: ``UserPyHook``, ``FormatPyHook`` and ``ConfigPyHook`` (all located in modules in the ``ucsschool.importer.utils`` package). * ``self.dry_run`` is always ``False`` * ``self.lo`` is always a LDAP connection with write permissions (``cn=admin``) as ``dry_run`` is always ``False`` * ``FormatPyHook`` and ``ConfigPyHook`` are the same as in the UCS@school import, but a ``UserPyHook`` hook instance has an additional member ``self.udm``. [feature/kelvin] ea16c2346 Bug #50711: add support for executing import hooks in Kelvin API [feature/kelvin] 95a556019 Bug #50711: fix encoding and role detection [feature/kelvin] 77323a961 Bug #50711: fix test [feature/kelvin] e0360a5d7 Bug #50711: add tests for hooks [feature/kelvin] 0c15278c4 Bug #50711: linting fixes
[feature/kelvin b5d7f1dda] Bug #50711: improve readme in hook dir
In contrast to the UCS@school import, the Kelvin API server should not stop working, when a hook with an error is loaded: [feature/kelvin] 053b461ec Bug #50711: prevent crashing API server when failing to load a hook The hook tests didn't remove their files from the Python cache and contained duplicate code: [feature/kelvin] e1f167ad5 Bug #50711: cleanup python cache, refactor common code Linting fixes: [feature/kelvin] 508bac753 Bug #50711: fix format
[feature/kelvin fa879a099] Bug #50711: remove temporary files after test run
What I tested: Tests look good and are green -> OK Added a hook -> OK -> Verified
A Kelvin API app with the changes in this bug has been published.