Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 24ff45e

Browse files
Add support for external modules
This commmit adds support to define and use external modules for custom migration steps. Signed-off-by: Tobias Wolf <[email protected]>
1 parent eca2435 commit 24ff45e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ LABEL org.opencontainers.image.source="https://github.com/SovereignCloudStack/ro
2727

2828
ARG ROOKIFY_VERSION=0.0.0.dev1
2929
ENV ROOKIFY_VERSION=$ROOKIFY_VERSION
30+
ENV PYTHONPATH="${PYTHONPATH}:/app/rookify/src"
3031

3132
WORKDIR /app/rookify
3233

src/rookify/modules/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ def _load_module(machine: Machine, config: Dict[str, Any], module_name: str) ->
3030
:return: returns tuple of preflight_modules, modules
3131
"""
3232

33-
module = importlib.import_module("rookify.modules.{0}".format(module_name))
33+
if "." in module_name:
34+
absolute_module_name = module_name
35+
else:
36+
absolute_module_name = "rookify.modules.{0}".format(module_name)
37+
38+
try:
39+
module = importlib.import_module(absolute_module_name)
40+
except ModuleNotFoundError as e:
41+
raise ModuleLoadException(module_name, str(e))
42+
3443
additional_modules = []
3544

3645
if not hasattr(module, "ModuleHandler") or not callable(
@@ -63,6 +72,11 @@ def load_modules(machine: Machine, config: Dict[str, Any]) -> None:
6372
migration_modules.remove(entry.name)
6473
_load_module(machine, config, entry.name)
6574

75+
for migration_module in migration_modules.copy():
76+
if "." in migration_module:
77+
migration_modules.remove(migration_module)
78+
_load_module(machine, config, migration_module)
79+
6680
if len(migration_modules) > 0 or len(config["migration_modules"]) < 1:
6781
logger = get_logger()
6882

0 commit comments

Comments
 (0)